os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/scstestsubsession.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/scstestsubsession.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,101 @@
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 CScsTestSubsession. See class and function definitons
1.19 +* for more information.
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 +*/
1.27 +
1.28 +#include "scstestserver.h"
1.29 +
1.30 +
1.31 +CScsTestSubsession* CScsTestSubsession::NewL(CScsTestSession &aSession, const RMessage2& aMessage)
1.32 +/**
1.33 + Factory function allocates new, initialized instance of CScsTestSubsession.
1.34 +
1.35 + @param aSession Reference to our parent session
1.36 + @param aMessage Create subsession message sent from the client.
1.37 + This contains the integer on which the subsession
1.38 + is curried.
1.39 + @return New, initialized instance of CScsTestSubsession
1.40 + which is owned by the caller.
1.41 + */
1.42 + {
1.43 + CScsTestSubsession* self = new(ELeave) CScsTestSubsession(aSession);
1.44 +
1.45 + // record value on which this subsession is curried
1.46 + self->iValue = aMessage.Int0();
1.47 + return self;
1.48 + }
1.49 +
1.50 +CScsTestSubsession::CScsTestSubsession(CScsTestSession &aSession)
1.51 +/**
1.52 + This private constructor prevents direct instantiation and provides
1.53 + a single point of definition.
1.54 + */
1.55 +: CScsSubsession(aSession)
1.56 + {
1.57 + // empty.
1.58 + }
1.59 +
1.60 +CScsTestSubsession::~CScsTestSubsession()
1.61 +/**
1.62 + This destructor is only defined to breakpoint when the
1.63 + subsession is destroyed.
1.64 + */
1.65 + {
1.66 + // empty.
1.67 + }
1.68 +
1.69 +TBool CScsTestSubsession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
1.70 +/**
1.71 + Implement CSscSubsession by handling messages sent to this subsession.
1.72 +
1.73 + @param aFunction Function identifier without SCS code.
1.74 + @param aMessage Standard server-side handle to message.
1.75 + @return ETrue means complete client request now.
1.76 + */
1.77 + {
1.78 + ScsTestImpl::TSubsessionFunction f =
1.79 + static_cast<ScsTestImpl::TSubsessionFunction>(aFunction);
1.80 +
1.81 + TBool completeMessage = ETrue;
1.82 + switch (f)
1.83 + {
1.84 + case ScsTestImpl::ESubsessQuadruple:
1.85 + {
1.86 + TPckgBuf<TInt> times4 = iValue * 4;
1.87 + aMessage.WriteL(0, times4);
1.88 + }
1.89 + break;
1.90 +
1.91 + case ScsTestImpl::ESubsessTreble:
1.92 + {
1.93 + CScsTestSession* owningSession = static_cast<CScsTestSession*>(&iSession);
1.94 + CTrebleRequest::NewL(owningSession, this, aMessage);
1.95 + completeMessage = EFalse; // do not complete yet
1.96 + }
1.97 + break;
1.98 +
1.99 + default:
1.100 + User::Leave(KErrNotSupported);
1.101 + }
1.102 + return completeMessage;
1.103 + }
1.104 +