os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/scstestsession.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/scstestsession.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,126 @@
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 CScsTestSession. See class and function definitions
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 +CScsTestSession* CScsTestSession::NewL(CScsTestServer &aServer)
1.32 +/**
1.33 + Factory function allocates new instance of CScsTestSession.
1.34 +
1.35 + @param aServer Reference to our parent server
1.36 + @return New, initialized instance of CScsTestSession
1.37 + which is owned by the caller.
1.38 + */
1.39 + {
1.40 + CScsTestSession* s = new(ELeave) CScsTestSession(aServer);
1.41 + CleanupStack::PushL(s);
1.42 + s->ConstructL(); // CScsSession implementation
1.43 + CleanupStack::Pop(s);
1.44 + return s;
1.45 + }
1.46 +
1.47 +CScsTestSession::CScsTestSession(CScsTestServer &aServer)
1.48 +/**
1.49 + This private constructor prevents direct instantiation.
1.50 + */
1.51 +: CScsSession(aServer)
1.52 + {
1.53 + // empty.
1.54 + }
1.55 +
1.56 +CScsTestSession::~CScsTestSession()
1.57 +/**
1.58 + Because this object does not (yet) own any resources, this
1.59 + destructor is only defined to ensure a single definition is
1.60 + generated.
1.61 +
1.62 + The base class destructor destroys any remaining subsessions
1.63 + or outstanding requests.
1.64 + */
1.65 + {
1.66 + // empty.
1.67 + }
1.68 +
1.69 +TBool CScsTestSession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
1.70 +/**
1.71 + Implement CScsTestSession by handling the supplied message.
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 + @see CScsSession::ServiceError.
1.78 + */
1.79 + {
1.80 + ScsTestImpl::TSessionFunction f = static_cast<ScsTestImpl::TSessionFunction>(aFunction);
1.81 +
1.82 + switch (f)
1.83 + {
1.84 + case ScsTestImpl::ESessNukeServer:
1.85 + CActiveScheduler::Stop();
1.86 + return EFalse; // Server will crash due to outstanding reqs
1.87 +
1.88 + case ScsTestImpl::ESessDouble:
1.89 + {
1.90 + TPckgBuf<TInt> value;
1.91 + aMessage.Read(0, value);
1.92 + value() *= 2;
1.93 + aMessage.WriteL(0, value);
1.94 + }
1.95 + break;
1.96 +
1.97 + case ScsTestImpl::ESessTreble:
1.98 + {
1.99 + CTrebleRequest::NewL(this, /* aSubsession */ NULL, aMessage);
1.100 + return EFalse; // Do NOT complete client request yet
1.101 + }
1.102 +
1.103 + default:
1.104 + User::Leave(KErrNotSupported);
1.105 + }
1.106 + return ETrue; // Complete client request now
1.107 + }
1.108 +
1.109 +CScsSubsession* CScsTestSession::DoCreateSubsessionL(TInt aFunction, const RMessage2& aMessage)
1.110 +/**
1.111 + Override CScsSession by allocating an instance of CScsTestSubsession
1.112 + to handle ScsTestImpl::ESessSubsessFromInt.
1.113 +
1.114 + @param aFunction Function identifier without SCS code.
1.115 + @param aMessage Standard server-side handle to message.
1.116 + @see ScsTestImpl::ESessSubsessFromInt
1.117 + */
1.118 + {
1.119 + switch (aFunction)
1.120 + {
1.121 + case ScsTestImpl::ESessSubsessFromInt:
1.122 + return CScsTestSubsession::NewL(*this, aMessage);
1.123 +
1.124 + default:
1.125 + User::Leave(KErrNotSupported);
1.126 + return 0; // avoid compiler warning
1.127 + }
1.128 + }
1.129 +