|
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 // Non-secure versions will be xxxServer.Dll and require a thread to be started |
|
15 // in the process of the client. The client initialises the server by calling the |
|
16 // one and only ordinal. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent - Internal Symbian test code |
|
23 */ |
|
24 #include "TClockTestServer.h" |
|
25 #include "TMsgWin0Step.h" |
|
26 #include "TCLCK0STEP.h" |
|
27 #include "TCLCK1STEP.h" |
|
28 #include "TCLCK2STEP.h" |
|
29 |
|
30 |
|
31 _LIT(KServerName,"TClockTestServer"); |
|
32 CTClockTestServer* CTClockTestServer::NewL() |
|
33 /** |
|
34 @return - Instance of the test server |
|
35 Same code for Secure and non-secure variants |
|
36 Called inside the MainL() function to create and start the |
|
37 CTestServer derived server. |
|
38 */ |
|
39 { |
|
40 CTClockTestServer * server = new (ELeave) CTClockTestServer(); |
|
41 CleanupStack::PushL(server); |
|
42 // CServer base class call |
|
43 server->StartL(KServerName); |
|
44 CleanupStack::Pop(server); |
|
45 return server; |
|
46 } |
|
47 |
|
48 |
|
49 // EKA2 much simpler |
|
50 // Just an E32Main and a MainL() |
|
51 LOCAL_C void MainL() |
|
52 /** |
|
53 Much simpler, uses the new Rendezvous() call to sync with the client |
|
54 */ |
|
55 { |
|
56 // Leave the hooks in for platform security |
|
57 #if (defined __DATA_CAGING__) |
|
58 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
59 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
60 #endif |
|
61 CActiveScheduler* sched=NULL; |
|
62 sched=new(ELeave) CActiveScheduler; |
|
63 CActiveScheduler::Install(sched); |
|
64 |
|
65 CTClockTestServer* server = NULL; |
|
66 // Create the CTestServer derived server |
|
67 |
|
68 TRAPD(err,server = CTClockTestServer::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 |
|
80 GLDEF_C TInt E32Main() |
|
81 /** |
|
82 @return - Standard Epoc error code on exit |
|
83 */ |
|
84 { |
|
85 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
86 if(cleanup == NULL) |
|
87 { |
|
88 return KErrNoMemory; |
|
89 } |
|
90 TRAP_IGNORE(MainL()); |
|
91 delete cleanup; |
|
92 return KErrNone; |
|
93 } |
|
94 |
|
95 |
|
96 |
|
97 CTestStep* CTClockTestServer::CreateTestStep(const TDesC& aStepName) |
|
98 /** |
|
99 @return - A CTestStep derived instance |
|
100 Secure and non-secure variants |
|
101 Implementation of CTestServer pure virtual |
|
102 */ |
|
103 { |
|
104 CTestStep* testStep = NULL; |
|
105 // This server creates just one step but create as many as you want |
|
106 // They are created "just in time" when the worker thread is created |
|
107 if(aStepName == KTMsgWin0Step) |
|
108 testStep = new CTMsgWin0Step(); |
|
109 if(aStepName == KTClck0Step) |
|
110 testStep = new CTClck0Step(); |
|
111 if(aStepName == KTClck1Step) |
|
112 testStep = new CTClck1Step(); |
|
113 if(aStepName == KTClck2Step) |
|
114 testStep = new CTClck2Step(); |
|
115 return testStep; |
|
116 } |