messagingfw/msgtestfw/TestActions/Email/Pop3/src/CMtfTestActionModifyPopSettings.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 // SavePopSettings
       
    17 // [Action Parameters]
       
    18 // accountId			input 			TPOP3Account
       
    19 // configFileIndex		input			Index of config file	
       
    20 // [Action Description]
       
    21 // SavePopSettings Test Action is intended to modify and save existing POP settings to 
       
    22 // CenRep for the specified POP account Id from configuration settings file.
       
    23 // [APIs Used]	
       
    24 // CEmailAccounts::SavePopSettingsL
       
    25 // CImPop3Settings::SetServerAddressL
       
    26 // CImPop3Settings::SetLoginNameL
       
    27 // CImPop3Settings::SetPasswordL
       
    28 // CImPop3Settings::SetMaxEmailSize
       
    29 // CImPop3Settings::SetPort
       
    30 // CImPop3Settings::SetInboxSynchronisationLimit
       
    31 // CImPop3Settings::SetUserAddressL
       
    32 // CImPop3Settings::SetAutoSendOnConnect
       
    33 // CImPop3Settings::SetApop
       
    34 // CImPop3Settings::SetDisconnectedUserMode
       
    35 // CImPop3Settings::SetDeleteEmailWhenDisconnecting
       
    36 // CImPop3Settings::SetAcknowledgeReceipts
       
    37 // CImPop3Settings::SetGetMailOptions
       
    38 // CImPop3Settings::SetPopulationLimit
       
    39 // CImSmtpSettings::SetServerAddressL
       
    40 // CImSmtpSettings::SetEmailAddressL
       
    41 // CImSmtpSettings::SetBodyEncoding
       
    42 // CImSmtpSettings::SetReceiptAddressL
       
    43 // CImSmtpSettings::SetRequestReceipts
       
    44 // CImSmtpSettings::SetSendMessageOption
       
    45 // CImSmtpSettings::SetPort
       
    46 // CImSmtpSettings::SetEmailAliasL
       
    47 // CImSmtpSettings::SetBodyEncoding
       
    48 // CImSmtpSettings::SetDefaultMsgCharSet
       
    49 // CImSmtpSettings::SetUserAddress
       
    50 // CImIAPPreferences::AddIAPL
       
    51 // __ACTION_INFO_END__
       
    52 // 
       
    53 //
       
    54 
       
    55 
       
    56 #include <pop3set.h>
       
    57 #include <smtpset.h>
       
    58 
       
    59 #include <cemailaccounts.h>
       
    60 #include <iapprefs.h>
       
    61 
       
    62 #include "CMtfTestActionModifyPopSettings.h"
       
    63 #include "CMtfTestCase.h"
       
    64 #include "CMtfTestActionParameters.h"
       
    65 #include "CMtfTestActionUtilsPopScripts.h"
       
    66 
       
    67 
       
    68 /**
       
    69   Function : NewL
       
    70   Description : 
       
    71   @internalTechnology
       
    72   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    73   @param : aActionParams - CMtfTestActionParameters 
       
    74   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionModifyPopSettings object
       
    75   @pre none
       
    76   @post none
       
    77 */
       
    78 CMtfTestAction* CMtfTestActionModifyPopSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    79 	{
       
    80 	CMtfTestActionModifyPopSettings* self = new (ELeave) CMtfTestActionModifyPopSettings(aTestCase);
       
    81 	CleanupStack::PushL(self);
       
    82 	self->ConstructL(aActionParameters);
       
    83 	CleanupStack::Pop(self);
       
    84 	return self;
       
    85 	}
       
    86 
       
    87 /**
       
    88   Function : CMtfTestActionModifyPopSettings
       
    89   Description : Constructor
       
    90   @internalTechnology
       
    91   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    92   @return : N/A
       
    93   @pre none
       
    94   @post none
       
    95 */
       
    96 CMtfTestActionModifyPopSettings::CMtfTestActionModifyPopSettings(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    97 	{
       
    98 	}
       
    99 
       
   100 /**
       
   101   Function : ~CMtfTestActionModifyPopSettings
       
   102   Description : Destructor
       
   103   @internalTechnology
       
   104   @param :
       
   105   @return : 
       
   106   @pre 
       
   107   @post 
       
   108 */
       
   109 CMtfTestActionModifyPopSettings::~CMtfTestActionModifyPopSettings()
       
   110 	{
       
   111 	}
       
   112 
       
   113 /**
       
   114   Function : ExecuteActionL
       
   115   Description : Entry point for the this test action in the test framework
       
   116   @internalTechnology
       
   117   @param : none
       
   118   @return : void
       
   119   @pre none 
       
   120   @post none
       
   121 */
       
   122 void CMtfTestActionModifyPopSettings::ExecuteActionL()
       
   123 	{
       
   124 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionModifyPopSettings);
       
   125 	TPopAccount popAccount = ObtainValueParameterL<TPopAccount>(TestCase(), ActionParameters().Parameter(0));
       
   126 	
       
   127 	HBufC* settingsFile = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(1) );
       
   128 	
       
   129 	CEmailAccounts* emailAccounts = CEmailAccounts::NewL();
       
   130 	CleanupStack::PushL(emailAccounts);
       
   131 	
       
   132 	CImIAPPreferences* smtpPrefs = CImIAPPreferences::NewLC();
       
   133 	CImSmtpSettings* smtpSettings = new(ELeave) CImSmtpSettings();
       
   134 	CleanupStack::PushL(smtpSettings);
       
   135 	
       
   136 	CImIAPPreferences* popPrefs = CImIAPPreferences::NewLC();
       
   137 	
       
   138 	CImPop3Settings* popSettings = new(ELeave) CImPop3Settings();
       
   139 	CleanupStack::PushL(popSettings);
       
   140 	
       
   141 	// populate the default settings to make sure that they contain no empty strings
       
   142 	emailAccounts->PopulateDefaultPopSettingsL(*popSettings, *popPrefs);
       
   143 	emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings, *smtpPrefs);
       
   144 
       
   145 	CMtfTestActionUtilsPopScripts::ReadPopSettingsFromConfigurationFileL(TestCase(), settingsFile->Des(), 
       
   146 							*popSettings, *popPrefs, *smtpSettings, *smtpPrefs);
       
   147 							
       
   148 													
       
   149 	emailAccounts->SavePopSettingsL(popAccount, *popSettings);
       
   150 	emailAccounts->SavePopIapSettingsL(popAccount, *popPrefs);
       
   151 	TSmtpAccount smtpAccount;
       
   152 	emailAccounts->GetSmtpAccountL(popAccount.iSmtpService, smtpAccount);
       
   153 	emailAccounts->SaveSmtpSettingsL(smtpAccount, *smtpSettings);
       
   154 	emailAccounts->SaveSmtpIapSettingsL(smtpAccount, *smtpPrefs);
       
   155 	
       
   156 	CleanupStack::PopAndDestroy( 5, emailAccounts ); 
       
   157 		
       
   158 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionModifyPopSettings);
       
   159 	TestCase().ActionCompletedL(*this); 
       
   160 	}
       
   161 
       
   162