messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionGetImapAccountSettings.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 // GetImapAccountSettings
       
    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 // GetImapAccountSettings Test Action is intended to retrieve IMAP settings 
       
    25 // from CenRep for the specified account Id.
       
    26 // [APIs Used]	
       
    27 // CEmailAccounts::GetImapAccountSettingsL
       
    28 // CImImap4Settings::SetServerAddressL
       
    29 // CImImap4Settings::SetLoginNameL
       
    30 // CImImap4Settings::SetPasswordL
       
    31 // CImSmtpSettings::SetServerAddressL
       
    32 // CImSmtpSettings::SetEmailAddressL
       
    33 // CImIAPPreferences::Version
       
    34 // CImIAPPreferences::AddIAPL
       
    35 // __ACTION_INFO_END__
       
    36 // 
       
    37 //
       
    38 
       
    39 
       
    40 #include <cemailaccounts.h>
       
    41 
       
    42 #include <imapset.h>
       
    43 #include <smtpset.h>
       
    44 #include <iapprefs.h>
       
    45 
       
    46 #include "CMtfTestCase.h"
       
    47 #include "CMtfTestActionParameters.h"
       
    48 #include "CMtfTestActionGetImapAccountSettings.h"
       
    49 
       
    50 /**
       
    51   Function : NewL
       
    52   Description : 
       
    53   @internalTechnology
       
    54   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    55   @param : aActionParams - CMtfTestActionParameters 
       
    56   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionGetImapAccountSettings object
       
    57   @pre none
       
    58   @post none
       
    59 */
       
    60 CMtfTestAction* CMtfTestActionGetImapAccountSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    61 	{
       
    62 	CMtfTestActionGetImapAccountSettings* self = new (ELeave) CMtfTestActionGetImapAccountSettings(aTestCase);
       
    63 	CleanupStack::PushL(self);
       
    64 	self->ConstructL(aActionParameters);
       
    65 	CleanupStack::Pop(self);
       
    66 	return self;
       
    67 	}
       
    68 	
       
    69 /**
       
    70   Function : CMtfTestActionGetImapAccountSettings
       
    71   Description : Constructor
       
    72   @internalTechnology
       
    73   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    74   @return : N/A
       
    75   @pre none
       
    76   @post none
       
    77 */
       
    78 CMtfTestActionGetImapAccountSettings::CMtfTestActionGetImapAccountSettings(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    79 	{
       
    80 	}
       
    81 
       
    82 /**
       
    83   Function : ~CMtfTestActionGetImapAccountSettings
       
    84   Description : Destructor
       
    85   @internalTechnology
       
    86   @param :
       
    87   @return : 
       
    88   @pre 
       
    89   @post 
       
    90 */
       
    91 CMtfTestActionGetImapAccountSettings::~CMtfTestActionGetImapAccountSettings()
       
    92 	{
       
    93 	}
       
    94 
       
    95 void CMtfTestActionGetImapAccountSettings::LoadSettingsL(CEmailAccounts& aAccounts, const TImapAccount& aAccount, CImImap4Settings& aImapSettings, CImIAPPreferences& aImapIapSettings, CImSmtpSettings& aSmtpSettings, CImIAPPreferences& aSmtpIapSettings)
       
    96 	{
       
    97 	aAccounts.LoadImapSettingsL(aAccount, aImapSettings);
       
    98 	aAccounts.LoadImapIapSettingsL(aAccount, aImapIapSettings);
       
    99 	TSmtpAccount smtpAccount;
       
   100 	aAccounts.GetSmtpAccountL(aAccount.iSmtpService, smtpAccount);
       
   101 	aAccounts.LoadSmtpSettingsL(smtpAccount, aSmtpSettings);
       
   102 	aAccounts.LoadSmtpIapSettingsL(smtpAccount, aSmtpIapSettings);
       
   103 	}
       
   104 
       
   105 /**
       
   106   Function : ExecuteActionL
       
   107   Description : Entry point for the this test action in the test framework
       
   108   @internalTechnology
       
   109   @param : none
       
   110   @return : void
       
   111   @pre none 
       
   112   @post none
       
   113 */
       
   114 void CMtfTestActionGetImapAccountSettings::ExecuteActionL()
       
   115 	{
       
   116 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionGetImapAccountSettings);
       
   117 	// Get the previously stored account id
       
   118 	TImapAccount accountId = ObtainValueParameterL<TImapAccount>( TestCase(),ActionParameters().Parameter(0) );
       
   119 
       
   120 	// create the objects neccessary for loading the settings
       
   121 	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
       
   122 	CImImap4Settings* imapSet =  new(ELeave) CImImap4Settings();
       
   123 	CleanupStack::PushL(imapSet);
       
   124 	CImIAPPreferences* imapIapPref = CImIAPPreferences::NewLC();
       
   125 	CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings();
       
   126 	CleanupStack::PushL(smtpSet);
       
   127 	CImIAPPreferences* smtpIapPref = CImIAPPreferences::NewLC();
       
   128 	
       
   129 	// load the settings
       
   130 	// this will leave if an attempt is made to access non existent settings
       
   131 	TRAPD( error, LoadSettingsL(*emailAccounts, accountId, *imapSet, *imapIapPref, *smtpSet, *smtpIapPref) );
       
   132 	if( error != KErrNone )
       
   133 		{
       
   134 		TestCase().ERR_PRINTF2(_L("LoadSettingsL Failed leave with code %d"), error );
       
   135 		TestCase().SetTestStepResult(EFail);		
       
   136 		}
       
   137 	
       
   138 	// params loaded ok so we can store them	
       
   139 	StoreParameterL<CImIAPPreferences>(TestCase(), *smtpIapPref , ActionParameters().Parameter(4) );
       
   140 	CleanupStack::Pop(smtpIapPref);
       
   141 
       
   142 	StoreParameterL<CImSmtpSettings>(TestCase(), *smtpSet , ActionParameters().Parameter(3) );
       
   143 	CleanupStack::Pop(smtpSet);
       
   144 
       
   145 	StoreParameterL<CImIAPPreferences>(TestCase(), *imapIapPref , ActionParameters().Parameter(2) );
       
   146 	CleanupStack::Pop(imapIapPref);
       
   147 
       
   148 	StoreParameterL<CImImap4Settings>(TestCase(), *imapSet , ActionParameters().Parameter(1) );
       
   149 	CleanupStack::Pop(imapSet);
       
   150 	
       
   151 	CleanupStack::PopAndDestroy(emailAccounts);
       
   152 		
       
   153 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionGetImapAccountSettings);
       
   154 	TestCase().ActionCompletedL(*this);
       
   155 	}
       
   156 
       
   157