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