LOCAL_C void ResetSettingsL(TBool aSecureSocket) { _LIT(KSmtpServer, "smtp.demon.co.uk"); _LIT(KSmtpEmailAlias, "SMTP STARTTLS"); _LIT(KSmtpEmailAddress, "<a@b>"); // Overwrite the setings with test code one. Don't want the default settings. CImSmtpSettings* settings = new(ELeave) CImSmtpSettings(); CleanupStack::PushL(settings); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccountId; accounts->GetSmtpAccountL(smtpService,smtpAccountId); accounts->LoadSmtpSettingsL(smtpAccountId, *settings); settings->SetServerAddressL(KSmtpServer); settings->SetEmailAliasL(KSmtpEmailAlias); settings->SetEmailAddressL(KSmtpEmailAddress); settings->SetReplyToAddressL(KSmtpEmailAddress); settings->SetBodyEncoding(EMsgOutboxMIME); settings->SetReceiptAddressL(KSmtpEmailAddress); settings->SetSecureSockets(aSecureSocket); settings->SetPort(25); accounts->SaveSmtpSettingsL(smtpAccountId, *settings); CleanupStack::PopAndDestroy(2, settings); //settings, store/accounts }
LOCAL_C void OverwriteSmtpSettingsL(TBool aRequestReceipt) { testUtils->iMsvEntry->SetEntryL(smtpService); //overwrite the setings with test code one. Don't want the default settings. CEmailAccounts* accounts = CEmailAccounts::NewLC(); CImSmtpSettings* settings = new(ELeave) CImSmtpSettings(); CleanupStack::PushL(settings); settings->Reset(); _LIT(KSmtpServer, "msg6"); // globel address for msg6 is fe80::2c0:4fff:fe84:61f7 // link local address fe80::1111:1111:dead:beef settings->SetServerAddressL(KSmtpServer); settings->SetEmailAliasL(_L("SMTP_IPV6 Test")); _LIT(KSmtpEmailAddress, "<kashifn@msg4>"); settings->SetEmailAddressL(KSmtpEmailAddress); settings->SetReplyToAddressL(KSmtpEmailAddress); settings->SetBodyEncoding(EMsgOutboxMIME); settings->SetReceiptAddressL(KSmtpEmailAddress); settings->SetRequestReceipts(aRequestReceipt); settings->SetPort(25); TSmtpAccount smtpAccountId; accounts->GetSmtpAccountL(smtpService, smtpAccountId); accounts->SaveSmtpSettingsL(smtpAccountId, *settings); CleanupStack::PopAndDestroy(2); //settings, store/account CTestTimer* timer = CTestTimer::NewL(); timer->After(5000000); CActiveScheduler::Start(); delete timer; }
/** Sets the default SMTP service. @param aService The default service */ EXPORT_C void CSmtpClientMtm::ChangeDefaultServiceL(const TMsvId& aService) { CEmailAccounts* account = CEmailAccounts::NewLC(); TSmtpAccount id; account->GetSmtpAccountL(aService, id); account->SetDefaultSmtpAccountL(id); CleanupStack::PopAndDestroy(account); }
void CMtfTestActionGetPopAccountSettings::LoadSettingsL(CEmailAccounts& aAccounts, const TPopAccount& aAccount, CImPop3Settings& aPopSettings, CImIAPPreferences& aPopIapSettings, CImSmtpSettings& aSmtpSettings, CImIAPPreferences& aSmtpIapSettings) { aAccounts.LoadPopSettingsL(aAccount, aPopSettings); aAccounts.LoadPopIapSettingsL(aAccount, aPopIapSettings); TSmtpAccount smtpAccount; aAccounts.GetSmtpAccountL(aAccount.iSmtpService, smtpAccount); aAccounts.LoadSmtpSettingsL(smtpAccount, aSmtpSettings); aAccounts.LoadSmtpIapSettingsL(smtpAccount, aSmtpIapSettings); }
/** LoadAccountSettingsL() This function loads the IMAP and SMTP settings object from the IMAP account given @param aEmailAccount An object of type CEmailAccounts @param aAccount An object of type TPopAccount @param aPopSettings An object of type CImPop3Settings @param aPopIapSettings An object of type CImIAPPreferences @param aSmtpSettings An object of type CImSmtpSettings @param aSmtpIapSettings An object of type CImIAPPreferences @return : void */ void CT_MsgComparePopSettings::LoadAccountSettingsL(CEmailAccounts& aEmailAccount, const TPopAccount& aAccount, CImPop3Settings& aPopSettings, CImIAPPreferences& aPopIapSettings,CImSmtpSettings& aSmtpSettings, CImIAPPreferences& aSmtpIapSettings) { aEmailAccount.LoadPopSettingsL(aAccount, aPopSettings); aEmailAccount.LoadPopIapSettingsL(aAccount, aPopIapSettings); TSmtpAccount smtpAccount; aEmailAccount.GetSmtpAccountL(aAccount.iSmtpService, smtpAccount); aEmailAccount.LoadSmtpSettingsL(smtpAccount, aSmtpSettings); aEmailAccount.LoadSmtpIapSettingsL(smtpAccount, aSmtpIapSettings); }
EXPORT_C void CSmtpClientMtm::RestoreSettingsL() /** Loads into the object's cache the service settings from the Central Repository for the current entry. */ { __ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid==KUidMsvServiceEntryValue, gPanic(ESmtcMTMNotAServiceEntry)); CEmailAccounts* account = CEmailAccounts::NewLC(); TSmtpAccount id; account->GetSmtpAccountL(iMsvEntry->Entry().Id(), id); account->LoadSmtpSettingsL(id, *iImSmtpSettings); CleanupStack::PopAndDestroy(account); }
LOCAL_C void CreateNewSmtpSettingsL() { testUtils->iMsvEntry->SetEntryL(smtpService); TMsvId serviceId = smtpService; //overwrite the settings with test code one. Don't want the default settings. CImSmtpSettings* settings = new(ELeave) CImSmtpSettings(); CleanupStack::PushL(settings); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccountId; accounts->GetSmtpAccountL( serviceId, smtpAccountId); accounts->LoadSmtpSettingsL(smtpAccountId, *settings); TInt serverLength = testUtils->MachineName().Length(); HBufC* serverad = HBufC::NewL(serverLength + 7 ); // 7 is the length of KServerAddress CleanupStack::PushL(serverad); serverad->Des().Copy(testUtils->MachineName()); serverad->Des().Append(KServer); settings->SetServerAddressL(*serverad); HBufC* emailaddress = HBufC::NewL(serverLength + 8 + serverad->Des().Length() + 1 ); CleanupStack::PushL(emailaddress); emailaddress->Des().Copy(testUtils->MachineName()); emailaddress->Des().Append(KAt); emailaddress->Des().Append(*serverad); settings->SetEmailAddressL(*emailaddress); settings->SetReplyToAddressL(*emailaddress); settings->SetReceiptAddressL(*emailaddress); settings->SetEmailAliasL(_L("Test Account")); settings->SetBodyEncoding(EMsgOutboxMIME); settings->SetRequestReceipts(EFalse); settings->SetPort(25); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(smtpService, smtpAccount); accounts->SaveSmtpSettingsL(smtpAccount, *settings); CleanupStack::PopAndDestroy(emailaddress); CleanupStack::PopAndDestroy(serverad); CleanupStack::PopAndDestroy(2,settings); testUtils->WriteComment(_L("Created New SmtpSettings ")); }
EXPORT_C void CSmtpClientMtm::CreateMessageL(TMsvId aServiceId) /** Creates a new message entry as a child of the current context. @param aServiceId ID of the service to own the entry. */ { // fix for DEF051564 - SMTP client MTM CreateMessageL not creating message in correct state TMsvEmailTypeList emailTypeList = KMsvEmailTypeListInvisibleMessage | KMsvEmailTypeListMessageInPreparation; CEmailAccounts* account = CEmailAccounts::NewLC(); CImSmtpSettings* smtpSettings = new (ELeave) CImSmtpSettings; CleanupStack::PushL(smtpSettings); TSmtpAccount id; account->GetSmtpAccountL(aServiceId, id); account->LoadSmtpSettingsL(id, *smtpSettings); switch (smtpSettings->BodyEncoding()) { case EMsgOutboxMHTMLAsMIME: case EMsgOutboxMHTMLAlternativeAsMIME: emailTypeList |= KMsvEmailTypeListMHTMLMessage; break; case EMsgOutboxDefault: case EMsgOutboxNoAlgorithm: case EMsgOutboxMIME: break; } CleanupStack::PopAndDestroy(2, account); // smtpSettings, account // Now invoke the create new mail operation. // Note that it is wrapped up to make the asynchronous call synchronous. CMsvOperationActiveSchedulerWait* waiter=CMsvOperationActiveSchedulerWait::NewLC(); CImEmailOperation* createNewMailOp = CImEmailOperation::CreateNewL(waiter->iStatus, iMsvEntry->Session(), iMsvEntry->Entry().Id(), aServiceId, KMsvMessagePartBody|KMsvMessagePartAttachments, emailTypeList, KUidMsgTypeSMTP); CleanupStack::PushL(createNewMailOp); waiter->Start(); // The the entry is expected to be set to the new message. TMsvId temp; TPckgC<TMsvId> paramPack(temp); const TDesC8& progBuf = createNewMailOp->ProgressL(); paramPack.Set(progBuf); TMsvId messageId = paramPack(); iMsvEntry->SetEntryL(messageId); CMsvStore* store = iMsvEntry->ReadStoreL(); CleanupStack::PushL(store); iHeader->RestoreL(*store); CleanupStack::PopAndDestroy(3, waiter); // waiter, createNewMailOp, store }
LOCAL_C void SetDefaultServiceL(TMsvId smtpService) { CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(smtpService, smtpAccount); accounts->SetDefaultSmtpAccountL(smtpAccount); // is default service ?? TSmtpAccount defaultAccount; accounts->DefaultSmtpAccountL(defaultAccount); if (smtpService != defaultAccount.iSmtpService) { User::Leave(KErrNotFound); } CleanupStack::PopAndDestroy(accounts); }
LOCAL_C void SetAddVCardToEmailL(TBool addVCard, TMsvId serviceId) { CImSmtpSettings* smtpSettings = new (ELeave) CImSmtpSettings; CleanupStack::PushL(smtpSettings); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(serviceId, smtpAccount); accounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings); smtpSettings->SetAddVCardToEmail(addVCard); accounts->SaveSmtpSettingsL(smtpAccount, *smtpSettings); CleanupStack::PopAndDestroy(2); // smtpSettings, accounts }
LOCAL_C void doMainL() { InitL(); test.Printf(_L("\nPerforming Tests\n")); testUtils->iMsvEntry->SetEntryL(smtpService); CTestTimer* timer = CTestTimer::NewL(); timer->After(5000000); CActiveScheduler::Start(); delete timer; // store service as default service CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccountId; accounts->GetSmtpAccountL(smtpService, smtpAccountId); accounts->SetDefaultSmtpAccountL(smtpAccountId); CleanupStack::PopAndDestroy(accounts); OverwriteSmtpSettingsL(EFalse); CreateMessageL(); // Create a message that will request a receipt OverwriteSmtpSettingsL(ETrue); CreateMessageL(); testUtils->InstantiateSmtpClientMtmL(); timer = CTestTimer::NewL(); timer->After(5000000); CActiveScheduler::Start(); delete timer; testUtils->TestStart(testNo++); TestSendingMessagesL(); testUtils->TestFinish(testNo-1); testUtils->TestStart(testNo++); TestCapabilityL(); testUtils->TestFinish(testNo-1); testUtils->TestHarnessCompleted(); Closedown(); }
LOCAL_C void SetSignatureToEmailL(TBool addSignature, TMsvId serviceId) { CImSmtpSettings* smtpSettings = new (ELeave) CImSmtpSettings; CleanupStack::PushL(smtpSettings); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(serviceId, smtpAccount); accounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings); smtpSettings->SetAddSignatureToEmail(addSignature); accounts->SaveSmtpSettingsL(smtpAccount, *smtpSettings); CleanupStack::PopAndDestroy(2); // smtpSettings, accounts if (addSignature) testUtils->WriteComment(_L("\tAdd VCard")); }
/** ExecuteActionL Parse the Email file and creates an email in the specified local folder. Creates simple emails, emails with HTML, attachments, multipart and embedded emails. @internalTechnology @pre None @post None @leave System wide errors */ void CMtfTestActionCreateSmtpMessageFromEmailFile::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateSmtpMessageFromEmailFile); CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(), ActionParameters().Parameter(0)); TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(), ActionParameters().Parameter(1)); TMsvId paramFolderId = ObtainValueParameterL<TMsvId>(TestCase(), ActionParameters().Parameter(2)); TInt paramConfigIndexMailFile = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(3),0); TInt overrideAddress=0; if(ActionParameters().Count()>5) { overrideAddress=ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(5)); } TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfEmailFile, paramConfigIndexMailFile); /************************************************************************************ Get the name of the Email file save at the Configuration file index, open the file, read one line of text from the file, parse the line and set the fields of the email message based on the contents of the parsed line. ************************************************************************************/ // Set the context ot the folder in which emails have to be created CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramFolderId,TMsvSelectionOrdering()); CleanupStack::PushL(entry); entry->SetEntryL(paramFolderId); RFs fs; fs.Connect(); CImCltRecvConvert* recvConvert = CImCltRecvConvert::NewLC(fs,entry,KUidMsgTypeSMTP, paramServiceId); recvConvert->SetMsvId(paramFolderId); // Open the Email file RFile file; User::LeaveIfError(file.Open(fs,fileName,EFileRead)); TestCase().INFO_PRINTF2(_L("Email Data file: %S"), &fileName); TBuf8<KMaxLenghtOfLine> line; TBuf8<1> aChar; // To read one character from the file TBool finished = FALSE; recvConvert->ResetL(); // Parse each line from the do { line.FillZ(); line.SetLength(0); // Read one line from email file do { file.Read(aChar, 1); if(aChar.Length()) { line.Append(aChar); } else { finished = TRUE; } } while(aChar.Length() && aChar[0] != 0x0A); if(!line.Length()) { break; } // Parse the line for the fields of the email and store them recvConvert->ParseNextFieldL(line); } while(!finished); /**************************************************************************** Complete the message creation by setting all the required fields and storing the email on to the message store. The created email's ID is returned by MessageCompelteL function ****************************************************************************/ TMsvId paramMessageId; paramMessageId = recvConvert->MessageCompleteL(); if(paramMessageId == 0) { User::Leave(KErrUnknown); } file.Close(); CleanupStack::PopAndDestroy(recvConvert); if(overrideAddress) { #ifndef __MESSAGING_API_V2__ entry->SetEntryL(paramServiceId); CMsvStore* store=entry->ReadStoreL(); CleanupStack::PushL(store); #endif CImSmtpSettings* settings= new(ELeave) CImSmtpSettings(); CleanupStack::PushL(settings); #ifdef __MESSAGING_API_V2__ CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(paramServiceId, smtpAccount); accounts->LoadSmtpSettingsL(smtpAccount, *settings); CleanupStack::PopAndDestroy(); #else settings->RestoreL(*store); CleanupStack::PopAndDestroy(); #endif HBufC* emailAddress=settings->EmailAddress().AllocL(); CleanupStack::PopAndDestroy(); CleanupStack::PushL(emailAddress); entry->SetEntryL(paramMessageId); #ifdef __MESSAGING_API_V2__ CMsvStore* store=entry->EditStoreL(); #else store=entry->EditStoreL(); #endif CleanupStack::PushL(store); CImHeader* header= CImHeader::NewLC(); header->RestoreL(*store); header->ToRecipients().Reset(); header->ToRecipients().AppendL(*emailAddress); header->StoreL(*store); store->CommitL(); CleanupStack::PopAndDestroy(3,emailAddress); } CleanupStack::PopAndDestroy(entry); TestCase().INFO_PRINTF2(_L("Created a email from file %S"),&fileName); StoreParameterL<TMsvId>(TestCase(),paramMessageId,ActionParameters().Parameter(4)); fs.Close(); TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateSmtpMessageFromEmailFile); TestCase().ActionCompletedL(*this); }
/** Initialises the tests. */ void CTestCImPlainTextStore::SetupL() { iActiveWaiter = new (ELeave) CActiveWaiter(); testUtils = CEmailTestUtils::NewL(test); testUtils->CreateAllTestDirectories(); testUtils->FileSession().SetSessionPath(_L("C:\\")); testUtils->ClearEmailAccountsL(); testUtils->CleanMessageFolderL(); testUtils->GoServerSideL(); TBuf<KMaxFilePathLength>emailbodyfile(KEmail40kBodyFile); RFs fsSession; RFile infile; User::LeaveIfError(fsSession.Connect()); User::LeaveIfError(infile.Open(fsSession, emailbodyfile, EFileRead)); TInt size = 0; infile.Size(size); //read the 8 bit data from the file TInt chunkLength = size / 3; HBufC8* tempBuf1 = HBufC8::NewL(chunkLength); TPtr8 tempBufPtr1(tempBuf1->Des()); infile.Read(tempBufPtr1,chunkLength); iFilebuf1 = HBufC16::NewL(chunkLength); TPtr16 ptr1=iFilebuf1->Des(); ptr1.Copy(tempBufPtr1); HBufC8* tempBuf2 = HBufC8::NewL(chunkLength); TPtr8 tempBufPtr2(tempBuf2->Des()); infile.Read(tempBufPtr2,chunkLength); iFilebuf2 = HBufC16::NewL(chunkLength); TPtr16 ptr2=iFilebuf2->Des(); ptr2.Copy(tempBufPtr2); HBufC8* tempBuf3 = HBufC8::NewL(chunkLength); TPtr8 tempBufPtr3(tempBuf3->Des()); infile.Read(tempBufPtr3,chunkLength); iFilebuf3 = HBufC16::NewL(chunkLength); TPtr16 ptr3=iFilebuf3->Des(); ptr3.Copy(tempBufPtr3); infile.Close(); testUtils->GoClientSideL(); testUtils->ClearEmailAccountsL(); smtpService = testUtils->CreateSmtpServiceL(); pop3Service = testUtils->CreatePopServiceL(); testUtils->GoServerSideL(); testUtils->FileSession().SetSessionPath(_L("c:\\")); test.Printf(_L("\nPerforming Tests\n")); testUtils->GoClientSideL(); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(smtpService, smtpAccount); accounts->SetDefaultSmtpAccountL(smtpAccount); CleanupStack::PopAndDestroy(accounts); TParse parsedFileName; TFileName name(KTestMessageDir); testUtils->ResolveLogFile(name, parsedFileName); // Get the default charset CCnvCharacterSetConverter* characterConverter = CCnvCharacterSetConverter::NewL(); CleanupStack::PushL(characterConverter); CImConvertCharconv* charConv = CImConvertCharconv::NewL(*characterConverter,fsSession ); CleanupStack::PushL(charConv); iDefaultCharset = charConv->SystemDefaultCharset(); CleanupStack::PopAndDestroy(2); fsSession.Close(); }
LOCAL_C void InitL() { // Load the serial comms device drivers. If this is not done, // connecting via NT-RAS returns KErrNotFound (-1). TInt driverErr; driverErr=User::LoadPhysicalDevice(PDD_NAME); if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) User::Leave(driverErr); driverErr=User::LoadLogicalDevice(LDD_NAME); if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) User::Leave(driverErr); CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; CActiveScheduler::Install(scheduler); CleanupStack::PushL(scheduler); testUtils = CEmailTestUtils::NewLC(test); testUtils->CreateAllTestDirectories(); testUtils->FileSession().SetSessionPath(_L("C:\\")); testUtils->CleanMessageFolderL(); testUtils->GoServerSideL(); testUtils->ClearEmailAccountsL(); test.Next(_L("Create Data Component FileStores")); testUtils->CreateSmtpServerMtmRegL(); // Loading the DLLs testUtils->CreateRegistryObjectAndControlL(); testUtils->InstallSmtpMtmGroupL(); testUtils->GoClientSideL(); // Create Services smtpService = testUtils->CreateSmtpServiceL(); imap4Service = testUtils->CreateImapServiceL(); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(smtpService, smtpAccount); accounts->SetDefaultSmtpAccountL(smtpAccount); testUtils->WriteComment(_L("Create Imap Services ")); // Delete any *.scr files in c:\logs\email directory. testUtils->DeleteScriptFilesFromLogsDirL(); testUtils->iMsvEntry->SetEntryL(imap4Service); //overwrite the settings with test code one. Don't want the default settings. CImImap4Settings* settings = new(ELeave) CImImap4Settings(); CleanupStack::PushL(settings); settings->Reset(); TInt serverLength = testUtils->MachineName().Length(); HBufC* serverad = HBufC::NewL(serverLength + 7 ); // 7 is the length of KServerAddress CleanupStack::PushL(serverad); serverad->Des().Copy(testUtils->MachineName()); serverad->Des().Append(KServer); settings->SetServerAddressL(*serverad); CleanupStack::PopAndDestroy(serverad); settings->SetDeleteEmailsWhenDisconnecting(ETrue); settings->SetAcknowledgeReceipts(ETrue); settings->SetAutoSendOnConnect(ETrue); settings->SetLoginNameL(testUtils->MachineName()); settings->SetPasswordL(testUtils->MachineName()); settings->SetPort(143); settings->SetFolderPathL(KFolderPath); accounts->GetImapAccountL(imap4Service, imapAccount); accounts->SaveImapSettingsL(imapAccount, *settings); CleanupStack::PopAndDestroy(2,accounts); //accounts,settings test.Printf(_L("Instantiating IMAP4 Client MTM")); testUtils->InstantiateImapClientMtmL(); }
/** ExecuteActionL Obtain the input parameters 1. sendAsMessage 2. recipientAddress 3. alias (Default value implies empty string) 4. recipientAddress1 5. recipientType IF alias for recipient address is provided as input Call RSendAsMessage::AddRecipient (const TDesC& aAddress, const TDesC& aAlias, TSendAsRecipientType aRecipientType) passing recipientAddress, alias and recipientType as input parameters ELSE Call RSendAsMessage::AddRecipient (const TDesC& aAddress, TSendAsRecipientType aRecipientType) passing recipientAddress and recipientType as input parameters @internalTechnology @pre None @post None @leave System wide errors */ void CMtfTestActionSendAsAddMultipleRecipient::ExecuteActionL() { if((TestCase().TestStepResult()) == EPass) { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsAddMultipleRecipient); // Get test action input parameters RSendAsMessage sendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(), ActionParameters().Parameter(0)); HBufC* recipientAddress = ObtainParameterReferenceL<HBufC>(TestCase(), ActionParameters().Parameter(1), NULL); HBufC* alias = ObtainParameterReferenceL<HBufC>(TestCase(), ActionParameters().Parameter(2), NULL); RSendAsMessage::TSendAsRecipientType recipientType = ObtainValueParameterL<RSendAsMessage::TSendAsRecipientType>(TestCase(), ActionParameters().Parameter(3)); TUid msgTypeId = ObtainValueParameterL<TUid>(TestCase(), ActionParameters().Parameter(4)); TInt expectedErr = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(5)); //Get the second recipient address HBufC* recipientAddress1 = ObtainParameterReferenceL<HBufC>(TestCase(), ActionParameters().Parameter(6), NULL); TInt err = KErrNone; TBuf16<3> btAddress; if(recipientAddress == NULL) { if( msgTypeId.operator == (KUidMsgTypeSMTP)) { TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(), ActionParameters().Parameter(7), 0); CImSmtpSettings* settings = new(ELeave) CImSmtpSettings(); CleanupStack::PushL(settings); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TSmtpAccount smtpAccount; accounts->GetSmtpAccountL(paramServiceId, smtpAccount); accounts->LoadSmtpSettingsL(smtpAccount, *settings); CleanupStack::PopAndDestroy(accounts); recipientAddress=settings->EmailAddress().AllocL(); CleanupStack::PopAndDestroy(settings); } else { TestCase().ERR_PRINTF1(_L("Recipient address is not provided")); TestCase().SetTestStepResult(EFail); } } else { if( msgTypeId.operator == (KUidMsgTypeBt)) { CMtfTestActionUtilsMessage::FormatBtRecipientAddress(*recipientAddress, btAddress); } } if((TestCase().TestStepResult()) == EPass) { if(alias == NULL ) { if( msgTypeId.operator == (KUidMsgTypeBt)) { TRAP(err,sendAsMessage.AddRecipientL(btAddress, recipientType)); } else { TRAP(err,sendAsMessage.AddRecipientL(*recipientAddress, recipientType)); TRAP(err, sendAsMessage.AddRecipientL(*recipientAddress1, recipientType)); } if(err == expectedErr) { TestCase().INFO_PRINTF1(_L("Recipient address added successfully")); } else { TestCase().ERR_PRINTF2(_L("Add Recipient address failed with error %d"), err); } } else { if( msgTypeId.operator == (KUidMsgTypeBt)) { TRAP(err,sendAsMessage.AddRecipientL(btAddress, alias->Des(), recipientType)); } else { TRAP(err, sendAsMessage.AddRecipientL(recipientAddress->Des(), alias->Des(), recipientType)); } if (err == expectedErr) { if(err == KErrNone) { TestCase().INFO_PRINTF1(_L("Recipient address with alias added successfully")); } else { TestCase().INFO_PRINTF1(_L("Recipient address with alias failed with expected error")); } } else { TestCase().ERR_PRINTF2(_L("Add Recipient address with alias failed with error %d"), err); } } } TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsAddMultipleRecipient); } TestCase().ActionCompletedL(*this); }
/** doTestStepL() Populate the default POP and SMTP settings, Load the settings of the account created with the default settings, and compares the settings objects. The test passes if all the settings objects match else it fails. @return Returns the test step result */ TVerdict CT_MsgVerifyPopSettings::doTestStepL() { INFO_PRINTF1(_L("Test Step: VerifyPopSettings")); // Read the Pop account name from the ini file TPtrC popAccountName; if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) { ERR_PRINTF1(_L("PopAccount Name is not specified")); SetTestStepResult(EFail); } else { // Retrieving the Pop service Id for the given Pop account TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName); INFO_PRINTF2(_L("Pop service id is %d"),popServiceId); if(popServiceId == KMsvNullIndexEntryId) { ERR_PRINTF1(_L("Invalid POP account name specified")); SetTestStepResult(EFail); } else { CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); CImPop3Settings* popSettings1 = new(ELeave) CImPop3Settings(); CleanupStack::PushL(popSettings1); CImIAPPreferences* popIapPrefs1 = CImIAPPreferences::NewLC(); CImSmtpSettings* smtpSettings1 = new(ELeave) CImSmtpSettings(); CleanupStack::PushL(smtpSettings1); CImIAPPreferences* smtpIapPrefs1 = CImIAPPreferences::NewLC(); emailAccounts->PopulateDefaultPopSettingsL(*popSettings1, *popIapPrefs1); emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings1, *smtpIapPrefs1); CImPop3Settings* popSettings2 = new(ELeave) CImPop3Settings(); CleanupStack::PushL(popSettings2); CImIAPPreferences* popIapPrefs2 = CImIAPPreferences::NewLC(); CImSmtpSettings* smtpSettings2 = new(ELeave) CImSmtpSettings(); CleanupStack::PushL(smtpSettings2); CImIAPPreferences* smtpIapPrefs2 = CImIAPPreferences::NewLC(); TPopAccount popAccount; emailAccounts->GetPopAccountL(popServiceId, popAccount); emailAccounts->LoadPopSettingsL(popAccount, *popSettings2); emailAccounts->LoadPopIapSettingsL(popAccount, *popIapPrefs2); TSmtpAccount smtpAccount; emailAccounts->GetSmtpAccountL(popAccount.iSmtpService, smtpAccount); emailAccounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings2); emailAccounts->LoadSmtpIapSettingsL(smtpAccount, *smtpIapPrefs2); TVerdict result = EPass; if (!(*popSettings1 == *popSettings2)) { // failed ERR_PRINTF1(_L("Pop3 Settings objects do not match !")); result = EFail; } else if (!(*smtpSettings1 == *smtpSettings2)) { // failed ERR_PRINTF1(_L("SMTP Settings objects do not match !")); result = EFail; } else if (!CT_MsgUtilsReadEmailSettingsFromConfigFile::CompareIapPrefs(*popIapPrefs1, *popIapPrefs2)) { // failed ERR_PRINTF1(_L("Pop3 IAP Preference objects do not match !")); result = EFail; } else if (!CT_MsgUtilsReadEmailSettingsFromConfigFile::CompareIapPrefs(*smtpIapPrefs1, *smtpIapPrefs2)) { // failed ERR_PRINTF1(_L("SMTP IAP Preference objects do not match !")); result = EFail; } SetTestStepResult(result); CleanupStack::PopAndDestroy(9,emailAccounts); } } return TestStepResult(); }