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