/** ReadImapIAPAndAddField() Modifies the CImIAPPreferences object. @param aScriptFileParser CT_MsgUtilsConfigFileParserUtility object. @param aFieldName @param aImapIapPref CImIAPPreferences object. */ EXPORT_C void CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadImapIAPAndAddFieldL( CT_MsgUtilsConfigFileParserUtility* aScriptFileParser, const TDesC& aFieldName, CImIAPPreferences& aImapIapPref) { TPtrC stringPtr; TInt intTmp; TImIAPChoice iapChoice; iapChoice.iIAP = 0; iapChoice.iDialogPref = ECommDbDialogPrefUnknown; TInt index = 0; TBool modified = EFalse; HBufC* buf = HBufC::NewLC(100); buf->Des() = aFieldName; buf->Des().Append(KImapIAPSuffix); if(aScriptFileParser->GetFieldAsInteger(buf->Des(), intTmp) == KErrNone) { iapChoice.iIAP = intTmp; modified = ETrue; } buf->Des() = aFieldName; buf->Des().Append(KImapCommDbDialogPref); if(aScriptFileParser->GetFieldAsString(buf->Des(), stringPtr) == KErrNone) { TCommDbDialogPref setCommDbDialogPref = CT_MsgUtilsEnumConverter::ConvertDesToTCommDbDialogPref(stringPtr); iapChoice.iDialogPref = setCommDbDialogPref; modified = ETrue; } buf->Des() = aFieldName; buf->Des().Append(KImapIAPIndex); if(aScriptFileParser->GetFieldAsInteger(buf->Des(), intTmp) == KErrNone) { index = intTmp; modified = ETrue; } if (modified) { aImapIapPref.AddIAPL(iapChoice ,index ); } CleanupStack::PopAndDestroy(buf); }
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")); }