messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfDoInvokeAsyncFunctionWithSelectionTestAction.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 //
       
    15 
       
    16 /**
       
    17  @file 
       
    18  @internalTechnology 
       
    19 */
       
    20 
       
    21 
       
    22 // EPOC include
       
    23 #include <imapset.h>
       
    24 
       
    25 
       
    26 // User include
       
    27 #include "CMtfDoInvokeAsyncFunctionWithSelectionTestAction.h"
       
    28 #include "CMtfTestCase.h"
       
    29 #include "CMtfTestActionParameters.h"
       
    30 
       
    31 
       
    32 /**   Constructor  */
       
    33 CMtfDoInvokeAsyncFunctionWithSelectionTestAction::
       
    34 		CMtfDoInvokeAsyncFunctionWithSelectionTestAction(CMtfTestCase& aTestCase)
       
    35 	: CMtfDoInvokeAsyncFunctionTestAction(aTestCase), iMailSelection(NULL)
       
    36 	{
       
    37 	}
       
    38 
       
    39 
       
    40 /**
       
    41   Destructor.
       
    42 */
       
    43 CMtfDoInvokeAsyncFunctionWithSelectionTestAction::
       
    44 	~CMtfDoInvokeAsyncFunctionWithSelectionTestAction()
       
    45 	{
       
    46 	delete iMailSelection;
       
    47 	}
       
    48 
       
    49 /** 
       
    50   DoCancel
       
    51   Cancels the pending asynchronous operation
       
    52 */
       
    53 void CMtfDoInvokeAsyncFunctionWithSelectionTestAction::DoCancel()
       
    54 	{
       
    55 	delete iMailSelection;
       
    56 	iMailSelection = NULL;
       
    57 	CMtfDoInvokeAsyncFunctionTestAction::DoCancel();
       
    58 	}
       
    59 
       
    60 
       
    61 /**
       
    62   ExecuteIMAP4CommandL
       
    63   Obtains the Test Action input parameters, appends IMAP4 
       
    64   service Id to the mail selection and calls the base class  
       
    65   function InvokeAsyncImap4PopulateCommandL()
       
    66   @internalTechnology 
       
    67   @param	aImap4Command	IMAP4-specific command
       
    68   @pre		None
       
    69   @post		Asynchronous operation for the IMAP4 command is initiated
       
    70   @leave	System wide errors
       
    71 */	
       
    72 void CMtfDoInvokeAsyncFunctionWithSelectionTestAction::ExecuteIMAP4CommandL
       
    73 														 (TImap4Cmds aImap4Command)
       
    74 	{
       
    75 	// Obtain input parameter IMAP4 Service Id
       
    76 	TMsvId			  paramServiceId  =	ObtainValueParameterL<TMsvId>(TestCase(),
       
    77 										  ActionParameters().Parameter(0));
       
    78 
       
    79 		// // Obtain input parameter mail selection
       
    80 	CMsvEntrySelection* paramMailSelection=	ObtainParameterReferenceL<CMsvEntrySelection>
       
    81 										(TestCase(),ActionParameters().Parameter(3));
       
    82 	
       
    83 									  
       
    84 	/************************************************************************
       
    85 	 A selection of mails that need to be downloaded to a local folder
       
    86 	 The first entry in this selection MUST be the service. 
       
    87 	 For populating a selection of mails, the selection of mails should
       
    88 	 be appended after the service ID. The selection of mails MUST have the
       
    89 	 same parent i.e. MUST be in the same folder.
       
    90 	*************************************************************************/
       
    91 	
       
    92 	iMailSelection =  new (ELeave) CMsvEntrySelection;
       
    93 	
       
    94 	if(aImap4Command != KIMAP4MTMPopulate)
       
    95 		{
       
    96 		iMailSelection->InsertL(0, paramServiceId);
       
    97 		}	
       
    98 
       
    99 	TInt mailCount = paramMailSelection->Count();
       
   100 
       
   101 	for (TInt selecIndex=0; selecIndex < mailCount; selecIndex++)	
       
   102 		{
       
   103 		TMsvId msvId = paramMailSelection->At(selecIndex);
       
   104 		iMailSelection->AppendL(msvId);
       
   105 		}
       
   106 		
       
   107 	// Call the base class function to invokes asynchronous IMAP4-specific operation
       
   108 	InvokeAsyncImap4PopulateCommandL(aImap4Command, *iMailSelection);
       
   109 	}