messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionModifyImapSettings.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 // ModifyImapSettings
       
    17 // [Action Parameters]
       
    18 // accountId			input		TIMAP4Account
       
    19 // ImapSettings			output		CImImap4Settings
       
    20 // ImapIAP				output		CImIAPPreferences
       
    21 // SMTPSettings			output		CImSMTPSettings
       
    22 // SmtpIAP				output		CImIAPPreferences
       
    23 // [Action Description]
       
    24 // ModifyImapSettings Test Action is intended to modify and save the existing settings to CenRep 
       
    25 // for the specified IMAP account Id
       
    26 // [APIs Used]	
       
    27 // CEmailAccounts::ModifyImapSettingsL
       
    28 // CImImap4Settings::SetServerAddressL
       
    29 // CImImap4Settings::SetUserAddressL
       
    30 // CImImap4Settings::SetLoginNameL
       
    31 // CImImap4Settings::SetPasswordL
       
    32 // CImImap4Settings::SetPort
       
    33 // CImImap4Settings::SetSecureSockets
       
    34 // CImImap4Settings::SetVersion
       
    35 // CImImap4Settings::SetFolderPathL
       
    36 // CImImap4Settings::SetPathSeparator
       
    37 // CImImap4Settings::SetMaxEmailSize
       
    38 // CImImap4Settings::SetGetMailOptions
       
    39 // CImImap4Settings::SetInboxSynchronisationLimit
       
    40 // CImImap4Settings::SetMailboxSynchronisationLimit
       
    41 // CImSmtpSettings::SetServerAddressL
       
    42 // CImSmtpSettings::SetEmailAddressL
       
    43 // CImSmtpSettings::SetBodyEncoding
       
    44 // CImSmtpSettings::SetReceiptAddressL
       
    45 // CImSmtpSettings::SetRequestReceipts
       
    46 // CImSmtpSettings::SetSendMessageOption
       
    47 // CImSmtpSettings::SetPort
       
    48 // CImSmtpSettings::SetEmailAliasL
       
    49 // CImSmtpSettings::SetBodyEncoding
       
    50 // CImSmtpSettings::SetDefaultMsgCharSet
       
    51 // CImSmtpSettings::SetUserAddress
       
    52 // CImSmtpSettings::SetVersion
       
    53 // CImIAPPreferences::Version
       
    54 // CImIAPPreferences::AddIAPL 
       
    55 // __ACTION_INFO_END__
       
    56 // 
       
    57 //
       
    58 
       
    59 
       
    60 
       
    61 
       
    62 #include <imapset.h>
       
    63 #include <smtpset.h>
       
    64 #include <iapprefs.h>
       
    65 
       
    66 #include <cemailaccounts.h>
       
    67 
       
    68 
       
    69 #include "CMtfTestCase.h"
       
    70 #include "CMtfTestActionParameters.h"
       
    71 #include "CMtfTestActionUtilsImapScripts.h"
       
    72 #include "CMtfTestActionModifyImapSettings.h"
       
    73 
       
    74 
       
    75 /**
       
    76   Function : NewL
       
    77   Description : 
       
    78   @internalTechnology
       
    79   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    80   @param : aActionParams - CMtfTestActionParameters 
       
    81   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionModifyImapSettings object
       
    82   @pre none
       
    83   @post none
       
    84 */
       
    85 CMtfTestAction* CMtfTestActionModifyImapSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    86 	{
       
    87 	CMtfTestActionModifyImapSettings* self = new (ELeave) CMtfTestActionModifyImapSettings(aTestCase);
       
    88 	CleanupStack::PushL(self);
       
    89 	self->ConstructL(aActionParameters);
       
    90 	CleanupStack::Pop(self);
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 /**
       
    95   Function : CMtfTestActionModifyImapSettings
       
    96   Description : Constructor
       
    97   @internalTechnology
       
    98   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    99   @return : N/A
       
   100   @pre none
       
   101   @post none
       
   102 */
       
   103 CMtfTestActionModifyImapSettings::CMtfTestActionModifyImapSettings(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
   104 	{
       
   105 	}
       
   106 	
       
   107 /**
       
   108   Function : ~CMtfTestActionModifyImapSettings
       
   109   Description : Destructor
       
   110   @internalTechnology
       
   111   @param :
       
   112   @return : 
       
   113   @pre 
       
   114   @post 
       
   115 */
       
   116 CMtfTestActionModifyImapSettings::~CMtfTestActionModifyImapSettings()
       
   117 	{
       
   118 	}
       
   119 
       
   120 /**
       
   121   Function : ExecuteActionL
       
   122   Description : Entry point for the this test action in the test framework
       
   123   @internalTechnology
       
   124   @param : none
       
   125   @return : void
       
   126   @pre none 
       
   127   @post none
       
   128 */
       
   129 void CMtfTestActionModifyImapSettings::ExecuteActionL()
       
   130 	{
       
   131 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionModifyImapSettings);
       
   132 	TImapAccount accountId = ObtainValueParameterL<TImapAccount>( TestCase(),ActionParameters().Parameter(0) );
       
   133 
       
   134 	HBufC* settingsFile = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(1) );
       
   135 
       
   136 	CEmailAccounts* emailAccounts=CEmailAccounts::NewLC();
       
   137 	
       
   138 	CImImap4Settings* imapSet = new(ELeave) CImImap4Settings();
       
   139 	CleanupStack::PushL(imapSet);
       
   140 	
       
   141 	CImIAPPreferences* imapIapPref = CImIAPPreferences::NewLC();
       
   142 	
       
   143 	CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings();
       
   144 	CleanupStack::PushL(smtpSet);
       
   145 
       
   146 	CImIAPPreferences* smtpIapPref = CImIAPPreferences::NewLC();
       
   147 
       
   148 	// load the settings for the account with the current settings
       
   149 	emailAccounts->LoadImapSettingsL(accountId, *imapSet);
       
   150 	emailAccounts->LoadImapIapSettingsL(accountId, *imapIapPref);
       
   151 	TSmtpAccount smtpAccount;
       
   152 	emailAccounts->GetSmtpAccountL(accountId.iSmtpService, smtpAccount);
       
   153 	emailAccounts->LoadSmtpSettingsL(smtpAccount, *smtpSet);
       
   154 	emailAccounts->LoadSmtpIapSettingsL(smtpAccount, *smtpIapPref);
       
   155 	
       
   156 	// Read the settings from the file
       
   157 	CMtfTestActionUtilsImapScripts::ReadImapSettingsFromConfigurationFileL( TestCase(), settingsFile->Des(), 
       
   158 											*imapSet, *imapIapPref, *smtpSet, *smtpIapPref);
       
   159 	
       
   160 	// Save the new settings
       
   161 	emailAccounts->SaveImapSettingsL(accountId, *imapSet);
       
   162 	emailAccounts->SaveImapIapSettingsL(accountId, *imapIapPref);
       
   163 	emailAccounts->SaveSmtpSettingsL(smtpAccount, *smtpSet);
       
   164 	emailAccounts->SaveSmtpIapSettingsL(smtpAccount, *smtpIapPref);
       
   165 
       
   166 	CleanupStack::PopAndDestroy(5, emailAccounts); // smtpIapPref, smtpSet, imapIapPref, imapSet
       
   167 		
       
   168 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionModifyImapSettings);
       
   169 
       
   170 	TestCase().ActionCompletedL(*this);
       
   171 	}
       
   172 
       
   173