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