CMsvOperation* CTextMtmClient::ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus) // Create forwarded message // Destination folder is aForwardEntryL // { __ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet)); __ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid == KUidMsvMessageEntryValue, gPanic(ETxtcEntryTypeNotSupported)); __ASSERT_DEBUG(iMsvEntry->Entry().iServiceId == KMsvLocalServiceIndexEntryId, gPanic(ETxtcInvalidServiceId)); // Create the forwarded index entry TMsvEntry forwardEntry; forwardEntry.iMtm = KUidMsgTypeText; forwardEntry.iServiceId = Entry().Entry().iServiceId; forwardEntry.iType = KUidMsvMessageEntry; forwardEntry.iDetails.Set(iMsvEntry->Entry().iDetails); forwardEntry.iSize = iMsvEntry->Entry().iSize; if(aPartList&KMsvMessagePartDate) forwardEntry.iDate.HomeTime(); if(aPartList&KMsvMessagePartDescription) forwardEntry.iDescription.Set(iMsvEntry->Entry().iDescription); // Get CMsvEntry for destination (parent) CMsvEntry* cEntry = CMsvEntry::NewL(Session(), aForwardEntryId, TMsvSelectionOrdering()); CleanupStack::PushL(cEntry); // Synchronously create new child CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC(); CMsvOperation* opert = cEntry->CreateL(forwardEntry, wait->iStatus); CleanupStack::PushL(opert); wait->Start(); User::LeaveIfError(opert->iStatus.Int()); // Check result TPckgBuf<TMsvLocalOperationProgress> progressPack; progressPack.Copy(opert->ProgressL()); TMsvLocalOperationProgress progress = progressPack(); User::LeaveIfError(progress.iError); CleanupStack::PopAndDestroy(2); // opert, wait // Get CMsvEntry for new entry TMsvId forwardId=progress.iId; cEntry->SetEntryL(forwardId); // Populate new forwarded message with Body text if(aPartList&KMsvMessagePartBody) { CMsvStore* store=cEntry->EditStoreL(); CleanupStack::PushL(store); StoreBodyL(*store); // Current context is original message store->CommitL(); CleanupStack::PopAndDestroy(); // store } CleanupStack::PopAndDestroy(); // cEntry // Request was performed synchronously, so return a completed operation object return CMsvCompletedOperation::NewL(Session(), KUidMsgTypeText, progressPack, KMsvNullIndexEntryId, aCompletionStatus); }
void MsgStoreHandler::RunL() { TSsmState ssmState = iStateAwareSession.State(); if (ssmState.MainState() != ESsmNormal) { iStateAwareSession.RequestStateNotification(iStatus); SetActive(); } else { //Create the query/operation object CMsvSearchSortOperation *operation = CMsvSearchSortOperation::NewL(*iMsvSession); CleanupStack::PushL(operation); CMsvSearchSortQuery *query = CMsvSearchSortQuery::NewL(); CleanupStack::PushL(query); //set the query options query->SetParentId(KMsvGlobalInBoxIndexEntryId); query->SetResultType(EMsvResultAsTMsvId); query->AddSearchOptionL(EMsvMtmTypeUID, KSenduiMtmSmsUidValue, EMsvEqual); query->AddSearchOptionL(EMsvUnreadMessages, ETrue); CleanupStack::Pop(query); CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC(); //ownership of Query transferred to Operation operation->RequestL(query, EFalse, wait->iStatus); wait->Start(); //Get No of entries RArray<TMsvId> messageArray; operation->GetResultsL(messageArray); CMsvEntry* entry = NULL; for (TInt i = 0; i < messageArray.Count(); ++i) { entry = iMsvSession->GetEntryL(messageArray[i]); TMsvSmsEntry smsEntry = entry->Entry(); TSmsDataCodingScheme::TSmsClass classType(TSmsDataCodingScheme::ESmsClass0); if (smsEntry.Class(classType)) { HandleClass0SmsL(entry, smsEntry.Id()); } else { delete entry; entry = NULL; } } messageArray.Close(); CleanupStack::PopAndDestroy(2, operation); } }
/** ConstructL() Used to ensure that MMsvAttachmentManager is not destroyed until we want it to be. To do this we need to preserve certain objects of CImEmailMessage, which if disappeared would invalidate MMsvAttachmentManager. But this should be deleted in a controlled manner. @param aSession An object of type CMsvSession object. @param aEntry An object of type TMsvEntry used to get the entry ID. */ void CAttachmentItem::ConstructL(CMsvSession& aSession, TMsvEntry aEntry) { iMsvEntry = aSession.GetEntryL(aEntry.Id()); iMsvEntry->SetEntryL(aEntry.Id()); iEmailMsg = CImEmailMessage::NewL(*iMsvEntry); CMsvOperationActiveSchedulerWait* waiter = CMsvOperationActiveSchedulerWait::NewLC(); iEmailMsg->GetAttachmentsListL(waiter->iStatus, aEntry.Id(), CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly); waiter->Start(); CleanupStack::PopAndDestroy(1, waiter); //waiter }
void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId ) { CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId); CleanupStack::PushL(messageEntry); TMsvEntry entry = messageEntry->Entry(); if(entry.MtmData1() == KUidMsgTypeBtTInt32) { CMsvStore* store = messageEntry->ReadStoreL(); CleanupStack::PushL(store); TInt attachmentCount = store->AttachmentManagerL().AttachmentCount(); RFile attachmentFile; if(attachmentCount != 0) { //get file handle for the attachment & the complete path of the file attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = messageEntry->Entry(); attachEntry.SetUnread(EFalse); messageEntry->ChangeL(attachEntry); } else { CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession); CleanupStack::PushL(mtmReg); //1st Push CBIOClientMtm* bioClientMtm = (CBIOClientMtm*) mtmReg->NewMtmL(KBioUidValueUid); CleanupStack::PushL(bioClientMtm); //2nd Push bioClientMtm->SwitchCurrentEntryL(aMessageId); CMsvEntry* attachmentEntry = CMsvEntry::NewL(bioClientMtm->Session(), aMessageId, TMsvSelectionOrdering()); CleanupStack::PushL(attachmentEntry); //3rd Push bioClientMtm->LoadMessageL(); CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); //4th Push selection->AppendL(aMessageId); TBuf8<1> aParameter; CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC(); //5th Push CMsvOperation* operation = bioClientMtm->InvokeAsyncFunctionL(KBiosMtmParse, *selection, aParameter, wait->iStatus); wait->Start(); CMsvStore* store = attachmentEntry->ReadStoreL(); CleanupStack::PushL(store); //6th Push MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); attachmentFile = attachMan.GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); //7th Push User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = attachmentEntry->Entry(); attachEntry.SetUnread(EFalse); attachmentEntry->ChangeL(attachEntry); delete operation; CleanupStack::PopAndDestroy(6); } CleanupStack::PopAndDestroy(store); } else { CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id()); CleanupStack::PushL(attachmentEntry); //1st push CMsvStore* store = attachmentEntry->ReadStoreL(); CleanupStack::PushL(store); //2nd push TBuf<KMaxPath> attachmentName(store->AttachmentManagerL().GetAttachmentInfoL(0)->AttachmentName()); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TEntry entry; User::LeaveIfError(fs.Entry(attachmentName, entry)); CleanupStack::PopAndDestroy(&fs); //get file handle for the attachment & the complete path of the file RFile attachmentFile; attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); //3rd Push User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = attachmentEntry->Entry(); attachEntry.SetUnread(EFalse); attachmentEntry->ChangeL(attachEntry); CleanupStack::PopAndDestroy(store); CleanupStack::PopAndDestroy(attachmentEntry); } CleanupStack::PopAndDestroy(messageEntry); }