os/ossrv/stdlibs/libcrypt/test/src/tcryptserver.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2010 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 "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
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#include <c32comm.h>
sl@0
    19
sl@0
    20
#if defined (__WINS__)
sl@0
    21
#define PDD_NAME		_L("ECDRV")
sl@0
    22
#else
sl@0
    23
#define PDD_NAME		_L("EUART1")
sl@0
    24
#define PDD2_NAME		_L("EUART2")
sl@0
    25
#define PDD3_NAME		_L("EUART3")
sl@0
    26
#define PDD4_NAME		_L("EUART4")
sl@0
    27
#endif
sl@0
    28
sl@0
    29
#define LDD_NAME		_L("ECOMM")
sl@0
    30
sl@0
    31
/**
sl@0
    32
 * @file
sl@0
    33
 *
sl@0
    34
 * Pipe test server implementation
sl@0
    35
 */
sl@0
    36
#include "tcryptserver.h"
sl@0
    37
#include "tcrypt.h"
sl@0
    38
sl@0
    39
_LIT(KServerName, "tcrypt");
sl@0
    40
sl@0
    41
CTestCryptServer* CTestCryptServer::NewL()
sl@0
    42
	{
sl@0
    43
	CTestCryptServer *server = new(ELeave) CTestCryptServer();
sl@0
    44
	CleanupStack::PushL(server);
sl@0
    45
	server->ConstructL(KServerName);
sl@0
    46
	CleanupStack::Pop(server);
sl@0
    47
	return server;
sl@0
    48
	}
sl@0
    49
sl@0
    50
static void InitCommsL()
sl@0
    51
    {
sl@0
    52
    TInt ret = User::LoadPhysicalDevice(PDD_NAME);
sl@0
    53
    User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
sl@0
    54
sl@0
    55
#ifndef __WINS__
sl@0
    56
    ret = User::LoadPhysicalDevice(PDD2_NAME);
sl@0
    57
    ret = User::LoadPhysicalDevice(PDD3_NAME);
sl@0
    58
    ret = User::LoadPhysicalDevice(PDD4_NAME);
sl@0
    59
#endif
sl@0
    60
sl@0
    61
    ret = User::LoadLogicalDevice(LDD_NAME);
sl@0
    62
    User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
sl@0
    63
    ret = StartC32();
sl@0
    64
    User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
sl@0
    65
    }
sl@0
    66
LOCAL_C void MainL()
sl@0
    67
	{
sl@0
    68
	// Leave the hooks in for platform security
sl@0
    69
#if (defined __DATA_CAGING__)
sl@0
    70
	RProcess().DataCaging(RProcess::EDataCagingOn);
sl@0
    71
	RProcess().SecureApi(RProcess::ESecureApiOn);
sl@0
    72
#endif
sl@0
    73
	//InitCommsL();
sl@0
    74
	CActiveScheduler* sched=NULL;
sl@0
    75
	sched=new(ELeave) CActiveScheduler;
sl@0
    76
	CActiveScheduler::Install(sched);
sl@0
    77
	CTestCryptServer* server = NULL;
sl@0
    78
	// Create the CTestServer derived server
sl@0
    79
	TRAPD(err, server = CTestCryptServer::NewL());
sl@0
    80
	if(!err)
sl@0
    81
		{
sl@0
    82
		// Sync with the client and enter the active scheduler
sl@0
    83
		RProcess::Rendezvous(KErrNone);
sl@0
    84
		sched->Start();
sl@0
    85
		}
sl@0
    86
	delete server;
sl@0
    87
	delete sched;
sl@0
    88
	}
sl@0
    89
sl@0
    90
/**
sl@0
    91
 * Server entry point
sl@0
    92
 * @return Standard Epoc error code on exit
sl@0
    93
 */
sl@0
    94
TInt main()
sl@0
    95
	{
sl@0
    96
	TRAP_IGNORE(MainL());
sl@0
    97
	return KErrNone;
sl@0
    98
	}
sl@0
    99
sl@0
   100
CTestStep* CTestCryptServer::CreateTestStep(const TDesC& aStepName)
sl@0
   101
	{
sl@0
   102
	CTestStep* testStep = NULL;
sl@0
   103
sl@0
   104
	// This server creates just one step but create as many as you want
sl@0
   105
	// They are created "just in time" when the worker thread is created
sl@0
   106
	// install steps
sl@0
   107
	if (aStepName == KEncrypt)
sl@0
   108
		testStep = new CTestCrypt(aStepName);
sl@0
   109
	else if (aStepName == KCrypt)
sl@0
   110
		testStep = new CTestCrypt(aStepName);
sl@0
   111
	return testStep;
sl@0
   112
	}