1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
228 // Notify the changed keys if a restoration was just completed |
228 // Notify the changed keys if a restoration was just completed |
229 if((lastBackupStatus == ERestoreInProgress)) |
229 if((lastBackupStatus == ERestoreInProgress)) |
230 { |
230 { |
231 for(TInt i = 0; i < iRestoredRepositoriesArray.Count(); i++) |
231 for(TInt i = 0; i < iRestoredRepositoriesArray.Count(); i++) |
232 { |
232 { |
|
233 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
234 __ASSERT_DEBUG(TServerResources::iPMADriveRepositories.FindInOrder( iRestoredRepositoriesArray[i]->Uid(), TLinearOrder<TUid>(TServerResources::CompareUids) ) == KErrNotFound, User::Invariant()); |
|
235 #endif |
233 iRepository->OpenL(iRestoredRepositoriesArray[i]->Uid(), *iNotifier, EFalse); |
236 iRepository->OpenL(iRestoredRepositoriesArray[i]->Uid(), *iNotifier, EFalse); |
234 iRepository->RestoreNotify(*iRestoredRepositoriesArray[i]); |
237 iRepository->RestoreNotify(*iRestoredRepositoriesArray[i]); |
235 iRepository->Close(); |
238 iRepository->Close(); |
236 } |
239 } |
237 iRestoredRepositoriesArray.ResetAndDestroy(); |
240 iRestoredRepositoriesArray.ResetAndDestroy(); |
479 while (restoreStreamIndex->GetNext(repositoryUid, settingsStreamId, deletedSettingsStreamId, installedSettingsStreamId) == KErrNone) |
482 while (restoreStreamIndex->GetNext(repositoryUid, settingsStreamId, deletedSettingsStreamId, installedSettingsStreamId) == KErrNone) |
480 { |
483 { |
481 iRepository->OpenL(repositoryUid, *iNotifier, EFalse); |
484 iRepository->OpenL(repositoryUid, *iNotifier, EFalse); |
482 iRepository->FailAllTransactions(); |
485 iRepository->FailAllTransactions(); |
483 TInt repIndex; |
486 TInt repIndex; |
484 TRAPD(err, RestoreRepositoryAndListL(repositoryUid, store, settingsStreamId, deletedSettingsStreamId, repIndex)); |
487 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
485 iRepository->Close(); |
488 // Under normal circumstances the repository should not be a |
486 User::LeaveIfError(err); |
489 // protected keyspace, but we need to check that we are not trying |
487 // If the backup contains an installed repository containing default values for the settings, read them in |
490 // restore a protected keyspace, incase the backup file has been |
488 if (installedSettingsStreamId != KNullStreamId) |
491 // tampered with. |
489 { |
492 if (iRepository->KeyspaceType() == ENonPMAKeyspace) |
490 // create an empty repository in install directory, and restore the data from backup file |
493 { |
491 iRepository->RestoreInstallRepositoryL(repositoryUid, *store, installedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]); |
494 #endif |
492 // remove the .ini install file (if exists) because it will clash with the restored file |
495 TRAPD(err, RestoreRepositoryAndListL(repositoryUid, store, settingsStreamId, deletedSettingsStreamId, repIndex)); |
493 TServerResources::DeleteCentrepFileL(repositoryUid, EInstall, EIni); |
496 |
494 } |
497 iRepository->Close(); |
|
498 User::LeaveIfError(err); |
|
499 // If the backup contains an installed repository containing default values for the settings, read them in |
|
500 if (installedSettingsStreamId != KNullStreamId) |
|
501 { |
|
502 // create an empty repository in install directory, and restore the data from backup file |
|
503 iRepository->RestoreInstallRepositoryL(repositoryUid, *store, installedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]); |
|
504 // remove the .ini install file (if exists) because it will clash with the restored file |
|
505 TServerResources::DeleteCentrepFileL(repositoryUid, EInstall, EIni); |
|
506 } |
|
507 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
508 } |
|
509 else // If it is a protected keyspace then we just want to move onto the next repository. |
|
510 { |
|
511 iRepository->Close(); |
|
512 } |
|
513 #endif |
495 } |
514 } |
496 |
515 |
497 CleanupStack::PopAndDestroy(restoreStreamIndex) ; |
516 CleanupStack::PopAndDestroy(restoreStreamIndex) ; |
498 CleanupStack::PopAndDestroy(&indexStream); |
517 CleanupStack::PopAndDestroy(&indexStream); |
499 CleanupStack::PopAndDestroy(store); |
518 CleanupStack::PopAndDestroy(store); |
651 TStreamId deletedSettingsStreamId(KNullStreamIdValue); |
670 TStreamId deletedSettingsStreamId(KNullStreamIdValue); |
652 TStreamId installedSettingStreamId(KNullStreamIdValue); |
671 TStreamId installedSettingStreamId(KNullStreamIdValue); |
653 // Found one match, open the repository and externalise content. |
672 // Found one match, open the repository and externalise content. |
654 TUid uid = TUid::Uid(lookupTableEntry.iRepUid); |
673 TUid uid = TUid::Uid(lookupTableEntry.iRepUid); |
655 TRAPD(err,iRepository->OpenL(uid, *iNotifier)); |
674 TRAPD(err,iRepository->OpenL(uid, *iNotifier)); |
|
675 |
656 if (err == KErrNoMemory) |
676 if (err == KErrNoMemory) |
657 { |
677 { |
658 User::Leave(err) ; |
678 User::Leave(err) ; |
659 } |
679 } |
660 else if (err == KErrNone) |
680 else if (err == KErrNone) |
661 { |
681 { |
|
682 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
683 // No protected keyspaces should be in iOwnerIdLookUpTable. |
|
684 __ASSERT_DEBUG(iRepository->KeyspaceType() != EPMAKeyspace, User::Invariant()); |
|
685 #endif |
|
686 |
662 iRepository->FailAllTransactions(); |
687 iRepository->FailAllTransactions(); |
663 // externalise repository contents |
688 // externalise repository contents |
664 iRepository->StoreRepositoryContentsL(*store, settingStreamId, deletedSettingsStreamId); |
689 iRepository->StoreRepositoryContentsL(*store, settingStreamId, deletedSettingsStreamId); |
665 // Close repository. |
690 // Close repository. |
666 iRepository->Close(); |
691 iRepository->Close(); |