os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,116 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +/**
1.24 + * @file
1.25 + *
1.26 + * SWIS test server implementation
1.27 + */
1.28 +
1.29 +#include "ttesttoolserver.h"
1.30 +#include "ttesttoolstep.h"
1.31 +
1.32 +_LIT(KServerName, "ttesttools");
1.33 +
1.34 +/**
1.35 + * Called inside the MainL() function to create and start the CTestServer
1.36 + * derived server.
1.37 + * @return Instance of the test server
1.38 + */
1.39 +CTestToolServer* CTestToolServer::NewL()
1.40 + {
1.41 + CTestToolServer *server = new(ELeave) CTestToolServer();
1.42 + CleanupStack::PushL(server);
1.43 + server->ConstructL(KServerName);
1.44 + CleanupStack::Pop(server);
1.45 + return server;
1.46 + }
1.47 +
1.48 +
1.49 +LOCAL_C void MainL()
1.50 + {
1.51 + // Leave the hooks in for platform security
1.52 +#if (defined __DATA_CAGING__)
1.53 + RProcess().DataCaging(RProcess::EDataCagingOn);
1.54 + RProcess().SecureApi(RProcess::ESecureApiOn);
1.55 +#endif
1.56 +
1.57 + CActiveScheduler* sched=NULL;
1.58 + sched=new(ELeave) CActiveScheduler;
1.59 + CActiveScheduler::Install(sched);
1.60 + CTestToolServer* server = NULL;
1.61 + // Create the CTestServer derived server
1.62 + TRAPD(err, server = CTestToolServer::NewL());
1.63 + if(!err)
1.64 + {
1.65 + // Sync with the client and enter the active scheduler
1.66 + RProcess::Rendezvous(KErrNone);
1.67 + sched->Start();
1.68 + }
1.69 + delete server;
1.70 + delete sched;
1.71 + }
1.72 +
1.73 +/**
1.74 + * Server entry point
1.75 + * @return Standard Epoc error code on exit
1.76 + */
1.77 +GLDEF_C TInt E32Main()
1.78 + {
1.79 + __UHEAP_MARK;
1.80 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.81 + if(cleanup == NULL)
1.82 + {
1.83 + return KErrNoMemory;
1.84 + }
1.85 + TRAP_IGNORE(MainL());
1.86 + delete cleanup;
1.87 + __UHEAP_MARKEND;
1.88 + return KErrNone;
1.89 + }
1.90 +
1.91 +/**
1.92 + * Implementation of CTestServer pure virtual
1.93 + * @return A CTestStep derived instance
1.94 + */
1.95 +CTestStep* CTestToolServer::CreateTestStep(const TDesC& aStepName)
1.96 + {
1.97 + CTestStep* testStep = NULL;
1.98 +
1.99 + // This server creates just one step but create as many as you want
1.100 + // They are created "just in time" when the worker thread is created
1.101 + // install steps
1.102 + if (aStepName == KTestToolListCertStep)
1.103 + testStep = new CTestToolListCertStep();
1.104 + else if (aStepName == KTestToolGetTrustAppsStep)
1.105 + testStep = new CTestToolGetTrustAppsStep();
1.106 + else if (aStepName == KTestToolGetTrustStep)
1.107 + testStep = new CTestToolGetTrustStep();
1.108 + else if (aStepName == KTestToolListKeyStep)
1.109 + testStep = new CTestToolListKeyStep();
1.110 + else if (aStepName == KTestToolGetPolicyStep)
1.111 + testStep = new CTestToolGetPolicyStep();
1.112 + else if (aStepName == KTestToolParseFileStep)
1.113 + testStep = new CTestToolParseFileStep();
1.114 + else if (aStepName == KTestToolCheckFileStep)
1.115 + testStep = new CTestToolCheckFileStep();
1.116 +
1.117 + return testStep;
1.118 +
1.119 + }