|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @released |
|
19 */ |
|
20 |
|
21 #include "t_burtestserver.h" |
|
22 #include "t_teststepbackup.h" |
|
23 #include "t_teststepbackup2.h" |
|
24 #include "t_teststeprestore.h" |
|
25 #include "t_teststepbackupasync.h" |
|
26 #include "t_teststeprestoreasync.h" |
|
27 |
|
28 _LIT( KServerName, "BURTestServer"); |
|
29 |
|
30 using namespace conn; |
|
31 |
|
32 namespace bur_ts |
|
33 { |
|
34 |
|
35 CBURTestServer* CBURTestServer::NewL() |
|
36 /** |
|
37 Symbian OS Constructor |
|
38 Called inside the MainL() function to create and start the |
|
39 CTestServer derived server. |
|
40 |
|
41 @internalComponent |
|
42 @released |
|
43 |
|
44 @return - A pointer to an instance of the test server |
|
45 */ |
|
46 { |
|
47 CBURTestServer* testServer = new (ELeave) CBURTestServer(); |
|
48 CleanupStack::PushL(testServer); |
|
49 |
|
50 // Either use a StartL or ConstructL, the latter will permit |
|
51 // Server Logging. |
|
52 //server->StartL(KServerName); |
|
53 testServer->ConstructL(KServerName); |
|
54 CleanupStack::Pop(testServer); |
|
55 return testServer; |
|
56 } |
|
57 |
|
58 CBURTestServer::~CBURTestServer() |
|
59 /** |
|
60 C++ Destructor |
|
61 |
|
62 @internalComponent |
|
63 @released |
|
64 */ |
|
65 {} |
|
66 |
|
67 CTestStep* CBURTestServer::CreateTestStep(const TDesC& aStepName) |
|
68 /** |
|
69 Implementation of CTestServer pure virtual |
|
70 Creates and returns a bur_ts::CBURTestStepBase object |
|
71 |
|
72 @internalComponent |
|
73 @released |
|
74 |
|
75 @return - A CTestStep derived instance |
|
76 */ |
|
77 { |
|
78 CBURTestStepBase* testStep = NULL; |
|
79 |
|
80 // Create a test step based on the string name passed: |
|
81 TInt error = KErrNone; |
|
82 if (aStepName == KBURTestBackup) |
|
83 { |
|
84 TRAP(error, testStep = CBURTestStepBackup::NewL(*this)); |
|
85 } |
|
86 else if (aStepName == KBURTestBackup2) |
|
87 { |
|
88 TRAP(error, testStep = CBURTestStepBackup2::NewL(*this)); |
|
89 } |
|
90 else if (aStepName == KBURTestRestore) |
|
91 { |
|
92 TRAP(error, testStep = CBURTestStepRestore::NewL(*this)); |
|
93 } |
|
94 else if (aStepName == KBURTestBackupAsync) |
|
95 { |
|
96 TRAP(error, testStep = CBURTestStepBackupAsync::NewL(*this)) |
|
97 } |
|
98 else |
|
99 { |
|
100 TRAP(error, testStep = CBURTestStepRestoreAsync::NewL(*this)); |
|
101 } |
|
102 |
|
103 if (error != KErrNone) |
|
104 { |
|
105 User::Leave(error); |
|
106 } |
|
107 |
|
108 return testStep; |
|
109 } |
|
110 |
|
111 } // end namespace |
|
112 |
|
113 // |
|
114 |
|
115 // EKA2 much simpler |
|
116 // Just an E32Main and a MainL() |
|
117 LOCAL_C void MainL() |
|
118 /** |
|
119 Much simpler, uses the new Rendezvous() call to sync with the client |
|
120 */ |
|
121 { |
|
122 // Leave the hooks in for platform security |
|
123 #if (defined __DATA_CAGING__) |
|
124 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
125 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
126 #endif |
|
127 |
|
128 // Rename the thread: |
|
129 User::RenameThread(KServerName); |
|
130 |
|
131 CActiveScheduler* scheduler = NULL; |
|
132 scheduler = new(ELeave) CActiveScheduler; |
|
133 CleanupStack::PushL(scheduler); |
|
134 CActiveScheduler::Install(scheduler); |
|
135 |
|
136 |
|
137 bur_ts::CBURTestServer* testServer = NULL; |
|
138 |
|
139 // Create the CTestServer derived server |
|
140 TRAPD(err, testServer = bur_ts::CBURTestServer::NewL()); |
|
141 if(!err) |
|
142 { |
|
143 CleanupStack::PushL(testServer); |
|
144 |
|
145 // Sync with the client and enter the active scheduler |
|
146 RProcess::Rendezvous(KErrNone); |
|
147 scheduler->Start(); |
|
148 CleanupStack::Pop(testServer); |
|
149 } |
|
150 |
|
151 CleanupStack::Pop(scheduler); |
|
152 delete testServer; |
|
153 delete scheduler; |
|
154 } |
|
155 |
|
156 |
|
157 |
|
158 // Only a DLL on emulator for typhoon and earlier |
|
159 |
|
160 GLDEF_C TInt E32Main() |
|
161 /** |
|
162 @return - Standard Epoc error code on exit |
|
163 */ |
|
164 { |
|
165 __UHEAP_MARK; |
|
166 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
167 if(cleanup == NULL) |
|
168 { |
|
169 return KErrNoMemory; |
|
170 } |
|
171 TRAPD(err,MainL()); |
|
172 delete cleanup; |
|
173 __UHEAP_MARKEND; |
|
174 return err; |
|
175 } |
|
176 |
|
177 // Create a thread in the calling process |
|
178 // Emulator typhoon and earlier |
|
179 |