|
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 the License "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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 |
|
27 #include "trecogserver.h" |
|
28 #include "trecogstep.h" |
|
29 |
|
30 CRecogServer* CRecogServer::NewL() |
|
31 /** |
|
32 @return - Instance of the test server |
|
33 Same code for Secure and non-secure variants |
|
34 Called inside the MainL() function to create and start the |
|
35 CTestServer derived server. |
|
36 */ |
|
37 { |
|
38 CRecogServer * server = new (ELeave) CRecogServer(); |
|
39 CleanupStack::PushL(server); |
|
40 // CServer base class call |
|
41 TParsePtrC serverName(RProcess().FileName()); |
|
42 server->StartL(serverName.Name()); |
|
43 CleanupStack::Pop(server); |
|
44 return server; |
|
45 } |
|
46 |
|
47 // __EDIT_ME__ - Use your own server class name |
|
48 CTestStep* CRecogServer::CreateTestStep(const TDesC& aStepName) |
|
49 /** |
|
50 @return - A CTestStep derived instance |
|
51 Secure and non-secure variants |
|
52 Implementation of CTestServer pure virtual |
|
53 */ |
|
54 { |
|
55 CTestStep* testStep = NULL; |
|
56 // User::After(TTimeIntervalMicroSeconds32(5000000)); |
|
57 // This server creates just one step but create as many as you want |
|
58 // They are created "just in time" when the worker thread is created |
|
59 |
|
60 |
|
61 if(aStepName == KRecogStep) |
|
62 { |
|
63 testStep = new CRecogStep(); |
|
64 } |
|
65 |
|
66 return testStep; |
|
67 } |
|
68 |
|
69 // EKA2 much simpler |
|
70 // Just an E32Main and a MainL() |
|
71 LOCAL_C void MainL() |
|
72 /** |
|
73 Much simpler, uses the new Rendezvous() call to sync with the client |
|
74 */ |
|
75 { |
|
76 // Leave the hooks in for platform security |
|
77 #if (defined __DATA_CAGING__) |
|
78 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
79 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
80 #endif |
|
81 CActiveScheduler* sched=NULL; |
|
82 sched=new(ELeave) CActiveScheduler; |
|
83 CActiveScheduler::Install(sched); |
|
84 CRecogServer* server = NULL; |
|
85 // Create the CTestServer derived server |
|
86 TRAPD(err,server = CRecogServer::NewL());; |
|
87 |
|
88 if(!err) |
|
89 { |
|
90 // Sync with the client and enter the active scheduler |
|
91 RProcess::Rendezvous(KErrNone); |
|
92 sched->Start(); |
|
93 } |
|
94 delete server; |
|
95 delete sched; |
|
96 } |
|
97 |
|
98 // Only a DLL on emulator for typhoon and earlier |
|
99 GLDEF_C TInt E32Main() |
|
100 /** |
|
101 @return - Standard Epoc error code on exit |
|
102 */ |
|
103 { |
|
104 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
105 if(cleanup == NULL) |
|
106 { |
|
107 return KErrNoMemory; |
|
108 } |
|
109 TRAPD(err,MainL()); |
|
110 // This if statement is here just to shut up RVCT, which would otherwise warn |
|
111 // that err was set but never used |
|
112 if (err) |
|
113 { |
|
114 err = KErrNone; |
|
115 } |
|
116 delete cleanup; |
|
117 return KErrNone; |
|
118 } |
|
119 |
|
120 // Create a thread in the calling process |
|
121 // Emulator typhoon and earlier |