|
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 // Implementation of CDataOwnerManager |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 #include "sbpackagedatatransfer.h" |
|
22 #include "sbedataowner.h" |
|
23 #include "sbedataownermanager.h" |
|
24 #include "sbebufferhandler.h" |
|
25 #include "sblog.h" |
|
26 #include "abserver.h" |
|
27 |
|
28 #include "sbecompressionandencryption.h" |
|
29 |
|
30 #include <e32svr.h> |
|
31 #include <arc4.h> |
|
32 #include <babackup.h> |
|
33 #include <ezcompressor.h> |
|
34 #include <ezdecompressor.h> |
|
35 #include <swi/sisregistrypackage.h> |
|
36 #include <swi/sisregistryentry.h> |
|
37 #include <swi/swispubsubdefs.h> |
|
38 |
|
39 namespace conn |
|
40 { |
|
41 const TInt KSID = 0x10202D56; |
|
42 _LIT_SECURITY_POLICY_S0(KWritePolicy, KSID); |
|
43 _LIT_SECURITY_POLICY_PASS(KReadPolicy); |
|
44 _LIT_SECURE_ID(KDummyId,0x00000000); |
|
45 |
|
46 CDataOwnerContainer* CDataOwnerContainer::NewL(TSecureId aSecureId, CDataOwnerManager* apDataOwnerManager) |
|
47 /** Symbian OS static constructor |
|
48 */ |
|
49 { |
|
50 CDataOwnerContainer* self = new(ELeave) CDataOwnerContainer(aSecureId); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(apDataOwnerManager); |
|
53 CleanupStack::Pop(self); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 CDataOwnerContainer::CDataOwnerContainer(TSecureId aSecureId) : |
|
59 iSecureId(aSecureId) |
|
60 /** Standard C++ constructor |
|
61 */ |
|
62 { |
|
63 } |
|
64 |
|
65 CDataOwnerContainer::~CDataOwnerContainer() |
|
66 { |
|
67 delete ipDataOwner; |
|
68 } |
|
69 |
|
70 void CDataOwnerContainer::ConstructL(CDataOwnerManager* apDataOwnerManager) |
|
71 /* Symbian second phase constructor |
|
72 */ |
|
73 { |
|
74 ipDataOwner = CDataOwner::NewL(iSecureId, apDataOwnerManager); |
|
75 } |
|
76 |
|
77 TSecureId CDataOwnerContainer::SecureId() const |
|
78 /** Secure Id accessor |
|
79 |
|
80 @return the secure id for the data owner container |
|
81 */ |
|
82 { |
|
83 return iSecureId; |
|
84 } |
|
85 |
|
86 CDataOwner& CDataOwnerContainer::DataOwner() const |
|
87 /** Data owner accessor |
|
88 |
|
89 @return the data owner |
|
90 */ |
|
91 { |
|
92 return (*ipDataOwner); |
|
93 } |
|
94 |
|
95 /** |
|
96 Method will be used for Sort on RPointerArray |
|
97 |
|
98 @param aFirst CDataOwnerContainer& data owner container to compare |
|
99 @param aSecond CDataOwnerContainer& data owner container to compare |
|
100 |
|
101 @see RArray::Sort() |
|
102 */ |
|
103 TInt CDataOwnerContainer::Compare(const CDataOwnerContainer& aFirst, const CDataOwnerContainer& aSecond) |
|
104 { |
|
105 if (aFirst.SecureId() < aSecond.SecureId()) |
|
106 { |
|
107 return -1; |
|
108 } |
|
109 else if (aFirst.SecureId() > aSecond.SecureId()) |
|
110 { |
|
111 return 1; |
|
112 } |
|
113 else |
|
114 { |
|
115 return 0; |
|
116 } |
|
117 } |
|
118 |
|
119 /** |
|
120 Method will be used for Find on RPointerArray |
|
121 |
|
122 @param aFirst CDataOwnerContainer& data owner container to match |
|
123 @param aSecond CDataOwnerContainer& data owner container to match |
|
124 |
|
125 @see RArray::Find() |
|
126 */ |
|
127 TBool CDataOwnerContainer::Match(const CDataOwnerContainer& aFirst, const CDataOwnerContainer& aSecond) |
|
128 { |
|
129 return (aFirst.SecureId() == aSecond.SecureId()); |
|
130 } |
|
131 |
|
132 CDataOwnerManager* CDataOwnerManager::NewLC() |
|
133 /** Symbian OS static constructor |
|
134 */ |
|
135 { |
|
136 CDataOwnerManager* self = new(ELeave) CDataOwnerManager(); |
|
137 CleanupStack::PushL(self); |
|
138 self->ConstructL(); |
|
139 |
|
140 return self; |
|
141 } |
|
142 |
|
143 |
|
144 CDataOwnerManager::CDataOwnerManager() |
|
145 /** |
|
146 Standard C++ |
|
147 */ |
|
148 : ipABServer(NULL), iBufferFileReader(NULL), iDecompressor(NULL), |
|
149 iResetAfterRestore(EFalse), iJavaDOM(NULL), iSIDListForPartial(NULL), |
|
150 iConfig(NULL), iBaBackupSession(NULL) |
|
151 { |
|
152 } |
|
153 |
|
154 void CDataOwnerManager::ConstructL() |
|
155 /** Symbian OS second phase contrutor |
|
156 */ |
|
157 { |
|
158 User::LeaveIfError(iFs.Connect()); |
|
159 TInt err = RProperty::Define(TUid::Uid(KUidSystemCategoryValue), |
|
160 KUidBackupRestoreKey, |
|
161 RProperty::EInt, KReadPolicy, KWritePolicy, 0); |
|
162 if ((err != KErrNone) && (err != KErrAlreadyExists)) |
|
163 { |
|
164 User::Leave(err); |
|
165 } |
|
166 |
|
167 // Load a reference plugin with implementation Uid 0x2000D926 |
|
168 const TUid aImplementationUid = { 0x2000D926 }; |
|
169 iJavaDOM = CJavaManagerInterface::NewL( aImplementationUid ); |
|
170 |
|
171 iDecompressor = CSBEDecompressAndEncrypt::NewL(); |
|
172 iConfig = CSBEConfig::NewL(iFs); |
|
173 TRAP(err, iConfig->ParseL()); |
|
174 if (err != KErrNone) |
|
175 { |
|
176 __LOG1("Error trying to parse sbeconfig.xml : %d", err); |
|
177 __LOG("Using Default Settings !"); |
|
178 iConfig->SetDefault(); |
|
179 } |
|
180 else |
|
181 { |
|
182 __LOG("sbeconfig.xml parsed sucessfully"); |
|
183 } |
|
184 iBaBackupSession = CBaBackupSessionWrapper::NewL(); |
|
185 iParserProxy = CSBEParserProxy::NewL(iFs); |
|
186 } |
|
187 |
|
188 |
|
189 CDataOwnerManager::~CDataOwnerManager() |
|
190 /** C++ Destructor |
|
191 |
|
192 Destructor functions are the inverse of constructor functions. They are called |
|
193 when objects are destroyed (deallocated). |
|
194 |
|
195 The destructor is commonly used to "clean up" when an object is no longer necessary. |
|
196 */ |
|
197 { |
|
198 if(iJavaDOM) |
|
199 { |
|
200 delete iJavaDOM; |
|
201 } |
|
202 |
|
203 delete iParserProxy; |
|
204 delete iBufferFileReader; |
|
205 delete iDecompressor; |
|
206 iDataOwners.ResetAndDestroy(); |
|
207 iDataOwners.Close(); |
|
208 iPackageDataOwners.ResetAndDestroy(); |
|
209 iPackageDataOwners.Close(); |
|
210 iFs.Close(); |
|
211 if (iSIDListForPartial != NULL) |
|
212 { |
|
213 iSIDListForPartial->Close(); |
|
214 delete iSIDListForPartial; |
|
215 } |
|
216 delete iConfig; |
|
217 delete iBaBackupSession; |
|
218 } |
|
219 |
|
220 void CDataOwnerManager::AllSystemFilesRestoredL() |
|
221 /** |
|
222 Handle send from the client informing us that the reg files have now all been supplied and |
|
223 we can parse/start active data owners etc. |
|
224 */ |
|
225 { |
|
226 if(iBURType == EBURRestoreFull || iBURType == EBURRestorePartial) |
|
227 { |
|
228 __LOG("CDataOwnerManager::AllSystemFilesRestored() - called, parse reg files & start active DO's"); |
|
229 // Build the list of dataOwners |
|
230 |
|
231 TInt err; |
|
232 TRAP(err, FindDataOwnersL()); |
|
233 if (err != KErrNone) |
|
234 { |
|
235 __LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while finding data owners: %d", err); |
|
236 } |
|
237 |
|
238 TInt doCount = iDataOwners.Count(); |
|
239 |
|
240 // Loop throught the list |
|
241 for (TInt x = 0; x < doCount; x++) |
|
242 { |
|
243 CDataOwnerContainer* pContainer = iDataOwners[x]; |
|
244 CDataOwner& dataOwner = pContainer->DataOwner(); |
|
245 TRAP_IGNORE(dataOwner.ParseFilesL()); |
|
246 } |
|
247 |
|
248 doCount = iDataOwners.Count(); |
|
249 |
|
250 // update partial state of active data owners |
|
251 TRAP(err, UpdateDataOwnersPartialStateL()); |
|
252 if (err != KErrNone) |
|
253 { |
|
254 __LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while updating state: %d", err); |
|
255 } |
|
256 |
|
257 for (TInt index = 0; index < doCount; index++) |
|
258 { |
|
259 // Start data owning process if necessary for active data owners |
|
260 TRAP(err, iDataOwners[index]->DataOwner().StartProcessIfNecessaryL()); |
|
261 if (err != KErrNone) |
|
262 { |
|
263 __LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while starting process if necessary: %d", err); |
|
264 } |
|
265 |
|
266 // Set up the internal state of the data owners now that all reg files and proxies are back |
|
267 TRAP(err, iDataOwners[index]->DataOwner().BuildDriveStateArrayL()); |
|
268 if (err != KErrNone) |
|
269 { |
|
270 __LOG1("CDataOwnerManager::AllSystemFilesRestored() - Error while building drive array: %d", err); |
|
271 } |
|
272 } |
|
273 |
|
274 if(iJavaDOM) |
|
275 { |
|
276 TRAP_IGNORE(iJavaDOM->AllSystemFilesRestored()); |
|
277 } |
|
278 else |
|
279 { |
|
280 __LOG("CDataOwnerManager::AllSystemFilesRestored() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
281 } |
|
282 |
|
283 // now deal with special case packages |
|
284 CDesCArray* files = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity); |
|
285 CleanupStack::PushL(files); |
|
286 TRAP_IGNORE(FindRegistrationFilesL(KImportDir, *files)); |
|
287 const TInt count = files->Count(); |
|
288 for (TInt x = 0; x < count; x++) |
|
289 { |
|
290 // Strip the SID |
|
291 TSecureId sid; |
|
292 const TDesC& fileName = (*files)[x]; |
|
293 TRAPD(err, StripSecureIdL(fileName, sid)); |
|
294 |
|
295 if (err == KErrNone) // If there was an error then ignore it as it is probally not a dir |
|
296 { |
|
297 CPackageDataTransfer* pDataTransfer = NULL; |
|
298 TRAPD(err, pDataTransfer = FindPackageDataContainerL(sid)); |
|
299 if (err == KErrNone) |
|
300 { |
|
301 TRAP(err, pDataTransfer->SetRegistrationFileL(fileName)); |
|
302 if (err == KErrNone) |
|
303 { |
|
304 TRAP(err, pDataTransfer->ParseL()); |
|
305 } |
|
306 __LOG2("CDataOwnerManager::AllSystemFilesRestored() - found reg file: %S for Package: 0x%08x", &fileName, sid.iId); |
|
307 } |
|
308 if (err == KErrNoMemory) |
|
309 { |
|
310 User::Leave(KErrNoMemory); |
|
311 } |
|
312 } |
|
313 } // for |
|
314 |
|
315 CleanupStack::PopAndDestroy(files); |
|
316 |
|
317 } // end if |
|
318 else |
|
319 { |
|
320 __LOG("CDataOwnerManager::AllSystemFilesRestored() - *Error: called when device is not in Restore mode !"); |
|
321 } |
|
322 |
|
323 } |
|
324 |
|
325 |
|
326 void CDataOwnerManager::SetBURModeL(const TDriveList& aDriveList, TBURPartType aBURType, |
|
327 TBackupIncType aBackupIncType) |
|
328 /** Sets the publish & subscribe backup flag |
|
329 |
|
330 @param aDriveList a list of drives involved in the backup |
|
331 @param aBURType the type |
|
332 @param aBackupIncType the incremental type |
|
333 @leave KErrInUse a Software install is in progress, plus system wide errors |
|
334 */ |
|
335 { |
|
336 __LOG2("CDataOwnerManager::SetBURModeL() - Request new BURType (0x%08x), IncType (0x%08x)", aBURType, aBackupIncType); |
|
337 __LOG2("CDataOwnerManager::SetBURModeL() - Previous BURType (0x%08x), IncType (0x%08x)", iBURType, iIncType); |
|
338 // Ensure that the device can't transition directly from backup to restore mode. It must |
|
339 // go through a normal state first. Allow the state to be set to the same. |
|
340 switch(aBURType) |
|
341 { |
|
342 case EBURNormal: |
|
343 // allow to set Normal mode in any case. no need to do anything if previous mode was Normal |
|
344 if (iBURType == EBURNormal) |
|
345 { |
|
346 return; |
|
347 } |
|
348 break; |
|
349 case EBURUnset: |
|
350 // don't do anything if previous modes were Normal or Unset |
|
351 if (iBURType == EBURNormal || iBURType == EBURUnset) |
|
352 { |
|
353 return; |
|
354 } |
|
355 break; |
|
356 case EBURBackupFull: |
|
357 case EBURBackupPartial: |
|
358 case EBURRestoreFull: |
|
359 case EBURRestorePartial: |
|
360 // don't allow mode change unless , device was put into normal mode before |
|
361 if (iBURType != EBURNormal && iBURType != EBURUnset) |
|
362 { |
|
363 __LOG2("CDataOwnerManager::SetBURModeL() - *Error: BUR type has not transitioned between modes correctly, %d became %d", iBURType, aBURType); |
|
364 User::Leave(KErrCorrupt); |
|
365 } |
|
366 break; |
|
367 } // switch |
|
368 |
|
369 TBURPartType previousBURType = iBURType; |
|
370 |
|
371 // Need to reset the list of data owners, and old style babackup |
|
372 if ((aBURType == EBURNormal) || (aBURType == EBURUnset)) |
|
373 { |
|
374 __LOG1("CDataOwnerManager::SetBURModeL() - Going Normal/Unset/NoBackup (%d)", aBURType); |
|
375 // If we've transitioned from a Restore to a Normal mode, we need to send a RestoreComplete |
|
376 if (previousBURType == EBURRestoreFull || previousBURType == EBURRestorePartial) |
|
377 { |
|
378 __LOG("CDataOwnerManager::SetBURModeL() - Calling RestoreCompleteL on all active data owners"); |
|
379 TInt restoreCompleteCount = iDataOwners.Count(); |
|
380 |
|
381 for (TInt index = 0; index < restoreCompleteCount; index++) |
|
382 { |
|
383 // Start data owning process if necessary for active data owners |
|
384 TRAP_IGNORE(iDataOwners[index]->DataOwner().RestoreCompleteL()); |
|
385 } |
|
386 |
|
387 // Do we need to reset the device |
|
388 if (iResetAfterRestore) |
|
389 { |
|
390 // |
|
391 // Currently there is no Symbian wide way to reset a device. The below call |
|
392 // was intended to perform this function but has not been implemented. |
|
393 // |
|
394 // When/If a Symbian way to reset a device comes into existance, or a licencee |
|
395 // has specific reset calls then this is the location to add such code. |
|
396 // |
|
397 //UserSvr::ResetMachine(EStartupWarmReset); |
|
398 } // if |
|
399 } |
|
400 |
|
401 iResetAfterRestore = EFalse; |
|
402 iDataOwners.ResetAndDestroy(); |
|
403 iPackageDataOwners.ResetAndDestroy(); |
|
404 __LOG("CDataOwnerManager::SetBURModeL() - Restart All Non-System Applications"); |
|
405 iBaBackupSession->NotifyBackupOperationL(TBackupOperationAttributes(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd)); |
|
406 iBaBackupSession->RestartAll(); |
|
407 } |
|
408 else |
|
409 { |
|
410 // Check that SWInstall are not doing anything. |
|
411 TInt value; |
|
412 TInt regErr = RProperty::Get(KUidSystemCategory, Swi::KUidSoftwareInstallKey, value); |
|
413 if (regErr == KErrNone && value != Swi::ESwisNone) |
|
414 { |
|
415 __LOG("CDataOwnerManager::SetBURModeL() - *Error: Leave software Install in progress."); |
|
416 User::Leave(KErrInUse); |
|
417 } // if |
|
418 else if (regErr != KErrNotFound && regErr != KErrNone) |
|
419 { |
|
420 __LOG("CDataOwnerManager::SetBURModeL() - *Error: Leave could not get KUidSoftwareInsallKey"); |
|
421 User::Leave(regErr); |
|
422 } // else |
|
423 |
|
424 // Clobber files that are locked open |
|
425 TRequestStatus status; |
|
426 __LOG("CDataOwnerManager::SetBURModeL() - Calling CloseAll()"); |
|
427 if(aBURType == EBURBackupFull || aBURType == EBURBackupPartial) |
|
428 { |
|
429 TBackupOperationAttributes atts(MBackupObserver::EReleaseLockReadOnly, MBackupOperationObserver::EStart); |
|
430 iBaBackupSession->NotifyBackupOperationL(atts); |
|
431 iBaBackupSession->CloseAll(MBackupObserver::EReleaseLockReadOnly, status); |
|
432 } |
|
433 else |
|
434 { |
|
435 TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); |
|
436 iBaBackupSession->NotifyBackupOperationL(atts); |
|
437 iBaBackupSession->CloseAll(MBackupObserver::EReleaseLockNoAccess, status); |
|
438 } |
|
439 User::WaitForRequest(status); |
|
440 |
|
441 __LOG("CDataOwnerManager::SetBURModeL() - CloseAll() returned"); |
|
442 |
|
443 // update partial state for active data owners |
|
444 if (aBURType == EBURBackupPartial) |
|
445 { |
|
446 UpdateDataOwnersPartialStateL(); |
|
447 } |
|
448 |
|
449 if (aBURType == EBURBackupPartial || aBURType == EBURBackupFull) |
|
450 { |
|
451 TInt doCount = iDataOwners.Count(); |
|
452 for (TInt index = 0; index < doCount; index++) |
|
453 { |
|
454 // Start data owning process if necessary for active data owners |
|
455 TRAPD(err, iDataOwners[index]->DataOwner().StartProcessIfNecessaryL()); |
|
456 if (err != KErrNone) |
|
457 { |
|
458 __LOG2("CDataOwnerManager::SetBURModeL() - Data owner (or proxy) with SID 0x%08x errored (%d) whilst starting", iDataOwners[index]->SecureId().iId, err); |
|
459 } |
|
460 } |
|
461 } |
|
462 } |
|
463 |
|
464 TInt setError = RProperty::Set(TUid::Uid(KUidSystemCategoryValue), KUidBackupRestoreKey, aBURType | aBackupIncType); |
|
465 __LOG3("CDataOwnerManager::SetBURModeL() - Setting P&S flag to BURType (0x%08x), IncType (0x%08x), err: ", aBURType, aBackupIncType, setError); |
|
466 User::LeaveIfError(setError); |
|
467 |
|
468 // This configurable delay allows extra time to close all non-system apps. |
|
469 TUint closeDelay = iConfig->AppCloseDelay(); |
|
470 if((closeDelay>0) && (aBURType == EBURBackupFull || aBURType == EBURBackupPartial || |
|
471 aBURType == EBURRestoreFull || aBURType == EBURRestorePartial)) |
|
472 { |
|
473 User::After(closeDelay); |
|
474 } |
|
475 |
|
476 iDriveList = aDriveList; |
|
477 iBURType = aBURType; |
|
478 iIncType = aBackupIncType; |
|
479 |
|
480 //When we set back to normal mode, invalidate all current available |
|
481 //CABSessions,since they could not be used in sequent backup/restore event |
|
482 if (aBURType == EBURUnset || aBURType == EBURNormal) |
|
483 { |
|
484 __LOG1("Invalidate all ABSessions after set Setting P&S flag to 0x%08x", aBURType); |
|
485 ipABServer->InvalidateABSessions(); |
|
486 } |
|
487 } |
|
488 |
|
489 |
|
490 void CDataOwnerManager::GetDataOwnersL(RPointerArray<CDataOwnerInfo>& aDataOwners) |
|
491 /** Gets the Information about data owners |
|
492 |
|
493 @param aDataOwners on return the list of data owners |
|
494 */ |
|
495 { |
|
496 if (iBURType != EBURNormal && iBURType != EBURUnset) |
|
497 { |
|
498 __LOG("CDataOwnerManager::GetDataOwnersL() - *Error: ListOfDataOnwers called when device isn't in Normal/Unset mode"); |
|
499 User::Leave(KErrAccessDenied); |
|
500 } |
|
501 |
|
502 // Build the list of dataOwners |
|
503 FindDataOwnersL(); |
|
504 Swi::RSisRegistrySession registrySession; |
|
505 User::LeaveIfError(registrySession.Connect()); |
|
506 CleanupClosePushL(registrySession); |
|
507 |
|
508 TInt err = KErrNone; |
|
509 TUint count = iDataOwners.Count(); |
|
510 // Loop throught the list |
|
511 while(count--) |
|
512 { |
|
513 CDataOwnerContainer* pContainer = iDataOwners[count]; |
|
514 CDataOwner& dataOwner = pContainer->DataOwner(); |
|
515 TSecureId secureId = pContainer->SecureId(); |
|
516 |
|
517 // forwards declarations |
|
518 TDriveList driveList; |
|
519 driveList.SetMax(); |
|
520 |
|
521 TCommonBURSettings commonSettings = ENoOptions; |
|
522 |
|
523 // parse registration files |
|
524 TRAP(err, dataOwner.ParseFilesL()); |
|
525 if (err != KErrNone) |
|
526 { |
|
527 __LOG2("CDataOwnerManager::GetDataOwnersL() - ParseFilesL() - Error in sid: 0x%08x (%d)", secureId.iId, err); |
|
528 } // if |
|
529 else |
|
530 { |
|
531 // Reset the state for these data owners |
|
532 TRAP(err, dataOwner.BuildDriveStateArrayL()); |
|
533 if (err != KErrNone) |
|
534 { |
|
535 __LOG2("CDataOwnerManager::GetDataOwnersL() - BuildDriveStateArrayL() - Error in sid: 0x%08x (%d)", secureId.iId, err); |
|
536 }//if |
|
537 else |
|
538 { |
|
539 // Get drive list (this is needed to update drive list for packages) |
|
540 TRAP(err, dataOwner.GetDriveListL(driveList)); |
|
541 if (err != KErrNone) |
|
542 { |
|
543 __LOG2("CDataOwnerManager::GetDataOwnersL() - GetDriveListL() - Error in sid: 0x%08x (%d)", secureId.iId, err); |
|
544 }//if |
|
545 else |
|
546 { |
|
547 TRAP(err, commonSettings = dataOwner.CommonSettingsL()); |
|
548 if (err != KErrNone) |
|
549 { |
|
550 __LOG2("CDataOwnerManager::GetDataOwnersL() - CommonSettingsL() - Error in sid: 0x%08x (%d)", secureId.iId, err); |
|
551 }//if |
|
552 }//else |
|
553 } |
|
554 }//else |
|
555 |
|
556 CSBGenericDataType* pId = NULL; |
|
557 if (err == KErrNone) |
|
558 { |
|
559 // check if the sid is part of the package |
|
560 if ((commonSettings & EHasSystemFiles) == EHasSystemFiles) |
|
561 { |
|
562 Swi::CSisRegistryPackage* pRegistryPackage = NULL; |
|
563 TRAPD(error, pRegistryPackage = registrySession.SidToPackageL(secureId)); |
|
564 if ((error == KErrNone)) |
|
565 { |
|
566 TUid packageUid = pRegistryPackage->Uid(); |
|
567 __LOG2("CDataOwnerManager::GetDataOwnersL() - Found package for secure id 0x%08x, package id 0x%08x", secureId.iId, packageUid); |
|
568 |
|
569 CleanupStack::PushL(pRegistryPackage); |
|
570 pId = CSBPackageId::NewL(packageUid, secureId, pRegistryPackage->Name()); |
|
571 CleanupStack::PopAndDestroy(pRegistryPackage); |
|
572 CleanupStack::PushL(pId); |
|
573 |
|
574 // finds or adds package to the internal array |
|
575 CPackageDataTransfer* pak = FindPackageDataContainerL(packageUid); |
|
576 //renews the drive list |
|
577 TRAP(err, pak->GetDriveListL(driveList)); |
|
578 if (err != KErrNone) |
|
579 {//Non-removable, ignore this data owner |
|
580 iDataOwners.Remove(count); |
|
581 CleanupStack::PopAndDestroy(pId); |
|
582 continue; |
|
583 } |
|
584 } // if |
|
585 else |
|
586 { |
|
587 __LOG2("CDataOwnerManager::GetDataOwnersL() - Error(%d) retrieving package data for sid 0x%08x", error, secureId.iId); |
|
588 } // else |
|
589 } // if |
|
590 } // if |
|
591 |
|
592 if (pId == NULL) // not a package or error happend |
|
593 { |
|
594 pId = CSBSecureId::NewL(secureId); |
|
595 CleanupStack::PushL(pId); |
|
596 } |
|
597 |
|
598 // |
|
599 // dont create it if not required |
|
600 |
|
601 CDataOwnerInfo* pDataOwnerInfo = NULL; |
|
602 if (err != KErrNone) |
|
603 { |
|
604 // There has been an error create a blank data owner so the PC will now |
|
605 pDataOwnerInfo = CDataOwnerInfo::NewL(pId, ENoOptions, ENoPassiveOptions, |
|
606 ENoActiveOptions, driveList); |
|
607 } |
|
608 else |
|
609 { |
|
610 if (commonSettings & EPassiveBUR || commonSettings & EHasSystemFiles || dataOwner.ActiveInformation().iActiveType != EProxyImpOnly || dataOwner.PassiveSettingsL() & EHasPublicFiles) |
|
611 { |
|
612 pDataOwnerInfo = CDataOwnerInfo::NewL(pId, commonSettings, dataOwner.PassiveSettingsL(), |
|
613 dataOwner.ActiveSettingsL(), driveList); |
|
614 } |
|
615 } // else |
|
616 |
|
617 if (pDataOwnerInfo != NULL) |
|
618 { |
|
619 // ownership was trasferred to pDataOwnerInfo |
|
620 CleanupStack::Pop(pId); |
|
621 CleanupStack::PushL(pDataOwnerInfo); |
|
622 aDataOwners.AppendL(pDataOwnerInfo); |
|
623 CleanupStack::Pop(pDataOwnerInfo); |
|
624 } |
|
625 else |
|
626 { |
|
627 CleanupStack::PopAndDestroy(pId); |
|
628 } |
|
629 } // for |
|
630 |
|
631 // find special case packages which don't have private directories. |
|
632 TRAP_IGNORE(FindImportPackagesL(registrySession, aDataOwners)); |
|
633 |
|
634 CleanupStack::PopAndDestroy(®istrySession); |
|
635 |
|
636 if(iJavaDOM) |
|
637 { |
|
638 iJavaDOM->GetDataOwnersL(aDataOwners); |
|
639 } |
|
640 else |
|
641 { |
|
642 __LOG("CDataOwnerManager::GetDataOwnersL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
643 } |
|
644 } |
|
645 |
|
646 CDataOwner& CDataOwnerManager::DataOwnerL(TSecureId aSID) |
|
647 /** |
|
648 Called by the ABServer when creating a session in order for the session to query the DataOwner |
|
649 |
|
650 @param aSID The SID of the active data owner |
|
651 */ |
|
652 { |
|
653 CDataOwnerContainer* pDOContainer = NULL; |
|
654 |
|
655 pDOContainer = FindL(aSID); |
|
656 |
|
657 if (!pDOContainer) |
|
658 { |
|
659 User::Leave(KErrNotFound); |
|
660 } |
|
661 |
|
662 return pDOContainer->DataOwner(); |
|
663 } |
|
664 |
|
665 void CDataOwnerManager::GetExpectedDataSizeL(CSBGenericTransferType* apGenericTransferType, TUint& aSize) |
|
666 /** Gets the expected data size of a backup for the given information |
|
667 |
|
668 @param apGenericTransferType the generic transfer type |
|
669 @param aSize on return the expected data size of the backup |
|
670 @post deletes the apGenericTransferType |
|
671 @leave KErrNotSupported unsupported transfer type |
|
672 @leave KErrNotFound object relating to apGenericTransferType not found |
|
673 */ |
|
674 { |
|
675 if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull) |
|
676 { |
|
677 __LOG("CDataOwnerManager::GetExpectedDataSizeL() - *Error: GetExpectedDataSizeL called when device is not in Backup mode !"); |
|
678 User::Leave(KErrAccessDenied); |
|
679 } |
|
680 |
|
681 switch (apGenericTransferType->DerivedTypeL()) |
|
682 { |
|
683 case ESIDTransferDerivedType: |
|
684 { |
|
685 __LOG("CDataOwnerManager::GetExpectedDataSizeL() - ESIDTransferDerivedType"); |
|
686 CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apGenericTransferType); |
|
687 CleanupStack::PushL(pSIDTransferType); |
|
688 |
|
689 DataOwnerL(pSIDTransferType->SecureIdL()).GetExpectedDataSizeL(pSIDTransferType->DataTypeL(), pSIDTransferType->DriveNumberL(), aSize); |
|
690 CleanupStack::PopAndDestroy(pSIDTransferType); |
|
691 break; |
|
692 }; |
|
693 case EPackageTransferDerivedType: |
|
694 { |
|
695 __LOG("CDataOwnerManager::GetExpectedDataSizeL() - EPackageTransferDerivedType"); |
|
696 |
|
697 // This code should be changed. Ideally, the GetExpectedDataSizeL method should be virtual, rendering |
|
698 // this switch statement unnecessary. When java support is added this will become even more important. |
|
699 // |
|
700 // For the moment, to avoid re-structuring the data owner class, |
|
701 // we are using completely separate classes to handle packages and non packages |
|
702 |
|
703 CSBPackageTransferType* pPackageTransferType = CSBPackageTransferType::NewL(apGenericTransferType); |
|
704 CleanupStack::PushL(pPackageTransferType); |
|
705 // |
|
706 const TUid packageId = pPackageTransferType->PackageIdL(); |
|
707 const TPackageDataType dataType = pPackageTransferType->DataTypeL(); |
|
708 const TDriveNumber driveNumber = pPackageTransferType->DriveNumberL(); |
|
709 // |
|
710 __LOG3("CDataOwnerManager::GetExpectedDataSizeL() - package id: 0x%08x, dataType: %d, drive: %c ", packageId.iUid, dataType, driveNumber + 'A'); |
|
711 CPackageDataTransfer* pDataTransfer = FindPackageDataContainerL(pPackageTransferType->PackageIdL()); |
|
712 pDataTransfer->GetExpectedDataSizeL(dataType, driveNumber, aSize); |
|
713 CleanupStack::PopAndDestroy(pPackageTransferType); |
|
714 break; |
|
715 } |
|
716 |
|
717 case EJavaTransferDerivedType: |
|
718 { |
|
719 __LOG("CDataOwnerManager::GetExpectedDataSizeL() - EJavaTransferDerivedType"); |
|
720 |
|
721 // Call the Java DOM to calculate and return the expected size of the data specified in |
|
722 // apGenericTransferType |
|
723 if(iJavaDOM) |
|
724 { |
|
725 iJavaDOM->GetExpectedDataSizeL(apGenericTransferType, aSize); |
|
726 } |
|
727 else |
|
728 { |
|
729 __LOG("CDataOwnerManager::GetExpectedDataSizeL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
730 } |
|
731 |
|
732 break; |
|
733 } |
|
734 |
|
735 default: |
|
736 { |
|
737 __LOG("CDataOwnerManager::GetExpectedDataSizeL() - ERROR - unsupported transfer type"); |
|
738 User::Leave(KErrNotSupported); |
|
739 } |
|
740 } // switch |
|
741 __LOG1("CDataOwnerManager::GetExpectedDataSizeL() - END - size is: %d", aSize); |
|
742 } |
|
743 |
|
744 |
|
745 void CDataOwnerManager::GetPublicFileListL(CSBGenericDataType* aGenericDataType, |
|
746 TDriveNumber aDriveNumber, |
|
747 RFileArray& aFiles) |
|
748 /** Retreives the public file list for the given secure id |
|
749 |
|
750 @param aSID the Secure Id of the data owner you are requesting information for |
|
751 @param aDriveNumber the drive number to obtain the public files for |
|
752 @param aFiles on return the list of public files |
|
753 */ |
|
754 { |
|
755 if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull) |
|
756 { |
|
757 __LOG("CDataOwnerManager::GetPublicFileListL() - *Error: GetPublicFileListL called when device is not in Backup mode !"); |
|
758 User::Leave(KErrAccessDenied); |
|
759 } |
|
760 |
|
761 if (!(iDriveList[aDriveNumber])) |
|
762 { |
|
763 __LOG("CDataOwnerManager::GetPublicFileListL() - The drive in the argument is not in the list of the drives for backup/restore"); |
|
764 User::Leave(KErrArgument); |
|
765 } |
|
766 |
|
767 switch (aGenericDataType->DerivedTypeL()) |
|
768 { |
|
769 case EPackageDerivedType: |
|
770 { |
|
771 CSBPackageId* pUID = CSBPackageId::NewL(aGenericDataType); |
|
772 CleanupStack::PushL(pUID); |
|
773 |
|
774 FindPackageDataContainerL(pUID->PackageIdL())->GetPublicFileListL(aDriveNumber, aFiles); |
|
775 CleanupStack::PopAndDestroy(pUID); |
|
776 break; |
|
777 } |
|
778 case ESIDDerivedType: |
|
779 { |
|
780 CSBSecureId* pSID = CSBSecureId::NewL(aGenericDataType); |
|
781 CleanupStack::PushL(pSID); |
|
782 |
|
783 DataOwnerL(pSID->SecureIdL()).GetPublicFileListL(aDriveNumber, aFiles); |
|
784 CleanupStack::PopAndDestroy(pSID); |
|
785 break; |
|
786 } |
|
787 |
|
788 case EJavaDerivedType: |
|
789 { |
|
790 if(iJavaDOM) |
|
791 { |
|
792 iJavaDOM->GetPublicFileListL(aGenericDataType, aDriveNumber, aFiles); |
|
793 } |
|
794 else |
|
795 { |
|
796 __LOG("CDataOwnerManager::GetPublicFileListL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
797 } |
|
798 break; |
|
799 } |
|
800 |
|
801 default: |
|
802 { |
|
803 User::Leave(KErrNotSupported); |
|
804 } |
|
805 } |
|
806 } |
|
807 |
|
808 |
|
809 void CDataOwnerManager::GetRawPublicFileListL(CSBGenericDataType* aGenericDataType, TDriveNumber aDriveNumber, |
|
810 RRestoreFileFilterArray& aFileFilter) |
|
811 /** Retrieves the raw list as described in the XML files |
|
812 |
|
813 @param aSID the secure id |
|
814 @param aDriveNumber the drive number |
|
815 @param aFileFilter on return an array of TRestoreFileFilter |
|
816 */ |
|
817 { |
|
818 if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull) |
|
819 { |
|
820 __LOG("CDataOwnerManager::GetRawPublicFileListL() - *Error: GetRawPublicFileListL called when device is not in Backup mode !"); |
|
821 User::Leave(KErrAccessDenied); |
|
822 } |
|
823 |
|
824 if (!(iDriveList[aDriveNumber])) |
|
825 { |
|
826 __LOG("CDataOwnerManager::GetRawPublicFileListL() - The drive in the argument is not in the list of the drives for backup/restore"); |
|
827 User::Leave(KErrArgument); |
|
828 } |
|
829 |
|
830 switch (aGenericDataType->DerivedTypeL()) |
|
831 { |
|
832 case EPackageDerivedType: |
|
833 { |
|
834 CSBPackageId* pUID = CSBPackageId::NewL(aGenericDataType); |
|
835 CleanupStack::PushL(pUID); |
|
836 |
|
837 FindPackageDataContainerL(pUID->PackageIdL())->GetRawPublicFileListL(aDriveNumber, aFileFilter); |
|
838 CleanupStack::PopAndDestroy(pUID); |
|
839 break; |
|
840 } |
|
841 case ESIDDerivedType: |
|
842 { |
|
843 CSBSecureId* pSID = CSBSecureId::NewL(aGenericDataType); |
|
844 CleanupStack::PushL(pSID); |
|
845 |
|
846 DataOwnerL(pSID->SecureIdL()).GetRawPublicFileListL(aDriveNumber, aFileFilter); |
|
847 |
|
848 CleanupStack::PopAndDestroy(pSID); |
|
849 break; |
|
850 } |
|
851 |
|
852 case EJavaDerivedType: |
|
853 { |
|
854 if(iJavaDOM) |
|
855 { |
|
856 iJavaDOM->GetRawPublicFileListL(aGenericDataType, aDriveNumber, aFileFilter); |
|
857 } |
|
858 else |
|
859 { |
|
860 __LOG("CDataOwnerManager::GetRawPublicFileListL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
861 } |
|
862 break; |
|
863 } |
|
864 |
|
865 default: |
|
866 { |
|
867 User::Leave(KErrNotSupported); |
|
868 } |
|
869 } |
|
870 } |
|
871 |
|
872 |
|
873 void CDataOwnerManager::GetXMLPublicFileListL(TSecureId /*aSID*/, TDriveNumber /*aDriveNumber*/, |
|
874 HBufC*& /*aBuffer*/) |
|
875 /** Gets the XML public file list |
|
876 |
|
877 @param aSID the secure id |
|
878 @param aDriveNumber the drive number |
|
879 @param aBuffer the buffer to write the data too |
|
880 |
|
881 */ |
|
882 { |
|
883 if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull) |
|
884 { |
|
885 __LOG("CDataOwnerManager::GetXMLPublicFileListL() - *Error: GetXMLPublicFileListL called when device is not in Backup mode !"); |
|
886 User::Leave(KErrAccessDenied); |
|
887 } |
|
888 else |
|
889 { |
|
890 //will need to check if the drive exists in our list |
|
891 __LOG("CDataOwnerManager::GetXMLPublicFileListL() - *Error: GetXMLPublicFileListL Not Yet Implemented"); |
|
892 User::Leave(KErrNotSupported); |
|
893 } |
|
894 } |
|
895 |
|
896 void CDataOwnerManager::SetSIDListForPartialBURL(TDesC8& aFlatArrayPtr) |
|
897 /** |
|
898 Sets the list of Active SID's participating in a backup or restore |
|
899 |
|
900 @param aFlatArrayPtr Flat Array Pointer |
|
901 */ |
|
902 { |
|
903 if (iBURType != EBURNormal && iBURType != EBURUnset) |
|
904 { |
|
905 __LOG("CDataOwnerManager::SetSIDListForPartialBURL() - *Error: called when device isn't in Normal/Unset mode"); |
|
906 User::Leave(KErrAccessDenied); |
|
907 } |
|
908 |
|
909 if (iSIDListForPartial != NULL) |
|
910 { |
|
911 iSIDListForPartial->Close(); |
|
912 delete iSIDListForPartial; |
|
913 iSIDListForPartial = NULL; |
|
914 } |
|
915 |
|
916 iSIDListForPartial = RSIDArray::InternaliseL(aFlatArrayPtr); |
|
917 } |
|
918 |
|
919 void CDataOwnerManager::UpdateDataOwnersPartialStateL() |
|
920 /** |
|
921 Specifies the list of SID's that are to be backed up in a partial backup |
|
922 |
|
923 */ |
|
924 { |
|
925 if (iSIDListForPartial != NULL) |
|
926 { |
|
927 TUint count = iSIDListForPartial->Count(); |
|
928 |
|
929 while(count--) |
|
930 { |
|
931 // Find the data owner responsible for this SID and set it's partial backup flag to ETrue |
|
932 DataOwnerL((*iSIDListForPartial)[count]).SetBackedUpAsPartial(ETrue); |
|
933 } // for |
|
934 } // if |
|
935 } |
|
936 |
|
937 void CDataOwnerManager::SIDStatusL(RSIDStatusArray& aSIDStatus) |
|
938 /** |
|
939 Returns the ready statuses of selected Data Owner's |
|
940 |
|
941 @param aSIDStatus Array of SID's and their associated statuses. The statuses will be populated upon return |
|
942 */ |
|
943 { |
|
944 if (iBURType == EBURNormal || iBURType == EBURUnset) |
|
945 { |
|
946 __LOG("CDataOwnerManager::SIDStatusL() - *Error: called when device is in Normal/Unset mode"); |
|
947 User::Leave(KErrAccessDenied); |
|
948 } |
|
949 |
|
950 TUint count = aSIDStatus.Count(); |
|
951 CDataOwnerContainer* pDOContainer = NULL; |
|
952 |
|
953 while(count--) |
|
954 { |
|
955 pDOContainer = FindL(aSIDStatus[count].iSID); |
|
956 if (!pDOContainer) |
|
957 { |
|
958 aSIDStatus[count].iStatus = EDataOwnerNotFound; |
|
959 } |
|
960 else |
|
961 { |
|
962 // Assign the status of the data owner to the array element |
|
963 aSIDStatus[count].iStatus = pDOContainer->DataOwner().ReadyState(); |
|
964 } |
|
965 } |
|
966 } |
|
967 |
|
968 void CDataOwnerManager::AllSnapshotsSuppliedL() |
|
969 /** |
|
970 All the snapshots have been supplied |
|
971 */ |
|
972 { |
|
973 __LOG("CDataOwnerManager::AllSnapshotsSuppliedL() - Begin"); |
|
974 if (iBURType == EBURBackupPartial || iBURType == EBURBackupFull) |
|
975 { |
|
976 TUint count = iDataOwners.Count(); |
|
977 while(count--) |
|
978 { |
|
979 CDataOwner* dataOwner = &iDataOwners[count]->DataOwner(); |
|
980 if (dataOwner->PartialAffectsMe() && dataOwner->ActiveInformation().iActiveDataOwner && (dataOwner->ActiveInformation().iActiveType != EProxyImpOnly)) |
|
981 { |
|
982 TSecureId id = dataOwner->SecureId(); |
|
983 const TUint KActiveStateMaxRetries = 4; |
|
984 const TUint KActiveStateDelay = 500000; |
|
985 TUint retries = 0; |
|
986 do |
|
987 { |
|
988 TRAPD(err, ipABServer->AllSnapshotsSuppliedL(id)); |
|
989 if (err == KErrNotFound) |
|
990 { |
|
991 retries++; |
|
992 User::After(KActiveStateDelay); |
|
993 } |
|
994 else |
|
995 { |
|
996 break; |
|
997 } |
|
998 } while (retries < KActiveStateMaxRetries); |
|
999 } // if |
|
1000 } // while |
|
1001 } //if |
|
1002 else |
|
1003 { |
|
1004 __LOG("CDataOwnerManager::AllSnapshotsSuppliedL() - *Error: can only be called in Backup mode"); |
|
1005 User::Leave(KErrAccessDenied); |
|
1006 } // else |
|
1007 __LOG("CDataOwnerManager::AllSnapshotsSuppliedL() - End"); |
|
1008 } |
|
1009 |
|
1010 void CDataOwnerManager::GetNextPublicFileL(CSBGenericDataType* aGenericDataType, |
|
1011 TBool aReset, |
|
1012 TDriveNumber aDriveNumber, |
|
1013 TEntry& aEntry) |
|
1014 /** Retreives the next public file associated with the given secure id |
|
1015 |
|
1016 @param aGenericDataType the generic data type |
|
1017 @param aReset set true to start reading from the beginning of the list |
|
1018 @param aDriveNumber the drive to retrieve the public files for |
|
1019 @param aEntry on return the next entry in the list, an empty entry indicates the end of the list has been reached |
|
1020 */ |
|
1021 { |
|
1022 __LOG("CDataOwnerManager::GetNextPublicFileL() - Begin"); |
|
1023 if (iBURType != EBURBackupPartial && iBURType != EBURBackupFull) |
|
1024 { |
|
1025 __LOG("CDataOwnerManager::GetNextPublicFileL() - *Error: GetPublicFileListL called when device is not in Backup mode !"); |
|
1026 User::Leave(KErrAccessDenied); |
|
1027 } |
|
1028 |
|
1029 if (!(iDriveList[aDriveNumber])) |
|
1030 { |
|
1031 __LOG("CDataOwnerManager::GetNextPublicFileL() - The drive in the argument is not in the list of the drives for backup/restore"); |
|
1032 User::Leave(KErrArgument); |
|
1033 } |
|
1034 |
|
1035 if (aGenericDataType->DerivedTypeL() == ESIDDerivedType) |
|
1036 { |
|
1037 CSBSecureId* pSID = CSBSecureId::NewL(aGenericDataType); |
|
1038 CleanupStack::PushL(pSID); |
|
1039 |
|
1040 DataOwnerL(pSID->SecureIdL()).GetNextPublicFileL(aReset, aDriveNumber, aEntry); |
|
1041 CleanupStack::PopAndDestroy(pSID); |
|
1042 } |
|
1043 else |
|
1044 { |
|
1045 User::Leave(KErrNotSupported); |
|
1046 } |
|
1047 __LOG("CDataOwnerManager::GetNextPublicFileL() - End"); |
|
1048 } |
|
1049 |
|
1050 |
|
1051 void CDataOwnerManager::SupplyDataL(CSBGenericTransferType* apGenericTransferType, TDesC8& aBuffer, |
|
1052 TBool aLastSection) |
|
1053 /** Supply data |
|
1054 |
|
1055 @param apGenericTransferType the generic transfertype. NOTE: This function will delete this. |
|
1056 @param aBuffer the buffer to supply data from. |
|
1057 @param aLastSection is this the last section. |
|
1058 @leave KErrNotSupported Unknown transfer type |
|
1059 @leave KErrNotFound Unknown object |
|
1060 */ |
|
1061 { |
|
1062 __LOG1("CDataOwnerManager::SupplyDataL() - START - about to decompress %d bytes of data", aBuffer.Length()); |
|
1063 |
|
1064 if (iBURType == EBURNormal || iBURType == EBURUnset) |
|
1065 { |
|
1066 __LOG("CDataOwnerManager::SupplyDataL() - *Error: called not when device in Normal/Unset mode"); |
|
1067 User::Leave(KErrAccessDenied); |
|
1068 } |
|
1069 |
|
1070 // The buffer that we are given is compressed. We need to uncompress this into |
|
1071 // 64K chunks and then pass through the code |
|
1072 iDecompressor->SetGenericTransferTypeL(apGenericTransferType); |
|
1073 iDecompressor->SetBuffer(aBuffer); |
|
1074 TBool moreData = ETrue; |
|
1075 |
|
1076 // Packages some times need to stop before the data has all been uncompressed. |
|
1077 TBool packageContinue = ETrue; |
|
1078 |
|
1079 HBufC8* uncompressedData = NULL; |
|
1080 while (moreData && packageContinue) |
|
1081 { |
|
1082 uncompressedData = NULL; |
|
1083 if (!iDecompressor->NextLC(uncompressedData, moreData)) |
|
1084 { |
|
1085 __LOG("CDataOwnerManager::SupplyDataL() - iDecompressor->NextLC returned EFalse"); |
|
1086 if (uncompressedData != NULL) |
|
1087 { |
|
1088 __LOG("CDataOwnerManager::SupplyDataL() - uncompressedData not NULL so cleaning up"); |
|
1089 CleanupStack::PopAndDestroy(uncompressedData); |
|
1090 } |
|
1091 break; |
|
1092 } |
|
1093 |
|
1094 if (uncompressedData == NULL) |
|
1095 { |
|
1096 __LOG("CDataOwnerManager::SupplyDataL() - uncompressedData is NULL after NextLC, corrupt data"); |
|
1097 User::Leave(KErrCorrupt); |
|
1098 } |
|
1099 |
|
1100 TPtr8 dataPtr(uncompressedData->Des()); |
|
1101 __LOG1("CDataOwnerManager::SupplyDataL() - decompressed data length: %d", dataPtr.Length()); |
|
1102 |
|
1103 // Check aLastSection |
|
1104 TBool lastSection = aLastSection && !moreData; |
|
1105 |
|
1106 switch(apGenericTransferType->DerivedTypeL()) |
|
1107 { |
|
1108 case ESIDTransferDerivedType: |
|
1109 { |
|
1110 __LOG("CDataOwnerManager::SupplyDataL() - ESIDTransferDerivedType"); |
|
1111 CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apGenericTransferType); |
|
1112 CleanupStack::PushL(pSIDTransferType); |
|
1113 |
|
1114 // Is this the data for registration files? These are now not supported |
|
1115 if (pSIDTransferType->DataTypeL() == ERegistrationData) |
|
1116 { |
|
1117 User::Leave(KErrNotSupported); |
|
1118 } // if |
|
1119 else |
|
1120 { |
|
1121 // Does this dataowner require a reboot? |
|
1122 const TSecureId sid = pSIDTransferType->SecureIdL(); |
|
1123 const TDriveNumber driveNumber = pSIDTransferType->DriveNumberL(); |
|
1124 CDataOwner& dataOwner = DataOwnerL(sid); |
|
1125 __LOG2("CDataOwnerManager::SupplyDataL() - trying to restore data for SID: 0x%08x, drive: %c", sid.iId, 'A' + driveNumber); |
|
1126 |
|
1127 if ((dataOwner.CommonSettingsL() & ERequiresReboot) == ERequiresReboot) |
|
1128 { |
|
1129 __LOG1("CDataOwnerManager::SupplyDataL() - data owner 0x%08x requires a REBOOT!", sid.iId); |
|
1130 iResetAfterRestore = ETrue; |
|
1131 } |
|
1132 |
|
1133 dataOwner.SupplyDataL(driveNumber, pSIDTransferType->DataTypeL(), dataPtr, lastSection); |
|
1134 } // else |
|
1135 |
|
1136 CleanupStack::PopAndDestroy(pSIDTransferType); |
|
1137 break; |
|
1138 } |
|
1139 case EPackageTransferDerivedType: |
|
1140 { |
|
1141 __LOG("CDataOwnerManager::SupplyDataL() - EPackageTransferDerivedType"); |
|
1142 // Ideally, we would use the same CDataOwner class, or a class derived |
|
1143 // from it to handle the package backup/restore, however to do this would |
|
1144 // require a re-design. |
|
1145 CSBPackageTransferType *pPackageTransferType = CSBPackageTransferType::NewL(apGenericTransferType); |
|
1146 CleanupStack::PushL(pPackageTransferType); |
|
1147 |
|
1148 TUid packageId = pPackageTransferType->PackageIdL(); |
|
1149 |
|
1150 CPackageDataTransfer* pDataTransfer = FindPackageDataContainerL(packageId); |
|
1151 pDataTransfer->SupplyDataL(pPackageTransferType->DriveNumberL(), |
|
1152 pPackageTransferType->DataTypeL(), |
|
1153 dataPtr, lastSection); |
|
1154 |
|
1155 CleanupStack::PopAndDestroy(pPackageTransferType); |
|
1156 break; |
|
1157 } |
|
1158 |
|
1159 case EJavaTransferDerivedType: |
|
1160 { |
|
1161 __LOG("CDataOwnerManager::SupplyDataL() - EJavaTransferDerivedType"); |
|
1162 if(iJavaDOM) |
|
1163 { |
|
1164 iJavaDOM->SupplyDataL(apGenericTransferType, dataPtr, lastSection); |
|
1165 } |
|
1166 else |
|
1167 { |
|
1168 __LOG("CDataOwnerManager::SupplyDataL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
1169 } |
|
1170 break; |
|
1171 } |
|
1172 |
|
1173 default: |
|
1174 { |
|
1175 User::Leave(KErrNotSupported); |
|
1176 } |
|
1177 } // switch |
|
1178 |
|
1179 // Cleanup |
|
1180 CleanupStack::PopAndDestroy(uncompressedData); |
|
1181 } // while |
|
1182 __LOG("CDataOwnerManager::SupplyDataL() - END"); |
|
1183 } |
|
1184 |
|
1185 |
|
1186 void CDataOwnerManager::RequestDataL(CSBGenericTransferType* apGenericTransferType, |
|
1187 TPtr8& aBuffer, TBool& aLastSection) |
|
1188 /** Request data |
|
1189 |
|
1190 @param apGenericTransferType the generic transfertype. NOTE: This function will delete this. |
|
1191 @param aBuffer the buffer to write data to. |
|
1192 @param aLastSection is this the last section. |
|
1193 @leave KErrNotSupported Unknown transfer type |
|
1194 @leave KErrNotFound Unknown object |
|
1195 */ |
|
1196 { |
|
1197 __LOG2("CDataOwnerManager::RequestDataL() - START - aBuffer.Ptr(): 0x%08x, aBuffer.Length(): %d", aBuffer.Ptr(), aBuffer.Length()); |
|
1198 if (iBURType == EBURNormal || iBURType == EBURUnset) |
|
1199 { |
|
1200 __LOG("CDataOwnerManager::RequestDataL() - *Error: called when device is in Normal/Unset mode"); |
|
1201 User::Leave(KErrAccessDenied); |
|
1202 } |
|
1203 |
|
1204 // Reserve space to perform inline compression later |
|
1205 CSBECompressAndEncrypt* pCE = CSBECompressAndEncrypt::NewLC(apGenericTransferType, aBuffer); |
|
1206 |
|
1207 switch(apGenericTransferType->DerivedTypeL()) |
|
1208 { |
|
1209 case ESIDTransferDerivedType: |
|
1210 { |
|
1211 CSBSIDTransferType* pSIDTransferType = CSBSIDTransferType::NewL(apGenericTransferType); |
|
1212 CleanupStack::PushL(pSIDTransferType); |
|
1213 TSecureId sid(pSIDTransferType->SecureIdL()); |
|
1214 DataOwnerL(sid).RequestDataL(pSIDTransferType->DriveNumberL(), |
|
1215 pSIDTransferType->DataTypeL(), |
|
1216 aBuffer, aLastSection); |
|
1217 |
|
1218 CleanupStack::PopAndDestroy(pSIDTransferType); |
|
1219 break; |
|
1220 } |
|
1221 case EPackageTransferDerivedType: |
|
1222 { |
|
1223 CSBPackageTransferType *pPackageTransferType = CSBPackageTransferType::NewL(apGenericTransferType); |
|
1224 CleanupStack::PushL(pPackageTransferType); |
|
1225 |
|
1226 CPackageDataTransfer *packageDataTransfer = |
|
1227 FindPackageDataContainerL(pPackageTransferType->PackageIdL()); |
|
1228 |
|
1229 packageDataTransfer->RequestDataL(pPackageTransferType->DriveNumberL(), |
|
1230 pPackageTransferType->DataTypeL(), |
|
1231 aBuffer, aLastSection); |
|
1232 |
|
1233 CleanupStack::PopAndDestroy(pPackageTransferType); |
|
1234 |
|
1235 break; |
|
1236 } |
|
1237 |
|
1238 case EJavaTransferDerivedType: |
|
1239 { |
|
1240 if(iJavaDOM) |
|
1241 { |
|
1242 iJavaDOM->RequestDataL(apGenericTransferType, aBuffer, aLastSection); |
|
1243 } |
|
1244 else |
|
1245 { |
|
1246 __LOG("CDataOwnerManager::RequestDataL() - Java Backup-Restore Plug-In not loaded, java files won't be backed or restored"); |
|
1247 } |
|
1248 break; |
|
1249 } |
|
1250 |
|
1251 default: |
|
1252 { |
|
1253 User::Leave(KErrNotSupported); |
|
1254 } |
|
1255 } // switch |
|
1256 |
|
1257 // Compress the data block |
|
1258 if (aBuffer.Size() > 0) // Dont compress no data |
|
1259 { |
|
1260 __LOG1("CDataOwnerManager::RequestDataL() - got %d bytes of uncompressed data, about to pack it...", aBuffer.Length()); |
|
1261 pCE->PackL(aBuffer); |
|
1262 } |
|
1263 else |
|
1264 { |
|
1265 __LOG1("CDataOwnerManager::RequestDataL() - got %d bytes of uncompressed data, free reserved space...", aBuffer.Length()); |
|
1266 pCE->FreeReservedSpace(aBuffer); |
|
1267 } |
|
1268 |
|
1269 |
|
1270 CleanupStack::PopAndDestroy(pCE); |
|
1271 __LOG("CDataOwnerManager::RequestDataL() - End"); |
|
1272 } |
|
1273 |
|
1274 // Accessors |
|
1275 void CDataOwnerManager::SetActiveBackupServer(CABServer* aABServer) |
|
1276 { |
|
1277 ipABServer = aABServer; |
|
1278 } |
|
1279 |
|
1280 RFs& CDataOwnerManager::GetRFs() |
|
1281 { |
|
1282 return iFs; |
|
1283 } |
|
1284 |
|
1285 // PRIVATE // |
|
1286 /** Searches for registration files in Import Directories |
|
1287 |
|
1288 @param aDataOwners appended list of data owners infos |
|
1289 |
|
1290 */ |
|
1291 void CDataOwnerManager::FindImportPackagesL(Swi::RSisRegistrySession& aRegistry, RPointerArray<CDataOwnerInfo>& aDataOwners) |
|
1292 { |
|
1293 __LOG("CDataOwnerManager::FindImportPackagesL() - Begin"); |
|
1294 CDesCArray* files = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity); |
|
1295 CleanupStack::PushL(files); |
|
1296 FindRegistrationFilesL(KImportDir, *files); |
|
1297 const TInt count = files->Count(); |
|
1298 |
|
1299 RSisRegistryEntry entry; |
|
1300 CleanupClosePushL(entry); |
|
1301 |
|
1302 for (TInt x = 0; x < count; x++) |
|
1303 { |
|
1304 // Strip the SID |
|
1305 TSecureId sid; |
|
1306 const TDesC& fileName = (*files)[x]; |
|
1307 TRAPD(err, StripSecureIdL(fileName, sid)); |
|
1308 |
|
1309 if (err == KErrNone) // If there was an error then ignore it as it is probally not a dir |
|
1310 { |
|
1311 err = entry.Open(aRegistry, sid); |
|
1312 if (err == KErrNone) |
|
1313 { |
|
1314 __LOG2("CDataOwnerManager::FindImportPackagesL() - found reg file: %S for Package: 0x%08x", &fileName, sid.iId); |
|
1315 CPackageDataTransfer* pDataTransfer = FindPackageDataContainerL(sid); |
|
1316 |
|
1317 TRAP(err, pDataTransfer->SetRegistrationFileL(fileName)); |
|
1318 if (err == KErrNone) |
|
1319 { |
|
1320 TRAP(err, pDataTransfer->ParseL()); |
|
1321 } |
|
1322 if (err == KErrNoMemory) |
|
1323 { |
|
1324 User::Leave(KErrNoMemory); |
|
1325 } |
|
1326 // create generic data type |
|
1327 HBufC* pkgName = entry.PackageNameL(); |
|
1328 CleanupStack::PushL(pkgName); |
|
1329 CSBGenericDataType* pId = CSBPackageId::NewL(sid, KDummyId, *pkgName); |
|
1330 CleanupStack::PopAndDestroy(pkgName); |
|
1331 CleanupStack::PushL(pId); |
|
1332 |
|
1333 TDriveList driveList; |
|
1334 TRAP(err, pDataTransfer->GetDriveListL(driveList)); |
|
1335 if (err != KErrNone) |
|
1336 {//Non-removable, ignore this data owner |
|
1337 CleanupStack::PopAndDestroy(pId); |
|
1338 continue; |
|
1339 } |
|
1340 // create a data owner info |
|
1341 CDataOwnerInfo* pDataOwnerInfo = CDataOwnerInfo::NewL(pId, pDataTransfer->CommonSettingsL(), |
|
1342 pDataTransfer->PassiveSettingsL(), pDataTransfer->ActiveSettingsL(), |
|
1343 driveList); |
|
1344 CleanupStack::PushL(pDataOwnerInfo); |
|
1345 aDataOwners.AppendL(pDataOwnerInfo); |
|
1346 CleanupStack::Pop(pDataOwnerInfo); |
|
1347 |
|
1348 CleanupStack::Pop(pId); |
|
1349 |
|
1350 /* |
|
1351 * Check wheahter Package has public files or not. If yes then add the SID dataowner to process public files. * |
|
1352 */ |
|
1353 TPassiveBURSettings passiveBURSettings = ENoPassiveOptions; |
|
1354 TRAPD( passiveErr, passiveBURSettings = pDataTransfer->PassiveSettingsL()); |
|
1355 |
|
1356 if ( passiveErr == KErrNone && EHasPublicFiles & passiveBURSettings ) |
|
1357 { |
|
1358 CDataOwnerContainer* pDataOwner = FindL(sid); |
|
1359 if (pDataOwner == NULL) // If it does not exist we need to create it |
|
1360 { |
|
1361 __LOG1("CDataOwnerManager::FindImportPackagesL() - Package has the public files for SID: 0x%08x", sid.iId); |
|
1362 |
|
1363 pDataOwner = CDataOwnerContainer::NewL(sid, this); |
|
1364 CleanupStack::PushL(pDataOwner); |
|
1365 |
|
1366 iDataOwners.InsertInOrder(pDataOwner, CDataOwnerContainer::Compare); |
|
1367 CleanupStack::Pop(pDataOwner); |
|
1368 } // if |
|
1369 else |
|
1370 { |
|
1371 __LOG1("CDataOwnerManager::FindImportPackagesL() - SID already exists in the list SID: 0x%08x", sid.iId); |
|
1372 } |
|
1373 |
|
1374 TRAP_IGNORE(pDataOwner->DataOwner().AddRegistrationFilesL(fileName)); |
|
1375 |
|
1376 // forwards declarations |
|
1377 TDriveList driveList; |
|
1378 driveList.SetMax(); |
|
1379 |
|
1380 |
|
1381 // parse registration files |
|
1382 TRAP(err, pDataOwner->DataOwner().ParseFilesL()); |
|
1383 if (err != KErrNone) |
|
1384 { |
|
1385 __LOG2("CDataOwnerManager::GetDataOwnersL() - ParseFilesL() - Error in sid: 0x%08x (%d)", sid.iId, err); |
|
1386 } // if |
|
1387 else |
|
1388 { |
|
1389 // Reset the state for these data owners |
|
1390 TRAP(err, pDataOwner->DataOwner().BuildDriveStateArrayL()); |
|
1391 if (err != KErrNone) |
|
1392 { |
|
1393 __LOG2("CDataOwnerManager::GetDataOwnersL() - BuildDriveStateArrayL() - Error in sid: 0x%08x (%d)", sid.iId, err); |
|
1394 }//if |
|
1395 else |
|
1396 { |
|
1397 // Get drive list (this is needed to update drive list for packages) |
|
1398 TRAP(err, pDataOwner->DataOwner().GetDriveListL(driveList)); |
|
1399 if (err != KErrNone) |
|
1400 { |
|
1401 __LOG2("CDataOwnerManager::GetDataOwnersL() - GetDriveListL() - Error in sid: 0x%08x (%d)", sid.iId, err); |
|
1402 }//if |
|
1403 else |
|
1404 { |
|
1405 TRAP(err, pDataOwner->DataOwner().CommonSettingsL()); |
|
1406 if (err != KErrNone) |
|
1407 { |
|
1408 __LOG2("CDataOwnerManager::GetDataOwnersL() - CommonSettingsL() - Error in sid: 0x%08x (%d)", sid.iId, err); |
|
1409 }//if |
|
1410 }//else |
|
1411 } |
|
1412 }//else |
|
1413 |
|
1414 } // if EHasPublicFiles & passiveBURSettings |
|
1415 |
|
1416 } //if |
|
1417 entry.Close(); |
|
1418 } // if |
|
1419 |
|
1420 if (err != KErrNone) |
|
1421 { |
|
1422 __LOG1("CDataOwnerManager::FindImportPackagesL() - cannot get Package UID for reg file: %S", &fileName); |
|
1423 |
|
1424 CSBGenericDataType* pId = CSBPackageId::NewL(sid, KDummyId, KNullDesC); |
|
1425 CleanupStack::PushL(pId); |
|
1426 TDriveList driveList; |
|
1427 driveList.SetLength(driveList.MaxLength()); |
|
1428 driveList.FillZ(); |
|
1429 CDataOwnerInfo* pDataOwnerInfo = CDataOwnerInfo::NewL(pId, ENoOptions, ENoPassiveOptions, |
|
1430 ENoActiveOptions, driveList); |
|
1431 CleanupStack::PushL(pDataOwnerInfo); |
|
1432 aDataOwners.AppendL(pDataOwnerInfo); |
|
1433 CleanupStack::Pop(pDataOwnerInfo); |
|
1434 |
|
1435 CleanupStack::Pop(pId); |
|
1436 } // if |
|
1437 |
|
1438 |
|
1439 } // for x |
|
1440 |
|
1441 |
|
1442 CleanupStack::PopAndDestroy(&entry); |
|
1443 |
|
1444 CleanupStack::PopAndDestroy(files); |
|
1445 __LOG("CDataOwnerManager::FindImportPackagesL() - End"); |
|
1446 } |
|
1447 |
|
1448 void CDataOwnerManager::FindRegistrationFilesL(const TDesC& aPath, CDesCArray& aFiles) |
|
1449 /** Searches the device for registration files |
|
1450 |
|
1451 @param aFiles on return a list of registration files on the device |
|
1452 */ |
|
1453 { |
|
1454 __LOG("CDataOwnerManager::FindRegistrationFilesL() - START"); |
|
1455 |
|
1456 // Find private directorys |
|
1457 TFindFile findDir(iFs); |
|
1458 CDir* pDir = NULL; |
|
1459 TInt errD = findDir.FindWildByDir(KStar, aPath, pDir); |
|
1460 while (errD == KErrNone) |
|
1461 { |
|
1462 CleanupStack::PushL(pDir); |
|
1463 |
|
1464 // Loop through the directorys and look for registration files |
|
1465 TUint dirCount = pDir->Count(); |
|
1466 while(dirCount--) |
|
1467 { |
|
1468 const TEntry& dirEntry = (*pDir)[dirCount]; |
|
1469 if (dirEntry.IsDir()) |
|
1470 { |
|
1471 // Full path of dir |
|
1472 TParse path; |
|
1473 path.Set(dirEntry.iName, &findDir.File(), NULL); |
|
1474 |
|
1475 // See if there are any backup registration files |
|
1476 TFindFile findFile(iFs); |
|
1477 CDir* pFile = NULL; |
|
1478 TFileName fullPath(path.FullName()); |
|
1479 fullPath.Append(KPathDelimiter); |
|
1480 TInt errF = findFile.FindWildByPath(KBackupRegistrationFile, &fullPath, pFile); |
|
1481 if (errF == KErrNone) // Where registration files found? |
|
1482 { |
|
1483 CleanupStack::PushL(pFile); |
|
1484 // Add to the list of registration files |
|
1485 TUint fileCount = pFile->Count(); |
|
1486 while(fileCount--) |
|
1487 { |
|
1488 path.Set((*pFile)[fileCount].iName, &findFile.File(), NULL); |
|
1489 __LOG1("CDataOwnerManager::FindRegistrationFilesL() - found file: %S", &path.FullName()); |
|
1490 aFiles.AppendL(path.FullName()); |
|
1491 } // for y |
|
1492 |
|
1493 // Cleanup |
|
1494 CleanupStack::PopAndDestroy(pFile); |
|
1495 } // if |
|
1496 } // if |
|
1497 } // for x |
|
1498 |
|
1499 // Cleanup |
|
1500 CleanupStack::PopAndDestroy(pDir); |
|
1501 |
|
1502 // Check next drive |
|
1503 errD = findDir.FindWild(pDir); |
|
1504 } // while |
|
1505 |
|
1506 __LOG1("CDataOwnerManager::FindRegistrationFilesL() - END - total files %d", aFiles.Count()); |
|
1507 } |
|
1508 |
|
1509 CDataOwnerContainer* CDataOwnerManager::FindL(TSecureId aSID) |
|
1510 /** Finds a data owner in the array given a secure id |
|
1511 |
|
1512 @param aSID the Secure Id of the data owner you want |
|
1513 @leave KErrNotFound no such secure id |
|
1514 */ |
|
1515 { |
|
1516 CDataOwnerContainer* tempCont = CDataOwnerContainer::NewL(aSID, this); |
|
1517 TInt res = iDataOwners.Find(tempCont, CDataOwnerContainer::Match); |
|
1518 delete tempCont; |
|
1519 |
|
1520 if (res == KErrNotFound) |
|
1521 { |
|
1522 return NULL; |
|
1523 } |
|
1524 else |
|
1525 { |
|
1526 return iDataOwners[res]; |
|
1527 } |
|
1528 } |
|
1529 |
|
1530 |
|
1531 CPackageDataTransfer* CDataOwnerManager::FindPackageDataContainerL(TUid aPid) |
|
1532 /** Finds the package data container |
|
1533 |
|
1534 @param aPid The process id |
|
1535 */ |
|
1536 { |
|
1537 CPackageDataTransfer* pPackageTransfer = CPackageDataTransfer::NewL(aPid, this); |
|
1538 CleanupStack::PushL(pPackageTransfer); |
|
1539 TInt res = iPackageDataOwners.Find(pPackageTransfer, CPackageDataTransfer::Match); |
|
1540 if (res == KErrNotFound) |
|
1541 { |
|
1542 User::LeaveIfError(iPackageDataOwners.InsertInOrder(pPackageTransfer, CPackageDataTransfer::Compare)); |
|
1543 CleanupStack::Pop(pPackageTransfer); |
|
1544 return pPackageTransfer; |
|
1545 } |
|
1546 else |
|
1547 { |
|
1548 CleanupStack::PopAndDestroy(pPackageTransfer); |
|
1549 return iPackageDataOwners[res]; |
|
1550 } |
|
1551 } |
|
1552 |
|
1553 void CDataOwnerManager::StripSecureIdL(const TDesC& aStrip, TSecureId& aSecureId) |
|
1554 /** Strips a Secure Id from a text string |
|
1555 |
|
1556 Looks for a "//private//" directory in the string and strips the SID after it. |
|
1557 */ |
|
1558 { |
|
1559 |
|
1560 TInt start = aStrip.FindF(KImportDir); |
|
1561 if (start == KErrNotFound) |
|
1562 { |
|
1563 start = aStrip.FindF(KPrivate); |
|
1564 if (start == KErrNotFound) |
|
1565 { |
|
1566 User::Leave(KErrArgument); |
|
1567 } |
|
1568 start += KPrivate().Length(); |
|
1569 } |
|
1570 else |
|
1571 { |
|
1572 start += KImportDir().Length(); |
|
1573 } |
|
1574 |
|
1575 // Find the end of the SID |
|
1576 TInt end = (aStrip.Right(aStrip.Length() - start)).FindF(KBackSlash); |
|
1577 end += start; |
|
1578 |
|
1579 // Create the secure Id |
|
1580 TLex sIdLex(aStrip.Mid(start, end - start + 1)); |
|
1581 // If we cant do the convert then ignore as it is a directory that is not a SID. |
|
1582 if (sIdLex.Val(aSecureId.iId, EHex) != KErrNone) |
|
1583 { |
|
1584 User::Leave(KErrArgument); |
|
1585 } |
|
1586 } |
|
1587 |
|
1588 |
|
1589 void CDataOwnerManager::FindDataOwnersL() |
|
1590 /** Gets a list of data owners |
|
1591 |
|
1592 This list only contains the Secure ID's for applications that have a backup |
|
1593 registration files. |
|
1594 */ |
|
1595 { |
|
1596 __LOG("CDataOwnerManager::FindDataOwnersL() - Begin"); |
|
1597 // Clear out any current list |
|
1598 iDataOwners.ResetAndDestroy(); |
|
1599 |
|
1600 // Find all registration files on the device |
|
1601 CDesCArray* registrationFiles = new(ELeave) CDesCArrayFlat(KDesCArrayGranularity); |
|
1602 CleanupStack::PushL(registrationFiles); |
|
1603 FindRegistrationFilesL(KPrivate, *registrationFiles); |
|
1604 __LOG(" "); |
|
1605 |
|
1606 // Add registration files to iDataOwners |
|
1607 const TInt count = registrationFiles->Count(); |
|
1608 for (TInt x = 0; x < count; x++) |
|
1609 { |
|
1610 // Strip the SID |
|
1611 TSecureId sid; |
|
1612 const TDesC& fileName = (*registrationFiles)[x]; |
|
1613 TRAPD(err, StripSecureIdL(fileName, sid)); |
|
1614 if (err == KErrNone) // If there was an error then ignore it as it is probally not a dir |
|
1615 { |
|
1616 CDataOwnerContainer* pDataOwner = FindL(sid); |
|
1617 if (pDataOwner == NULL) // If it does not exist we need to create it |
|
1618 { |
|
1619 __LOG2("CDataOwnerManager::FindDataOwnersL() - found reg file: %S for sid: 0x%08x", &fileName, sid.iId); |
|
1620 |
|
1621 pDataOwner = CDataOwnerContainer::NewL(sid, this); |
|
1622 CleanupStack::PushL(pDataOwner); |
|
1623 |
|
1624 iDataOwners.InsertInOrder(pDataOwner, CDataOwnerContainer::Compare); |
|
1625 CleanupStack::Pop(pDataOwner); |
|
1626 } // if |
|
1627 else |
|
1628 { |
|
1629 __LOG2("CDataOwnerManager::FindDataOwnersL() - found reg file: %S for existing sid: 0x%08x", &fileName, sid.iId); |
|
1630 } |
|
1631 |
|
1632 pDataOwner->DataOwner().AddRegistrationFilesL(fileName); |
|
1633 } // if |
|
1634 } // for x |
|
1635 |
|
1636 CleanupStack::PopAndDestroy(registrationFiles); |
|
1637 __LOG("CDataOwnerManager::FindDataOwnersL() - End"); |
|
1638 } |
|
1639 |
|
1640 CSBEConfig& CDataOwnerManager::Config() |
|
1641 /** Getter for the Secure Backup configuration |
|
1642 @return Reference to the CSBEConfig instance |
|
1643 */ |
|
1644 { |
|
1645 return *iConfig; |
|
1646 } |
|
1647 |
|
1648 TBool CDataOwnerManager::IsSetForPartialL(TSecureId aSecureId) const |
|
1649 /** Queries whether a SID is included in a partial operation |
|
1650 @return TBool specifying whether a SID is included or not |
|
1651 */ |
|
1652 { |
|
1653 TBool found = EFalse; |
|
1654 |
|
1655 if (iSIDListForPartial != NULL) |
|
1656 { |
|
1657 TInt result = iSIDListForPartial->Find(aSecureId); |
|
1658 if (result != KErrNotFound) |
|
1659 { |
|
1660 found = ETrue; |
|
1661 } |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 __LOG("CDataOwnerManager::IsSetForPartialL() - SID list not created yet so leaving!"); |
|
1666 User::Leave(KErrNotFound); |
|
1667 } |
|
1668 |
|
1669 __LOG2("CDataOwnerManager::IsSetForPartialL() - SID: 0x%08x, found: %d", aSecureId.iId, found); |
|
1670 |
|
1671 return found; |
|
1672 } |
|
1673 } // namespace conn |