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