os/security/cryptomgmtlibs/securitycommonutils/test/source/scstestclient/rscstestsession.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 * Client-side API tests an implementation of the session count server
    16 * by implementing a handle to a session.
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file
    23 */
    24 
    25 
    26 #include "scstestclient.h"
    27 #include "scstestcommon.h"
    28 
    29 
    30 EXPORT_C RScsTestSession::RScsTestSession()
    31 /**
    32 	This constructor defines a single point from which
    33 	the base class constructor is called.
    34  */
    35 :	RScsClientBase()
    36 	{
    37 	// empty.
    38 	}
    39 
    40 EXPORT_C TInt RScsTestSession::Connect()
    41 /**
    42 	Connect to the SCS test server using the default version.
    43 
    44 	@return					Symbian OS error code where KErrNone indicates
    45 							success and any other value indicates failure.
    46  */
    47 	{
    48 	const TVersion serverVersion = ScsTestImpl::Version();
    49 	return Connect(serverVersion);
    50 	}
    51 
    52 EXPORT_C TInt RScsTestSession::Connect(const TVersion& aVersion)
    53 /**
    54 	Connect to the SCS test server with the supplied version.  This
    55 	function is defined to test the version checking functionality in
    56 	CScsServer.  A client API would normally just ask for a server
    57 	version which at least matches its own.
    58 
    59 	@param	aVersion		Server version to ask for.
    60 	@return					Symbian OS error code where KErrNone indicates
    61 							success and any other value indicates failure.
    62  */
    63 	{
    64 	const TUidType serverFullUid = ScsTestImpl::ServerImageFullUid();
    65 	
    66 	TInt r = RScsClientBase::Connect(
    67 		ScsTestImpl::KServerName, aVersion,
    68 		ScsTestImpl::KServerImageName, serverFullUid);
    69 	
    70 	return r;
    71 	}
    72 
    73 EXPORT_C TInt RScsTestSession::SendCustomFunction(TInt aFunction)
    74 /**
    75 	Sends the supplied function identifier to the server with
    76 	no IPC arguments.  This function should be used to test the
    77 	server can handle an invalid SCS or session function.
    78 	
    79 	@param	aFunction		Function identifier to send to server-side
    80 							session.  This is sent as-is, and can use the
    81 							SCS field.
    82  */
    83 	{
    84 	return SendReceive(aFunction);
    85 	}
    86 
    87 EXPORT_C TInt RScsTestSession::NukeServer()
    88 /**
    89 	Calls an synchronous function which causes the server to panic
    90 */
    91 	{
    92 	return CallSessionFunction(ScsTestImpl::ESessNukeServer);
    93 	}
    94 
    95 EXPORT_C TInt RScsTestSession::Double(TInt& aValue)
    96 /**
    97 	Calls a synchronous session function to ensure the function
    98 	call is routed to the session subclass on the server side.
    99 	
   100 	@param	aValue			An arbitrary integer.  On completion
   101 							this should be double its entry value.
   102 	@return					Symbian OS error code where KErrNone indicates
   103 							success and any other value indicates failure.
   104  */
   105 	{
   106 	TPckg<TInt> valPckg(aValue);
   107 	TIpcArgs ipc(&valPckg);
   108 	return CallSessionFunction(ScsTestImpl::ESessDouble, ipc);
   109 	}
   110 
   111 EXPORT_C void RScsTestSession::Treble(TDes8& aValue, TRequestStatus& aStatus)
   112 /**
   113 	Calls an asynchronous function to test the SCS can successfully manage
   114 	asynchronous requests.
   115 	
   116 	@param	aValue			Describes an integer, e.g. TPckgBuf<TInt>.
   117 							The descriptor must be supplied by the caller
   118 							instead of being constructed in this function
   119 							because it must persist until the request has
   120 							been completed.
   121 	@param	aStatus			The server will complete this status object
   122 							when it has handled the function.
   123 	@see CancelTreble
   124  */
   125 	{
   126 	TIpcArgs ipc(&aValue);
   127 	CallSessionFunction(ScsTestImpl::ESessTreble, ipc, aStatus);
   128 	}
   129 
   130 EXPORT_C void RScsTestSession::CancelTreble()
   131 /**
   132 	Cancel an outstanding request set up with Treble.  This function has
   133 	no effect if there is no outstanding request.
   134 
   135 	@see Treble
   136  */
   137 	{
   138 	CancelSessionFunction(ScsTestImpl::ESessTreble);
   139 	}