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