// ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- TInt CIpsPlgPop3ConnectOp::GetPopulateLimitFromSettingsL() { FUNC_LOG; TInt limit( KDefaultPopulateLimit ); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL( settings ); TPopAccount popAccountId; CEmailAccounts* accounts = CEmailAccounts::NewLC(); accounts->GetPopAccountL( iService , popAccountId ); accounts->LoadPopSettingsL( popAccountId, *settings ); limit = settings->PopulationLimit(); if ( limit > 0 ) { // basically doing a _very_rough_ conversion from kilobyte value to number-of-rows limit = ( limit * KPopulateAlgorithmBytesInKilo ) / KPopulateAlgorithmRowLength; } CleanupStack::PopAndDestroy( 2, settings ); return limit; }
void CPopsTestHarness::SetUpPopServiceL() { // Create the POP3 service and set the settings for this test. iPop3Service = iTestUtils->CreatePopServiceL(); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(settings); settings->Reset(); _LIT(KPopServer, "pop3.demon.co.uk"); settings->SetServerAddressL(KPopServer); settings->SetLoginNameL(iTestUtils->MachineName()); settings->SetPasswordL(iTestUtils->MachineName()); settings->SetPort(110); settings->SetDisconnectedUserMode(ETrue); // eh xxxx, must test this when set to EFalse CEmailAccounts* accounts = CEmailAccounts::NewLC(); TPopAccount popAccount; accounts->GetPopAccountL(iPop3Service, popAccount); accounts->SavePopSettingsL(popAccount, *settings); CleanupStack::PopAndDestroy(2, settings); // accounts/store, settings test.Printf(_L("\nPerforming Tests\n")); }
// // Get all email services // void CEmailNotificationParser::GetEmailServicesL() { CCnvCharacterSetConverter* charconv = CCnvCharacterSetConverter::NewL(); CleanupStack::PushL(charconv); CArrayFix<CCnvCharacterSetConverter::SCharacterSet> *charsetsAvailable = charconv->CreateArrayOfCharacterSetsAvailableL(iFs); CleanupStack::PushL(charsetsAvailable); charconv->PrepareToConvertToOrFromL(KUidCharsetISO88591,*charsetsAvailable,iFs); const TMsvId current = iEntry.Entry().Id(); iEntry.SetEntryL(KMsvRootIndexEntryId); // Get all POP3 and Imap services CMsvEntrySelection* rootChildren = iEntry.ChildrenL(); CleanupStack::PushL(rootChildren); TMsvEntry entry; CEmailAccounts* accounts = CEmailAccounts::NewLC(); const TInt count = rootChildren->Count(); TInt j =0; while(j < count && iFoundServer ==EFalse) { // set context to service entry iEntry.SetEntryL((*rootChildren)[j]); entry = iEntry.Entry(); if (entry.iType == KUidMsvServiceEntry && (entry.iMtm == KUidMsgTypePOP3 || entry.iMtm == KUidMsgTypeIMAP4)) { TBuf8<8> port; if(entry.iMtm == KUidMsgTypePOP3) { // calculate hash value CImPop3Settings* settings = new(ELeave)CImPop3Settings; CleanupStack::PushL(settings); TPopAccount id; accounts->GetPopAccountL(entry.Id(), id); accounts->LoadPopSettingsL(id, *settings); port.Num((TUint)KPOP3DefaultPortNumber); iFoundServer = CalcHashValueL( *charconv, settings->LoginName(), settings->ServerAddress(), port); } else // entry.iMtm == KUidMsgTypeIMAP4 { CImImap4Settings* settings = new(ELeave)CImImap4Settings; CleanupStack::PushL(settings); TImapAccount id; accounts->GetImapAccountL(entry.Id(), id); accounts->LoadImapSettingsL(id, *settings); port.Num((TUint)KIMAPDefaultPortNumber); iFoundServer = CalcHashValueL( *charconv, settings->LoginName(), settings->ServerAddress(), port); } CleanupStack::PopAndDestroy(); // settings } j++; } if( iFoundServer ) iServiceMsvId = entry.Id(); CleanupStack::PopAndDestroy(4, charconv); // charconv, charsetsAvailable, rootChildren, accounts iEntry.SetEntryL(current); }
/** Function : doTestStepL Description : Reads the Pop account name and config file name from the .ini file and it then modifies the account with the settings read from the config file. @return : TVerdict - Test step result @leave : KMsvNullIndexEntryId Invalid POP account name specified */ TVerdict CT_MsgModifyPopSettings2::doTestStepL() { INFO_PRINTF1(_L("Test Step: ModifyPopSettings2")); // Read the POP account name from the ini file TPtrC popAccountName; if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) { ERR_PRINTF1(_L("POP account name is not specified")); SetTestStepResult(EFail); } else { // Read the POP Config file name from the ini file TPtrC configFileName; if(!GetStringFromConfig(ConfigSection(), KPopConfigFileName, configFileName)) { ERR_PRINTF1(_L("Configuration file path 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); } // Creates the settings object else { CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); CImPop3Settings* popSettings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(popSettings); CImIAPPreferences* popIapPrefs = CImIAPPreferences::NewLC(); // Loads the settings for the account with the current settings TPopAccount popAccount; emailAccounts->GetPopAccountL(popServiceId, popAccount); emailAccounts->LoadPopSettingsL(popAccount, *popSettings); emailAccounts->LoadPopIapSettingsL(popAccount, *popIapPrefs); // Reads the settings from the config file TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(configFileName, *popSettings, *popIapPrefs)); if(err) { ERR_PRINTF2(_L("Failure while setting the POP setting parameters, failed with error %d"), err); SetTestStepError(err); } else { // Saves the new settings emailAccounts->SavePopSettingsL(popAccount, *popSettings); emailAccounts->SavePopIapSettingsL(popAccount, *popIapPrefs); } CleanupStack::PopAndDestroy(3, emailAccounts);// popIapPrefs,popSettings,emailAccounts } } } return TestStepResult(); }
LOCAL_C void doMainL() { Init(); testUtils->FileSession().SetSessionPath(_L("c:\\")); // smtpService = testUtils->CreateSmtpServiceL(); // Create the POP3 service and set the settings for this test. pop3Service = testUtils->CreatePopServiceL(); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(settings); settings->Reset(); _LIT(KPopServer, "internet-test.plc.psion.com"); settings->SetServerAddressL(KPopServer); settings->SetLoginNameL(testUtils->MachineName()); settings->SetPasswordL(testUtils->MachineName()); settings->SetPort(110); // Saving POP settings CEmailAccounts* accounts = CEmailAccounts::NewLC(); TPopAccount popAccount; accounts->GetPopAccountL(pop3Service, popAccount); accounts->SavePopSettingsL(popAccount, *settings); CleanupStack::PopAndDestroy(2, settings); // accounts/store, settings // Set the IAP to Demon (even though we're not going to dial up as such.) User::LeaveIfError(testUtils->iServerEntry->SetEntry(pop3Service)); TMsvEntry entry = testUtils->iServerEntry->Entry(); entry.SetMtmData1(3); User::LeaveIfError(testUtils->iServerEntry->ChangeEntry(entry)); test.Printf(_L("\nPerforming Tests\n")); CTestActive* activeObjectTester = new (ELeave) CTestActive; CleanupStack::PushL(activeObjectTester); // Get server MTM. testUtils->InstantiatePopServerMtmL(); CBaseServerMtm* pop3ServerMtm = testUtils->iPopServerMtm; // Get the POP3 server MTM to connect. log->AppendComment(_L8("Connect to POP3 server")); CMsvEntrySelection* serviceId = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(serviceId); serviceId->AppendL(pop3Service); TBuf8<1> parameters; activeObjectTester->StartL(); User::LeaveIfError(testUtils->iServerEntry->SetEntry(pop3Service)); pop3ServerMtm->StartCommandL(*serviceId, KPOP3MTMConnect, parameters, activeObjectTester->iStatus); CActiveScheduler::Start(); // Get the progress TPop3Progress prog; TPckgC<TPop3Progress> paramPack(prog); paramPack.Set(pop3ServerMtm->Progress()); TPop3Progress progress=paramPack(); // Check that the reported progress is EPopConnecting test(progress.iPop3Progress == TPop3Progress::EPopConnecting); CleanupStack::PopAndDestroy(); // serviceId // Cleanup CleanupStack::PopAndDestroy(); // activeObjectTester Closedown(); }
void CPopsTestHarness::SetUpPopServiceL() { // Handle command line arguments CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); TInt count = cmdLineArg->Count(); TBool isCmdLine=FALSE; if (count>2) // Command line arguments? { if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd) isCmdLine=TRUE; } // Create the POP3 service and set the settings for this test. iPop3Service = iTestUtils.CreatePopServiceL(); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(settings); settings->Reset(); TBuf<100> buf; if (isCmdLine) { TLex lex(cmdLineArg->Arg(EArgServerAddress)); buf=lex.NextToken(); test.Printf(_L("Server address: %S\n"),&buf); } else { readConsoleLineBuf(_L("Server address: "),buf); } settings->SetServerAddressL(buf); buf.Zero(); if (isCmdLine) { TLex lex(cmdLineArg->Arg(EArgLogin)); buf=lex.NextToken(); test.Printf(_L("Login: %S\n"),&buf); } else { readConsoleLineBuf(_L("login: "******"Password: %S\n"),&buf); } else { readConsoleLineBuf(_L("password: "******"Use APOP: %c\n"),choice); if (choice=='y' || choice=='Y') settings->SetApop(ETrue); else settings->SetApop(EFalse); } else { test.Printf(_L("\n Use APOP? Enter (Y/N): ")); settings->SetApop(GetTrueOrFalse()); } if (isCmdLine) { TLex lex(cmdLineArg->Arg(EArgUseSecureSockets)); choice=lex.Get(); test.Printf(_L("Use secure sockets: %c\n"),choice); if (choice=='y' || choice=='Y') settings->SetSecureSockets(ETrue); else settings->SetSecureSockets(EFalse); } else { test.Printf(_L("\n Use secure sockets? Enter (Y/N): ")); settings->SetSecureSockets(GetTrueOrFalse()); } // Add IAP's to iIAPPreferences TImIAPChoice iap; CImIAPPreferences* prefs = CImIAPPreferences::NewLC(); TInt iapId = 0; CMDBSession* iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion()); CCDConnectionPrefsRecord *connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); CleanupStack::PushL(connPrefRecord); connPrefRecord->iDirection = ECommDbConnectionDirectionOutgoing; if(!connPrefRecord->FindL(*iDBSession)) { User::Leave(KErrNotFound); } iapId = iap.iIAP = connPrefRecord->iDefaultIAP; CleanupStack::PopAndDestroy(connPrefRecord); delete iDBSession; iDBSession= NULL; iap.iDialogPref = ECommDbDialogPrefDoNotPrompt; prefs->AddIAPL(iap); iap.iIAP = iapId; iap.iDialogPref = ECommDbDialogPrefPrompt; prefs->AddIAPL(iap, 1); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TPopAccount popAccount; accounts->GetPopAccountL(iPop3Service, popAccount); accounts->SavePopSettingsL(popAccount, *settings); accounts->SavePopIapSettingsL(popAccount, *prefs); CleanupStack::PopAndDestroy(4, cmdLineArg); // (accounts,) prefs, settings, (store,) cmdLineArg test.Printf(_L("\nPerforming Tests\n")); }
/** 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(); }