|
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 // T_TestStepRestore.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @released |
|
21 */ |
|
22 #include "t_teststeprestoreasync.h" |
|
23 |
|
24 namespace bur_ts |
|
25 { |
|
26 |
|
27 CBURTestStepRestoreAsync* CBURTestStepRestoreAsync::NewL(CBURTestServer& aTestServer) |
|
28 /** |
|
29 Symbian OS Constructor |
|
30 |
|
31 @internalComponent |
|
32 @released |
|
33 |
|
34 @param aParent - The parent CBURTestServer of this child test step. |
|
35 @return Pointer to a newly created CBURTestStepRestoreAsyncAsync object. |
|
36 */ |
|
37 { |
|
38 CBURTestStepRestoreAsync* self = new (ELeave) CBURTestStepRestoreAsync(aTestServer); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CBURTestStepRestoreAsync::CBURTestStepRestoreAsync(CBURTestServer& aTestServer) |
|
46 /** |
|
47 C++ Constructor |
|
48 |
|
49 @internalComponent |
|
50 @released |
|
51 |
|
52 @param aParent - The parent CBURTestServer of this child test step. |
|
53 */ |
|
54 :CBURTestStepBase(aTestServer) |
|
55 {} |
|
56 |
|
57 void CBURTestStepRestoreAsync::ConstructL() |
|
58 /** |
|
59 Symbian OS 2nd-phase Constructor |
|
60 |
|
61 @internalComponent |
|
62 @released |
|
63 */ |
|
64 { |
|
65 TInt error; |
|
66 |
|
67 // Initialise the drive list to empty: |
|
68 iDriveList.FillZ(); |
|
69 |
|
70 iMode = ERestoreMode; |
|
71 |
|
72 User::LeaveIfError(iFs.Connect()); |
|
73 |
|
74 // Install an active scheduler for this test step |
|
75 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
76 CActiveScheduler::Install(iActiveScheduler); |
|
77 |
|
78 TRAP(error, iBackupClient = CSBEClient::NewL()); |
|
79 if (error != KErrNone) |
|
80 { |
|
81 _LIT(KClientConnection, "SBEClientConn"); |
|
82 User::Panic(KClientConnection,error); |
|
83 } |
|
84 |
|
85 _LIT(KBURTRestore, "BURTestServerRestore"); |
|
86 User::RenameThread(KBURTRestore); |
|
87 //User::SetCritical(User::ESystemCritical); |
|
88 |
|
89 SetTestStepName(KBURTestRestoreAsync); |
|
90 } |
|
91 |
|
92 CBURTestStepRestoreAsync::~CBURTestStepRestoreAsync() |
|
93 /** |
|
94 C++ Destructor |
|
95 |
|
96 @internalComponent |
|
97 @released |
|
98 */ |
|
99 { |
|
100 } |
|
101 |
|
102 TVerdict CBURTestStepRestoreAsync::doTestStepPreambleL() |
|
103 /** |
|
104 Override of base class virtual function |
|
105 |
|
106 @internalComponent |
|
107 @released |
|
108 @return TVerdict code |
|
109 */ |
|
110 { |
|
111 SetTestStepResult(EPass); |
|
112 return TestStepResult(); |
|
113 } |
|
114 |
|
115 TVerdict CBURTestStepRestoreAsync::doTestStepL() |
|
116 /** |
|
117 Override of base class pure virtual |
|
118 |
|
119 @internalComponent |
|
120 @released |
|
121 @return TVerdict code |
|
122 */ |
|
123 { |
|
124 _LIT(KLog1, "Processing user options..."); |
|
125 Log(LOG_LEVEL2, KLog1); |
|
126 ProcessUserOptionsL(); |
|
127 |
|
128 TBURPartType type = EBURRestoreFull; |
|
129 |
|
130 iStorageManager->ReadDataOwnersFromDiskL(iDataOwners); |
|
131 |
|
132 CheckValidRegistrationL(); |
|
133 |
|
134 if (iIsPartial) |
|
135 { |
|
136 _LIT(KLog2, "Preparing for PARTIAL restore..."); |
|
137 Log(LOG_LEVEL2, KLog2); |
|
138 PrepareForPartialBURL(); |
|
139 SetSIDListForPartialL(); |
|
140 type = EBURRestorePartial; |
|
141 } |
|
142 else |
|
143 { |
|
144 _LIT(KLog3, "Preparing for FULL restore..."); |
|
145 Log(LOG_LEVEL2, KLog3); |
|
146 } |
|
147 |
|
148 // Set restore mode: |
|
149 _LIT(KLog4, "Setting restore mode..."); |
|
150 Log(LOG_LEVEL2, KLog4); |
|
151 TRAPD(burmode, SetBURModeAsyncL(type, iBackupIncType)); |
|
152 if (burmode != KErrNone) |
|
153 { |
|
154 _LIT(KLog5, "Error setting restore Mode "); |
|
155 LogWithNum(LOG_LEVEL3, KLog5, burmode); |
|
156 } |
|
157 |
|
158 //SupplyRegistrationDataL(); |
|
159 |
|
160 // system data |
|
161 SupplySystemSnapshotDataL(); |
|
162 RestoreSystemBaseDataL(); |
|
163 |
|
164 RestoreJavaMidletL(); |
|
165 |
|
166 // confirm system files restored |
|
167 CBURActiveObject* active = CBURActiveObject::NewL(); |
|
168 CleanupStack::PushL(active); |
|
169 iBackupClient->AllSystemFilesRestoredL(active->iStatus); |
|
170 active->StartL(); |
|
171 User::LeaveIfError(active->Error()); |
|
172 CleanupStack::PopAndDestroy(active); |
|
173 |
|
174 /** Restore data according to user preferences */ |
|
175 if (iBackupIncType == EBackupIncrement) |
|
176 { |
|
177 IncrementalRestoreL(); |
|
178 } |
|
179 else |
|
180 { |
|
181 BaseRestoreL(); |
|
182 } |
|
183 |
|
184 Log(LOG_LEVEL2, _L("Setting backup mode to Normal ...")); |
|
185 TRAPD(err2,SetBURModeAsyncL(EBURNormal, ENoBackup)); |
|
186 if (err2 != KErrNone) |
|
187 { |
|
188 _LIT(KBURError, "Error setting Backup mode "); |
|
189 LogWithNum(LOG_LEVEL3, KBURError, err2); |
|
190 } |
|
191 |
|
192 return TestStepResult(); |
|
193 } |
|
194 |
|
195 void CBURTestStepRestoreAsync::BaseRestoreL() |
|
196 /** |
|
197 @internalComponent |
|
198 @released |
|
199 */ |
|
200 { |
|
201 RestoreJavaMidletDataL(); |
|
202 |
|
203 // passive |
|
204 SupplyPassiveSnapshotDataL(); |
|
205 RestorePassiveBaseDataL(); |
|
206 |
|
207 //active |
|
208 SupplyActiveSnapshotDataL(); |
|
209 RestoreActiveBaseDataL(); |
|
210 } |
|
211 |
|
212 void CBURTestStepRestoreAsync::IncrementalRestoreL() |
|
213 /** |
|
214 @internalComponent |
|
215 @released |
|
216 */ |
|
217 { |
|
218 RestoreJavaMidletDataL(); |
|
219 |
|
220 // passive |
|
221 SupplyPassiveSnapshotDataL(); |
|
222 RestorePassiveBaseDataL(); |
|
223 RestorePassiveIncDataL(); |
|
224 |
|
225 |
|
226 //active |
|
227 SupplyActiveSnapshotDataL(); |
|
228 RestoreActiveBaseDataL(); |
|
229 RestoreActiveIncDataL(); |
|
230 } |
|
231 |
|
232 |
|
233 void CBURTestStepRestoreAsync::SupplyRegistrationDataL() |
|
234 /** |
|
235 @internalComponent |
|
236 @released |
|
237 */ |
|
238 { |
|
239 _LIT(KRes, "Supplying registration data..."); |
|
240 Log(LOG_LEVEL2, KRes); |
|
241 DoSupplyL(ERegistrationData); |
|
242 } |
|
243 |
|
244 void CBURTestStepRestoreAsync::SupplyPassiveSnapshotDataL() |
|
245 /** |
|
246 @internalComponent |
|
247 @released |
|
248 */ |
|
249 { |
|
250 _LIT(KSupp, "Supplying passive snapshot data..."); |
|
251 Log(LOG_LEVEL2, KSupp); |
|
252 DoSupplyL(EPassiveSnapshotData); |
|
253 } |
|
254 |
|
255 void CBURTestStepRestoreAsync::RestorePassiveBaseDataL() |
|
256 /** |
|
257 @internalComponent |
|
258 @released |
|
259 */ |
|
260 { |
|
261 _LIT(KResBase, "Restoring passive base data..."); |
|
262 Log(LOG_LEVEL2, KResBase); |
|
263 DoSupplyL(EPassiveBaseData); |
|
264 } |
|
265 |
|
266 void CBURTestStepRestoreAsync::RestorePassiveIncDataL() |
|
267 /** |
|
268 @internalComponent |
|
269 @released |
|
270 */ |
|
271 { |
|
272 _LIT(KPassInc, "Restoring passive incremental data..."); |
|
273 Log(LOG_LEVEL2, KPassInc); |
|
274 DoSupplyL(EPassiveIncrementalData); |
|
275 } |
|
276 |
|
277 void CBURTestStepRestoreAsync::SupplyActiveSnapshotDataL() |
|
278 /** |
|
279 @internalComponent |
|
280 @released |
|
281 */ |
|
282 { |
|
283 _LIT(KSuppSnap, "Supplying active snapshot data..."); |
|
284 Log(LOG_LEVEL2, KSuppSnap); |
|
285 DoSupplyL(EActiveSnapshotData); |
|
286 } |
|
287 |
|
288 void CBURTestStepRestoreAsync::RestoreActiveBaseDataL() |
|
289 /** |
|
290 @internalComponent |
|
291 @released |
|
292 */ |
|
293 { |
|
294 _LIT(KActBase, "Restoring active base data..."); |
|
295 Log(LOG_LEVEL2, KActBase); |
|
296 DoSupplyL(EActiveBaseData); |
|
297 } |
|
298 |
|
299 void CBURTestStepRestoreAsync::RestoreActiveIncDataL() |
|
300 /** |
|
301 @internalComponent |
|
302 @released |
|
303 */ |
|
304 { |
|
305 _LIT(KActIncD, "Restoring active incremental data..."); |
|
306 Log(LOG_LEVEL2, KActIncD); |
|
307 DoSupplyL(EActiveIncrementalData); |
|
308 } |
|
309 |
|
310 void CBURTestStepRestoreAsync::RestoreSystemBaseDataL() |
|
311 /** |
|
312 @internalComponent |
|
313 @released |
|
314 */ |
|
315 { |
|
316 GeneratePIDTransferTypesL(iTransferTypes, ESystemData); |
|
317 // go through each of them and check if we have snapshot to supply |
|
318 if (iTransferTypes.Count()) |
|
319 { |
|
320 _LIT(KSysBase, "Restoring system base data..."); |
|
321 Log(LOG_LEVEL2, KSysBase); |
|
322 SupplyDataL(iTransferTypes); |
|
323 } |
|
324 } |
|
325 |
|
326 void CBURTestStepRestoreAsync::SupplySystemSnapshotDataL() |
|
327 /** |
|
328 @internalComponent |
|
329 @released |
|
330 */ |
|
331 { |
|
332 GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData); |
|
333 // go through each of them and check if we have snapshot to supply |
|
334 if (iTransferTypes.Count()) |
|
335 { |
|
336 _LIT(KSysSnap, "Supply System Snapshot Data ..."); |
|
337 Log(LOG_LEVEL2, KSysSnap); |
|
338 SupplyDataL(iTransferTypes); |
|
339 } |
|
340 } |
|
341 |
|
342 void CBURTestStepRestoreAsync::RestoreJavaMidletL() |
|
343 /** |
|
344 @internalComponent |
|
345 @released |
|
346 */ |
|
347 { |
|
348 GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet); |
|
349 if (iTransferTypes.Count()) |
|
350 { |
|
351 _LIT(KJMidlet, "Restoring Java Midlets ..."); |
|
352 Log(LOG_LEVEL2, KJMidlet); |
|
353 SupplyDataL(iTransferTypes); |
|
354 } |
|
355 } |
|
356 |
|
357 void CBURTestStepRestoreAsync::RestoreJavaMidletDataL() |
|
358 /** |
|
359 @internalComponent |
|
360 @released |
|
361 */ |
|
362 { |
|
363 GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData); |
|
364 if (iTransferTypes.Count()) |
|
365 { |
|
366 _LIT(KJMidletData, "Restoring Java Midlets Data ..."); |
|
367 Log(LOG_LEVEL2, KJMidletData); |
|
368 SupplyDataL(iTransferTypes); |
|
369 } |
|
370 } |
|
371 |
|
372 TVerdict CBURTestStepRestoreAsync::doTestStepPostambleL() |
|
373 /** |
|
374 @return - TVerdict code |
|
375 Override of base class pure virtual |
|
376 */ |
|
377 { |
|
378 _LIT(KLog, "Number of failures:"); |
|
379 LogWithNum(LOG_LEVEL3, KLog, iFailures); |
|
380 if (iFailures) |
|
381 { |
|
382 SetTestStepResult(TVerdict(EFail)); |
|
383 } |
|
384 return TestStepResult(); |
|
385 } |
|
386 |
|
387 |
|
388 } // end namespace |