sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Implements CScsTestSession. See class and function definitions sl@0: * for more information. sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: sl@0: #include "scstestserver.h" sl@0: sl@0: sl@0: CScsTestSession* CScsTestSession::NewL(CScsTestServer &aServer) sl@0: /** sl@0: Factory function allocates new instance of CScsTestSession. sl@0: sl@0: @param aServer Reference to our parent server sl@0: @return New, initialized instance of CScsTestSession sl@0: which is owned by the caller. sl@0: */ sl@0: { sl@0: CScsTestSession* s = new(ELeave) CScsTestSession(aServer); sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(); // CScsSession implementation sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CScsTestSession::CScsTestSession(CScsTestServer &aServer) sl@0: /** sl@0: This private constructor prevents direct instantiation. sl@0: */ sl@0: : CScsSession(aServer) sl@0: { sl@0: // empty. sl@0: } sl@0: sl@0: CScsTestSession::~CScsTestSession() sl@0: /** sl@0: Because this object does not (yet) own any resources, this sl@0: destructor is only defined to ensure a single definition is sl@0: generated. sl@0: sl@0: The base class destructor destroys any remaining subsessions sl@0: or outstanding requests. sl@0: */ sl@0: { sl@0: // empty. sl@0: } sl@0: sl@0: TBool CScsTestSession::DoServiceL(TInt aFunction, const RMessage2& aMessage) sl@0: /** sl@0: Implement CScsTestSession by handling the supplied message. sl@0: sl@0: @param aFunction Function identifier without SCS code. sl@0: @param aMessage Standard server-side handle to message. sl@0: @return ETrue means complete client request now. sl@0: sl@0: @see CScsSession::ServiceError. sl@0: */ sl@0: { sl@0: ScsTestImpl::TSessionFunction f = static_cast(aFunction); sl@0: sl@0: switch (f) sl@0: { sl@0: case ScsTestImpl::ESessNukeServer: sl@0: CActiveScheduler::Stop(); sl@0: return EFalse; // Server will crash due to outstanding reqs sl@0: sl@0: case ScsTestImpl::ESessDouble: sl@0: { sl@0: TPckgBuf value; sl@0: aMessage.Read(0, value); sl@0: value() *= 2; sl@0: aMessage.WriteL(0, value); sl@0: } sl@0: break; sl@0: sl@0: case ScsTestImpl::ESessTreble: sl@0: { sl@0: CTrebleRequest::NewL(this, /* aSubsession */ NULL, aMessage); sl@0: return EFalse; // Do NOT complete client request yet sl@0: } sl@0: sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: return ETrue; // Complete client request now sl@0: } sl@0: sl@0: CScsSubsession* CScsTestSession::DoCreateSubsessionL(TInt aFunction, const RMessage2& aMessage) sl@0: /** sl@0: Override CScsSession by allocating an instance of CScsTestSubsession sl@0: to handle ScsTestImpl::ESessSubsessFromInt. sl@0: sl@0: @param aFunction Function identifier without SCS code. sl@0: @param aMessage Standard server-side handle to message. sl@0: @see ScsTestImpl::ESessSubsessFromInt sl@0: */ sl@0: { sl@0: switch (aFunction) sl@0: { sl@0: case ScsTestImpl::ESessSubsessFromInt: sl@0: return CScsTestSubsession::NewL(*this, aMessage); sl@0: sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: return 0; // avoid compiler warning sl@0: } sl@0: } sl@0: