// ----------------------------------------------------------------------------- // 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 }
TBool CSmsReplyToStep::CheckMessageL() { INFO_PRINTF1(_L("Received new message in Inbox - should be status report...")); TMsvSelectionOrdering ordering; ordering.ShowInvisibleEntries(); CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId,ordering); CleanupStack::PushL(entry); CMsvEntrySelection* msvEntrySelection; msvEntrySelection=entry->ChildrenL(); CleanupStack::PushL(msvEntrySelection); // Check how many mesasges there are - should be just 1 TInt count = msvEntrySelection->Count(); INFO_PRINTF3(_L("Number of new messages: %d, should be: %d"), count, 1); // Restore the message CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iTestUtils->iRichText); CleanupStack::PushL(header); entry->SetEntryL((*msvEntrySelection)[0]); CMsvStore* store = entry->ReadStoreL(); CleanupStack::PushL(store); header->RestoreL(*store); if(store->HasBodyTextL()) { store->RestoreBodyTextL(*iTestUtils->iRichText); } TBuf<KSmsDescriptionLength> desc; User::LeaveIfError(TSmsUtilities::GetDescription(header->Message(), desc)); //Check for a reply address field CSmsReplyAddressOperations& operations = STATIC_CAST(CSmsReplyAddressOperations&,header->Message().GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat)); TBool result=operations.ContainsReplyAddressIEL(); CleanupStack::PopAndDestroy(4,entry); return result; }