os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/treblerequest.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/treblerequest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,108 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Implements CTrebleRequest. See class and function definitions for information.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 +*/
1.26 +
1.27 +#include "scstestserver.h"
1.28 +
1.29 +
1.30 +CTrebleRequest* CTrebleRequest::NewL(CScsTestSession* aSession, CScsTestSubsession* aSubsession, const RMessage2& aMessage)
1.31 +/**
1.32 + Factory function allocates new instance of CTrebleRequest which and queues a timer.
1.33 + When the timer expires it trebles the value of an integer in client space to complete
1.34 + the request later.
1.35 +
1.36 + @param aSession Session on which this request was launched.
1.37 + @param aSubsession Subsession on which this request was launched.
1.38 + @param aMessage Standard server-side handle to message.
1.39 + */
1.40 + {
1.41 + CTrebleRequest* self = new(ELeave) CTrebleRequest(aSession, aSubsession, aMessage);
1.42 + CleanupStack::PushL(self);
1.43 + self->ConstructL();
1.44 + CleanupStack::Pop(self);
1.45 + return self;
1.46 + }
1.47 +
1.48 +CTrebleRequest::CTrebleRequest(CScsTestSession* aSession, CScsTestSubsession* aSubsession, const RMessage2& aMessage)
1.49 +/**
1.50 + This private constructor is defined to initialize the CAsyncRequest base class with
1.51 + the supplied arguments.
1.52 +
1.53 + @param aSession Session on which this request was launched.
1.54 + @param aSubsession Subsession on which this request was launched.
1.55 + @param aMessage Standard server-side handle to message.
1.56 + */
1.57 +: CAsyncRequest(aSession, aSubsession, aMessage)
1.58 + {
1.59 + // empty.
1.60 + }
1.61 +
1.62 +void CTrebleRequest::ConstructL()
1.63 +/**
1.64 + Second-phase constructor initializes and launches the timer.
1.65 + */
1.66 + {
1.67 + TInt r = iTimer.CreateLocal();
1.68 + User::LeaveIfError(r);
1.69 +
1.70 + CAsyncRequest::TransferToScsFrameworkL();
1.71 +
1.72 + iTimer.After(iStatus, ScsTestImpl::KTrebleTimerDelayUs);
1.73 + SetActive();
1.74 + }
1.75 +
1.76 +CTrebleRequest::~CTrebleRequest()
1.77 +/**
1.78 + Close the timer which this object used to create a delay.
1.79 + */
1.80 + {
1.81 + iTimer.Close();
1.82 + }
1.83 +
1.84 +void CTrebleRequest::RunL()
1.85 +/**
1.86 + Treble the value passed by the client and complete
1.87 + the request.
1.88 + */
1.89 + {
1.90 + // if these descriptor functions leave then RunError
1.91 + // will be called by the active object framework.
1.92 + TPckgBuf<TInt> valBuf;
1.93 + iMessagePtr2.ReadL(0, valBuf);
1.94 + valBuf() *= 3;
1.95 + iMessagePtr2.WriteL(0, valBuf);
1.96 +
1.97 + // CompleteAndMarkForDeletion(KErrNone);
1.98 + // Call base class to call CompleteAndMarkForDeletion as this
1.99 + // improves code coverage
1.100 + CAsyncRequest::RunL();
1.101 + }
1.102 +
1.103 +void CTrebleRequest::DoCancel()
1.104 +/**
1.105 + Implement CActive by cancelling the outstanding activity.
1.106 + This does not complete the client request or mark this object
1.107 + for deletion.
1.108 + */
1.109 + {
1.110 + iTimer.Cancel();
1.111 + }