messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionSaveImapSettings.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 // SaveImapSettings
       
    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 // SaveImapSettings 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::SaveImapSettingsL
       
    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 "CMtfTestActionSaveImapSettings.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 CMtfTestActionSaveImapSettings object
       
    82   @pre none
       
    83   @post none
       
    84 */
       
    85 CMtfTestAction* CMtfTestActionSaveImapSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    86 	{
       
    87 	CMtfTestActionSaveImapSettings* self = new (ELeave) CMtfTestActionSaveImapSettings(aTestCase);
       
    88 	CleanupStack::PushL(self);
       
    89 	self->ConstructL(aActionParameters);
       
    90 	CleanupStack::Pop(self);
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 /**
       
    95   Function : CMtfTestActionSaveImapSettings
       
    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 CMtfTestActionSaveImapSettings::CMtfTestActionSaveImapSettings(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
   104 	{
       
   105 	}
       
   106 	
       
   107 /**
       
   108   Function : ~CMtfTestActionSaveImapSettings
       
   109   Description : Destructor
       
   110   @internalTechnology
       
   111   @param :
       
   112   @return : 
       
   113   @pre 
       
   114   @post 
       
   115 */
       
   116 CMtfTestActionSaveImapSettings::~CMtfTestActionSaveImapSettings()
       
   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 CMtfTestActionSaveImapSettings::ExecuteActionL()
       
   130 	{
       
   131 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSaveImapSettings);
       
   132 	TImapAccount accountId = ObtainValueParameterL<TImapAccount>( TestCase(),ActionParameters().Parameter(0) );
       
   133 	TInt paramDefaultIndex = ObtainValueParameterL<TInt>( TestCase(),ActionParameters().Parameter(1) );
       
   134 	const TPtrC settingsFile = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfImap4Settings, paramDefaultIndex);
       
   135 	
       
   136 	CImImap4Settings* imapSet = new(ELeave) CImImap4Settings();
       
   137 	CleanupStack::PushL(imapSet);
       
   138 	
       
   139 	CImIAPPreferences* imapIapPref = CImIAPPreferences::NewLC();
       
   140 	
       
   141 	CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings();
       
   142 	CleanupStack::PushL(smtpSet);
       
   143 
       
   144 	CImIAPPreferences* smtpIapPref = CImIAPPreferences::NewLC();
       
   145 	
       
   146 	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();			
       
   147 	
       
   148 	CMtfTestActionUtilsImapScripts::ReadImapSettingsFromConfigurationFileL( TestCase(), settingsFile, 
       
   149 											*imapSet, *imapIapPref, *smtpSet, *smtpIapPref);
       
   150 	
       
   151 	emailAccounts->SaveImapSettingsL(accountId, *imapSet);
       
   152 	emailAccounts->SaveImapIapSettingsL(accountId, *imapIapPref);
       
   153 	TSmtpAccount smtpAccount;
       
   154 	emailAccounts->GetSmtpAccountL(accountId.iSmtpService, smtpAccount);
       
   155 	emailAccounts->SaveSmtpSettingsL(smtpAccount, *smtpSet);
       
   156 	emailAccounts->SaveSmtpIapSettingsL(smtpAccount, *smtpIapPref);
       
   157 	
       
   158 	CleanupStack::PopAndDestroy(emailAccounts);
       
   159 	
       
   160 	StoreParameterL<CImIAPPreferences>(TestCase(), *smtpIapPref , ActionParameters().Parameter(5) );
       
   161 	CleanupStack::Pop(smtpIapPref);
       
   162 	
       
   163 	StoreParameterL<CImSmtpSettings>(TestCase(), *smtpSet , ActionParameters().Parameter(4) );
       
   164 	CleanupStack::Pop(smtpSet);
       
   165 	
       
   166 	StoreParameterL<CImIAPPreferences>(TestCase(), *imapIapPref , ActionParameters().Parameter(3) );
       
   167 	CleanupStack::Pop(imapIapPref);
       
   168 
       
   169 	StoreParameterL<CImImap4Settings>(TestCase(), *imapSet , ActionParameters().Parameter(2) );
       
   170 	CleanupStack::Pop(imapSet);
       
   171 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSaveImapSettings);
       
   172 	TestCase().ActionCompletedL(*this);
       
   173 	}
       
   174 
       
   175