LOCAL_C void TestSessionWithPriorityL() { CDummyObserver ob; CMsvSession* session = CMsvSession::OpenSyncL(ob,CMsvSession::EPriorityStandard); if (session->Priority() == session->EPriorityStandard) { CMsgsTestUtils::Next(_L("Dfault priority is EPriorityStandard ")); } delete session; session= NULL; session = CMsvSession::OpenAsyncL(ob,CMsvSession::EPriorityLow); if (session->Priority() == session->EPriorityLow) { CMsgsTestUtils::Next(_L("Dfault priority is EPriorityLow ")); } delete session; session= NULL; RFs rfs; User::LeaveIfError(rfs.Connect()); CleanupClosePushL(rfs); session = CMsvSession::OpenAsyncL(ob,rfs,CMsvSession::EPriorityHigh); if (session->Priority() == session->EPriorityHigh) { CMsgsTestUtils::Next(_L("Dfault priority is EPriorityHigh ")); } delete session; session= NULL; CleanupStack::PopAndDestroy(&rfs); }
// methods from CSendAsEditUtils void CSendAsTestEditUtils::LaunchEditorL(TMsvId /*aId*/, TRequestStatus& aStatus) { CDummyObserver* ob1 = new(ELeave) CDummyObserver; CleanupStack::PushL(ob1); CMsvSession* session = CMsvSession::OpenSyncL(*ob1); CleanupStack::PushL(session); CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue)); CleanupStack::PushL(cEntry); CMsvEntrySelection* selection = cEntry->ChildrenL(); CleanupStack::PushL(selection); CMsvEntry* cEntry2 = session->GetEntryL(selection->At(0)); CleanupStack::PushL(cEntry2); TMsvEntry entry = cEntry2->Entry(); entry.SetMtmData3(234567890); // Show we've been called by touching the TMsvEntry. cEntry2->ChangeL(entry); CleanupStack::PopAndDestroy(5, ob1); // cEntry2, selection, cEntry, session, ob1 iUserStatus = &aStatus; aStatus = KRequestPending; // wait a few seconds before completing iEditTimer->After(KSendAsTestEditWaitTime); }
void CMtfTestActionAddFileAttachmentByHandle::RunTestL() { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(2)); HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(3)); iEntry = paramSession->GetEntryL(messageEntry); iStore = iEntry->EditStoreL(); iAttachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); iAttachment->SetMimeTypeL(*paramMimeType); RFile fileHandle = OpenFileL(paramSession->FileSession(), *paramFilePath); CleanupClosePushL(fileHandle); TFileName fileName; User::LeaveIfError(fileHandle.Name(fileName)); iAttachment->SetAttachmentNameL(fileName); TInt fileSize = 0; User::LeaveIfError(fileHandle.Size(fileSize)); iAttachment->SetSize(fileSize); MMsvAttachmentManager& manager = iStore->AttachmentManagerL(); CActiveScheduler::Add(this); SetActive(); manager.AddAttachmentL(fileHandle, iAttachment, iStatus); iAttachmentId = iAttachment->Id(); iAttachment = NULL; // ownership passed to manager CleanupStack::Pop(&fileHandle); }
void CMtfTestActionGetAttachmentFileFromIndex::RunTestActionL() { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TInt attachIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2)); HBufC* dataFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3), NULL); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CMsvStore* store = entry->ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& manager = store->AttachmentManagerL(); RFile fileAttachment = manager.GetAttachmentFileL(attachIndex); CleanupClosePushL(fileAttachment); if( dataFilePath != NULL ) { // check of contents of attachment file is requested CompareFileL(fileAttachment, *dataFilePath); } CleanupStack::PopAndDestroy(3, entry); // fileAttachment, store, entry }
void CMtfTestActionSmtpGetAttachmentFileFromId::RunTestActionL() { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); HBufC* dataFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3), NULL); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); CleanupStack::PushL(emailMsg); MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); RFile fileAttachment = manager.GetAttachmentFileL(attachId); CleanupClosePushL(fileAttachment); if( dataFilePath != NULL ) { // check of contents of attachment file is requested CompareFileL(fileAttachment, *dataFilePath); } CleanupStack::PopAndDestroy(3, entry); // fileAttachment, emailMsg, entry }
/** Function : ExecuteActionL Description : Issues command to Pigeon Server MTM to schedule/reschedule the messages @internalTechnology @param : none @return : void @pre @post none */ void CMtfTestActionSchedulePigeonMessage::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSchedulePigeonMessage); // Obtain input parameters CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(), ActionParameters().Parameter(0)); TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(), ActionParameters().Parameter(1)); TInt paramCommand = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(2)); //Error Handling Just in case one of the above inputs fail. if(TestCase().TestStepResult() == EPass) { CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering()); // Get the selection of Pigeon Messages iSelection = entry->ChildrenWithMtmL(KUidMsgTypePigeon); // Initiate asynchronous operation, passing the schedule/reschedule the message in the selection // Dummy aParameter value passed as Pigeon MTM does not make use of it. iOperation = paramSession->TransferCommandL(*iSelection,paramCommand, _L8("aaaa"), iStatus); CActiveScheduler::Add(this); SetActive(); } TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSchedulePigeonMessage); }
void CMtfTestActionCompareAttachment::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareAttachment); CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); HBufC* dataFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CMsvStore* store = entry->ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& manager = store->AttachmentManagerL(); RFile fileAttachment = manager.GetAttachmentFileL(attachId); CleanupClosePushL(fileAttachment); CompareFileL(fileAttachment, *dataFilePath); CleanupStack::PopAndDestroy(&fileAttachment); CleanupStack::PopAndDestroy(2, entry); // store, entry TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareAttachment); TestCase().ActionCompletedL(*this); }
LOCAL_C void TestDeleteStoreOperationL() { CMsgsTestUtils::SetDriveL(EDriveC); CSessionObserver* ob = new(ELeave)CSessionObserver; CleanupStack::PushL(ob); // Set session in observer CMsvSession* session = CMsvSession::OpenAsyncL(*ob); ob->iSession = session; CleanupStack::PushL(session); CActiveScheduler::Start(); test(ob->iType==MMsvSessionObserver::EMsvServerReady); CTestActive* active = new(ELeave)CTestActive; CleanupStack::PushL(active); // Test Delete MailStore active->StartL(); CMsvOperation* operation = NULL; TDriveUnit unit =(EDriveD); operation = session->DeleteStoreL(unit, active->iStatus); test(operation->Mtm() == KUidMsvServerMtm); CleanupStack::PushL(operation); CActiveScheduler::Start(); //Retrieve progress TPckgBuf<TMsvCopyProgress> package; package.Copy(operation->ProgressL()); test((package().iError == KErrNone) || (package().iError == KErrPathNotFound)) ; CleanupStack::PopAndDestroy(4); }
LOCAL_C void CloseServerL() { CDummyObserver ob; CMsvSession* session = CMsvSession::OpenSyncL(ob); session->CloseMessageServer(); delete session; User::After(1000000); }
void CMtfTestActionSmtpModifyAttachmentInfo::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpModifyAttachmentInfo); CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TMsvAttachmentId attachmentId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); CleanupStack::PushL(emailMsg); MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); CleanupStack::PushL(mimeHeaders); mimeHeaders->SetContentDescriptionL(KTxtContentDescription()); mimeHeaders->SetContentBaseL(KTxtContentBase()); mimeHeaders->SetContentLocationL(KTxtContentLocation()); mimeHeaders->SetContentIdL(KTxtContentId()); mimeHeaders->SetContentTypeL(KTxtContentType()); mimeHeaders->SetContentSubTypeL(KTxtContentSubType()); mimeHeaders->SetContentDispositionL(KTxtContentDisposition()); mimeHeaders->ContentTypeParams().AppendL(KTxtParam1()); mimeHeaders->ContentTypeParams().AppendL(KTxtParam2()); mimeHeaders->ContentTypeParams().AppendL(KTxtParam3()); mimeHeaders->ContentDispositionParams().AppendL(KTxtParam4()); mimeHeaders->ContentDispositionParams().AppendL(KTxtParam5()); mimeHeaders->ContentDispositionParams().AppendL(KTxtParam6()); mimeHeaders->XTypeParams().AppendL(KTxtParam7()); mimeHeaders->XTypeParams().AppendL(KTxtParam8()); mimeHeaders->XTypeParams().AppendL(KTxtParam9()); CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); CMsvAttachment* attachment = manager.GetAttachmentInfoL(attachmentId); CleanupStack::PushL(attachment); mimeHeaders->StoreL(*attachment); manager.ModifyAttachmentInfoL(attachment, waiter->iStatus); CleanupStack::Pop(attachment); waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(2, mimeHeaders); // waiter, mimeHeaders CompareMimeHeadersL(*emailMsg, attachmentId); CleanupStack::PopAndDestroy(2, entry);//emailMsg, entry TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpModifyAttachmentInfo); TestCase().ActionCompletedL(*this); }
void CMtfTestActionSmtpAddLinkedAttachment::RunTestL() { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(2)); HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(3)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); CleanupStack::PushL(emailMsg); CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile); CleanupStack::PushL(attachment); attachment->SetMimeTypeL(*paramMimeType); TParse fileNameParser; User::LeaveIfError(fileNameParser.Set(*paramFilePath, NULL, NULL)); attachment->SetAttachmentNameL(fileNameParser.NameAndExt()); TEntry fileEntry; User::LeaveIfError(paramSession->FileSession().Entry( fileNameParser.FullName(), fileEntry)); attachment->SetSize(fileEntry.iSize); MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); manager.AddLinkedAttachmentL(*paramFilePath, attachment, waiter->iStatus); CleanupStack::Pop(attachment); // ownership passed to manager waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); attachment = NULL; TInt attachmentCount = manager.AttachmentCount(); attachment = manager.GetAttachmentInfoL(attachmentCount - 1); CleanupStack::PushL(attachment); TMsvAttachmentId attachmentId = attachment->Id(); CleanupStack::PopAndDestroy(attachment); CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(4)); }
void CSessionObserver::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny*) { if (aEvent == EMsvServerReady || aEvent == EMsvCorruptedIndexRebuilt || aEvent == EMsvMediaIncorrect || aEvent == EMsvCorruptedIndexRebuilding) { // See if the index is available if (aEvent != EMsvMediaIncorrect && aEvent != EMsvCorruptedIndexRebuilding) { TMsvId service; TMsvEntry entry; // Check we can retrieve the inbox details from the index test(iSession->GetEntry(KMsvGlobalInBoxIndexEntryId, service, entry) == KErrNone); } iType = aEvent; if (aArg1) iArg1 = *(TInt*)aArg1; if (aArg2) iArg2 = *(TInt*)aArg2; CActiveScheduler::Stop(); } }
void CMtfTestActionRemoveAllAttachments::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRemoveAllAttachments); CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TInt attachIdFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), 0); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CMsvStore* store = entry->EditStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& manager = store->AttachmentManagerL(); TInt attachmentCount = manager.AttachmentCount(); for ( ; attachmentCount > 0 ; attachmentCount-- ) { CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); if( attachIdFlag == 1 ) { CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(0); CleanupStack::PushL(attachInfo); manager.RemoveAttachmentL(attachInfo->Id(), waiter->iStatus); CleanupStack::PopAndDestroy(attachInfo); } else { manager.RemoveAttachmentL(0, waiter->iStatus); } waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); } store->CommitL(); CleanupStack::PopAndDestroy(2, entry); // store, entry TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRemoveAllAttachments); TestCase().ActionCompletedL(*this); }
void CMtfTestActionSmtpRemoveEntryAttachmentById::RunTestL() { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); CleanupStack::PushL(emailMsg); MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachId); CleanupStack::PushL(attachInfo); // First ensure that the attachment is a file attachment if( attachInfo->Type() != CMsvAttachment::EMsvMessageEntry ) { User::Leave(KErrGeneral); } // Get the linked file TMsvId msgId = attachInfo->EntryAttachmentId(); CleanupStack::PopAndDestroy(attachInfo); // Remove the attachment CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); manager.RemoveAttachmentL(attachId, waiter->iStatus); waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); CleanupStack::PopAndDestroy(2, entry); // email msg, entry // Ensure that the message entry still exists CMsvEntry* checkEntry = paramSession->GetEntryL(msgId); delete checkEntry; checkEntry = NULL; }
// Get the TMsvEntry of the message whose TMsvId is passed from the client.. void CDummyServerSession::GetTMsvEntryL(const RMessage2& aMessage) { CDummyObserver* ob = new(ELeave) CDummyObserver; CleanupStack::PushL(ob); TPckgBuf<TMsvId> idBuf; idBuf = aMessage.Int0(); CMsvSession* session = CMsvSession::OpenSyncL(*ob); CleanupStack::PushL(session); TMsvId entryId = idBuf(); CMsvEntry* cEntry = session->GetEntryL(entryId); CleanupStack::PushL(cEntry); TPckgBuf<TMsvEntry> pckg = cEntry->Entry(); aMessage.WriteL(1,pckg); CleanupStack::PopAndDestroy(3,ob);//cEntry,session,ob }
void CMtfTestActionGetEntry::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionAddGetEntry); if(TestCase().TestStepResult() == EPass) { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); entry->SetEntryL(messageEntry); StoreParameterL<CMsvEntry>(TestCase(),*entry,ActionParameters().Parameter(2)); CleanupStack::Pop(entry); TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionAddGetEntry); } TestCase().ActionCompletedL(*this); }
LOCAL_C void TestStoreExistsL() { CMsgsTestUtils::SetDriveL(EDriveC); //Check that message store exists on the drive at this stage CSessionObserver* ob = new(ELeave)CSessionObserver; CleanupStack::PushL(ob); // Set session in observer CMsvSession* session = CMsvSession::OpenAsyncL(*ob); ob->iSession = session; CleanupStack::PushL(session); CActiveScheduler::Start(); test(ob->iType==MMsvSessionObserver::EMsvServerReady); CTestActive* active = new(ELeave)CTestActive; CleanupStack::PushL(active); // Test Copy MailStore active->StartL(); CMsvOperation* operation = NULL; TDriveUnit unit = EDriveD; operation = session->CopyStoreL(unit, active->iStatus); test(operation->Mtm() == KUidMsvServerMtm); CleanupStack::PushL(operation); CActiveScheduler::Start(); //Retrieve progress //Should retrun KErrAlreadyExists TPckgBuf<TMsvCopyProgress> package; package.Copy(operation->ProgressL()); test(package().iError == KErrAlreadyExists); //delete session; CleanupStack::PopAndDestroy(4, ob); CMsgsTestUtils::WaitForServerClose(); }
LOCAL_C void TestSetSendingStateAttributeL() { CDummyObserver* ob = new(ELeave)CDummyObserver; CleanupStack::PushL(ob); CMsvSession* session = CMsvSession::OpenSyncL(*ob); CleanupStack::PushL(session); CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering()); CleanupStack::PushL(cEntry); CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection; CleanupStack::PushL(selection); TMsvEntry entry1; entry1.iType = KUidMsvMessageEntry; entry1.iMtm = KUidMsvLocalServiceMtm; entry1.iServiceId = KMsvLocalServiceIndexEntryId; entry1.SetSendingState(12); cEntry->CreateL(entry1); selection->AppendL(entry1.Id()); TMsvEntry entry2; entry2.iType = KUidMsvMessageEntry; entry2.iMtm = KUidMsvLocalServiceMtm; entry2.iServiceId = KMsvLocalServiceIndexEntryId; entry2.SetSendingState(3); cEntry->CreateL(entry2); selection->AppendL(entry2.Id()); session->ChangeAttributesL(*selection, 6<<KMsvSendingStateShift, 0); cEntry->SetEntryL(entry1.Id()); test(cEntry->Entry().SendingState() == 6); cEntry->SetEntryL(entry2.Id()); test(cEntry->Entry().SendingState() == 6); CleanupStack::PopAndDestroy(4); // selection, cEntry, session, ob }
void CMtfTestActionAddEntryAttachment::RunTestL() { CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TMsvId attachmentMessageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CMsvStore* store = entry->EditStoreL(); CleanupStack::PushL(store); CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvMessageEntry); CleanupStack::PushL(attachment); TMsvEntry attachmentEntry; TMsvId attachmentServiceEntry; User::LeaveIfError(paramSession->GetEntry(attachmentMessageEntry, attachmentServiceEntry, attachmentEntry)); attachment->SetSize(attachmentEntry.iSize); MMsvAttachmentManager& manager = store->AttachmentManagerL(); manager.AddEntryAsAttachmentL(attachmentMessageEntry, attachment, waiter->iStatus); CleanupStack::Pop(attachment); // ownership passed to manager waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); TMsvAttachmentId attachmentId = attachment->Id(); store->CommitL(); CleanupStack::PopAndDestroy(2, entry); // store, entry StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(3)); }
void CMtfTestActionRemoveFileAttachmentWithDestroy::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRemoveFileAttachmentWithDestroy); CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); CMsvEntry* entry = paramSession->GetEntryL(messageEntry); CleanupStack::PushL(entry); CMsvStore* store = entry->EditStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& manager = store->AttachmentManagerL(); CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachId); CleanupStack::PushL(attachInfo); // First ensure that the attachment is a file attachment if( attachInfo->Type() != CMsvAttachment::EMsvFile ) { User::Leave(KErrGeneral); } CleanupStack::PopAndDestroy(attachInfo); CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); CleanupStack::PushL(waiter); manager.RemoveAttachmentL(attachId, waiter->iStatus); waiter->StartAndWait(); User::LeaveIfError(waiter->Result()); CleanupStack::PopAndDestroy(waiter); // destroy the store without commit CleanupStack::PopAndDestroy(2, entry); // store, entry TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRemoveFileAttachmentWithDestroy); TestCase().ActionCompletedL(*this); }
/** Function : ExecuteActionL Description : Installs a new group of MTMs @internalTechnology @param : none @return : void @pre : @post : none */ void CMtfTestActionInstallMtmGroup::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionInstallMtmGroup); // Obtain input parameters CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(), ActionParameters().Parameter(0)); HBufC* paramFileName = ObtainParameterReferenceL<HBufC>(TestCase(), ActionParameters().Parameter(1)); // If valid parameters received, call install MTM group if( (paramFileName != NULL) && (paramSession != NULL) ) { TInt result = paramSession->InstallMtmGroup(*paramFileName); // Print the result if(result == KErrAlreadyExists) { TestCase().INFO_PRINTF1(_L("MTM already installed")); } else if(result == KErrNone) { TestCase().INFO_PRINTF1(_L("MTM installed successfully")); } else { TestCase().ERR_PRINTF2(_L("MTM installation Failed with error %d"), result); User::Leave(result); } } else { // Invaid parameters received, leave the Test Action User::Leave(KErrArgument); } TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionInstallMtmGroup); TestCase().ActionCompletedL(*this); }
LOCAL_C void TestCleanupStackL() { CDummyObserver* ob = new(ELeave)CDummyObserver; CleanupStack::PushL(ob); CMsvSession* session = CMsvSession::OpenSyncL(*ob); CleanupStack::PushL(session); CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering()); CleanupStack::PushL(cEntry); TMsvEntry entry; entry.iType = KUidMsvMessageEntry; entry.iMtm = KUidMsvLocalServiceMtm; entry.iServiceId = KMsvLocalServiceIndexEntryId; // Create an entry cEntry->CreateL(entry); // Make sure heap failure occurs in CleanupEntryPushL // If a failure occurs the entry should still be on cleanup stack __UHEAP_FAILNEXT(0); TRAPD(error, session->CleanupEntryPushL(entry.Id()); session->CleanupEntryPop(); );
/** 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 }
// --------------------------------------------------------------------------- // Second level constructor. Creates the data members to the heap. // Creates also the folder CMsvEntry. // --------------------------------------------------------------------------- // void CIpsPlgMsgIterator::ConstructL( CMsvSession& aMsvSession, const TFSMailMsgId aFolderId, const RArray<TFSMailSortCriteria>& aSorting ) { FUNC_LOG; iFolderEntry = aMsvSession.GetEntryL( aFolderId.Id() ); StoreSortCriteriaL(aSorting); iMsgSortKey = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, iSortingCriteria ); iMsgSwapper = new (ELeave) TIpsPlgMsgSwap( *iFolderEntry ); iSortingOn = ( aSorting.Count() > 0 ) && ( aSorting[0].iField != EFSMailDontCare); iMsgMapper = CIpsPlgMsgMapper::NewL( aMsvSession, iPlugin ); iMsvSession = &aMsvSession; }
/** Stores the Unknown Push message in the message store. Saves the message data in a new attachment file. This makes it more efficient for the UI to read the data. @param aSession Message server session @param aParent ID of the parent for the new entry. It is the caller's responsibility to ensure that the parent ID is correct. @return ID of the new message server entry. @see CPushMsgEntryBase::SaveL() */ EXPORT_C TMsvId CUnknownPushMsgEntry::SaveL(CMsvSession& aSession, TMsvId aParent) { CMsvEntry* entryPtr = aSession.GetEntryL(KMsvRootIndexEntryId); CleanupStack::PushL(entryPtr); // This tidies itself up TMsvId newEntry = CPushMsgEntryBase::SaveL(aSession, aParent); #ifdef __MESSAGING_API_V2__ TRAPD( saveError, TFileName fileName = ContentFileNameL(); entryPtr->SetEntryL(newEntry); CMsvStore* store = entryPtr->EditStoreL(); CleanupStack::PushL(store); SaveMessageBodyL(store->AttachmentManagerL(), fileName); store->CommitL(); CleanupStack::PopAndDestroy(store); )
//--------------------------------------------------------------- // TestUniDataModelPlugin::testInboxMessage //--------------------------------------------------------------- void TestUniDataModelMMSPlugin::testInboxMessage() { //Create the MMS First createMMS(KMsvGlobalInBoxIndexEntryIdValue,ETrue); QTest::qWait(50000); //to ensure path completion //MMS Message created, will now be validated //Checking if Another Instance of MMS Data Plugin can be created form an existing one QObject* anotherInstance = pluginInterface->createInstance(); QVERIFY(anotherInstance != NULL); delete anotherInstance; //Setting a Message ID, thereby populating the MMS message at the Plugin QVERIFY(pluginInterface->setMessageId(iMessageId) == KErrNone); //Verifying the MMS message size QVERIFY(pluginInterface->messageSize() == msgSize); //Verifying the MMS timestamp QVERIFY(pluginInterface->timeStamp() == retTimeStamp); //Verifying is the MMP Plugin works file afetr it has been Reset and Restored pluginInterface->reset(); pluginInterface->restore(*iMmsClientMtm); QVERIFY(pluginInterface->setMessageId(iMessageId) == KErrNone); //Subject Verification QVERIFY(pluginInterface->subject().compare(QString(TEST_MSG_SUBJECT)) == 0); //MMS message have no Body String QString body; pluginInterface->body(body); QVERIFY(body == QString("")); //Message type verification QVERIFY(pluginInterface->messageType().compare(QString("mms")) == 0); //Fetch the To List ConvergedMessageAddressList recipientList; pluginInterface->toRecipientList(recipientList); QVERIFY(recipientList.count() != 0); QVERIFY(recipientList[0]->address().compare(QString(TEST_MSG_RECIEPIENT1)) == 0); //Fetch the CC List ConvergedMessageAddressList recipientList2; pluginInterface->ccRecipientList(recipientList2); QVERIFY(recipientList2.count() != 0); QVERIFY(recipientList2[0]->address().compare(QString(TEST_MSG_RECIEPIENT2)) == 0); //Fetch the BCC List ConvergedMessageAddressList recipientList3; pluginInterface->bccRecipientList(recipientList3); QVERIFY(recipientList3.count() != 0); QVERIFY(recipientList3[0]->address().compare(QString(TEST_MSG_RECIEPIENT3)) == 0); //Fetch the From Address QString recepient(TEST_MSG_FROM1); QString fromaddress; pluginInterface->fromAddress(fromaddress); QVERIFY(recepient == fromaddress); //Verifying Attachments UniMessageInfoList attList = pluginInterface->attachmentList(); QVERIFY(attList.count() == 0); QVERIFY(pluginInterface->hasAttachment() == false); QVERIFY(pluginInterface->attachmentCount() == 0); QVERIFY(pluginInterface->messagePriority() == 1); //Verifying various objects added to the MMS Message during creation QVERIFY(pluginInterface->objectCount() == 2); UniMessageInfoList objectlist = pluginInterface->objectList(); QVERIFY(!objectlist.isEmpty()); QVERIFY(objectlist[1]->path().contains(QString("TestUnidataModelMMSPluginPhoto.jpg"), Qt::CaseInsensitive) == true); QVERIFY(objectlist[1]->mimetype().contains(QString("image/jpeg"), Qt::CaseInsensitive) == true); QVERIFY(pluginInterface->slideCount() == 1); QVERIFY(pluginInterface->slideContent(0)[0]->path().contains(QString("Story.txt"), Qt::CaseInsensitive) == true); QVERIFY(pluginInterface->slideContent(0)[0]->mimetype().contains(QString("text/plain"), Qt::CaseInsensitive) == true); //Verifying if the plugin returns the correct session, thus will correctly delete the MMS we just created CMsvSession* msvSession = pluginInterface->session(); QVERIFY(msvSession != NULL); msvSession->RemoveEntry(iMessageId); qDebug() << "Verified Test MMS Successfully"; }
LOCAL_C void TestRemovingAllFilesL() { CDummyObserver ob; CMsvSession* session = CMsvSession::OpenSyncL(ob); CleanupStack::PushL(session); CMsvEntry* cEntry1 = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue)); CleanupStack::PushL(cEntry1); CMsvEntrySelection* selection; CMsvOperation* opert; CTestActive* active = new (ELeave) CTestActive; CleanupStack::PushL(active); CDir* dir; TFileName filename; TInt count; // delete everything under the outbox cEntry1->SetEntryL(KMsvGlobalOutBoxIndexEntryId); selection = cEntry1->ChildrenL(); if (selection->Count()) { active->StartL(); opert = cEntry1->DeleteL(*selection, active->iStatus); CActiveScheduler::Start(); // operation complete delete opert; } delete selection; // delete everything under the inbox cEntry1->SetEntryL(KMsvGlobalInBoxIndexEntryId); selection = cEntry1->ChildrenL(); if (selection->Count()) { active->StartL(); opert = cEntry1->DeleteL(*selection, active->iStatus); CActiveScheduler::Start(); // operation complete delete opert; } delete selection; // delete everything under the draft cEntry1->SetEntryL(KMsvDraftEntryId); selection = cEntry1->ChildrenL(); if (selection->Count()) { active->StartL(); opert = cEntry1->DeleteL(*selection, active->iStatus); CActiveScheduler::Start(); // operation complete delete opert; } delete selection; // delete everything under the sent cEntry1->SetEntryL(KMsvSentEntryId); selection = cEntry1->ChildrenL(); if (selection->Count()) { active->StartL(); opert = cEntry1->DeleteL(*selection, active->iStatus); CActiveScheduler::Start(); // operation complete delete opert; } delete selection; // delete everything under the local service cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId); selection = cEntry1->ChildrenL(); count=selection->Count(); while (count--) { TMsvId id = selection->At(count); #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) id = UnmaskTMsvId(id); #endif if (id==KMsvGlobalOutBoxIndexEntryId || id==KMsvGlobalInBoxIndexEntryId || id==KMsvDraftEntryId || id==KMsvSentEntryId || id==KMsvDeletedEntryFolderEntryId) selection->Delete(count); } if (selection->Count()) { active->StartL(); opert = cEntry1->DeleteL(*selection, active->iStatus); CActiveScheduler::Start(); // operation complete delete opert; } delete selection; // test cEntry1->SetEntryL(KMsvRootIndexEntryId); cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId); selection = cEntry1->ChildrenL(); test(selection->Count()==5); delete selection; RFs file; file.Connect(); CleanupClosePushL(file); TPtrC driveName = TDriveUnit(MessageServer::CurrentDriveL(file)).Name(); CleanupStack::PopAndDestroy(); file.Close(); filename = driveName; filename.Append(KMsvDefaultFolder2); MsvUtils::ConstructEntryName(KMsvLocalServiceIndexEntryId, KMsvLocalServiceIndexEntryId, filename, MsvUtils::EPath); REPORT_IF_ERROR(theUtils->FileSession().GetDir(filename, KEntryAttMaskSupported, ESortNone, dir)); test(dir->Count()==0); delete dir; // everything under the root cEntry1->SetEntryL(KMsvRootIndexEntryId); selection = cEntry1->ChildrenL(); count=selection->Count(); while (count--) { TMsvId id = selection->At(count); #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) id = UnmaskTMsvId(id); #endif if (id==KMsvLocalServiceIndexEntryId) selection->Delete(count); } if (selection->Count()) { active->StartL(); opert = cEntry1->DeleteL(*selection, active->iStatus); CActiveScheduler::Start(); // operation complete delete opert; } delete selection; #if (!defined SYMBIAN_MESSAGESTORE_USING_SQLDB) // check corrupt index flag was set when index file was corrupted TBool corrupt=session->GetAndClearIndexCorruptFlagL(); test(corrupt!=EFalse); #endif // test cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId); cEntry1->SetEntryL(KMsvRootIndexEntryId); selection = cEntry1->ChildrenL(); test(selection->Count()==1); delete selection; filename = driveName; filename.Append(KMsvDefaultFolder2); REPORT_IF_ERROR(theUtils->FileSession().GetDir(filename, KEntryAttMaskSupported, ESortNone, dir)); test(dir->Count()==1); //no Index file under Mail2 folder after PREQ1189. delete dir; CleanupStack::PopAndDestroy(3); }
LOCAL_C void DoExecuteL() { CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler(); CleanupStack::PushL(activeScheduler); CActiveScheduler::Install(activeScheduler); // Create Session CSessionObserver* sessionObserver; sessionObserver = new (ELeave) CSessionObserver; CleanupStack::PushL(sessionObserver); CMsvSession* session = CMsvSession::OpenSyncL(*sessionObserver); CleanupStack::PushL(session); // Set the message entry to global Outbox folder CMsvEntry* msvEntry = session->GetEntryL(KMsvGlobalOutBoxIndexEntryId); CleanupStack::PushL(msvEntry); // Get the selection of Pigeon messages present in Outbox CMsvEntrySelection* selection = msvEntry->ChildrenWithMtmL(KUidMsgTypePigeon); CleanupStack::PushL(selection); // Schedule it to send immediately - use default settings. CMsvScheduleSettings* settings = CMsvScheduleSettings::NewL(); CleanupStack::PushL(settings); RScheduler scheduler; TSchedulerItemRef ref; CMsvScheduleSend::ConnectAndRegisterL(scheduler, *settings); CleanupClosePushL(scheduler); TInt selCount = selection->Count(); for( TInt index = 0; index < selCount; ++index ) { msvEntry->SetEntryL(selection->At(index)); if(msvEntry != NULL) { TMsvEntry entry = msvEntry->Entry(); ref.iHandle = KErrNotFound; FindOrCreateScheduleL(scheduler, entry.iDate, *settings, ref); User::LeaveIfError(scheduler.DisableSchedule(ref.iHandle)); TMsvSchedulePackage package; package.iPollProgress = 3000000; package.iCommandId = ESendScheduledL; package.iId = selection->At(index); TTaskInfo info; CMsvScheduleSend::ScheduleEntryL(scheduler, ref, package, info); User::LeaveIfError(scheduler.EnableSchedule(ref.iHandle)); } } CleanupStack::PopAndDestroy(7, activeScheduler); }
/* Test to check the new API ** CopyStoreL(TInt aDrive, TMsvOp aOperationId, TRequestStatus& aStatus) */ LOCAL_C void TestCopyStoreOperationL() { CMsgsTestUtils::SetDriveL(EDriveC); CSessionObserver* ob = new(ELeave)CSessionObserver; CleanupStack::PushL(ob); // Set session in observer CMsvSession* session = CMsvSession::OpenAsyncL(*ob); ob->iSession = session; CleanupStack::PushL(session); CActiveScheduler::Start(); test(ob->iType==MMsvSessionObserver::EMsvServerReady); //Create an entry in the mail CMsvEntry* entry=session->GetEntryL(KMsvDraftEntryId); CleanupStack::PushL(entry); // create entry to work under TMsvEntry folder; folder.iType = KUidMsvFolderEntry; folder.iMtm = KUidMsvLocalServiceMtm; folder.iServiceId = KMsvLocalServiceIndexEntryId; _LIT(KTestDescription,"A Description"); _LIT(KTestDetails,"A Details"); folder.iDescription.Set(KTestDescription); folder.iDetails.Set(KTestDetails); entry->CreateL(folder); entry->SetEntryL(folder.Id()); CMsvStore* store=entry->EditStoreL(); CleanupStack::PushL(store); RMsvWriteStream stream; stream.AssignLC(*store,TUid::Uid(0x1000)); stream.WriteL(KTestDescription); stream.CommitL(); store->CommitL(); CleanupStack::PopAndDestroy(3); CTestActive* active = new(ELeave)CTestActive; CleanupStack::PushL(active); // Test Copy MailStore active->StartL(); CMsvOperation* operation = NULL; TDriveUnit unit =(EDriveD); operation = session->CopyStoreL(unit, active->iStatus); test(operation->Mtm() == KUidMsvServerMtm); CleanupStack::PushL(operation); CActiveScheduler::Start(); //Retrieve progress TPckgBuf<TMsvCopyProgress> package; package.Copy(operation->ProgressL()); test(package().iError == KErrNone); //delete session; CleanupStack::PopAndDestroy(4); //Check that both the source and destination //MailStore directory structure is same CMsgsTestUtils::WaitForServerClose(); CDir *srcDir; CDir *destDir; _LIT(intro, "Testing the directory structure"); _LIT(KEntryname,"%S"); theUtils->Printf(intro); TFileName dest = unit.Name(); dest.Append(KMsvDefaultFolder2); User::LeaveIfError(theUtils->FileSession().GetDir(dest, KEntryAttDir|KEntryAttNormal, ESortByName, destDir)); unit =EDriveC; TFileName src = unit.Name(); src.Append(KMsvDefaultFolder2); User::LeaveIfError(theUtils->FileSession().GetDir(src, KEntryAttDir|KEntryAttNormal, ESortByName, srcDir)); TInt counter=0; TEntry srcEntry; TEntry destEntry; while (counter<srcDir->Count()) { srcEntry = (*srcDir)[counter]; destEntry = (*destDir)[counter]; //Check the sizes test(srcEntry.iSize == destEntry.iSize); //Check the names test(srcEntry.iName == destEntry.iName); //Print out the names on the log theUtils->Printf(KEntryname,&(srcEntry.iName)); counter++; } delete srcDir; delete destDir; }
void CSMSSender::CreateSMSMessageL(const TDesC& aText, const TDesC& aAddress) /** Prepare SMS specific objects ready to send via ESOCK @param aText buffer containing ascii contents of message to send @param aAddress buffer with telephone number of SMS receiver */ { #ifndef __WINS__ TSmsAddr smsAddr; smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly); smsAddr.SetPort(smsAddr.Port() + 1);//ycf __LOGSTR_TOFILE("sockent bind"); iSocket.Bind(smsAddr); CSmsBuffer* smsBuffer = CSmsBuffer::NewL(); //CleanupStack::PushL(smsBuffer) is NOT used because CSmsMessage takes ownership of our buffer :-) CSmsMessage* smsMsg = CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit, smsBuffer); CleanupStack::PushL(smsMsg); TSmsUserDataSettings smsSettings; smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabetUCS2); smsSettings.SetTextCompressed(EFalse); smsMsg->SetUserDataSettingsL(smsSettings); TBuf<KMaxAddressSize> toAddress; toAddress.Copy(aAddress); smsMsg->SetToFromAddressL(toAddress); //Get service centre address. // The method used here assumes the SMS settings are provisioned, which is true in known cases. // There are alternative partner-only APIs, however this allow this source to be kept public #ifdef EKA2 CSmsSettings* smsSCSettings = CSmsSettings::NewL(); CleanupStack::PushL(smsSCSettings); CSmsAccount* smsAccount=CSmsAccount::NewLC(); smsAccount->LoadSettingsL(*smsSCSettings); // index of the default service centre address for this service TInt defIndex; User::LeaveIfError(defIndex = smsSCSettings->DefaultServiceCenter()); // Get the service center address CSmsServiceCenter& scAddr = smsSCSettings->GetServiceCenter(defIndex); TPtrC theAddress=scAddr.Address(); HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length()); *serviceCentreAddress=theAddress; smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress); CleanupStack::PopAndDestroy(serviceCentreAddress);// CleanupStack::PopAndDestroy(smsAccount); CleanupStack::PopAndDestroy(smsSCSettings); #else TMsvId serviceId; CObserver* pObserver = new (ELeave) CObserver(); CleanupStack::PushL(pObserver); CMsvSession* pSession = CMsvSession::OpenSyncL(*pObserver); CleanupStack::PushL(pSession); TSmsUtilities::ServiceIdL(*pSession, serviceId, KUidMsgTypeSMS); CMsvEntry* service = pSession->GetEntryL(serviceId); CleanupStack::PushL(service); CMsvStore* msvstore = service->ReadStoreL(); CleanupStack::PushL(msvstore); CSmsSettings* smsSCSettings = CSmsSettings::NewL(); CleanupStack::PushL(smsSCSettings); smsSCSettings->RestoreL(*msvstore); TInt defIndex; User::LeaveIfError(defIndex = smsSCSettings->DefaultSC()); defIndex = smsSCSettings->DefaultSC(); // Get the default service center address CSmsNumber& scAddr = smsSCSettings->SCAddress(defIndex); TPtrC theAddress=scAddr.Address(); HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length()); *serviceCentreAddress=theAddress; smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress); CleanupStack::PopAndDestroy(serviceCentreAddress);// CleanupStack::PopAndDestroy(smsSCSettings); //smsSettings CleanupStack::PopAndDestroy(msvstore); CleanupStack::PopAndDestroy(service); CleanupStack::PopAndDestroy(pSession); CleanupStack::PopAndDestroy(pObserver); #endif //convert to wide HBufC* payload = HBufC::NewL(aText.Length()); CleanupStack::PushL(payload); TPtr pPayload=payload->Des(); pPayload.Copy(aText); //copy from narrow to wide and convert smsBuffer->InsertL(0, pPayload); //copies payload RSmsSocketWriteStream writeStream(iSocket); CleanupClosePushL(writeStream); writeStream << *smsMsg; // remember << operator _CAN_ leave __LOGSTR_TOFILE("write stream commit"); writeStream.CommitL(); CleanupStack::PopAndDestroy(&writeStream); CleanupStack::PopAndDestroy(2);//smsMsg, payload #endif }