os/security/cryptomgmtlibs/securitycommonutils/source/scsclient/scsclientsubsessionbase.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 * Defines the functionality which client-side subsession handles use
    16 * to create and destroy subsessions, and to send messages to them.
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file
    23 */
    24 
    25 
    26 #include <scs/scsclient.h>
    27 #include <scs/scscommon.h>
    28 
    29 using namespace ScsImpl;
    30 
    31 
    32 EXPORT_C RScsClientSubsessionBase::RScsClientSubsessionBase()
    33 /**
    34 	This protected constructor prevents the class from being
    35 	instantiated directly.
    36  */
    37 :	RSubSessionBase()
    38 	{
    39 	// empty.
    40 	}
    41 
    42 EXPORT_C void RScsClientSubsessionBase::Close()
    43 /**
    44 	Closes the subsession, releasing resources on the server side.
    45  */
    46 	{
    47 	CloseSubSession(ECloseSubsession);
    48 	}
    49 
    50 EXPORT_C TInt RScsClientSubsessionBase::CreateSubsession(const RScsClientBase& aSession, TInt aFunction, const TIpcArgs& aArgs)
    51 /**
    52 	Create a subsession over the supplied session.
    53 
    54 	@param	aSession		Session which will host the subsession.
    55 	@param	aFunction		Command identifier.	 Bits 31:24 must be zero, because
    56 							they are reserved for SCS commands.
    57 	@param	aArgs			Standard IPC arguments.	 The fourth argument cannot be
    58 							used because that is reserved for the subsession handle.
    59 	@return					Error code with which the server completed the request.
    60  */
    61 	{
    62 	return RSubSessionBase::CreateSubSession(
    63 		aSession,
    64 		ECreateSubsession | aFunction,
    65 		aArgs);
    66 	}
    67 
    68 EXPORT_C TInt RScsClientSubsessionBase::CallSubsessionFunction(TInt aFunction) const
    69 /**
    70 	Send a command to the corresponding server-side subsession.
    71 	The subclass uses this function instead of directly calling
    72 	RSubSessionBase::SendReceive because it adds the SCS code which
    73 	marks this as a subsession call.  Therefore, it can be routed
    74 	to the subsession object on the server side without any custom
    75 	decoding.
    76 	
    77 	@param	aFunction		Subsession command identifier.	Bits 31:24 must be zero,
    78 							because they are reserved for SCS commands.
    79 	@return					Error code with which the server completed the request.
    80  */
    81 	{
    82 	__ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClNoArgsSubsessUsedScs));
    83 	
    84 	TInt f = ECallSubsessionFunc | aFunction;
    85 	return RSubSessionBase::SendReceive(f);
    86 	}
    87 
    88 EXPORT_C TInt RScsClientSubsessionBase::CallSubsessionFunction(TInt aFunction, const TIpcArgs& aArgs) const
    89 /**
    90 	Send a command to the corresponding server-side subsession.
    91 	The subclass uses this function instead of directly calling
    92 	RSubSessionBase::SendReceive because it adds the SCS code which
    93 	marks this as a subsession call.  Therefore, it can be routed
    94 	to the subsession object on the server side without any custom
    95 	decoding.
    96 	
    97 	@param	aFunction		Subsession command identifier.	Bits 31:24 must be zero,
    98 							because they are reserved for SCS commands.
    99 	@param	aArgs			Standard IPC arguments.	 The fourth argument cannot be
   100 							used because that is reserved for the subsession handle.
   101 	@return					Error code with which the server completed the request.
   102  */
   103 	{
   104 	__ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClArgsSubsessUsedScs));
   105 	
   106 	TInt f = ECallSubsessionFunc | aFunction;
   107 	return RSubSessionBase::SendReceive(f, aArgs);	
   108 	}
   109 
   110 EXPORT_C void RScsClientSubsessionBase::CallSubsessionFunction(TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus) const
   111 /**
   112 	Send a command to the corresponding server-side subsession.
   113 	
   114 	@param	aFunction		Subsession command identifier.	Bits 31:24 must be zero,
   115 							because they are reserved for SCS commands.
   116 	@param	aArgs			Standard IPC arguments.	 The fourth argument cannot be
   117 							used because that is reserved for the subsession handle.
   118 	@param	aStatus			The server completes this object when it has finished
   119 							handling the session.
   120  */
   121 	{
   122 	__ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClArgsSubsessAsyncUsedScs));
   123 	
   124 	TInt f = ECallSubsessionFunc | aFunction;
   125 	RSubSessionBase::SendReceive(f, aArgs, aStatus);		
   126 	}
   127 
   128 EXPORT_C void RScsClientSubsessionBase::CancelSubsessionFunction(TInt aFunction) const
   129 /**
   130 	Cancel an outstanding subsession request.  This has no effect if the
   131 	request is not outstanding.
   132 	
   133 	@param	aFunction		Implementation function.  This must be the
   134 							same value that was supplied to CallSubsessionFunction.
   135  */
   136 	{
   137 	__ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClCancelSubsessUsedScs));
   138 	
   139 	TInt f = ECancelSubsessionFunc | aFunction;
   140 	RSubSessionBase::SendReceive(f);
   141 	}
   142