os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolserver.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 *
    16 */
    17 
    18 
    19 
    20 /**
    21  * @file
    22  *
    23  * SWIS test server implementation
    24  */
    25 
    26 #include "ttesttoolserver.h"
    27 #include "ttesttoolstep.h"
    28 
    29 _LIT(KServerName, "ttesttools");
    30 
    31 /**
    32  * Called inside the MainL() function to create and start the CTestServer 
    33  * derived server.
    34  * @return Instance of the test server
    35  */
    36 CTestToolServer* CTestToolServer::NewL()
    37 	{
    38 	CTestToolServer *server = new(ELeave) CTestToolServer();
    39 	CleanupStack::PushL(server);
    40 	server->ConstructL(KServerName);
    41 	CleanupStack::Pop(server);
    42 	return server;
    43 	}
    44 
    45 
    46 LOCAL_C void MainL()
    47 	{
    48 	// Leave the hooks in for platform security
    49 #if (defined __DATA_CAGING__)
    50 	RProcess().DataCaging(RProcess::EDataCagingOn);
    51 	RProcess().SecureApi(RProcess::ESecureApiOn);
    52 #endif
    53 	
    54 	CActiveScheduler* sched=NULL;
    55 	sched=new(ELeave) CActiveScheduler;
    56 	CActiveScheduler::Install(sched);
    57 	CTestToolServer* server = NULL;
    58 	// Create the CTestServer derived server
    59 	TRAPD(err, server = CTestToolServer::NewL());
    60 	if(!err)
    61 		{
    62 		// Sync with the client and enter the active scheduler
    63 		RProcess::Rendezvous(KErrNone);
    64  		sched->Start();
    65 		}
    66 	delete server;
    67 	delete sched;
    68 	}
    69 
    70 /**
    71  * Server entry point
    72  * @return Standard Epoc error code on exit
    73  */
    74 GLDEF_C TInt E32Main()
    75 	{
    76 	__UHEAP_MARK;
    77 	CTrapCleanup* cleanup = CTrapCleanup::New();
    78 	if(cleanup == NULL)
    79 		{
    80 		return KErrNoMemory;
    81 		}
    82 	TRAP_IGNORE(MainL());
    83 	delete cleanup;
    84 	__UHEAP_MARKEND;
    85 	return KErrNone;
    86 	}
    87 
    88 /**
    89  * Implementation of CTestServer pure virtual
    90  * @return A CTestStep derived instance
    91  */
    92 CTestStep* CTestToolServer::CreateTestStep(const TDesC& aStepName)
    93 	{
    94 	CTestStep* testStep = NULL;
    95 
    96 	// This server creates just one step but create as many as you want
    97 	// They are created "just in time" when the worker thread is created
    98 	// install steps
    99 	if (aStepName == KTestToolListCertStep)	
   100 		testStep = new CTestToolListCertStep();
   101 	else if (aStepName == KTestToolGetTrustAppsStep)	
   102 		testStep = new CTestToolGetTrustAppsStep();
   103 	else if (aStepName == KTestToolGetTrustStep)	
   104 		testStep = new CTestToolGetTrustStep();
   105 	else if (aStepName == KTestToolListKeyStep)	
   106 		testStep = new CTestToolListKeyStep();
   107 	else if (aStepName == KTestToolGetPolicyStep)	
   108 		testStep = new CTestToolGetPolicyStep();
   109 	else if (aStepName == KTestToolParseFileStep)	
   110 		testStep = new CTestToolParseFileStep();
   111 	else if (aStepName == KTestToolCheckFileStep)
   112 		testStep = new CTestToolCheckFileStep();
   113 
   114 	return testStep;
   115 
   116 	}