cryptomgmtlibs/securitycommonutils/test/source/scstestserver/treblerequest.cpp
changeset 8 35751d3474b7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Implements CTrebleRequest.  See class and function definitions for information.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22 */
       
    23 
       
    24 #include "scstestserver.h"
       
    25 
       
    26 
       
    27 CTrebleRequest* CTrebleRequest::NewL(CScsTestSession* aSession, CScsTestSubsession* aSubsession, const RMessage2& aMessage)
       
    28 /**
       
    29 	Factory function allocates new instance of CTrebleRequest which and queues a timer.
       
    30 	When the timer expires it trebles the value of an integer in client space to complete
       
    31 	the request later.
       
    32 
       
    33 	@param	aSession		Session on which this request was launched.
       
    34 	@param	aSubsession		Subsession on which this request was launched.
       
    35 	@param	aMessage		Standard server-side handle to message.
       
    36  */
       
    37 	{
       
    38 	CTrebleRequest* self = new(ELeave) CTrebleRequest(aSession, aSubsession, aMessage);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(self);
       
    42 	return self;
       
    43 	}
       
    44 
       
    45 CTrebleRequest::CTrebleRequest(CScsTestSession* aSession, CScsTestSubsession* aSubsession, const RMessage2& aMessage)
       
    46 /**
       
    47 	This private constructor is defined to initialize the CAsyncRequest base class with
       
    48 	the supplied arguments.
       
    49 
       
    50 	@param	aSession		Session on which this request was launched.
       
    51 	@param	aSubsession		Subsession on which this request was launched.
       
    52 	@param	aMessage		Standard server-side handle to message.
       
    53  */
       
    54 :	CAsyncRequest(aSession, aSubsession, aMessage)
       
    55 	{
       
    56 	// empty.
       
    57 	}
       
    58 
       
    59 void CTrebleRequest::ConstructL()
       
    60 /**
       
    61 	Second-phase constructor initializes and launches the timer.
       
    62  */
       
    63 	{
       
    64 	TInt r = iTimer.CreateLocal();
       
    65 	User::LeaveIfError(r);
       
    66 	
       
    67 	CAsyncRequest::TransferToScsFrameworkL();
       
    68 	
       
    69 	iTimer.After(iStatus, ScsTestImpl::KTrebleTimerDelayUs);
       
    70 	SetActive();
       
    71 	}
       
    72 
       
    73 CTrebleRequest::~CTrebleRequest()
       
    74 /**
       
    75 	Close the timer which this object used to create a delay.
       
    76  */
       
    77 	{
       
    78 	iTimer.Close();
       
    79 	}
       
    80 
       
    81 void CTrebleRequest::RunL()
       
    82 /**
       
    83 	Treble the value passed by the client and complete
       
    84 	the request.
       
    85  */
       
    86 	{
       
    87 	// if these descriptor functions leave then RunError
       
    88 	// will be called by the active object framework.
       
    89 	TPckgBuf<TInt> valBuf;
       
    90 	iMessagePtr2.ReadL(0, valBuf);
       
    91 	valBuf() *= 3;
       
    92 	iMessagePtr2.WriteL(0, valBuf);
       
    93 	
       
    94 	//	CompleteAndMarkForDeletion(KErrNone);
       
    95 	// Call base class to call CompleteAndMarkForDeletion as this
       
    96 	// improves code coverage
       
    97 	CAsyncRequest::RunL();
       
    98 	}
       
    99 
       
   100 void CTrebleRequest::DoCancel()
       
   101 /**
       
   102 	Implement CActive by cancelling the outstanding activity.
       
   103 	This does not complete the client request or mark this object
       
   104 	for deletion.
       
   105  */
       
   106 	{
       
   107 	iTimer.Cancel();
       
   108 	}