messagingfw/msgtestfw/TestActions/Email/Pop3/src/CMtfTestActionCreatePopAccount.cpp
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // CreatePopAccount
       
    17 // [Action Parameters]
       
    18 // accountName		<input>:	Name of the account to create
       
    19 // configFile		<input>:	Configuration file to use for the settings
       
    20 // accountId		<output>:	POP3 account ID
       
    21 // popSettings		<output>:	POP3 settings object
       
    22 // popIAPPrefs		<output>:	POP3 IAP Preferences
       
    23 // smtpSettings		<output>:	SMTP settings object
       
    24 // smtpIAPPrefs		<output>:	SMTP IAP Preferences
       
    25 // [Action Description]
       
    26 // CreatePopAccount Test Action is intended to create a POP account in the 
       
    27 // Central Repository using the configuration settings from ini file.  
       
    28 // This ini file includes both POP, SMTP settings and IAP preference settings 
       
    29 // for both POP and SMTP.
       
    30 // [APIs Used]	
       
    31 // CEmailAccounts::CreatePopAccountL
       
    32 // CImPop3Settings::SetServerAddressL
       
    33 // CImPop3Settings::SetLoginNameL
       
    34 // CImPop3Settings::SetPasswordL
       
    35 // CImPop3Settings::SetMaxEmailSize
       
    36 // CImPop3Settings::SetPort
       
    37 // CImPop3Settings::SetInboxSynchronisationLimit
       
    38 // CImPop3Settings::SetUserAddressL
       
    39 // CImPop3Settings::SetAutoSendOnConnect
       
    40 // CImPop3Settings::SetApop
       
    41 // CImPop3Settings::SetDisconnectedUserMode
       
    42 // CImPop3Settings::SetDeleteEmailWhenDisconnecting
       
    43 // CImPop3Settings::SetAcknowledgeReceipts
       
    44 // CImPop3Settings::SetGetMailOptions
       
    45 // CImPop3Settings::SetPopulationLimit
       
    46 // CImSmtpSettings::SetServerAddressL
       
    47 // CImSmtpSettings::SetEmailAddressL
       
    48 // CImSmtpSettings::SetBodyEncoding
       
    49 // CImSmtpSettings::SetReceiptAddressL
       
    50 // CImSmtpSettings::SetRequestReceipts
       
    51 // CImSmtpSettings::SetSendMessageOption
       
    52 // CImSmtpSettings::SetPort
       
    53 // CImSmtpSettings::SetEmailAliasL
       
    54 // CImSmtpSettings::SetBodyEncoding
       
    55 // CImSmtpSettings::SetDefaultMsgCharSet
       
    56 // CImSmtpSettings::SetUserAddress
       
    57 // CImSmtpSettings::SetVersion
       
    58 // CImIAPPreferences::Version
       
    59 // CImIAPPreferences::AddIAPL
       
    60 // __ACTION_INFO_END__
       
    61 // 
       
    62 //
       
    63 
       
    64 
       
    65 
       
    66 
       
    67 #include <pop3set.h>
       
    68 #include <smtpset.h>
       
    69 #include <iapprefs.h>
       
    70 
       
    71 #include <cemailaccounts.h>
       
    72 
       
    73 #include "CMtfTestCase.h"
       
    74 //#include "CMtfTestServer.h"
       
    75 #include "CMtfTestActionParameters.h"
       
    76 #include "CMtfTestActionCreatePopAccount.h"
       
    77 #include "CMtfTestActionUtilsPopScripts.h"
       
    78 
       
    79 /**
       
    80   Function : NewL
       
    81   Description : 
       
    82   @internalTechnology
       
    83   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    84   @param : aActionParams - CMtfTestActionParameters 
       
    85   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionCreatePopAccount object
       
    86   @pre none
       
    87   @post none
       
    88 */
       
    89 CMtfTestAction* CMtfTestActionCreatePopAccount::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    90 	{
       
    91 	CMtfTestActionCreatePopAccount* self = new (ELeave) CMtfTestActionCreatePopAccount(aTestCase);
       
    92 	CleanupStack::PushL(self);
       
    93 	self->ConstructL(aActionParameters);
       
    94 	CleanupStack::Pop(self);
       
    95 	return self;
       
    96 	}
       
    97 	
       
    98 /**
       
    99   Function : CMtfTestActionCreatePopAccount
       
   100   Description : Constructor
       
   101   @internalTechnology
       
   102   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
   103   @return : N/A
       
   104   @pre none
       
   105   @post none
       
   106 */
       
   107 CMtfTestActionCreatePopAccount::CMtfTestActionCreatePopAccount(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
   108 	{
       
   109 	}
       
   110 	
       
   111 /**
       
   112   Function : ~CMtfTestActionCreatePopAccount
       
   113   Description : Destructor
       
   114   @internalTechnology
       
   115   @param :
       
   116   @return : 
       
   117   @pre 
       
   118   @post 
       
   119 */
       
   120 CMtfTestActionCreatePopAccount::~CMtfTestActionCreatePopAccount()
       
   121 	{
       
   122 	}
       
   123 
       
   124 /**
       
   125   Function : ExecuteActionL
       
   126   Description : Entry point for the this test action in the test framework
       
   127   @internalTechnology
       
   128   @param : none
       
   129   @return : void
       
   130   @pre none 
       
   131   @post none
       
   132 */
       
   133 void CMtfTestActionCreatePopAccount::ExecuteActionL()
       
   134 	{
       
   135 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreatePopAccount);
       
   136 
       
   137 	HBufC* paramAccountName = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(0) );
       
   138 	HBufC* settingsFile = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(1) );
       
   139 
       
   140 	CEmailAccounts *emailAccounts = CEmailAccounts::NewL();
       
   141 	CleanupStack::PushL(emailAccounts);
       
   142 	
       
   143 	CImIAPPreferences* smtpPrefs = CImIAPPreferences::NewLC();
       
   144 	CImSmtpSettings* smtpSettings = new(ELeave) CImSmtpSettings();
       
   145 	CleanupStack::PushL(smtpSettings);
       
   146 	
       
   147 	CImIAPPreferences* popPrefs = CImIAPPreferences::NewLC();
       
   148 	CImPop3Settings* popSettings = new(ELeave) CImPop3Settings();
       
   149 	CleanupStack::PushL(popSettings);
       
   150 
       
   151 	emailAccounts->PopulateDefaultPopSettingsL(*popSettings, *popPrefs);
       
   152 	emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings, *smtpPrefs);
       
   153 		
       
   154 	if( settingsFile->CompareF( _L("none") ) != 0 )
       
   155 		{
       
   156 		CMtfTestActionUtilsPopScripts::ReadPopSettingsFromConfigurationFileL(
       
   157 			TestCase(), settingsFile->Des(), *popSettings, *popPrefs, *smtpSettings, *smtpPrefs);
       
   158 		}
       
   159 	
       
   160 	//Store settings for later comparison
       
   161 	StoreParameterL<CImPop3Settings>(TestCase(), *popSettings , ActionParameters().Parameter(3) );	
       
   162 	StoreParameterL<CImIAPPreferences>(TestCase(), *popPrefs , ActionParameters().Parameter(4) );
       
   163 	StoreParameterL<CImSmtpSettings>(TestCase(), *smtpSettings , ActionParameters().Parameter(5) );
       
   164 	StoreParameterL<CImIAPPreferences>(TestCase(), *smtpPrefs , ActionParameters().Parameter(6) );
       
   165 	
       
   166 	TPopAccount popAccount = emailAccounts->CreatePopAccountL(paramAccountName->Des(), *popSettings, *popPrefs, EFalse);
       
   167 	TSmtpAccount smtpAccount = emailAccounts->CreateSmtpAccountL(popAccount, *smtpSettings, *smtpPrefs, EFalse);
       
   168 	emailAccounts->SetDefaultSmtpAccountL(smtpAccount);	
       
   169 
       
   170 	StoreParameterL<TPopAccount>(TestCase(), popAccount, ActionParameters().Parameter(2));	
       
   171 	
       
   172   	CleanupStack::Pop(4, smtpPrefs); // popSettings, popPrefs, smtpSettings, smtpPrefs
       
   173   	CleanupStack::PopAndDestroy(emailAccounts);
       
   174 	
       
   175 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreatePopAccount);
       
   176 	TestCase().ActionCompletedL(*this);
       
   177 	}
       
   178 
       
   179