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