|
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_burteststepbase.h" |
|
22 |
|
23 namespace bur_ts |
|
24 { |
|
25 _LIT(KTabText, "\t|"); |
|
26 _LIT(KFormatText2, "%S%S"); |
|
27 _LIT(KFormatText3, "%S%S%S"); |
|
28 _LIT(KFormatText4, "%S%S%d"); |
|
29 _LIT(KFormatText5, "%S%S%X"); |
|
30 _LIT(KFormatText6, "%S%S%s"); |
|
31 |
|
32 const TUint8 KMaxHexLength = 8; |
|
33 |
|
34 CBURTestStepBase::CBURTestStepBase(CBURTestServer& aParent) |
|
35 /** |
|
36 C++ Constructor |
|
37 |
|
38 @internalComponent |
|
39 @released |
|
40 |
|
41 @param aParent - The parent CBURTestServer of this child test step. |
|
42 */ |
|
43 :iParentTestServer(aParent), |
|
44 iBackupClient(NULL), |
|
45 iBackupIncType(EBackupBase), |
|
46 iIsPartial(EFalse), |
|
47 iFailures(KErrNone), |
|
48 iStorageManager(NULL), |
|
49 iMode(EBackupMode), |
|
50 iWaitedForActive(EFalse) |
|
51 {} |
|
52 |
|
53 CBURTestStepBase::~CBURTestStepBase() |
|
54 /** |
|
55 C++ Destructor |
|
56 @internalComponent |
|
57 @released |
|
58 */ |
|
59 { |
|
60 iDataOwners.ResetAndDestroy(); |
|
61 iDataOwners.Close(); |
|
62 |
|
63 iSidArray.Close(); |
|
64 iJidArray.Close(); |
|
65 |
|
66 iFs.Close(); |
|
67 |
|
68 iTransferTypes.ResetAndDestroy(); |
|
69 iTransferTypes.Close(); |
|
70 |
|
71 delete iStorageManager; |
|
72 delete iActiveScheduler; |
|
73 |
|
74 delete iBackupClient; |
|
75 } |
|
76 |
|
77 // LOGGING METHODS |
|
78 void CBURTestStepBase::Log(TUint aIndentationLevel, const TDesC& aLog) |
|
79 /** |
|
80 Logs the data inside the string as text string at aIndentationLevel. |
|
81 |
|
82 @internalComponent |
|
83 @released |
|
84 |
|
85 @param aIndentationLevel - The indentation level in the TestExecute test report. |
|
86 @param aLog - The message to be logged. |
|
87 */ |
|
88 { |
|
89 HBufC* indentation = NULL; |
|
90 indentation = GetIndentation(aIndentationLevel); |
|
91 TPtr ptr = indentation->Des(); |
|
92 INFO_PRINTF3(KFormatText2, &ptr, &aLog); |
|
93 delete indentation; |
|
94 } |
|
95 |
|
96 void CBURTestStepBase::LogWithText(TUint aIndentationLevel, const TDesC& aLog, const TDesC& aText) |
|
97 /** |
|
98 Writes the message with a text string. |
|
99 |
|
100 @internalComponent |
|
101 @released |
|
102 |
|
103 @param aIndentationLevel - The indentation level in the TestExecute test report. |
|
104 @param aLog - The message to be logged. |
|
105 @param aText - Textual data to be logged with the main message. |
|
106 */ |
|
107 { |
|
108 HBufC* indentation = NULL; |
|
109 indentation = GetIndentation(aIndentationLevel); |
|
110 TPtr ptr = indentation->Des(); |
|
111 INFO_PRINTF4(KFormatText3, &ptr, &aLog, &aText); |
|
112 delete indentation; |
|
113 } |
|
114 |
|
115 void CBURTestStepBase::LogWithText8(TUint aIndentationLevel, const TDesC& aLog, const TDesC8& aText) |
|
116 /** |
|
117 8-bit variant of the above |
|
118 |
|
119 @internalComponent |
|
120 @released |
|
121 |
|
122 @param aIndentationLevel - The indentation level in the TestExecute test report. |
|
123 @param aLog - The message to be logged. |
|
124 @param aText - 8-bit textual data to be logged with the main message. |
|
125 */ |
|
126 { |
|
127 HBufC* indentation = NULL; |
|
128 indentation = GetIndentation(aIndentationLevel); |
|
129 TPtr ptr = indentation->Des(); |
|
130 INFO_PRINTF4(KFormatText3, &ptr, &aLog, &aText); |
|
131 delete indentation; |
|
132 } |
|
133 |
|
134 void CBURTestStepBase::LogWithNum(TUint aIndentationLevel, const TDesC& aLog, TInt aNum) |
|
135 /** |
|
136 Writes to the report a number along with a message. |
|
137 |
|
138 @internalComponent |
|
139 @released |
|
140 |
|
141 @param aIndentationLevel - The indentation level in the TestExecute test report. |
|
142 @param aLog - The message to be logged. |
|
143 @param aNum - Number to be printed with the log. |
|
144 */ |
|
145 { |
|
146 HBufC* indentation = NULL; |
|
147 indentation = GetIndentation(aIndentationLevel); |
|
148 TPtr ptr = indentation->Des(); |
|
149 INFO_PRINTF4(KFormatText4, &ptr, &aLog, aNum); |
|
150 delete indentation; |
|
151 } |
|
152 |
|
153 void CBURTestStepBase::LogWithSID(TUint aIndentationLevel, const TDesC& aLog, TSecureId aSecureId) |
|
154 /** |
|
155 Writes out a TSecureId as a hexadecimal number along with a message. |
|
156 |
|
157 @internalComponent |
|
158 @released |
|
159 |
|
160 @param aIndentationLevel - The indentation level in the TestExecute test report. |
|
161 @param aLog - The message to be logged. |
|
162 @param aSecureId - A TSecureId to be printed as a hexadecimal number. |
|
163 */ |
|
164 { |
|
165 HBufC* indentation = NULL; |
|
166 indentation = GetIndentation(aIndentationLevel); |
|
167 TPtr ptr = indentation->Des(); |
|
168 INFO_PRINTF4(KFormatText5, &ptr, &aLog, aSecureId.iId); |
|
169 delete indentation; |
|
170 } |
|
171 |
|
172 void CBURTestStepBase::LogWithChar(TUint aIndentationLevel, const TDesC& aLog, TChar aChar) |
|
173 /** |
|
174 @internalComponent |
|
175 @released |
|
176 |
|
177 @param aIndentationLevel - The indentation level in the TestExecute test report. |
|
178 @param aLog - The message to be logged. |
|
179 @param aChar - A single char, appended at the end of the message. |
|
180 */ |
|
181 { |
|
182 HBufC* indentation = NULL; |
|
183 indentation = GetIndentation(aIndentationLevel); |
|
184 TPtr ptr = indentation->Des(); |
|
185 INFO_PRINTF4(KFormatText6, &ptr, &aLog, &aChar); |
|
186 delete indentation; |
|
187 } |
|
188 |
|
189 HBufC* CBURTestStepBase::GetIndentation(TInt aLevel) |
|
190 /** |
|
191 Generates a string of indentation markers (based on KIndentationMarker) the |
|
192 level of depth specified by aLevel |
|
193 |
|
194 @internalComponent |
|
195 @released |
|
196 |
|
197 @param aLevel - Level of depth required for indentation. |
|
198 */ |
|
199 { |
|
200 HBufC* hbuf = NULL; |
|
201 |
|
202 // Indentation level times the length of the indentation marker, |
|
203 // plus room for a tab and a '|' |
|
204 TInt indentationLength = aLevel * KIndentationMarker().Length() + 10; |
|
205 hbuf = HBufC::NewL(indentationLength); |
|
206 |
|
207 hbuf->Des().Append(KTabText); |
|
208 for(TInt i = 0; i < aLevel; ++i) |
|
209 { |
|
210 hbuf->Des().Append(KIndentationMarker); |
|
211 } |
|
212 |
|
213 return hbuf; |
|
214 } |
|
215 |
|
216 void CBURTestStepBase::CreateStorageManagerL() |
|
217 /** |
|
218 Must only be called after the user input has been processed. |
|
219 @internalComponent |
|
220 @released |
|
221 */ |
|
222 { |
|
223 iStorageManager = CStorageManager::NewL(iBackupDirName, iDriveList, this); |
|
224 } |
|
225 |
|
226 void CBURTestStepBase::ProcessUserOptionsL() |
|
227 /** |
|
228 This function uses TestExecute config file parsers to read in the user preferences |
|
229 from ini files |
|
230 |
|
231 @internalComponent |
|
232 @released |
|
233 */ |
|
234 { |
|
235 TPtrC backupDir; |
|
236 TInt isPartial = 0; |
|
237 TInt isBase = 0; |
|
238 TPtrC driveListText; |
|
239 |
|
240 // directory for archiving backup data |
|
241 _LIT(KBackupDirText1, "BackupDir"); |
|
242 GetStringFromConfig(ConfigSection(), KBackupDirText1, backupDir); |
|
243 |
|
244 _LIT(KBackupDirText2, "Backup directory: "); |
|
245 LogWithText(LOG_LEVEL3, KBackupDirText2, backupDir); |
|
246 iBackupDirName.Copy(backupDir); |
|
247 |
|
248 // affected drives |
|
249 _LIT(KDriveListText1, "DriveList"); |
|
250 GetStringFromConfig(ConfigSection(), KDriveListText1, driveListText); |
|
251 _LIT(KDriveListText2, "Drives: "); |
|
252 |
|
253 LogWithText(LOG_LEVEL3, KDriveListText2, driveListText); |
|
254 // extract all drives from the user input |
|
255 iDriveList = CBURTestStepBase::StringToDriveListL(driveListText); |
|
256 |
|
257 // create the storage handler based on the drives and backup directory |
|
258 CreateStorageManagerL(); |
|
259 |
|
260 // full/partial backup |
|
261 _LIT(KPartialText1, "IsPartial"); |
|
262 GetIntFromConfig(ConfigSection(), KPartialText1, isPartial); |
|
263 if (isPartial == 0) |
|
264 { |
|
265 iIsPartial = EFalse; |
|
266 |
|
267 _LIT(KPartialText2, "Full/Partial Type: Full"); |
|
268 Log(LOG_LEVEL3, KPartialText2); |
|
269 } //if |
|
270 else if (isPartial == 1) |
|
271 { |
|
272 iIsPartial = ETrue; |
|
273 TSecureId sid; |
|
274 |
|
275 TChar ch; |
|
276 TPtrC list; |
|
277 |
|
278 |
|
279 // PARSING ID LIST // |
|
280 |
|
281 _LIT(KSIDList, "IDs"); |
|
282 GetStringFromConfig(ConfigSection(), KSIDList, list); |
|
283 TLex sidLex(list); |
|
284 |
|
285 while (!sidLex.Eos()) |
|
286 { |
|
287 sidLex.Mark(); |
|
288 ch=sidLex.Peek(); |
|
289 |
|
290 while(!sidLex.Eos() && ( ch=sidLex.Peek() ) != TChar(',')) |
|
291 sidLex.Inc(); |
|
292 |
|
293 if(!sidLex.TokenLength()) |
|
294 continue; |
|
295 |
|
296 TPtrC pToken = sidLex.MarkedToken(); |
|
297 TLex token(pToken); |
|
298 |
|
299 if (pToken.Length() <= KMaxHexLength && token.Val(sid.iId, EHex) == KErrNone) |
|
300 { |
|
301 iSidArray.Append(sid); |
|
302 _LIT(KFound, "ID Found in ini file: "); |
|
303 LogWithSID(LOG_LEVEL4, KFound, sid); |
|
304 } //if |
|
305 else // must be a Java suite hash |
|
306 { |
|
307 iJidArray.Append(pToken); |
|
308 _LIT(KJFound, "Java ID Found in ini file: "); |
|
309 LogWithText(LOG_LEVEL4, KJFound, pToken); |
|
310 } |
|
311 |
|
312 if(ch==TChar(',')) |
|
313 sidLex.Inc(); |
|
314 |
|
315 sidLex.SkipSpace(); |
|
316 |
|
317 } //while |
|
318 |
|
319 |
|
320 _LIT(KPartialText3, "Full/Partial Type: Partial"); |
|
321 Log(LOG_LEVEL3, KPartialText3); |
|
322 } //if |
|
323 else |
|
324 { |
|
325 _LIT(KPartialText4, "Full/Partial Type: UNKNOWN"); |
|
326 _LIT(KPartialText5, "** PLEASE USE 0 OR 1 ONLY **"); |
|
327 _LIT(KPartialText6, "** Using FULL as default **"); |
|
328 Log(LOG_LEVEL4, KPartialText4); |
|
329 Log(LOG_LEVEL4, KPartialText5); |
|
330 Log(LOG_LEVEL4, KPartialText6); |
|
331 } |
|
332 |
|
333 // base/incremental |
|
334 _LIT(KIncrText1, "BaseOnly"); |
|
335 GetIntFromConfig(ConfigSection(), KIncrText1, isBase); |
|
336 if (isBase == 1) |
|
337 { |
|
338 iBackupIncType = EBackupBase; |
|
339 |
|
340 _LIT(KIncrText2, "Base/Incremental Type: Base Only"); |
|
341 Log(LOG_LEVEL3, KIncrText2); |
|
342 } |
|
343 else if (isBase == 0) |
|
344 { |
|
345 iBackupIncType = EBackupIncrement; |
|
346 |
|
347 _LIT(KIncrText3, "Base/Incremental Type: Incremental by Default"); |
|
348 Log(LOG_LEVEL3, KIncrText3); |
|
349 } |
|
350 else |
|
351 { |
|
352 _LIT(KIncrText4, "Base/Incremental Type: UNKNOWN"); |
|
353 _LIT(KIncrText5, "** PLEASE USE 0 OR 1 ONLY **"); |
|
354 _LIT(KIncrText6, "** Using BASE as default **"); |
|
355 Log(LOG_LEVEL4, KIncrText4); |
|
356 Log(LOG_LEVEL4, KIncrText5); |
|
357 Log(LOG_LEVEL4, KIncrText6); |
|
358 } |
|
359 } |
|
360 |
|
361 |
|
362 void CBURTestStepBase::PopulateListOfDataOwnersL() |
|
363 /** |
|
364 Uses CSBEClient::ListOfDataOwnersL() to extract a list of data owners that have |
|
365 registred for backup and restore. Populates iDataOwners. |
|
366 |
|
367 @internalComponent |
|
368 @released |
|
369 */ |
|
370 { |
|
371 _LIT(KTempText1, "Getting list of data owners from device"); |
|
372 Log(LOG_LEVEL2,KTempText1); |
|
373 |
|
374 TRAPD(err, iBackupClient->ListOfDataOwnersL(iDataOwners)); |
|
375 if (err != KErrNone) |
|
376 { |
|
377 _LIT(KTempText1, "Error getting list of data owners: "); |
|
378 LogWithNum(LOG_LEVEL2,KTempText1, err); |
|
379 iFailures++; |
|
380 } |
|
381 |
|
382 // Log |
|
383 if (iDataOwners.Count() == 0) |
|
384 { |
|
385 _LIT(KTempText3, "No data owners found."); |
|
386 Log(LOG_LEVEL3, KTempText3); |
|
387 } |
|
388 else |
|
389 { |
|
390 _LIT(KTempText4, "Number of data owners found on device: "); |
|
391 LogWithNum(LOG_LEVEL3, KTempText4, iDataOwners.Count()); |
|
392 } |
|
393 } |
|
394 |
|
395 void CBURTestStepBase::PopulateListOfDataOwnersAsyncL() |
|
396 /** |
|
397 Uses CSBEClient::ListOfDataOwnersL() to extract a list of data owners that have |
|
398 registred for backup and restore. Populates iDataOwners. |
|
399 |
|
400 @internalComponent |
|
401 @released |
|
402 */ |
|
403 { |
|
404 _LIT(KTempText1, "Getting list of data owners from device"); |
|
405 Log(LOG_LEVEL2,KTempText1); |
|
406 CBURActiveObject* active = CBURActiveObject::NewL(); |
|
407 CleanupStack::PushL(active); |
|
408 TRAPD(err, iBackupClient->ListOfDataOwnersL(iDataOwners, active->iStatus)); |
|
409 if (err == KErrNone) |
|
410 { |
|
411 active->StartL(); |
|
412 } |
|
413 |
|
414 if (err != KErrNone || active->Error() != KErrNone) |
|
415 { |
|
416 _LIT(KTempText1, "Error getting list of data owners: "); |
|
417 LogWithNum(LOG_LEVEL2,KTempText1, err); |
|
418 iFailures++; |
|
419 } |
|
420 CleanupStack::PopAndDestroy(active); |
|
421 |
|
422 // Log |
|
423 if (iDataOwners.Count() == 0) |
|
424 { |
|
425 _LIT(KTempText3, "No data owners found."); |
|
426 Log(LOG_LEVEL3, KTempText3); |
|
427 } |
|
428 else |
|
429 { |
|
430 _LIT(KTempText4, "Number of data owners found on device: "); |
|
431 LogWithNum(LOG_LEVEL3, KTempText4, iDataOwners.Count()); |
|
432 } |
|
433 } |
|
434 |
|
435 void CBURTestStepBase::SetBURModeL(TBURPartType aBURPartType, TBackupIncType aBackupIncType) |
|
436 /** |
|
437 Uses CSBEClient::SetBURModeL() to set backup and restore settings |
|
438 |
|
439 @internalComponent |
|
440 @released |
|
441 |
|
442 @param aBURPartType - Full/Partial backup/restore. |
|
443 @param aBackupIncType - Base/Incremental backup/restore. |
|
444 */ |
|
445 { |
|
446 iBackupClient->SetBURModeL(iDriveList, aBURPartType, aBackupIncType); |
|
447 } |
|
448 |
|
449 void CBURTestStepBase::SetBURModeAsyncL(TBURPartType aBURPartType, TBackupIncType aBackupIncType) |
|
450 /** |
|
451 Uses CSBEClient::SetBURModeL() Asyncrhonous version to set backup and restore settings |
|
452 |
|
453 @internalComponent |
|
454 @released |
|
455 |
|
456 @param aBURPartType - Full/Partial backup/restore. |
|
457 @param aBackupIncType - Base/Incremental backup/restore. |
|
458 */ |
|
459 { |
|
460 CBURActiveObject* active = CBURActiveObject::NewL(); |
|
461 CleanupStack::PushL(active); |
|
462 iBackupClient->SetBURModeL(iDriveList, aBURPartType, aBackupIncType, active->iStatus); |
|
463 active->StartL(); |
|
464 User::LeaveIfError(active->Error()); |
|
465 CleanupStack::PopAndDestroy(active); |
|
466 } |
|
467 |
|
468 void CBURTestStepBase::PrepareForPartialBURL() |
|
469 /** |
|
470 @internalComponent |
|
471 @released |
|
472 */ |
|
473 { |
|
474 TSecureId sid = NULL; |
|
475 |
|
476 // go through list of pids and sids |
|
477 for (TInt index = 0; index < iDataOwners.Count(); index++) |
|
478 { |
|
479 TBool notFound = ETrue; |
|
480 sid = ExtractIDL(*iDataOwners[index]); |
|
481 |
|
482 if (sid != NULL) |
|
483 { |
|
484 TInt position = iSidArray.Find(sid); |
|
485 if (position != KErrNotFound) |
|
486 { |
|
487 _LIT(KTempText2, "ID found in list of data owners: "); |
|
488 LogWithSID(LOG_LEVEL3, KTempText2, sid); |
|
489 notFound = EFalse; |
|
490 } |
|
491 else if (position == KErrNotFound) |
|
492 { |
|
493 notFound = ETrue; |
|
494 } // if else |
|
495 } // if |
|
496 else // possibly jid |
|
497 { |
|
498 HBufC* pSuiteHash = ExtractJavaIDL(*iDataOwners[index]); |
|
499 TPtrC suiteHash = pSuiteHash->Des(); |
|
500 if (iJidArray.Find(suiteHash) != KErrNotFound) |
|
501 { |
|
502 _LIT(KTempText3, "Java ID found in list of data owners: "); |
|
503 LogWithText(LOG_LEVEL3, KTempText3, suiteHash); |
|
504 notFound = EFalse; |
|
505 } |
|
506 else // not found |
|
507 { |
|
508 notFound = ETrue; |
|
509 } |
|
510 delete pSuiteHash; |
|
511 pSuiteHash = NULL; |
|
512 } |
|
513 if (notFound) |
|
514 { |
|
515 delete iDataOwners[index]; |
|
516 iDataOwners[index] = NULL; |
|
517 iDataOwners.Remove(index); |
|
518 index--; |
|
519 } |
|
520 } |
|
521 } |
|
522 |
|
523 void CBURTestStepBase::SetSIDListForPartialL() |
|
524 /** |
|
525 Set the list of active data owners for partial bur |
|
526 |
|
527 @param aDataOwners List of data owners for partial bur |
|
528 */ |
|
529 { |
|
530 iSidArray.Reset(); |
|
531 for (TInt i=0; i< iDataOwners.Count(); i++) |
|
532 { |
|
533 if (iDataOwners[i]->CommonSettings() & EActiveBUR) |
|
534 { |
|
535 TSBDerivedType type = iDataOwners[i]->Identifier().DerivedTypeL(); |
|
536 if (type == ESIDDerivedType) |
|
537 { |
|
538 // means it is definately a sid |
|
539 CSBSecureId* secureId = CSBSecureId::NewL(&(iDataOwners[i]->Identifier())); |
|
540 CleanupStack::PushL(secureId); |
|
541 |
|
542 iSidArray.AppendL(secureId->SecureIdL()); |
|
543 CleanupStack::PopAndDestroy(secureId); |
|
544 } |
|
545 else if (type == EPackageDerivedType) |
|
546 { |
|
547 CSBPackageId* packageId = CSBPackageId::NewL(&(iDataOwners[i]->Identifier())); |
|
548 CleanupStack::PushL(packageId); |
|
549 |
|
550 iSidArray.AppendL(packageId->SecureIdL()); |
|
551 CleanupStack::PopAndDestroy(packageId); |
|
552 } |
|
553 } //if |
|
554 }// for |
|
555 |
|
556 // set active owners array |
|
557 TRAPD(err,iBackupClient->SetSIDListForPartialBURL(iSidArray)); |
|
558 if (err != KErrNone) |
|
559 { |
|
560 iFailures++; |
|
561 _LIT(KSidP, "Error Setting list for partial : "); |
|
562 LogWithNum(LOG_LEVEL3, KSidP, err); |
|
563 } |
|
564 } |
|
565 |
|
566 void CBURTestStepBase::GenerateSIDTransferTypesL(RTransferTypeArray& aTransferTypes, TTransferDataType aDataType) |
|
567 /** |
|
568 For each data owner in iDataOwners, this method creates CSBGenericTransferTypes |
|
569 based on the TTransferDataType passed. One transfer type is created per drive that |
|
570 the data owner in question has data on. Only creates transfer types supported by data owner |
|
571 |
|
572 @internalComponent |
|
573 @released |
|
574 |
|
575 @param aTransferTypes - Array of transfer types. |
|
576 @param aDataType - Trasnfer data type, passive base, active base, etc. |
|
577 */ |
|
578 { |
|
579 TTransferDataType tempDataType = aDataType; |
|
580 aTransferTypes.ResetAndDestroy(); |
|
581 TSecureId sid = NULL; |
|
582 |
|
583 TInt length = iDriveList.Length(); |
|
584 for (TInt driveCount = 0; driveCount < length; driveCount++) |
|
585 { |
|
586 if (iDriveList[driveCount]) |
|
587 { |
|
588 for (TInt i = 0; i < iDataOwners.Count(); i++) |
|
589 { |
|
590 if (iDataOwners[i]->Identifier().DerivedTypeL() == ESIDDerivedType) |
|
591 { |
|
592 CSBSecureId* secureId = CSBSecureId::NewL(&(iDataOwners[i]->Identifier())); |
|
593 CleanupStack::PushL(secureId); |
|
594 |
|
595 sid = secureId->SecureIdL(); |
|
596 |
|
597 CleanupStack::PopAndDestroy(secureId); |
|
598 } |
|
599 else if (iDataOwners[i]->Identifier().DerivedTypeL() == EPackageDerivedType) |
|
600 { |
|
601 CSBPackageId* pkgId = CSBPackageId::NewL(&(iDataOwners[i]->Identifier())); |
|
602 CleanupStack::PushL(pkgId); |
|
603 |
|
604 sid = pkgId->SecureIdL(); |
|
605 |
|
606 CleanupStack::PopAndDestroy(pkgId); |
|
607 } // else if |
|
608 |
|
609 if (sid != NULL) |
|
610 { |
|
611 // decides if data owner supports that data type |
|
612 |
|
613 TBool checkIfHaveBase = EFalse; |
|
614 TBool baseOnly = EFalse; |
|
615 TBool supports = EFalse; |
|
616 switch (aDataType) |
|
617 { |
|
618 case ERegistrationData: |
|
619 supports = EFalse; |
|
620 break; |
|
621 case EPassiveBaseData: |
|
622 if (iDataOwners[i]->CommonSettings() & EPassiveBUR) |
|
623 { |
|
624 supports = ETrue; |
|
625 } |
|
626 break; |
|
627 case EPassiveSnapshotData: |
|
628 if (iDataOwners[i]->PassiveSettings() & EPassiveSupportsInc) |
|
629 { |
|
630 supports = ETrue; |
|
631 } |
|
632 break; |
|
633 case EPassiveIncrementalData: |
|
634 if (iDataOwners[i]->CommonSettings() & EPassiveBUR) |
|
635 { |
|
636 if (!(iDataOwners[i]->PassiveSettings() & EPassiveSupportsInc) && !iMode) |
|
637 { |
|
638 _LIT(KPsIncDt, "Base only for SID: "); |
|
639 LogWithSID(LOG_LEVEL3, KPsIncDt, sid); |
|
640 baseOnly = ETrue; |
|
641 supports = ETrue; |
|
642 aDataType = EPassiveBaseData; |
|
643 } |
|
644 else if (iDataOwners[i]->PassiveSettings() & EPassiveSupportsInc) |
|
645 { |
|
646 checkIfHaveBase = ETrue; |
|
647 } |
|
648 } // if |
|
649 break; |
|
650 case EActiveSnapshotData: |
|
651 if (iDataOwners[i]->ActiveSettings() & EActiveSupportsInc) |
|
652 { |
|
653 supports = ETrue; |
|
654 } |
|
655 break; |
|
656 case EActiveIncrementalData: |
|
657 if (iDataOwners[i]->CommonSettings() & EActiveBUR) |
|
658 { |
|
659 if (!(iDataOwners[i]->ActiveSettings() & EActiveSupportsInc) && !iMode) |
|
660 { |
|
661 _LIT(KAcIncDt, "Base only for SID: "); |
|
662 LogWithSID(LOG_LEVEL3, KAcIncDt, sid); |
|
663 baseOnly = ETrue; |
|
664 supports = ETrue; |
|
665 aDataType = EActiveBaseData; |
|
666 } |
|
667 else if (iDataOwners[i]->ActiveSettings() & EActiveSupportsInc) |
|
668 { |
|
669 checkIfHaveBase = ETrue; |
|
670 } |
|
671 } // if |
|
672 break; |
|
673 case EActiveBaseData: |
|
674 if (iDataOwners[i]->CommonSettings() & EActiveBUR) |
|
675 { |
|
676 supports = ETrue; |
|
677 } |
|
678 break; |
|
679 } //switch |
|
680 |
|
681 |
|
682 if (checkIfHaveBase) |
|
683 { |
|
684 TTransferDataType dType; |
|
685 if (aDataType == EActiveIncrementalData) |
|
686 { |
|
687 dType = EActiveBaseData; |
|
688 } |
|
689 else |
|
690 { |
|
691 dType = EPassiveBaseData; |
|
692 } // if else |
|
693 |
|
694 CSBSIDTransferType* tType = CSBSIDTransferType::NewL(sid, TDriveNumber(driveCount), dType); |
|
695 CleanupStack::PushL(tType); |
|
696 TFileName fileName; |
|
697 iStorageManager->GetFileNameL(tType, fileName, EFalse); |
|
698 if(iStorageManager->IsFileExists(fileName)) |
|
699 { |
|
700 supports = ETrue; |
|
701 } |
|
702 else |
|
703 { |
|
704 _LIT(KTempText2, "No increments found use Base instead for SID: "); |
|
705 LogWithSID(LOG_LEVEL3, KTempText2, sid); |
|
706 supports = ETrue; |
|
707 aDataType = dType; |
|
708 baseOnly = ETrue; |
|
709 } |
|
710 CleanupStack::PopAndDestroy(tType); |
|
711 } // if check if have base |
|
712 |
|
713 |
|
714 if (supports) |
|
715 { |
|
716 CSBSIDTransferType* sidType = CSBSIDTransferType::NewL(sid, TDriveNumber(driveCount), aDataType); |
|
717 CleanupStack::PushL(sidType); |
|
718 aTransferTypes.AppendL(sidType); |
|
719 CleanupStack::Pop(sidType); |
|
720 } // if else |
|
721 |
|
722 // change to the proper dataType if base only true |
|
723 if (baseOnly) |
|
724 { |
|
725 aDataType = tempDataType; |
|
726 } |
|
727 sid = NULL; |
|
728 }// if |
|
729 } // for |
|
730 } // if |
|
731 } //for |
|
732 } |
|
733 |
|
734 void CBURTestStepBase::GeneratePIDTransferTypesL(RTransferTypeArray& aTransferTypes, TPackageDataType aPkgDataType) |
|
735 /** |
|
736 For each data owner in iDataOwners, this method creates CSBGenericTransferTypes |
|
737 based on the TTransferDataType passed. One transfer type is created per drive that |
|
738 the data owner in question has data on. |
|
739 |
|
740 @internalComponent |
|
741 @released |
|
742 |
|
743 @param aTransferTypes - Array of transfer types. |
|
744 @param aDataType - Trasnfer data type, passive base, active base, etc. |
|
745 */ |
|
746 { |
|
747 aTransferTypes.ResetAndDestroy(); |
|
748 TUid id; |
|
749 //need array to avoid duplications |
|
750 RArray<TUid> uidArray; |
|
751 CleanupClosePushL(uidArray); |
|
752 |
|
753 TInt length = iDriveList.Length(); |
|
754 for (TInt driveCount = 0; driveCount < length; driveCount++) |
|
755 { |
|
756 if (iDriveList[driveCount]) |
|
757 { |
|
758 TInt count = iDataOwners.Count(); |
|
759 for (TInt i = 0; i < count; i++) |
|
760 { |
|
761 switch (iDataOwners[i]->Identifier().DerivedTypeL()) |
|
762 { |
|
763 case EPackageDerivedType: |
|
764 if (iDataOwners[i]->CommonSettings() & EHasSystemFiles) |
|
765 { |
|
766 CSBPackageId* pkgId = CSBPackageId::NewL(&(iDataOwners[i]->Identifier())); |
|
767 CleanupStack::PushL(pkgId); |
|
768 |
|
769 id = pkgId->PackageIdL(); |
|
770 if (uidArray.Find(id) == KErrNotFound) |
|
771 { |
|
772 CSBPackageTransferType* idType = CSBPackageTransferType::NewL(id, TDriveNumber(driveCount), aPkgDataType); |
|
773 CleanupStack::PushL(idType); |
|
774 aTransferTypes.AppendL(idType); |
|
775 CleanupStack::Pop(idType); |
|
776 //add to uid array |
|
777 uidArray.AppendL(id); |
|
778 } |
|
779 CleanupStack::PopAndDestroy(pkgId); |
|
780 } //if |
|
781 break; |
|
782 } // switch |
|
783 } //for |
|
784 } //if |
|
785 } //for |
|
786 CleanupStack::PopAndDestroy(&uidArray); |
|
787 } |
|
788 |
|
789 void CBURTestStepBase::GenerateJavaTransferTypesL(RTransferTypeArray& aTransferTypes, TJavaTransferType aJavaTransferType) |
|
790 /** |
|
791 For each data owner in iDataOwners, this method creates CSBGenericTransferTypes |
|
792 based on the TTransferDataType passed. One transfer type is created per drive that |
|
793 the data owner in question has data on. |
|
794 |
|
795 @internalComponent |
|
796 @released |
|
797 |
|
798 @param aTransferTypes - Array of transfer types. |
|
799 @param aJavaTransferType - Trasnfer data type |
|
800 */ |
|
801 { |
|
802 aTransferTypes.ResetAndDestroy(); |
|
803 |
|
804 TInt length = iDriveList.Length(); |
|
805 for (TInt driveCount = 0; driveCount < length; driveCount++) |
|
806 { |
|
807 if (iDriveList[driveCount]) |
|
808 { |
|
809 TInt count = iDataOwners.Count(); |
|
810 for (TInt i=0; i < count; i++) |
|
811 { |
|
812 switch (iDataOwners[i]->Identifier().DerivedTypeL()) |
|
813 { |
|
814 case EJavaDerivedType: |
|
815 { |
|
816 if ((aJavaTransferType == EJavaMIDlet && (iDataOwners[i]->CommonSettings() & EHasSystemFiles)) || aJavaTransferType == EJavaMIDletData) |
|
817 { |
|
818 CSBJavaId* javaId = CSBJavaId::NewL(&(iDataOwners[i]->Identifier())); |
|
819 CleanupStack::PushL(javaId); |
|
820 const TDesC& suiteHash = javaId->SuiteHashL(); |
|
821 CSBJavaTransferType* javaType = CSBJavaTransferType::NewL(suiteHash, TDriveNumber(driveCount), aJavaTransferType); |
|
822 CleanupStack::PushL(javaType); |
|
823 aTransferTypes.AppendL(javaType); |
|
824 CleanupStack::Pop(javaType); |
|
825 CleanupStack::PopAndDestroy(javaId); |
|
826 }//if |
|
827 } |
|
828 break; |
|
829 } // switch |
|
830 } //for |
|
831 } // if |
|
832 } // for |
|
833 } |
|
834 |
|
835 |
|
836 void CBURTestStepBase::GeneratePublicTransferTypesL(RPointerArray<CSBGenericDataType>& aTransferTypes) |
|
837 /** |
|
838 For each data owner in iDataOwners, this method creates CSBGenericTransferTypes |
|
839 based on the TTransferDataType passed. One transfer type is created per drive that |
|
840 the data owner in question has data on. |
|
841 |
|
842 @internalComponent |
|
843 @released |
|
844 |
|
845 @param aTransferTypes - Array of transfer types. |
|
846 @param aDataType - Trasnfer data type, passive base, active base, etc. |
|
847 */ |
|
848 { |
|
849 aTransferTypes.ResetAndDestroy(); |
|
850 |
|
851 TInt count = iDataOwners.Count(); |
|
852 for (TInt i = 0; i < count; i++) |
|
853 { |
|
854 switch (iDataOwners[i]->Identifier().DerivedTypeL()) |
|
855 { |
|
856 case EPackageDerivedType: |
|
857 case ESIDDerivedType: |
|
858 if (iDataOwners[i]->PassiveSettings() & EHasPublicFiles) |
|
859 { |
|
860 const TDesC8& desc = iDataOwners[i]->Identifier().Externalise(); |
|
861 CSBGenericDataType* idType = CSBGenericDataType::NewL(desc); |
|
862 CleanupStack::PushL(idType); |
|
863 aTransferTypes.AppendL(idType); |
|
864 CleanupStack::Pop(idType); |
|
865 } //if |
|
866 break; |
|
867 } // switch |
|
868 } |
|
869 } |
|
870 |
|
871 |
|
872 void CBURTestStepBase::SupplyDataL(RTransferTypeArray& aTransferTypes) |
|
873 /** |
|
874 Retrieves data from the storage handler and supplies to the backup client for |
|
875 the given transfer type |
|
876 |
|
877 @internalComponent |
|
878 @released |
|
879 |
|
880 @param aTransferTypes - Array of transfer types. |
|
881 */ |
|
882 { |
|
883 TInt transferTypesCount = aTransferTypes.Count(); |
|
884 for(TInt currentIndex = 0; currentIndex < transferTypesCount; ++currentIndex) |
|
885 { |
|
886 TInt error; |
|
887 TInt increments = 0; |
|
888 TInt incrIndex = 1; |
|
889 |
|
890 TSBDerivedType dataType = aTransferTypes[currentIndex]->DerivedTypeL(); |
|
891 |
|
892 // check for incremental data |
|
893 switch(dataType) |
|
894 { |
|
895 case ESIDTransferDerivedType: |
|
896 { |
|
897 CSBSIDTransferType* type = CSBSIDTransferType::NewL(aTransferTypes[currentIndex]); |
|
898 CleanupStack::PushL(type); |
|
899 |
|
900 _LIT(KSid, "Supplying data for ID: "); |
|
901 LogWithSID(LOG_LEVEL3, KSid, type->SecureIdL()); |
|
902 |
|
903 if (type->DataTypeL() == EActiveIncrementalData || type->DataTypeL() == EPassiveIncrementalData) |
|
904 { |
|
905 increments = iStorageManager->TotalIncFiles(type); |
|
906 if (!increments) |
|
907 { |
|
908 _LIT(KErrorText2, "No increments found"); |
|
909 Log(LOG_LEVEL4, KErrorText2); |
|
910 // cleanup |
|
911 CleanupStack::PopAndDestroy(type); |
|
912 continue; |
|
913 } |
|
914 else |
|
915 { |
|
916 _LIT(KIncFound, "Number of increments found: "); |
|
917 LogWithNum(LOG_LEVEL4, KIncFound, increments); |
|
918 } // else if |
|
919 } // if |
|
920 CleanupStack::PopAndDestroy(type); |
|
921 } |
|
922 break; |
|
923 case EPackageTransferDerivedType: |
|
924 { |
|
925 // package stuff |
|
926 CSBPackageTransferType* pType = CSBPackageTransferType::NewL(aTransferTypes[currentIndex]); |
|
927 CleanupStack::PushL(pType); |
|
928 _LIT(KPid, "Supplying data for Package ID: "); |
|
929 LogWithSID(LOG_LEVEL3, KPid, pType->PackageIdL()); |
|
930 CleanupStack::PopAndDestroy(pType); |
|
931 } |
|
932 break; |
|
933 case EJavaTransferDerivedType: |
|
934 { |
|
935 // java stuff |
|
936 CSBJavaTransferType* jType = CSBJavaTransferType::NewL(aTransferTypes[currentIndex]); |
|
937 CleanupStack::PushL(jType); |
|
938 _LIT(KJid, "Supplying data for Java SuiteHash: "); |
|
939 LogWithText(LOG_LEVEL3, KJid, jType->SuiteHashL()); |
|
940 CleanupStack::PopAndDestroy(jType); |
|
941 } |
|
942 break; |
|
943 |
|
944 } // switch |
|
945 TBool runAgain = ETrue; |
|
946 do |
|
947 { |
|
948 TBool finished; |
|
949 TPtr8* bufferPtr = NULL; |
|
950 TRAP(error, bufferPtr = &iBackupClient->TransferDataAddressL()); |
|
951 if (error != KErrNone) |
|
952 { |
|
953 _LIT(KErrTDA, "Error getting TransferDataAddress: "); |
|
954 LogWithNum(LOG_LEVEL4, KErrTDA, error); |
|
955 break; |
|
956 } |
|
957 TRAP(error, iStorageManager->RetrieveDataL(aTransferTypes[currentIndex], *bufferPtr, finished, incrIndex)); |
|
958 if (error != KErrNone) |
|
959 { |
|
960 iStorageManager->Reset(); |
|
961 if (error == KErrPathNotFound || error == KErrNotFound) |
|
962 { |
|
963 _LIT(KErrorText2, "Data doesn't exists"); |
|
964 Log(LOG_LEVEL4, KErrorText2); |
|
965 } |
|
966 else |
|
967 { |
|
968 _LIT(KErrorText1, "Error reading from archive: "); |
|
969 LogWithNum(LOG_LEVEL4, KErrorText1, error); |
|
970 iFailures++; |
|
971 } |
|
972 break; |
|
973 } |
|
974 else |
|
975 { |
|
976 _LIT(KLogBytes, "Number of bytes to send: "); |
|
977 LogWithNum(LOG_LEVEL4, KLogBytes, bufferPtr->Length()); |
|
978 |
|
979 TRAP(error, iBackupClient->SupplyDataL(*aTransferTypes[currentIndex], finished)); |
|
980 if (error != KErrNone) |
|
981 { |
|
982 _LIT(KErrorText2, "Error supplying data to backup server: "); |
|
983 LogWithNum(LOG_LEVEL4, KErrorText2, error); |
|
984 iFailures++; |
|
985 break; |
|
986 } |
|
987 else |
|
988 { |
|
989 _LIT(KSuccess, "Operation finished successfully"); |
|
990 Log(LOG_LEVEL4, KSuccess); |
|
991 } |
|
992 |
|
993 } // else |
|
994 |
|
995 if ((finished && !increments) || (incrIndex == increments && finished)) // if finished |
|
996 { |
|
997 runAgain = EFalse; |
|
998 } |
|
999 else if (finished && incrIndex < increments) // is incremental data move to next increment |
|
1000 { |
|
1001 incrIndex++; |
|
1002 runAgain = ETrue; |
|
1003 } |
|
1004 else |
|
1005 { |
|
1006 runAgain = ETrue; |
|
1007 } |
|
1008 } // do |
|
1009 while (runAgain); |
|
1010 } // for |
|
1011 |
|
1012 if (!iFailures) |
|
1013 { |
|
1014 _LIT(KComp, "No errors found"); |
|
1015 Log(LOG_LEVEL3, KComp); |
|
1016 } |
|
1017 // Do not delete bufferPtr, as it gets deleted by the iBackupClient |
|
1018 } |
|
1019 |
|
1020 TDriveList CBURTestStepBase::StringToDriveListL(TPtrC apText) |
|
1021 /** |
|
1022 @internalComponent |
|
1023 @released |
|
1024 |
|
1025 @param apText - String that needs to be converted into a TDriveList. |
|
1026 @return TDriveList with all the bytes set to 1 where a corresponding drive letter |
|
1027 was found in apText |
|
1028 */ |
|
1029 { |
|
1030 TInt error; |
|
1031 RFs fsSession; |
|
1032 CleanupClosePushL(fsSession); |
|
1033 error = fsSession.Connect(); |
|
1034 if (error != KErrNone) |
|
1035 { |
|
1036 User::Leave(error); |
|
1037 } |
|
1038 |
|
1039 TUint8 str[KMaxDrives]; |
|
1040 for (TInt i = 0; i < KMaxDrives; ++i) |
|
1041 { |
|
1042 str[i] = 0; // Initialise to zero |
|
1043 } |
|
1044 |
|
1045 TInt length = apText.Length(); |
|
1046 for (TInt i = 0; i < length; ++i) |
|
1047 { |
|
1048 TInt pos; |
|
1049 fsSession.CharToDrive(apText.Ptr()[i], pos); |
|
1050 str[pos] = 1; |
|
1051 } |
|
1052 |
|
1053 TDriveList driveList; |
|
1054 //driveList.FillZ(); // initialise to zeros |
|
1055 TPtr8 ptr(&str[0], KMaxDrives, KMaxDrives); |
|
1056 driveList.Copy(ptr); |
|
1057 |
|
1058 CleanupStack::PopAndDestroy(); |
|
1059 return driveList; |
|
1060 } |
|
1061 |
|
1062 |
|
1063 void CBURTestStepBase::SaveDataOwners() |
|
1064 /** |
|
1065 Saves data owners to storage Manager |
|
1066 */ |
|
1067 { |
|
1068 TInt count = iDataOwners.Count(); |
|
1069 for (TInt i =0; i < count; i++) |
|
1070 { |
|
1071 TRAPD(err, iStorageManager->SaveDataOwnerL(*iDataOwners[i])); |
|
1072 if (err != KErrNone) |
|
1073 { |
|
1074 _LIT(KDataOwnerErr, "Error saving Data Owner: "); |
|
1075 LogWithNum(LOG_LEVEL2, KDataOwnerErr, err); |
|
1076 } |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 void CBURTestStepBase::CheckSIDStatusL(RTransferTypeArray& aTransferTypes, RTransferTypeArray& aReadyArray) |
|
1081 /** |
|
1082 Checks the readyness status for Active Data Owner. The ones are ready put into ready array and removed from the original |
|
1083 |
|
1084 @param aTransferTypes - TransferTypes to check for status |
|
1085 @param aReadyArray - array of transfer types where dataowners are ready |
|
1086 */ |
|
1087 { |
|
1088 aReadyArray.ResetAndDestroy(); |
|
1089 if (aTransferTypes.Count()) |
|
1090 { |
|
1091 // used for getting statuses |
|
1092 RSIDStatusArray statusArray; |
|
1093 CleanupClosePushL(statusArray); |
|
1094 // create array of sid for status request |
|
1095 for (TInt i =0; i< aTransferTypes.Count(); i++) |
|
1096 { |
|
1097 TSecureId id = NULL; |
|
1098 TSBDerivedType type = aTransferTypes[i]->DerivedTypeL(); |
|
1099 if (type == ESIDTransferDerivedType) |
|
1100 { |
|
1101 CSBSIDTransferType* sidType = CSBSIDTransferType::NewL(aTransferTypes[i]); |
|
1102 CleanupStack::PushL(sidType); |
|
1103 id = sidType->SecureIdL(); |
|
1104 CleanupStack::PopAndDestroy(sidType); |
|
1105 statusArray.Append(TDataOwnerAndStatus(id, EUnset, KErrNone)); |
|
1106 } |
|
1107 } //for |
|
1108 |
|
1109 // get status for data owners |
|
1110 iBackupClient->SIDStatusL(statusArray); |
|
1111 |
|
1112 // check which sids ready |
|
1113 TInt total = statusArray.Count(); |
|
1114 for (TInt j=0; j < total; j++) |
|
1115 { |
|
1116 TDataOwnerAndStatus test = statusArray[j]; |
|
1117 if (statusArray[j].iStatus == EDataOwnerReady) |
|
1118 { |
|
1119 aReadyArray.Append(aTransferTypes[j]); |
|
1120 statusArray.Remove(j); |
|
1121 aTransferTypes.Remove(j); |
|
1122 j--; |
|
1123 total--; |
|
1124 } |
|
1125 else if (statusArray[j].iStatus == EDataOwnerReadyNoImpl || statusArray[j].iStatus == EDataOwnerFailed || statusArray[j].iStatus == EDataOwnerNotFound) |
|
1126 { |
|
1127 LogWithSID(LOG_LEVEL3, _L("Data Owner Failed, NotFound or Has No implementation : "),statusArray[j].iSID.iId); |
|
1128 statusArray.Remove(j); |
|
1129 delete aTransferTypes[j]; |
|
1130 aTransferTypes[j] = NULL; |
|
1131 aTransferTypes.Remove(j); |
|
1132 j--; |
|
1133 total--; |
|
1134 } |
|
1135 } //for |
|
1136 statusArray.Reset(); |
|
1137 CleanupStack::PopAndDestroy(&statusArray); |
|
1138 } // if |
|
1139 } |
|
1140 |
|
1141 TSecureId CBURTestStepBase::ExtractIDL(CDataOwnerInfo& aDataOwner) |
|
1142 /** |
|
1143 Gets Secure ID or UID from Data Owner |
|
1144 |
|
1145 @param aDataOwner Data Owner to get ID from |
|
1146 |
|
1147 @return TSecureId Secure ID of the data owner |
|
1148 */ |
|
1149 { |
|
1150 TSecureId id = NULL; |
|
1151 if (aDataOwner.Identifier().DerivedTypeL() == ESIDDerivedType) |
|
1152 { |
|
1153 CSBSecureId* secureId = CSBSecureId::NewL(&(aDataOwner.Identifier())); |
|
1154 CleanupStack::PushL(secureId); |
|
1155 |
|
1156 id = secureId->SecureIdL(); |
|
1157 |
|
1158 CleanupStack::PopAndDestroy(secureId); |
|
1159 } // if |
|
1160 else if (aDataOwner.Identifier().DerivedTypeL() == EPackageDerivedType) |
|
1161 { |
|
1162 CSBPackageId* pkgId = CSBPackageId::NewL(&(aDataOwner.Identifier())); |
|
1163 CleanupStack::PushL(pkgId); |
|
1164 |
|
1165 // package id |
|
1166 id = pkgId->PackageIdL(); |
|
1167 |
|
1168 CleanupStack::PopAndDestroy(pkgId); |
|
1169 } // else if |
|
1170 return id; |
|
1171 } |
|
1172 |
|
1173 HBufC* CBURTestStepBase::ExtractJavaIDL(CDataOwnerInfo& aDataOwner) |
|
1174 /** |
|
1175 Gets Suite Hash ID from the Data Owner |
|
1176 |
|
1177 @param aDataOwner - Data Owner to get suite hash from |
|
1178 |
|
1179 @return HBufC* pointe to a suite hash |
|
1180 */ |
|
1181 { |
|
1182 HBufC* jid = NULL; |
|
1183 if (aDataOwner.Identifier().DerivedTypeL() == EJavaDerivedType) |
|
1184 { |
|
1185 CSBJavaId* javaId = CSBJavaId::NewL(&(aDataOwner.Identifier())); |
|
1186 CleanupStack::PushL(javaId); |
|
1187 |
|
1188 const TDesC& suiteHash = javaId->SuiteHashL(); |
|
1189 jid = HBufC::NewLC(suiteHash.Size()); |
|
1190 *jid = suiteHash; |
|
1191 CleanupStack::Pop(jid); |
|
1192 CleanupStack::PopAndDestroy(javaId); |
|
1193 } |
|
1194 return jid; |
|
1195 } |
|
1196 |
|
1197 void CBURTestStepBase::CheckValidRegistrationL() |
|
1198 /** |
|
1199 Checks the list of data owners returned from the device for the validity of the registration file. |
|
1200 If registration is invalid the data owner is removed from the list and not backed up or restored. |
|
1201 */ |
|
1202 { |
|
1203 for (TInt i = 0; i < iDataOwners.Count(); i++) |
|
1204 { |
|
1205 switch (iDataOwners[i]->Identifier().DerivedTypeL()) |
|
1206 { |
|
1207 case ESIDDerivedType: |
|
1208 { |
|
1209 _LIT(KFoundSid, "Sid in the list: "); |
|
1210 LogWithSID(LOG_LEVEL3, KFoundSid, ExtractIDL(*iDataOwners[i])); |
|
1211 } |
|
1212 break; |
|
1213 |
|
1214 case EPackageDerivedType: |
|
1215 { |
|
1216 _LIT(KFoundPid, "Package in the list: "); |
|
1217 LogWithSID(LOG_LEVEL3, KFoundPid, ExtractIDL(*iDataOwners[i])); |
|
1218 } |
|
1219 break; |
|
1220 |
|
1221 case EJavaDerivedType: |
|
1222 { |
|
1223 HBufC* suiteHash = ExtractJavaIDL(*iDataOwners[i]); |
|
1224 _LIT(KJava, "Java ID found: "); |
|
1225 LogWithText(LOG_LEVEL3, KJava, *suiteHash); |
|
1226 delete suiteHash; |
|
1227 suiteHash = NULL; |
|
1228 } |
|
1229 break; |
|
1230 default: |
|
1231 _LIT(KLogErr, "Not supported type"); |
|
1232 Log(LOG_LEVEL3, KLogErr); |
|
1233 break; |
|
1234 } |
|
1235 |
|
1236 TCommonBURSettings settings = iDataOwners[i]->CommonSettings(); |
|
1237 // check if registration file was parsed correctly |
|
1238 if (!(settings & EPassiveBUR)) |
|
1239 { |
|
1240 if (!(settings & EActiveBUR)) |
|
1241 { |
|
1242 if (!(settings & EHasSystemFiles)) |
|
1243 { |
|
1244 delete iDataOwners[i]; |
|
1245 iDataOwners[i] = NULL; |
|
1246 iDataOwners.Remove(i); |
|
1247 i--; |
|
1248 if (iIsPartial) |
|
1249 { |
|
1250 iFailures++; |
|
1251 } |
|
1252 _LIT(KBadReg, "*** Error: Bad Registration file for ID above ^^^"); |
|
1253 Log(LOG_LEVEL3, KBadReg); |
|
1254 } |
|
1255 |
|
1256 }//if |
|
1257 }//if |
|
1258 }// for |
|
1259 } |
|
1260 |
|
1261 void CBURTestStepBase::DoSupplyL(TTransferDataType aDataType) |
|
1262 /** |
|
1263 @internalComponent |
|
1264 @released |
|
1265 */ |
|
1266 { |
|
1267 GenerateSIDTransferTypesL(iTransferTypes, aDataType); |
|
1268 if (iTransferTypes.Count()) |
|
1269 { |
|
1270 // TODO: need to check weather we can supply snapshot without waiting |
|
1271 if (aDataType == EActiveSnapshotData || aDataType == EActiveBaseData || aDataType == EActiveIncrementalData) |
|
1272 { |
|
1273 // used for sids which are ready |
|
1274 RTransferTypeArray readyArray; |
|
1275 CleanupClosePushL(readyArray); |
|
1276 |
|
1277 for (TInt i=0; i < KRetries;) |
|
1278 { |
|
1279 CheckSIDStatusL(iTransferTypes, readyArray); |
|
1280 |
|
1281 if (readyArray.Count()) // dataowners ready |
|
1282 { |
|
1283 // ========= Supply Data ================ |
|
1284 SupplyDataL(readyArray); |
|
1285 } |
|
1286 else if (iTransferTypes.Count()) // data owners not ready |
|
1287 { |
|
1288 User::After(KDelay); |
|
1289 i++; |
|
1290 } |
|
1291 else // finished with all sids |
|
1292 { |
|
1293 break; |
|
1294 } |
|
1295 } // for |
|
1296 if (iTransferTypes.Count()) |
|
1297 { |
|
1298 iFailures++; |
|
1299 _LIT(KLogNoTrans, "***Error: Some Data Owners were Not Ready or Failed to Connect"); |
|
1300 Log(LOG_LEVEL3, KLogNoTrans); |
|
1301 } |
|
1302 readyArray.ResetAndDestroy(); |
|
1303 CleanupStack::PopAndDestroy(&readyArray); |
|
1304 } //if |
|
1305 else |
|
1306 { |
|
1307 SupplyDataL(iTransferTypes); |
|
1308 } |
|
1309 } //if |
|
1310 } |
|
1311 |
|
1312 // CBURActiveObject // |
|
1313 |
|
1314 /** |
|
1315 Standard Symbian OS Constructor |
|
1316 @return pointer to newly allocated CBURActiveObject object |
|
1317 */ |
|
1318 CBURActiveObject* CBURActiveObject::NewL() |
|
1319 { |
|
1320 CBURActiveObject* self = new(ELeave) CBURActiveObject(); |
|
1321 CleanupStack::PushL(self); |
|
1322 self->ConstructL(); |
|
1323 CleanupStack::Pop(self); |
|
1324 return self; |
|
1325 } |
|
1326 |
|
1327 /** |
|
1328 C++ Standard destructor |
|
1329 */ |
|
1330 CBURActiveObject::~CBURActiveObject() |
|
1331 { |
|
1332 Cancel(); |
|
1333 delete iActiveScheduler; |
|
1334 } |
|
1335 |
|
1336 /** |
|
1337 C++ Standard Constructor |
|
1338 */ |
|
1339 CBURActiveObject::CBURActiveObject() |
|
1340 : CActive(EPriorityNormal), iError(KErrNone) |
|
1341 { |
|
1342 } |
|
1343 |
|
1344 /** |
|
1345 Symbian OS 2nd phase constructor |
|
1346 */ |
|
1347 void CBURActiveObject::ConstructL() |
|
1348 { |
|
1349 iActiveScheduler = new (ELeave) CActiveSchedulerWait(); |
|
1350 CActiveScheduler::Add(this); |
|
1351 } |
|
1352 |
|
1353 /** |
|
1354 CActive::DoCancel() implementation |
|
1355 Stops ActiveSchedulerWait if it is Started |
|
1356 */ |
|
1357 void CBURActiveObject::DoCancel() |
|
1358 { |
|
1359 if (iActiveScheduler->IsStarted()) |
|
1360 { |
|
1361 iActiveScheduler->AsyncStop(); |
|
1362 } |
|
1363 } |
|
1364 |
|
1365 /** |
|
1366 Waits for the Status to complete, remembers the iStatus code and calls AsyncStop |
|
1367 */ |
|
1368 void CBURActiveObject::RunL() |
|
1369 { |
|
1370 iError = iStatus.Int(); |
|
1371 iActiveScheduler->AsyncStop(); |
|
1372 } |
|
1373 /** |
|
1374 CActive::RunError() implementation |
|
1375 @param aError error code |
|
1376 @return KErrNone |
|
1377 */ |
|
1378 TInt CBURActiveObject::RunError(TInt aError) |
|
1379 { |
|
1380 iError = aError; |
|
1381 Cancel(); |
|
1382 return KErrNone; |
|
1383 } |
|
1384 |
|
1385 /** |
|
1386 Starts and active object and Scheduler, the call will be complete when RunL is called |
|
1387 */ |
|
1388 void CBURActiveObject::StartL() |
|
1389 { |
|
1390 if (IsActive()) |
|
1391 { |
|
1392 User::Leave(KErrInUse); |
|
1393 } |
|
1394 iStatus = KRequestPending; |
|
1395 SetActive(); |
|
1396 iActiveScheduler->Start(); |
|
1397 } |
|
1398 /** |
|
1399 Returns an error/completing code of the iStatus |
|
1400 */ |
|
1401 TInt CBURActiveObject::Error() |
|
1402 { |
|
1403 return iError; |
|
1404 } |
|
1405 |
|
1406 } // end namespace |
|
1407 |