os/security/cryptomgmtlibs/securitycommonutils/source/scsclient/scsclientsubsessionbase.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitycommonutils/source/scsclient/scsclientsubsessionbase.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,142 @@
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 +* Defines the functionality which client-side subsession handles use
1.19 +* to create and destroy subsessions, and to send messages to them.
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 +*/
1.27 +
1.28 +
1.29 +#include <scs/scsclient.h>
1.30 +#include <scs/scscommon.h>
1.31 +
1.32 +using namespace ScsImpl;
1.33 +
1.34 +
1.35 +EXPORT_C RScsClientSubsessionBase::RScsClientSubsessionBase()
1.36 +/**
1.37 + This protected constructor prevents the class from being
1.38 + instantiated directly.
1.39 + */
1.40 +: RSubSessionBase()
1.41 + {
1.42 + // empty.
1.43 + }
1.44 +
1.45 +EXPORT_C void RScsClientSubsessionBase::Close()
1.46 +/**
1.47 + Closes the subsession, releasing resources on the server side.
1.48 + */
1.49 + {
1.50 + CloseSubSession(ECloseSubsession);
1.51 + }
1.52 +
1.53 +EXPORT_C TInt RScsClientSubsessionBase::CreateSubsession(const RScsClientBase& aSession, TInt aFunction, const TIpcArgs& aArgs)
1.54 +/**
1.55 + Create a subsession over the supplied session.
1.56 +
1.57 + @param aSession Session which will host the subsession.
1.58 + @param aFunction Command identifier. Bits 31:24 must be zero, because
1.59 + they are reserved for SCS commands.
1.60 + @param aArgs Standard IPC arguments. The fourth argument cannot be
1.61 + used because that is reserved for the subsession handle.
1.62 + @return Error code with which the server completed the request.
1.63 + */
1.64 + {
1.65 + return RSubSessionBase::CreateSubSession(
1.66 + aSession,
1.67 + ECreateSubsession | aFunction,
1.68 + aArgs);
1.69 + }
1.70 +
1.71 +EXPORT_C TInt RScsClientSubsessionBase::CallSubsessionFunction(TInt aFunction) const
1.72 +/**
1.73 + Send a command to the corresponding server-side subsession.
1.74 + The subclass uses this function instead of directly calling
1.75 + RSubSessionBase::SendReceive because it adds the SCS code which
1.76 + marks this as a subsession call. Therefore, it can be routed
1.77 + to the subsession object on the server side without any custom
1.78 + decoding.
1.79 +
1.80 + @param aFunction Subsession command identifier. Bits 31:24 must be zero,
1.81 + because they are reserved for SCS commands.
1.82 + @return Error code with which the server completed the request.
1.83 + */
1.84 + {
1.85 + __ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClNoArgsSubsessUsedScs));
1.86 +
1.87 + TInt f = ECallSubsessionFunc | aFunction;
1.88 + return RSubSessionBase::SendReceive(f);
1.89 + }
1.90 +
1.91 +EXPORT_C TInt RScsClientSubsessionBase::CallSubsessionFunction(TInt aFunction, const TIpcArgs& aArgs) const
1.92 +/**
1.93 + Send a command to the corresponding server-side subsession.
1.94 + The subclass uses this function instead of directly calling
1.95 + RSubSessionBase::SendReceive because it adds the SCS code which
1.96 + marks this as a subsession call. Therefore, it can be routed
1.97 + to the subsession object on the server side without any custom
1.98 + decoding.
1.99 +
1.100 + @param aFunction Subsession command identifier. Bits 31:24 must be zero,
1.101 + because they are reserved for SCS commands.
1.102 + @param aArgs Standard IPC arguments. The fourth argument cannot be
1.103 + used because that is reserved for the subsession handle.
1.104 + @return Error code with which the server completed the request.
1.105 + */
1.106 + {
1.107 + __ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClArgsSubsessUsedScs));
1.108 +
1.109 + TInt f = ECallSubsessionFunc | aFunction;
1.110 + return RSubSessionBase::SendReceive(f, aArgs);
1.111 + }
1.112 +
1.113 +EXPORT_C void RScsClientSubsessionBase::CallSubsessionFunction(TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus) const
1.114 +/**
1.115 + Send a command to the corresponding server-side subsession.
1.116 +
1.117 + @param aFunction Subsession command identifier. Bits 31:24 must be zero,
1.118 + because they are reserved for SCS commands.
1.119 + @param aArgs Standard IPC arguments. The fourth argument cannot be
1.120 + used because that is reserved for the subsession handle.
1.121 + @param aStatus The server completes this object when it has finished
1.122 + handling the session.
1.123 + */
1.124 + {
1.125 + __ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClArgsSubsessAsyncUsedScs));
1.126 +
1.127 + TInt f = ECallSubsessionFunc | aFunction;
1.128 + RSubSessionBase::SendReceive(f, aArgs, aStatus);
1.129 + }
1.130 +
1.131 +EXPORT_C void RScsClientSubsessionBase::CancelSubsessionFunction(TInt aFunction) const
1.132 +/**
1.133 + Cancel an outstanding subsession request. This has no effect if the
1.134 + request is not outstanding.
1.135 +
1.136 + @param aFunction Implementation function. This must be the
1.137 + same value that was supplied to CallSubsessionFunction.
1.138 + */
1.139 + {
1.140 + __ASSERT_DEBUG(! ScsFieldUsed(aFunction), ClientSidePanic(EScsClCancelSubsessUsedScs));
1.141 +
1.142 + TInt f = ECancelSubsessionFunc | aFunction;
1.143 + RSubSessionBase::SendReceive(f);
1.144 + }
1.145 +