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"));
	}
/**
ReadPopSettingsFromConfigurationFileL()
Modifies the POP related default setting and IAP objects.

@param  aSettingsFile
Configuration/setting file path. 

@param  aPopSet
CImPop3Settings object.

@param  aPopIapPref
*/
EXPORT_C void CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(TDesC& aSettingsFile, 
											CImPop3Settings& aPopSet, CImIAPPreferences& aPopIapPref, const TDesC& /*aPtrEmailAdd*/)
	{
	// Parses the setting file
	CT_MsgUtilsConfigFileParserUtility* scriptFileParser = CT_MsgUtilsConfigFileParserUtility::NewL(aSettingsFile);
	CleanupStack::PushL(scriptFileParser);	
	
	TPtrC8 string8Ptr; 
	TPtrC stringPtr = KNone(); 
	TInt intValue;

	if(scriptFileParser->GetFieldAsString(KCfgPopServerAddress, stringPtr) == KErrNone)
		{	
		aPopSet.SetServerAddressL(stringPtr);
		}

	CT_MsgUtilsConfigFileMachineName* machineNameFile = CT_MsgUtilsConfigFileMachineName::NewLC(stringPtr);
	TPtrC8 machineName(machineNameFile->MachineName());

	
	if(scriptFileParser->GetFieldAsString8(KCfgPopLoginName, string8Ptr) == KErrNone)
		{
		aPopSet.SetLoginNameL(string8Ptr);
		}

	else
		{
		aPopSet.SetLoginNameL(machineName);
		}
	
	if(scriptFileParser->GetFieldAsString8(KCfgPopPassword, string8Ptr) == KErrNone)
		{
		aPopSet.SetPasswordL(string8Ptr);
		}

	else
		{
		aPopSet.SetPasswordL(machineName);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopMaxEmailSize, intValue) == KErrNone)
		{
		aPopSet.SetMaxEmailSize(intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopPort, intValue) == KErrNone)
		{
		aPopSet.SetPort(intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopInboxSynchronisationLimit, intValue) == KErrNone)
		{
		aPopSet.SetInboxSynchronisationLimit(intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopSecureSockets, intValue) == KErrNone)
		{
		aPopSet.SetSecureSockets((TBool)intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopSSLWrapper, intValue) == KErrNone)
		{
		aPopSet.SetSSLWrapper((TBool)intValue);
		}
	
	if(scriptFileParser->GetFieldAsString(KCfgPopGetMailOptions, stringPtr) == KErrNone)
		{
		TPop3GetMailOptions options = CT_MsgUtilsEnumConverter::ConvertDesToTPop3GetMailOptions(stringPtr);
		aPopSet.SetGetMailOptions(options);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopPopulationLimit, intValue) == KErrNone)
		{
		aPopSet.SetPopulationLimitL(intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopAutoSendOnConnect, intValue) == KErrNone)
		{	
		aPopSet.SetAutoSendOnConnect((TBool) intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopDeleteEmailsWhenDisconnecting, intValue) == KErrNone)
		{	
		aPopSet.SetDeleteEmailsWhenDisconnecting((TBool) intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopAcknowledgeReceipts, intValue) == KErrNone)
		{	
		aPopSet.SetAcknowledgeReceipts((TBool) intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopDisconnectedUserMode, intValue) == KErrNone)
		{	
		aPopSet.SetDisconnectedUserMode((TBool) intValue);
		}
	
	if(scriptFileParser->GetFieldAsInteger(KCfgPopAPOPEncryption, intValue) == KErrNone)
		{	
		aPopSet.SetApop((TBool) intValue);
		}
		
	if(scriptFileParser->GetFieldAsString(KCfgPopIapList, stringPtr) == KErrNone)
		{
		ReadPopIAPAndAddL(scriptFileParser, (TDesC&) KCfgPopIapList, aPopIapPref);
		}
		
	if(scriptFileParser->GetFieldAsInteger(KCfgPopSNAPId, intValue) == KErrNone)
		{		
		aPopIapPref.SetSNAPL(intValue);
		}
		
	if(scriptFileParser->GetFieldAsInteger(KCfgPopBearerMobility, intValue) == KErrNone)
		{	
		aPopSet.SetBearerMobility((TBool) intValue);
		}
		
	CleanupStack::PopAndDestroy(2,scriptFileParser);
	}
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"));
	}