messagingfw/msgtestfw/TestActions/Email/Pop3/src/CMtfTestActionCreatePop3Service.cpp
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     1 // Copyright (c) 2003-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 // CreatePop3Service
       
    17 // [Action Parameters]
       
    18 // Session       <input>: Reference to the session.
       
    19 // (Priority)     <input>: Value of the entry priority. Default is medium priority.
       
    20 // (ReadOnlyFlag) <input>: Value of the read only flag. Default is false.
       
    21 // (VisibleFlag)  <input>: Value of the visible flag. Default is true.
       
    22 // (Description)  <input>: Name of the description.	Default is blank.
       
    23 // (Details)      <input>: Name of the details. Default is blank.
       
    24 // ServiceId     <output>: Value of the created service id.
       
    25 // [Action Description]
       
    26 // Creates a POP3 service.
       
    27 // [APIs Used]
       
    28 // TMsvEntry::iType
       
    29 // TMsvEntry::SetPriority	
       
    30 // TMsvEntry::iMtm	
       
    31 // TMsvEntry::SetReadOnly	
       
    32 // TMsvEntry::SetVisible	
       
    33 // TMsvEntry::iDescription
       
    34 // TMsvEntry::iDetails
       
    35 // TMsvEntry::iDate
       
    36 // TMsvEntry::Id
       
    37 // CMsvEntry::SetEntryL
       
    38 // CMsvEntry::CreateL
       
    39 // __ACTION_INFO_END__
       
    40 // 
       
    41 //
       
    42 
       
    43 /**
       
    44  @file
       
    45 */
       
    46 
       
    47 
       
    48 #include <msvapi.h>
       
    49 #include <miutset.h>
       
    50 
       
    51 #include <cemailaccounts.h>
       
    52 #include <iapprefs.h>
       
    53 #include <pop3set.h>
       
    54 
       
    55 #include "CMtfTestActionUtilsPopScripts.h"
       
    56 
       
    57 
       
    58 
       
    59 
       
    60 
       
    61 #include "CMtfTestActionCreatePop3Service.h"
       
    62 #include "CMtfTestCase.h"
       
    63 #include "CMtfTestActionParameters.h"
       
    64 
       
    65 CMtfTestAction* CMtfTestActionCreatePop3Service::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    66 	{
       
    67 	CMtfTestActionCreatePop3Service* self = new (ELeave) CMtfTestActionCreatePop3Service(aTestCase);
       
    68 	CleanupStack::PushL(self);
       
    69 	self->ConstructL(aActionParameters);
       
    70 	CleanupStack::Pop();
       
    71 	return self;
       
    72 	}
       
    73 	
       
    74 
       
    75 CMtfTestActionCreatePop3Service::CMtfTestActionCreatePop3Service(CMtfTestCase& aTestCase)
       
    76 	: CMtfSynchronousTestAction(aTestCase)
       
    77 	{
       
    78 	}
       
    79 
       
    80 
       
    81 CMtfTestActionCreatePop3Service::~CMtfTestActionCreatePop3Service()
       
    82 	{
       
    83 	delete iBlank;
       
    84 	}
       
    85 
       
    86 void CMtfTestActionCreatePop3Service::ExecuteActionL()
       
    87 	{
       
    88 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreatePop3Service);
       
    89 	// need to create an account in the central repository and make it the default account
       
    90 	HBufC* paramAccountName = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(6) );
       
    91 	HBufC* settingsFile = ObtainParameterReferenceL<HBufC>( TestCase(),ActionParameters().Parameter(7) );
       
    92 
       
    93 	CEmailAccounts *emailAccounts = CEmailAccounts::NewLC();	
       
    94 	CImIAPPreferences *smtpPrefs = CImIAPPreferences::NewLC();
       
    95 	CImSmtpSettings *smtpSettings = new (ELeave) CImSmtpSettings;
       
    96 	CleanupStack::PushL(smtpSettings);
       
    97 	
       
    98 	CImIAPPreferences *popPrefs = CImIAPPreferences::NewLC();
       
    99 	CImPop3Settings *popSettings = new (ELeave) CImPop3Settings;
       
   100 	CleanupStack::PushL(popSettings);
       
   101 
       
   102 	emailAccounts->PopulateDefaultPopSettingsL(*popSettings, *popPrefs);
       
   103 	emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings, *smtpPrefs );
       
   104 		
       
   105 	if( settingsFile->Compare( _L("none") ) != 0 )
       
   106 		{
       
   107 		CMtfTestActionUtilsPopScripts::ReadPopSettingsFromConfigurationFileL(
       
   108 			TestCase(), settingsFile->Des(), *popSettings, *popPrefs, *smtpSettings, *smtpPrefs);
       
   109 		}
       
   110 	
       
   111 	TPopAccount popAccount = emailAccounts->CreatePopAccountL(paramAccountName->Des(), *popSettings, *popPrefs, EFalse);
       
   112 	TSmtpAccount smtpAccount = emailAccounts->CreateSmtpAccountL(popAccount, *smtpSettings, *smtpPrefs, EFalse);
       
   113 	emailAccounts->SetDefaultSmtpAccountL(smtpAccount);
       
   114 	
       
   115 	// need to obtain the service id from the account details and save this as the service id
       
   116 	TMsvId paramServiceId = popAccount.iPopService;
       
   117 	CleanupStack::PopAndDestroy(5, emailAccounts); // popSettings, popPrefs, smtpSettings, smtpPrefs, emailAccounts
       
   118 	
       
   119 	StoreParameterL<TMsvId>( TestCase(),paramServiceId, ActionParameters().Parameter(8) );
       
   120 	
       
   121 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreatePop3Service);
       
   122 	TestCase().ActionCompletedL(*this);
       
   123 	}
       
   124