|
1 /* |
|
2 * Copyright (c) 2005-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 "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 * This contains CTestPlatSecServer. This class creates and initializes |
|
16 * the test steps and return the pointer to TEF |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "TestPlatSecServer.h" |
|
22 #include "TestPlatSecSetCapabilities.h" |
|
23 #include "TestPlatSecLaunchApp.h" |
|
24 #include "TestPlatSecCleanup.h" |
|
25 |
|
26 |
|
27 |
|
28 /** |
|
29 Secure variant |
|
30 Much simpler, uses the new Rendezvous() call to sync with the client |
|
31 */ |
|
32 LOCAL_C void MainL() |
|
33 { |
|
34 #if (defined __DATA_CAGING__) |
|
35 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
36 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
37 #endif |
|
38 CActiveScheduler* sched=NULL; |
|
39 sched=new(ELeave) CActiveScheduler; |
|
40 CActiveScheduler::Install(sched); |
|
41 CTestPlatSecServer* server = NULL; |
|
42 // Create the CTestServer derived server |
|
43 TRAPD(err,server = CTestPlatSecServer::NewL()); |
|
44 if(!err) |
|
45 { |
|
46 // Sync with the client and enter the active scheduler |
|
47 RProcess::Rendezvous(KErrNone); |
|
48 sched->Start(); |
|
49 } |
|
50 delete server; |
|
51 delete sched; |
|
52 } |
|
53 |
|
54 |
|
55 /** |
|
56 Secure variant only |
|
57 Process entry point. Called by client using RProcess API |
|
58 @return - Standard Epoc error code on process exit |
|
59 */ |
|
60 GLDEF_C TInt E32Main() |
|
61 { |
|
62 __UHEAP_MARK; |
|
63 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
64 if(cleanup == NULL) |
|
65 { |
|
66 return KErrNoMemory; |
|
67 } |
|
68 TRAP_IGNORE(MainL()); |
|
69 delete cleanup; |
|
70 __UHEAP_MARKEND; |
|
71 return KErrNone; |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 /** |
|
77 Two Phase constructor |
|
78 @return CTestPlatSecServer object pointer |
|
79 @leave KErrNoMemory |
|
80 @leave system wide error codes |
|
81 */ |
|
82 CTestPlatSecServer* CTestPlatSecServer::NewL() |
|
83 { |
|
84 CTestPlatSecServer* server=new(ELeave) CTestPlatSecServer(); |
|
85 CleanupStack::PushL(server); |
|
86 RProcess handle = RProcess(); |
|
87 TParsePtrC serverName(handle.FileName()); |
|
88 server->ConstructL(serverName.Name()); |
|
89 CleanupStack::Pop(); |
|
90 return server; |
|
91 } |
|
92 |
|
93 /** |
|
94 Constructor |
|
95 */ |
|
96 CTestPlatSecServer::CTestPlatSecServer() |
|
97 { |
|
98 } |
|
99 |
|
100 /** |
|
101 Destructor |
|
102 */ |
|
103 CTestPlatSecServer::~CTestPlatSecServer() |
|
104 { |
|
105 } |
|
106 |
|
107 /** |
|
108 Implementation of CTestServer pure virtual. |
|
109 Creates the test step. |
|
110 @param aStepName - test step name to run. |
|
111 @return - A CTestStep derived instance |
|
112 */ |
|
113 |
|
114 CTestStep* CTestPlatSecServer::CreateTestStep(const TDesC& aStepName) |
|
115 { |
|
116 CTestStep* testStep = NULL; |
|
117 if(aStepName == _L("SetCapabilities")) |
|
118 { |
|
119 testStep = new CTestPlatSecSetCapabilities(); |
|
120 } |
|
121 else if (aStepName == _L("LaunchApp")) |
|
122 { |
|
123 testStep = new CTestPlatSecLaunchApp(); |
|
124 } |
|
125 else if (aStepName == _L("Cleanup")) |
|
126 { |
|
127 testStep = new CTestPlatSecCleanup(); |
|
128 } |
|
129 return testStep; |
|
130 } |
|
131 |