os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestserver/scstestsubsession.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * Implements CScsTestSubsession.  See class and function definitons
    16 * for more information.
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file
    23 */
    24 
    25 #include "scstestserver.h"
    26 
    27 
    28 CScsTestSubsession* CScsTestSubsession::NewL(CScsTestSession &aSession, const RMessage2& aMessage)
    29 /**
    30 	Factory function allocates new, initialized instance of CScsTestSubsession.
    31 
    32 	@param	aSession		Reference to our parent session
    33 	@param	aMessage		Create subsession message sent from the client.
    34 							This contains the integer on which the subsession
    35 							is curried.
    36 	@return					New, initialized instance of CScsTestSubsession
    37 							which is owned by the caller.
    38  */
    39 	{
    40 	CScsTestSubsession* self = new(ELeave) CScsTestSubsession(aSession);
    41 
    42 	// record value on which this subsession is curried
    43 	self->iValue = aMessage.Int0();
    44 	return self;
    45 	}
    46 
    47 CScsTestSubsession::CScsTestSubsession(CScsTestSession &aSession)
    48 /**
    49 	This private constructor prevents direct instantiation and provides
    50 	a single point of definition.
    51  */
    52 :	CScsSubsession(aSession)
    53 	{
    54 	// empty.
    55 	}
    56 
    57 CScsTestSubsession::~CScsTestSubsession()
    58 /**
    59 	This destructor is only defined to breakpoint when the
    60 	subsession is destroyed.
    61  */
    62 	{
    63 	// empty.
    64 	}
    65 
    66 TBool CScsTestSubsession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
    67 /**
    68 	Implement CSscSubsession by handling messages sent to this subsession.
    69 
    70 	@param	aFunction		Function identifier without SCS code.
    71 	@param	aMessage		Standard server-side handle to message.
    72 	@return ETrue means complete client request now.
    73  */
    74 	{
    75 	ScsTestImpl::TSubsessionFunction f =
    76 		static_cast<ScsTestImpl::TSubsessionFunction>(aFunction);
    77 
    78 	TBool completeMessage = ETrue;
    79 	switch (f)
    80 		{
    81 	case ScsTestImpl::ESubsessQuadruple:
    82 		{
    83 		TPckgBuf<TInt> times4 = iValue * 4;
    84 		aMessage.WriteL(0, times4);
    85 		}
    86 		break;
    87 
    88 	case ScsTestImpl::ESubsessTreble:
    89 		{
    90 		CScsTestSession* owningSession = static_cast<CScsTestSession*>(&iSession);
    91 		CTrebleRequest::NewL(owningSession, this, aMessage);
    92 		completeMessage = EFalse; // do not complete yet		
    93 		}
    94 		break;
    95 	
    96 	default:
    97 		User::Leave(KErrNotSupported);
    98 		}
    99 	return completeMessage;
   100 	}
   101