|
1 // Copyright (c) 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 // |
|
15 |
|
16 #include "ElementServer.h" |
|
17 #include "ElementStep.h" |
|
18 #include "StateMachineStep.h" |
|
19 |
|
20 _LIT(KServerName,"Te_ElementServer"); |
|
21 |
|
22 CElementServer* CElementServer::NewL() |
|
23 /** |
|
24 * @return - Instance of the test server |
|
25 * Same code for Secure and non-secure variants |
|
26 * Called inside the MainL() function to create and start the |
|
27 * CTestServer derived server. |
|
28 */ |
|
29 { |
|
30 CElementServer * server = new (ELeave) CElementServer(); |
|
31 CleanupStack::PushL(server); |
|
32 // CServer base class call |
|
33 server->StartL(KServerName); |
|
34 CleanupStack::Pop(server); |
|
35 return server; |
|
36 } |
|
37 |
|
38 |
|
39 |
|
40 LOCAL_C void MainL() |
|
41 /** |
|
42 * Secure variant |
|
43 * Uses the new Rendezvous() call to sync with the client |
|
44 */ |
|
45 { |
|
46 CActiveScheduler* sched=NULL; |
|
47 sched=new(ELeave) CActiveScheduler; |
|
48 CActiveScheduler::Install(sched); |
|
49 CElementServer* server = NULL; |
|
50 // Create the CTestServer derived server |
|
51 TRAPD(err,server = CElementServer::NewL()); |
|
52 if(!err) |
|
53 { |
|
54 // Sync with the client and enter the active scheduler |
|
55 RProcess::Rendezvous(KErrNone); |
|
56 sched->Start(); |
|
57 } |
|
58 delete server; |
|
59 delete sched; |
|
60 } |
|
61 |
|
62 GLDEF_C TInt E32Main() |
|
63 /** |
|
64 * @return - Standard Epoc error code on process exit |
|
65 * Process entry point. Called by client using RProcess API |
|
66 */ |
|
67 { |
|
68 __UHEAP_MARK; |
|
69 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
70 if(cleanup == NULL) |
|
71 { |
|
72 return KErrNoMemory; |
|
73 } |
|
74 TRAPD(err,MainL()); |
|
75 delete cleanup; |
|
76 __UHEAP_MARKEND; |
|
77 return err; |
|
78 } |
|
79 |
|
80 |
|
81 CTestStep* CElementServer::CreateTestStep(const TDesC& aStepName) |
|
82 /** |
|
83 * @return - A CTestStep derived instance |
|
84 * Implementation of CTestServer pure virtual |
|
85 */ |
|
86 { |
|
87 CTestStep* testStep = NULL; |
|
88 // This server creates just one step but create as many as you want |
|
89 // They are created "just in time" when the worker thread is created |
|
90 if(aStepName == KElementStep1) |
|
91 testStep = new CElementStep1(); |
|
92 else if(aStepName == KElementStep2) |
|
93 testStep = new CElementStep2(*this); |
|
94 else if(aStepName == KElementStep3) |
|
95 testStep = new CElementStep3(*this); |
|
96 else if (aStepName == KElementStateMachineStep1_1) |
|
97 testStep = new CElementStateMachineStep1_1(); |
|
98 else if (aStepName == KElementStateMachineStep1_2) |
|
99 testStep = new CElementStateMachineStep1_2(); |
|
100 else if (aStepName == KElementStateMachineStep1_3) |
|
101 testStep = new CElementStateMachineStep1_3(); |
|
102 else if (aStepName == KElementStateMachineStep1_4) |
|
103 testStep = new CElementStateMachineStep1_4(); |
|
104 else if (aStepName == KElementStateMachineStep1_5) |
|
105 testStep = new CElementStateMachineStep1_5(); |
|
106 else if (aStepName == KElementStateMachineStep2_1) |
|
107 testStep = new CElementStateMachineStep2_1(); |
|
108 else if (aStepName == KElementStateMachineStep2_2) |
|
109 testStep = new CElementStateMachineStep2_2(); |
|
110 else if (aStepName == KElementStateMachineStep2_3) |
|
111 testStep = new CElementStateMachineStep2_3(); |
|
112 else if (aStepName == KElementStateMachineStep2_4) |
|
113 testStep = new CElementStateMachineStep2_4(); |
|
114 else if (aStepName == KElementStateMachineStep2_5) |
|
115 testStep = new CElementStateMachineStep2_5(); |
|
116 else if (aStepName == KElementStateMachineStep2_6) |
|
117 testStep = new CElementStateMachineStep2_6(); |
|
118 else if (aStepName == KElementStateMachineStep2_7) |
|
119 testStep = new CElementStateMachineStep2_7(); |
|
120 else if (aStepName == KElementStateMachineStep2_8) |
|
121 testStep = new CElementStateMachineStep2_8(); |
|
122 return testStep; |
|
123 } |