// ----------------------------------------------------------------------------- // CWPMessage::StoreMsgL // ----------------------------------------------------------------------------- // void CWPMessage::StoreMsgL() { FLOG( _L( "CWPMessage::StoreMsgL" ) ); // create an invisible blank entry TMsvEntry entry; PrepareEntryLC( entry ); // details on cleanup stack entry.iBioType = iBioUID.iUid; entry.iMtm = KUidBIOMessageTypeMtm; // Look up and set the description FLOG( _L( "CWPMessage::StoreMsgL 1" ) ); TInt index; CBIODatabase* bioDB = CBIODatabase::NewLC( iSession->FileSession() ); FLOG( _L( "CWPMessage::StoreMsgL 2" ) ); TRAPD( err, bioDB->GetBioIndexWithMsgIDL( iBioUID, index ) ); if (err ==KErrNone) { FLOG( _L( "CWPMessage::StoreMsgL 3" ) ); HBufC* description = bioDB->BifReader(index).Description().AllocL(); FLOG( _L( "CWPMessage::StoreMsgL 4" ) ); entry.iDescription.Set(*description); FLOG( _L( "CWPMessage::StoreMsgL 5" ) ); CleanupStack::PopAndDestroy(); // bioDB CleanupStack::PushL( description ); } else { FTRACE(RDebug::Print(_L(" CWPMessage::StoreMsgL err (%d)"), err)); CleanupStack::PopAndDestroy(); // bioDB } FLOG( _L( "CWPMessage::StoreMsgL 6" ) ); // Store entry in inbox CMsvEntry* msvEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId ); FLOG( _L( "CWPMessage::StoreMsgL 7" ) ); CleanupStack::PushL(msvEntry); msvEntry->CreateL(entry); msvEntry->Session().CleanupEntryPushL(entry.Id()); msvEntry->SetEntryL(entry.Id()); FLOG( _L( "CWPMessage::StoreMsgL 8" ) ); // Save the message CMsvStore* store = msvEntry->EditStoreL(); CleanupStack::PushL(store); FLOG( _L( "CWPMessage::StoreMsgL 9" ) ); iMessage->StoreL( *store ); store->CommitL(); // Complete processing the message PostprocessEntryL( *msvEntry, entry ); CleanupStack::PopAndDestroy(); //store msvEntry->Session().CleanupEntryPop(); //entry CleanupStack::PopAndDestroy(3); //description, details, msvEntry FLOG( _L( "CWPMessage::StoreMsgL Done" ) ); }
// ----------------------------------------------------------------------------- // CWPMessage::StoreMsgL // ----------------------------------------------------------------------------- // void CWPMessage::StoreMsgL( TInt aResource ) { FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) ); // create an invisible blank entry TMsvEntry entry; PrepareEntryLC( entry ); // details on cleanup stack entry.iMtm = KUidMsgTypeSMS; // Store entry in inbox CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); CleanupStack::PushL(msvEntry); msvEntry->CreateL(entry); msvEntry->Session().CleanupEntryPushL(entry.Id()); msvEntry->SetEntryL(entry.Id()); // Save the message body CMsvStore* store = msvEntry->EditStoreL(); CleanupStack::PushL(store); CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); CleanupStack::PushL( paraFormat ); CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); CleanupStack::PushL( charFormat ); CRichText* body = CRichText::NewL( paraFormat, charFormat ); CleanupStack::PushL( body ); HBufC* text = LoadStringLC( aResource ); body->InsertL( body->DocumentLength(), *text ); store->StoreBodyTextL( *body ); // Store the actual message for post-mortem analysis iMessage->StoreL( *store ); // Save the SMS header and create a description field CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body ); CleanupStack::PushL( header ); TBuf<KSmsDescriptionLength> description; CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); CleanupStack::PushL( smsPlugin ); smsPlugin->GetDescription( header->Message(), description ); CleanupStack::PopAndDestroy( smsPlugin ); entry.iDescription.Set( description ); header->StoreL( *store ); store->CommitL(); CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat // Complete processing the message PostprocessEntryL( *msvEntry, entry ); CleanupStack::PopAndDestroy(); //store msvEntry->Session().CleanupEntryPop(); //entry CleanupStack::PopAndDestroy(2); //details, msvEntry }