|
1 // Copyright (c) 2004-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 // Dial API Test server test code. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include "TE_DialServer.h" |
|
23 #include "TE_DialTest.h" |
|
24 |
|
25 |
|
26 _LIT(KServerName,"TE_Dial"); |
|
27 |
|
28 |
|
29 /** |
|
30 * Called inside the MainL() function to create and start the CTestServer |
|
31 * derived server. |
|
32 * |
|
33 * @return Instance of the test server |
|
34 */ |
|
35 CDialTestServer* CDialTestServer::NewL() |
|
36 { |
|
37 CDialTestServer* server = new(ELeave) CDialTestServer(); |
|
38 CleanupStack::PushL(server); |
|
39 // CServer base class call |
|
40 server->StartL(KServerName); |
|
41 CleanupStack::Pop(server); |
|
42 return server; |
|
43 } // CDialTestIntServer::NewL |
|
44 |
|
45 |
|
46 /** |
|
47 * Much simpler, uses the new Rendezvous() call to sync with the client. |
|
48 */ |
|
49 LOCAL_C void MainL() |
|
50 { |
|
51 // |
|
52 // Start an active scheduler... |
|
53 // |
|
54 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
|
55 CleanupStack::PushL(scheduler); |
|
56 CActiveScheduler::Install(scheduler); |
|
57 |
|
58 // |
|
59 // Create the CTestServer derived server... |
|
60 // |
|
61 CDialTestServer* server = NULL; |
|
62 |
|
63 TRAPD(err, server = CDialTestServer::NewL()); |
|
64 if (err == KErrNone) |
|
65 { |
|
66 // |
|
67 // Sync with the client and enter the active scheduler |
|
68 // |
|
69 RProcess::Rendezvous(KErrNone); |
|
70 scheduler->Start(); |
|
71 } |
|
72 |
|
73 // |
|
74 // Clean up... |
|
75 // |
|
76 CleanupStack::Pop(scheduler); |
|
77 delete server; |
|
78 delete scheduler; |
|
79 } // MainL |
|
80 /** |
|
81 * @return Standard Epoc error code on exit. |
|
82 */ |
|
83 GLDEF_C TInt E32Main() |
|
84 { |
|
85 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
86 |
|
87 if (cleanup == NULL) |
|
88 { |
|
89 return KErrNoMemory; |
|
90 } |
|
91 |
|
92 TRAPD(err, MainL()); |
|
93 |
|
94 delete cleanup; |
|
95 |
|
96 return err; |
|
97 } // E32Main |
|
98 |
|
99 |
|
100 /** |
|
101 * Implementation of CTestServer pure virtual. |
|
102 * |
|
103 * @return A CTestStep derived instance. |
|
104 */ |
|
105 CTestStep* CDialTestServer::CreateTestStep(const TDesC& aStepName) |
|
106 { |
|
107 CTestStep* testStep = NULL; |
|
108 |
|
109 // |
|
110 // Create the required test step... |
|
111 // |
|
112 if (aStepName == _L("Test1")) |
|
113 { |
|
114 testStep = new CDialTestTest1(); |
|
115 } |
|
116 else if (aStepName == _L("Test2")) |
|
117 { |
|
118 testStep = new CDialTestTest2(); |
|
119 } |
|
120 else if (aStepName == _L("Test3")) |
|
121 { |
|
122 testStep = new CDialTestTest3(); |
|
123 } |
|
124 else if (aStepName == _L("Test4")) |
|
125 { |
|
126 testStep = new CDialTestTest4(); |
|
127 } |
|
128 else if (aStepName == _L("Test5")) |
|
129 { |
|
130 testStep = new CDialTestTest5(); |
|
131 } |
|
132 else if (aStepName == _L("Test6")) |
|
133 { |
|
134 testStep = new CDialTestTest6(); |
|
135 } |
|
136 else if (aStepName == _L("TestDtmf2")) |
|
137 { |
|
138 testStep = new CDialTestTestDtmf2(); |
|
139 } |
|
140 else if (aStepName == _L("Test7")) |
|
141 { |
|
142 testStep = new CDialTestTest7(); |
|
143 } |
|
144 else if (aStepName == _L("Test8")) |
|
145 { |
|
146 testStep = new CDialTestTest8(); |
|
147 } |
|
148 else if (aStepName == _L("IllegalTest")) |
|
149 { |
|
150 testStep = new CDialTestIllegalTest(); |
|
151 } |
|
152 |
|
153 return testStep; |
|
154 } // CDialTestServer::CreateTestStep |