|
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 // |
|
15 |
|
16 #include "Te_EchoTestServer.h" |
|
17 #include "Te_EchoSingleTestStep.h" |
|
18 |
|
19 _LIT(KServerName,"Te_Echo"); |
|
20 |
|
21 CEchoTestServer* CEchoTestServer::NewL() |
|
22 /** |
|
23 * @return - Instance of the test server |
|
24 * Same code for Secure and non-secure variants |
|
25 * Called inside the MainL() function to create and start the |
|
26 * CTestServer derived server. |
|
27 */ |
|
28 { |
|
29 CEchoTestServer * testServer = new (ELeave) CEchoTestServer(); |
|
30 CleanupStack::PushL(testServer); |
|
31 |
|
32 testServer->ConstructL(KServerName); |
|
33 CleanupStack::Pop(testServer); |
|
34 return testServer; |
|
35 } |
|
36 |
|
37 LOCAL_C void MainL() |
|
38 /** |
|
39 * Secure variant |
|
40 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
41 */ |
|
42 { |
|
43 CActiveScheduler* sched=NULL; |
|
44 sched=new(ELeave) CActiveScheduler; |
|
45 CActiveScheduler::Install(sched); |
|
46 CEchoTestServer* testServer = NULL; |
|
47 |
|
48 // Create the CTestServer derived server |
|
49 TRAPD(err,testServer = CEchoTestServer::NewL()); |
|
50 if(!err) |
|
51 { |
|
52 // Sync with the client and enter the active scheduler |
|
53 RProcess::Rendezvous(KErrNone); |
|
54 sched->Start(); |
|
55 } |
|
56 delete testServer; |
|
57 delete sched; |
|
58 } |
|
59 |
|
60 GLDEF_C TInt E32Main() |
|
61 /** |
|
62 * @return - Standard Epoc error code on process exit |
|
63 * Secure variant only |
|
64 * Process entry point. Called by client using RProcess API |
|
65 */ |
|
66 { |
|
67 __UHEAP_MARK; |
|
68 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
69 if(cleanup == NULL) |
|
70 { |
|
71 return KErrNoMemory; |
|
72 } |
|
73 TRAPD(err,MainL()); |
|
74 delete cleanup; |
|
75 __UHEAP_MARKEND; |
|
76 return err; |
|
77 } |
|
78 |
|
79 CTestStep* CEchoTestServer::CreateTestStep(const TDesC& aStepName) |
|
80 /** |
|
81 * @return - A CTestStep derived instance |
|
82 * Secure and non-secure variants |
|
83 * Implementation of CTestServer pure virtual |
|
84 */ |
|
85 { |
|
86 CTestStep* testStep = NULL; |
|
87 |
|
88 if(aStepName == KEchoTestStepName) |
|
89 { |
|
90 testStep = new CEchoTestStep(); |
|
91 } |
|
92 return testStep; |
|
93 } |