os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestclient/rscstestsession.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestclient/rscstestsession.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,139 @@
     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 +* Client-side API tests an implementation of the session count server
    1.19 +* by implementing a handle to a session.
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +#include "scstestclient.h"
    1.30 +#include "scstestcommon.h"
    1.31 +
    1.32 +
    1.33 +EXPORT_C RScsTestSession::RScsTestSession()
    1.34 +/**
    1.35 +	This constructor defines a single point from which
    1.36 +	the base class constructor is called.
    1.37 + */
    1.38 +:	RScsClientBase()
    1.39 +	{
    1.40 +	// empty.
    1.41 +	}
    1.42 +
    1.43 +EXPORT_C TInt RScsTestSession::Connect()
    1.44 +/**
    1.45 +	Connect to the SCS test server using the default version.
    1.46 +
    1.47 +	@return					Symbian OS error code where KErrNone indicates
    1.48 +							success and any other value indicates failure.
    1.49 + */
    1.50 +	{
    1.51 +	const TVersion serverVersion = ScsTestImpl::Version();
    1.52 +	return Connect(serverVersion);
    1.53 +	}
    1.54 +
    1.55 +EXPORT_C TInt RScsTestSession::Connect(const TVersion& aVersion)
    1.56 +/**
    1.57 +	Connect to the SCS test server with the supplied version.  This
    1.58 +	function is defined to test the version checking functionality in
    1.59 +	CScsServer.  A client API would normally just ask for a server
    1.60 +	version which at least matches its own.
    1.61 +
    1.62 +	@param	aVersion		Server version to ask for.
    1.63 +	@return					Symbian OS error code where KErrNone indicates
    1.64 +							success and any other value indicates failure.
    1.65 + */
    1.66 +	{
    1.67 +	const TUidType serverFullUid = ScsTestImpl::ServerImageFullUid();
    1.68 +	
    1.69 +	TInt r = RScsClientBase::Connect(
    1.70 +		ScsTestImpl::KServerName, aVersion,
    1.71 +		ScsTestImpl::KServerImageName, serverFullUid);
    1.72 +	
    1.73 +	return r;
    1.74 +	}
    1.75 +
    1.76 +EXPORT_C TInt RScsTestSession::SendCustomFunction(TInt aFunction)
    1.77 +/**
    1.78 +	Sends the supplied function identifier to the server with
    1.79 +	no IPC arguments.  This function should be used to test the
    1.80 +	server can handle an invalid SCS or session function.
    1.81 +	
    1.82 +	@param	aFunction		Function identifier to send to server-side
    1.83 +							session.  This is sent as-is, and can use the
    1.84 +							SCS field.
    1.85 + */
    1.86 +	{
    1.87 +	return SendReceive(aFunction);
    1.88 +	}
    1.89 +
    1.90 +EXPORT_C TInt RScsTestSession::NukeServer()
    1.91 +/**
    1.92 +	Calls an synchronous function which causes the server to panic
    1.93 +*/
    1.94 +	{
    1.95 +	return CallSessionFunction(ScsTestImpl::ESessNukeServer);
    1.96 +	}
    1.97 +
    1.98 +EXPORT_C TInt RScsTestSession::Double(TInt& aValue)
    1.99 +/**
   1.100 +	Calls a synchronous session function to ensure the function
   1.101 +	call is routed to the session subclass on the server side.
   1.102 +	
   1.103 +	@param	aValue			An arbitrary integer.  On completion
   1.104 +							this should be double its entry value.
   1.105 +	@return					Symbian OS error code where KErrNone indicates
   1.106 +							success and any other value indicates failure.
   1.107 + */
   1.108 +	{
   1.109 +	TPckg<TInt> valPckg(aValue);
   1.110 +	TIpcArgs ipc(&valPckg);
   1.111 +	return CallSessionFunction(ScsTestImpl::ESessDouble, ipc);
   1.112 +	}
   1.113 +
   1.114 +EXPORT_C void RScsTestSession::Treble(TDes8& aValue, TRequestStatus& aStatus)
   1.115 +/**
   1.116 +	Calls an asynchronous function to test the SCS can successfully manage
   1.117 +	asynchronous requests.
   1.118 +	
   1.119 +	@param	aValue			Describes an integer, e.g. TPckgBuf<TInt>.
   1.120 +							The descriptor must be supplied by the caller
   1.121 +							instead of being constructed in this function
   1.122 +							because it must persist until the request has
   1.123 +							been completed.
   1.124 +	@param	aStatus			The server will complete this status object
   1.125 +							when it has handled the function.
   1.126 +	@see CancelTreble
   1.127 + */
   1.128 +	{
   1.129 +	TIpcArgs ipc(&aValue);
   1.130 +	CallSessionFunction(ScsTestImpl::ESessTreble, ipc, aStatus);
   1.131 +	}
   1.132 +
   1.133 +EXPORT_C void RScsTestSession::CancelTreble()
   1.134 +/**
   1.135 +	Cancel an outstanding request set up with Treble.  This function has
   1.136 +	no effect if there is no outstanding request.
   1.137 +
   1.138 +	@see Treble
   1.139 + */
   1.140 +	{
   1.141 +	CancelSessionFunction(ScsTestImpl::ESessTreble);
   1.142 +	}