383 void CRepositoryBackupClient::RestoreComplete(TDriveNumber /* aDrive */) |
383 void CRepositoryBackupClient::RestoreComplete(TDriveNumber /* aDrive */) |
384 { |
384 { |
385 } |
385 } |
386 |
386 |
387 |
387 |
388 void CRepositoryBackupClient::RestoreRepositoryAndListL(TUid repositoryUid, CDirectFileStore* store, TStreamId settingsStreamId, TStreamId deletedSettingsStreamId, TInt& repIndex) |
|
389 { |
|
390 // Add the restored repository to the restored repositories list. |
|
391 // Pass its changed-keys list to further restoring functions to add entries for post-restoration notification. |
|
392 repIndex = AddRestoredRepositoryL(repositoryUid); |
|
393 iRepository->RestoreRepositoryContentsL(*store, settingsStreamId, deletedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]); |
|
394 iRepository->CommitChangesL(); |
|
395 } |
|
396 |
|
397 |
388 |
398 // |
389 // |
399 // CRepositoryBackupClient::RestoreCompleteL |
390 // CRepositoryBackupClient::RestoreCompleteL |
400 // |
391 // |
401 // Does the actual work of reconstructing repositories from backup data |
392 // Does the actual work of reconstructing repositories from backup data |
427 |
418 |
428 User::Leave(KErrCorrupt); |
419 User::Leave(KErrCorrupt); |
429 } |
420 } |
430 |
421 |
431 |
422 |
|
423 |
432 // Get the root stream and attempt to read a backup file header from it |
424 // Get the root stream and attempt to read a backup file header from it |
433 TStreamId rootStreamId = store->Root() ; |
425 TStreamId rootStreamId = store->Root() ; |
434 RStoreReadStream rootStream ; |
426 RStoreReadStream rootStream ; |
435 RStoreReadStream indexStream ; |
427 RStoreReadStream indexStream ; |
436 rootStream.OpenLC(*store, rootStreamId); |
428 rootStream.OpenLC(*store, rootStreamId); |
468 restoreStreamIndex->InternalizeL(indexStream, iBackupExtensionsSupported); |
460 restoreStreamIndex->InternalizeL(indexStream, iBackupExtensionsSupported); |
469 |
461 |
470 |
462 |
471 // Iterate through index and attempt restore of each repository stream |
463 // Iterate through index and attempt restore of each repository stream |
472 // we find in it. |
464 // we find in it. |
473 restoreStreamIndex->Reset(); |
465 restoreStreamIndex->Reset() ; |
474 TUid repositoryUid; |
466 TUid repositoryUid ; |
475 TStreamId settingsStreamId(KNullStreamIdValue); |
467 TStreamId settingsStreamId(KNullStreamIdValue); |
476 TStreamId deletedSettingsStreamId(KNullStreamIdValue); |
468 TStreamId deletedSettingsStreamId(KNullStreamIdValue); |
477 TStreamId installedSettingsStreamId(KNullStreamIdValue); |
469 TStreamId installedSettingsStreamId(KNullStreamIdValue); |
478 |
470 |
479 while (restoreStreamIndex->GetNext(repositoryUid, settingsStreamId, deletedSettingsStreamId, installedSettingsStreamId) == KErrNone) |
471 while (restoreStreamIndex->GetNext(repositoryUid, settingsStreamId, deletedSettingsStreamId, installedSettingsStreamId) == KErrNone) |
480 { |
472 { |
481 iRepository->OpenL(repositoryUid, *iNotifier, EFalse); |
473 iRepository->OpenL(repositoryUid, *iNotifier, EFalse); |
482 iRepository->FailAllTransactions(); |
474 iRepository->FailAllTransactions(); |
483 TInt repIndex; |
475 // Add the restored repository to the restored repositories list. |
484 TRAPD(err, RestoreRepositoryAndListL(repositoryUid, store, settingsStreamId, deletedSettingsStreamId, repIndex)); |
476 // Pass its changed-keys list to further restoring functions to add entries for post-restoration notification. |
|
477 TInt repIndex = AddRestoredRepositoryL(repositoryUid); |
|
478 iRepository->RestoreRepositoryContentsL(*store, settingsStreamId, deletedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]); |
|
479 iRepository->CommitChangesL(); |
485 iRepository->Close(); |
480 iRepository->Close(); |
486 User::LeaveIfError(err); |
|
487 // If the backup contains an installed repository containing default values for the settings, read them in |
481 // If the backup contains an installed repository containing default values for the settings, read them in |
488 if (installedSettingsStreamId != KNullStreamId) |
482 if (installedSettingsStreamId != KNullStreamId) |
489 { |
483 { |
490 // create an empty repository in install directory, and restore the data from backup file |
484 // create an empty repository in install directory, and restore the data from backup file |
491 iRepository->RestoreInstallRepositoryL(repositoryUid, *store, installedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]); |
485 iRepository->RestoreInstallRepositoryL(repositoryUid, *store, installedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]); |