messagingfw/msgtestfw/TestActions/Pigeon/src/CMtfTestActionSchedulePigeonMessage.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 // SchedulePigeonMessage
       
    17 // [Action Parameters]
       
    18 // CMsvSession	Session     <input>: Reference to the session
       
    19 // TMsvId		ParentId	<input>: Parent message Id
       
    20 // TInt			Command		<input>: Command to be passed to the Pigeon Server MTM	
       
    21 // [Action Description]
       
    22 // Issues command to Pigeon Server MTM to schedule/reschedule the messages.
       
    23 // [APIs Used]
       
    24 // none.
       
    25 // __ACTION_INFO_END__
       
    26 // 
       
    27 //
       
    28 
       
    29 // User includes
       
    30 #include "CMtfTestActionSchedulePigeonMessage.h"
       
    31 #include "CMtfTestCase.h"
       
    32 #include "CMtfTestActionParameters.h"
       
    33 #include "MtfTestActionUtilsUser.h"
       
    34 
       
    35 //User Include
       
    36 #include "pigeonservermtm.h"
       
    37 
       
    38 /**
       
    39   Function : NewL
       
    40   Description	: Constructs a new CMtfTestActionSchedulePigeonMessage object
       
    41   @internalTechnology
       
    42   @param		: aTestCase 		:Reference to the Test case
       
    43   @param		: aActionParams 	:Test Action parameters 
       
    44   @return		: CMtfTestAction* :a base class pointer to the newly created object
       
    45   @pre none
       
    46   @post: none
       
    47 */
       
    48 CMtfTestAction* CMtfTestActionSchedulePigeonMessage::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    49 	{
       
    50 	CMtfTestActionSchedulePigeonMessage* self = new (ELeave) CMtfTestActionSchedulePigeonMessage(aTestCase);
       
    51 	CleanupStack::PushL(self);
       
    52 	self->ConstructL(aActionParameters);
       
    53 	CleanupStack::Pop(self);
       
    54 	return self;
       
    55 	}
       
    56 	
       
    57 /**
       
    58   Function : CMtfTestActionSchedulePigeonMessage
       
    59   Description	: Constructor
       
    60   @internalTechnology
       
    61   @param		: aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    62   @pre none
       
    63   @post: none
       
    64 */
       
    65 CMtfTestActionSchedulePigeonMessage::CMtfTestActionSchedulePigeonMessage(CMtfTestCase& aTestCase)
       
    66 	:CMtfTestAction(aTestCase)
       
    67 	{
       
    68 	iOperation = NULL;
       
    69 	}
       
    70 
       
    71 /**
       
    72   Function : ~CMtfTestActionSchedulePigeonMessage
       
    73   Description : Destructor
       
    74   @internalTechnology
       
    75 */
       
    76 CMtfTestActionSchedulePigeonMessage::~CMtfTestActionSchedulePigeonMessage()
       
    77 	{
       
    78 	delete iSelection;
       
    79 	}
       
    80 
       
    81 /**
       
    82   Function : DoCancelL
       
    83   Description : Operation to be performed on cancellation of the asynchronous request
       
    84   @internalTechnology
       
    85   @param  : none
       
    86   @return : void
       
    87   @pre 
       
    88   @post none
       
    89 */
       
    90 void CMtfTestActionSchedulePigeonMessage::DoCancel()
       
    91 	{
       
    92 	iOperation->Cancel();
       
    93 	}
       
    94 
       
    95 /**
       
    96   Function : ExecuteActionL
       
    97   Description : Issues command to Pigeon Server MTM to schedule/reschedule the messages
       
    98   @internalTechnology
       
    99   @param  : none
       
   100   @return : void
       
   101   @pre  
       
   102   @post none
       
   103 */
       
   104 void CMtfTestActionSchedulePigeonMessage::ExecuteActionL()
       
   105 	{
       
   106 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSchedulePigeonMessage);
       
   107 	// Obtain input parameters
       
   108 	CMsvSession* paramSession	= ObtainParameterReferenceL<CMsvSession>(TestCase(),
       
   109 														ActionParameters().Parameter(0));
       
   110 	TMsvId paramParentId		= ObtainValueParameterL<TMsvId>(TestCase(),
       
   111 														ActionParameters().Parameter(1));
       
   112 	TInt paramCommand			= ObtainValueParameterL<TInt>(TestCase(),
       
   113 														ActionParameters().Parameter(2));
       
   114 	
       
   115 	//Error Handling Just in case one of the above inputs fail.
       
   116 	if(TestCase().TestStepResult() == EPass)
       
   117 		{
       
   118 		CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering());
       
   119 
       
   120 		// Get the selection of Pigeon Messages
       
   121 		iSelection = entry->ChildrenWithMtmL(KUidMsgTypePigeon);
       
   122 		
       
   123 		// Initiate asynchronous operation, passing the schedule/reschedule the message in the selection
       
   124 		// Dummy aParameter value passed as Pigeon MTM does not make use of it.
       
   125 		iOperation = paramSession->TransferCommandL(*iSelection,paramCommand, _L8("aaaa"), iStatus);
       
   126 		
       
   127 		CActiveScheduler::Add(this);
       
   128 		SetActive();
       
   129 		}
       
   130 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSchedulePigeonMessage);
       
   131 	}
       
   132 
       
   133 /**
       
   134   Function : RunL
       
   135   Description	: Handles the asynchronous request completion event. Informs the completion 
       
   136 				  of the Test Action to the Test Case
       
   137   @internalTechnology
       
   138   @param		: none
       
   139   @return		: void
       
   140   @pre none
       
   141   @post: none
       
   142 */
       
   143 void CMtfTestActionSchedulePigeonMessage::RunL()
       
   144 	{
       
   145 	TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus);
       
   146 	
       
   147 	delete iOperation;
       
   148 	iOperation = NULL;
       
   149 	
       
   150 	User::LeaveIfError(err);
       
   151 
       
   152 	TestCase().ActionCompletedL(*this);
       
   153 	}