|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Contains implementation of CTestPnPManager class |
|
15 // |
|
16 // |
|
17 |
|
18 #include "testpnp.h" |
|
19 #include "testpnpmanager.h" |
|
20 |
|
21 /* |
|
22 Static factory constructor. Uses two phase construction and leaves nothing on the |
|
23 CleanupStack. Creates a CTestPnP object. |
|
24 @param None |
|
25 @return Instance of the test server |
|
26 */ |
|
27 CTestPnP* CTestPnP::NewL() |
|
28 { |
|
29 CTestPnP * server = new (ELeave) CTestPnP(); |
|
30 CleanupStack::PushL(server); |
|
31 // CServer base class call |
|
32 RProcess handle = RProcess(); |
|
33 TParsePtrC serverName(handle.FileName()); |
|
34 server->ConstructL(serverName.Name()); |
|
35 CleanupStack::Pop(server); |
|
36 return server; |
|
37 } |
|
38 |
|
39 /* |
|
40 Function to create and start the CTestServer derived server. |
|
41 Secure variant.Much simpler, uses the new Rendezvous() call to sync with the client |
|
42 @param None |
|
43 @return None |
|
44 */ |
|
45 LOCAL_C void MainL() |
|
46 { |
|
47 // Leave the hooks in for platform security |
|
48 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
49 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
50 CActiveScheduler* sched = new(ELeave) CActiveScheduler; |
|
51 CActiveScheduler::Install(sched); |
|
52 CTestPnP* server = NULL; |
|
53 // Create the CTestServer derived server |
|
54 TRAPD(err,server = CTestPnP::NewL()); |
|
55 if(err == KErrNone) |
|
56 { |
|
57 // Sync with the client and enter the active scheduler |
|
58 RProcess::Rendezvous(KErrNone); |
|
59 sched->Start(); |
|
60 } |
|
61 delete server; |
|
62 delete sched; |
|
63 } |
|
64 |
|
65 /** |
|
66 Secure variant only |
|
67 Process entry point. Called by client using RProcess API. |
|
68 @param None |
|
69 @return Standard Epoc error code on process exit |
|
70 */ |
|
71 GLDEF_C TInt E32Main() |
|
72 { |
|
73 __UHEAP_MARK; |
|
74 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
75 if(cleanup == NULL) |
|
76 { |
|
77 return KErrNoMemory; |
|
78 } |
|
79 TRAPD( error, MainL() ); |
|
80 delete cleanup; |
|
81 __UHEAP_MARKEND; |
|
82 return error; |
|
83 } |
|
84 |
|
85 |
|
86 CTestStep* CTestPnP::CreateTestStep(const TDesC& aStepName) |
|
87 { |
|
88 CTestStep* testStep = NULL; |
|
89 TRAPD(err,testStep=CreateTestStepL(aStepName)); |
|
90 if(err == KErrNone) |
|
91 { |
|
92 return testStep; |
|
93 } |
|
94 else |
|
95 { |
|
96 return NULL; |
|
97 } |
|
98 } |
|
99 |
|
100 /** |
|
101 Secure and non-secure variants |
|
102 Implementation of CTestServer pure virtual |
|
103 @param aStepName a reference to string |
|
104 @return A CTestStep derived instance |
|
105 */ |
|
106 CTestStep* CTestPnP::CreateTestStepL(const TDesC& aStepName) |
|
107 { |
|
108 CTestStep* testStep = NULL; |
|
109 // They are created "just in time" when the worker thread is created |
|
110 // More test steps can be added below |
|
111 if(aStepName == KTestPnPManager) |
|
112 { |
|
113 testStep = new CTestPnPManager(); |
|
114 } |
|
115 return testStep; |
|
116 } |
|
117 |
|
118 |
|
119 |