messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionSetImap4FullDownloadLimits.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 // SetImap4FullDownloadLimits
       
    17 // [Action Parameters]
       
    18 // TInt     TotalSizeLimit          <input> : Value of the total size limit
       
    19 // Default value is KMaxTInt
       
    20 // TInt     PartialMailSizeOptions  <input> : Enumerated values defined in 
       
    21 // TImap4GetMailOptions
       
    22 // Default value is EGetImap4EmailHeaders
       
    23 // TMsvId   DestinationFolder       <input> : Value of the destination folder ID
       
    24 // TMsvId	ServiceId				<input> : Value of the Imap service id to use
       
    25 // TImImap4GetMailInfo  Imap4GetMailInfo <output-initiation>: Full Download limits
       
    26 // [Action Description]
       
    27 // Sets the member variables of TImImap4GetMailInfo
       
    28 // [APIs Used]
       
    29 // None
       
    30 // __ACTION_INFO_END__
       
    31 // 
       
    32 //
       
    33 
       
    34 /**
       
    35  @file
       
    36  @internalTechnology 
       
    37 */
       
    38 
       
    39 
       
    40 #include <cemailaccounts.h>
       
    41 #include <iapprefs.h>
       
    42 
       
    43 // EPOC include
       
    44 #include <imapset.h>
       
    45 
       
    46 // User include
       
    47 #include "CMtfTestActionSetImap4FullDownloadLimits.h"
       
    48 #include "CMtfTestCase.h"
       
    49 #include "CMtfTestActionParameters.h"
       
    50 
       
    51 
       
    52 /**
       
    53   NewL()
       
    54   Constructs a CMtfTestActionSetImap4FullDownloadLimits object.
       
    55   Uses two phase construction and leaves nothing on the CleanupStack.   
       
    56   @internalTechnology
       
    57   @param  aTestCase         Test Case to which this Test Action belongs
       
    58   @param  aActionParameters Action parameters, must not be NULL
       
    59   @return Created object of type CMtfTestActionSetImap4FullDownloadLimits
       
    60   @pre    None
       
    61   @post   CMtfTestActionSetImap4FullDownloadLimits object is created
       
    62 */
       
    63 CMtfTestAction* CMtfTestActionSetImap4FullDownloadLimits::
       
    64 		NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    65 	{
       
    66 	
       
    67 	CMtfTestActionSetImap4FullDownloadLimits* self = 
       
    68 						new (ELeave) CMtfTestActionSetImap4FullDownloadLimits(aTestCase);
       
    69 
       
    70 	CleanupStack::PushL(self);
       
    71 	self->ConstructL(aActionParameters);
       
    72 	CleanupStack::Pop(self);
       
    73 	return self;
       
    74 	}
       
    75 	
       
    76 
       
    77 /**
       
    78   CMtfTestActionSetImap4FullDownloadLimits constructor
       
    79   Calls the base class constructor
       
    80   @internalTechnology  
       
    81   @param  aTestCase  Test Case to which this Test Action belongs
       
    82   @pre    None
       
    83   @post   None
       
    84 */ 	
       
    85 CMtfTestActionSetImap4FullDownloadLimits::CMtfTestActionSetImap4FullDownloadLimits
       
    86 											(CMtfTestCase& aTestCase)
       
    87 	: CMtfSynchronousTestAction(aTestCase)
       
    88 	{
       
    89 	}
       
    90 
       
    91 
       
    92 /**
       
    93   ExecuteActionL
       
    94   Sets the values for TImImap4GetMailInfo memeber variables and then store it
       
    95   as an output parameter of the Test Action.
       
    96   @internalTechnology 
       
    97   @pre    None
       
    98   @post   None
       
    99   @leave  System wide errors
       
   100 */
       
   101 void CMtfTestActionSetImap4FullDownloadLimits::ExecuteActionL()
       
   102 	{	
       
   103 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetImap4FullDownloadLimits);
       
   104 	// Obtain Test Action input parameters
       
   105 	TInt  paramTotalSizeLimit	  = ObtainValueParameterL<TInt>(TestCase(),
       
   106 										ActionParameters().Parameter(0),KMaxTInt);
       
   107 
       
   108 	TImap4GetMailOptions  paramMailOptions	 = ObtainValueParameterL<TImap4GetMailOptions>
       
   109 												(TestCase(),ActionParameters().Parameter(1),
       
   110 												EGetImap4EmailHeaders);
       
   111 
       
   112  	TMsvId	paramDestinationFolder  = ObtainValueParameterL<TMsvId>
       
   113 										(TestCase(),ActionParameters().Parameter(2));
       
   114 										
       
   115 	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(3));
       
   116 
       
   117 	// Store the full donwload limits values 
       
   118 	TImImap4GetMailInfo  imap4GetMailInfo;
       
   119 		
       
   120 	imap4GetMailInfo.iMaxEmailSize      = paramTotalSizeLimit;
       
   121 	imap4GetMailInfo.iGetMailBodyParts  = paramMailOptions;
       
   122 	imap4GetMailInfo.iDestinationFolder = paramDestinationFolder;
       
   123 	
       
   124 	// Load the Imap account settings and save the download limits
       
   125 	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();	
       
   126 	CImImap4Settings* imapSettings =  new(ELeave) CImImap4Settings();
       
   127 	CleanupStack::PushL(imapSettings);
       
   128 
       
   129 	TImapAccount imapAccount;
       
   130 	emailAccounts->GetImapAccountL(paramServiceId, imapAccount);
       
   131 	emailAccounts->LoadImapSettingsL(imapAccount, *imapSettings);
       
   132 		
       
   133 	imapSettings->SetMaxEmailSize( imap4GetMailInfo.iMaxEmailSize );
       
   134 	imapSettings->SetGetMailOptions( imap4GetMailInfo.iGetMailBodyParts );
       
   135 	
       
   136 	emailAccounts->SaveImapSettingsL(imapAccount, *imapSettings);
       
   137 	CleanupStack::PopAndDestroy( 2, emailAccounts ); // imapSettings, emailSettings
       
   138 	
       
   139 
       
   140 	// Store the full download limits as the ouput parameter of the Test Action		
       
   141 	StoreParameterL<TImImap4GetMailInfo>(TestCase(),imap4GetMailInfo,
       
   142 											ActionParameters().Parameter(4));
       
   143 
       
   144 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetImap4FullDownloadLimits );
       
   145 	TestCase().ActionCompletedL(*this);
       
   146 	}