|
1 // Copyright (c) 2005-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 // Example file/test code to demonstrate how to develop a TestExecute Server |
|
15 // Developers should take this project as a template and substitute their own |
|
16 // code at the __EDIT_ME__ tags.\n |
|
17 // Secure and non-secure variants.\n |
|
18 // Secure EKA2 versions will be a simpler xxxServer.exe running in its own process.\n |
|
19 // Non-secure versions will be xxxServer.Dll and require a thread to be started |
|
20 // in the process of the client. The client initialises the server by calling the |
|
21 // one and only ordinal.\n |
|
22 // |
|
23 // |
|
24 |
|
25 /** |
|
26 @file |
|
27 @internalComponent - Internal Symbian test code |
|
28 */ |
|
29 #include "TGridTestServer.h" |
|
30 #include "TGlayStep.h" |
|
31 #include "TGrid0Step.h" |
|
32 #include "TCoGridStep.h" |
|
33 |
|
34 |
|
35 _LIT(KServerName,"TGridTestServer"); |
|
36 CTGridTestServer* CTGridTestServer::NewL() |
|
37 /** |
|
38 @return - Instance of the test server |
|
39 Same code for Secure and non-secure variants |
|
40 Called inside the MainL() function to create and start the |
|
41 CTestServer derived server. |
|
42 */ |
|
43 { |
|
44 CTGridTestServer * server = new (ELeave) CTGridTestServer(); |
|
45 CleanupStack::PushL(server); |
|
46 // CServer base class call |
|
47 server->StartL(KServerName); |
|
48 CleanupStack::Pop(server); |
|
49 return server; |
|
50 } |
|
51 |
|
52 |
|
53 LOCAL_C void MainL() |
|
54 /** |
|
55 Secure variant.\n |
|
56 Much simpler, uses the new Rendezvous() call to sync with the client.\n |
|
57 */ |
|
58 { |
|
59 #if (defined __DATA_CAGING__) |
|
60 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
61 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
62 #endif |
|
63 CActiveScheduler* sched=NULL; |
|
64 sched=new(ELeave) CActiveScheduler; |
|
65 CActiveScheduler::Install(sched); |
|
66 CTGridTestServer* server = NULL; |
|
67 // Create the CTestServer derived server |
|
68 TRAPD(err,server = CTGridTestServer::NewL()); |
|
69 if(!err) |
|
70 { |
|
71 // Sync with the client and enter the active scheduler |
|
72 RProcess::Rendezvous(KErrNone); |
|
73 sched->Start(); |
|
74 } |
|
75 delete server; |
|
76 delete sched; |
|
77 } |
|
78 |
|
79 GLDEF_C TInt E32Main() |
|
80 /** |
|
81 @return - Standard Epoc error code on process exit.\n |
|
82 |
|
83 Secure variant only.\n |
|
84 Process entry point. Called by client using RProcess API.\n |
|
85 */ |
|
86 { |
|
87 __UHEAP_MARK; |
|
88 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
89 if(cleanup == NULL) |
|
90 { |
|
91 return KErrNoMemory; |
|
92 } |
|
93 TRAP_IGNORE(MainL()); |
|
94 delete cleanup; |
|
95 __UHEAP_MARKEND; |
|
96 return KErrNone; |
|
97 } |
|
98 |
|
99 |
|
100 |
|
101 CTestStep* CTGridTestServer::CreateTestStep(const TDesC& aStepName) |
|
102 /** |
|
103 @return - A CTestStep derived instance |
|
104 Secure and non-secure variants |
|
105 Implementation of CTestServer pure virtual |
|
106 */ |
|
107 { |
|
108 CTestStep* testStep = NULL; |
|
109 // This server creates just one step but create as many as you want |
|
110 // They are created "just in time" when the worker thread is created |
|
111 if(aStepName == KTGlayStep) |
|
112 testStep = new CTGlayStep(); |
|
113 if(aStepName == KTGrid0Step) |
|
114 testStep = new CTGrid0Step(); |
|
115 if(aStepName == KTCoGridStep) |
|
116 testStep = new CTCoGridStep(); |
|
117 return testStep; |
|
118 } |