persistentstorage/centralrepository/cenrepsrv/srvrepos_noc.cpp
changeset 55 44f437012c90
parent 40 b8bdbc8f59c7
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
     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".
    50         {
    50         {
    51         TServerResources::iObserver->RemoveSharedRepositoryInfo(aUid);
    51         TServerResources::iObserver->RemoveSharedRepositoryInfo(aUid);
    52         User::Leave(err);
    52         User::Leave(err);
    53         }
    53         }
    54 	}
    54 	}
       
    55 
       
    56 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
    57 TInt8 CServerRepository::KeyspaceType()
       
    58     {
       
    59     return iRepository->iSimRep->KeyspaceType();
       
    60     }
       
    61 #endif
    55 
    62 
    56 void CServerRepository::Close()
    63 void CServerRepository::Close()
    57 	{
    64 	{
    58 	iRepository = NULL;
    65 	iRepository = NULL;
    59 
    66 
   221 
   228 
   222 #endif	
   229 #endif	
   223 
   230 
   224 TInt CServerRepository::ResetL(TUint32 aId)
   231 TInt CServerRepository::ResetL(TUint32 aId)
   225 	{
   232 	{
       
   233 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC 
       
   234 	// A protected repository should never be modified during a reset.   
       
   235     if ( ( iRepository->iSimRep->KeyspaceType() ) == EPMAKeyspace )
       
   236         {
       
   237         return KErrNotSupported;
       
   238         }
       
   239 #endif    
       
   240    
   226 	// not yet supported in transactions
   241 	// not yet supported in transactions
   227 	ASSERT(!IsInTransaction());
   242 	ASSERT(!IsInTransaction());
   228 
   243 
   229 	// if setting has not changed, there nothing to do
   244 	// if setting has not changed, there nothing to do
   230 	TServerSetting *targetSetting = GetSetting(aId) ;
   245 	TServerSetting *targetSetting = GetSetting(aId) ;
   413 					    {
   428 					    {
   414                         repository->Close();
   429                         repository->Close();
   415 					    User::LeaveNoMemory();
   430 					    User::LeaveNoMemory();
   416 					    }
   431 					    }
   417 				      else
   432 				      else
   418 					    {//Dont stop processing the rest of the persisted repositories becos one has a problem.
   433 					    {// Dont stop processing the rest of the persisted repositories because one has a problem.
   419 					     __CENTREP_TRACE1("CENTREP: CServerRepository::ProcessPersistsRepositoriesL - Error = %d", err);
   434 					     __CENTREP_TRACE1("CENTREP: CServerRepository::ProcessPersistsRepositoriesL - Error = %d", err);
   420 					    }
   435 					    }
   421 				      }
   436 				      }
   422 	
   437 	
   423 					// delete repository.
   438 					// delete repository.
   431 	CleanupStack::PopAndDestroy(&persistDir);
   446 	CleanupStack::PopAndDestroy(&persistDir);
   432 	}
   447 	}
   433 
   448 
   434 TInt CServerRepository::RFSRepositoryL()
   449 TInt CServerRepository::RFSRepositoryL()
   435 	{
   450 	{
       
   451 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC 
       
   452 	// A protected repository should never be modified during RFS.
       
   453     ASSERT( ( iRepository->iSimRep->KeyspaceType() ) != EPMAKeyspace );
       
   454 #endif
       
   455     
   436 	// for each key in combined ROM/Install restore
   456 	// for each key in combined ROM/Install restore
   437 	TUid uid = iRepository->Uid();
   457 	TUid uid = iRepository->Uid();
   438 
   458 
   439 	CSharedRepository* defaultRepository = 0;
   459 	CSharedRepository* defaultRepository = 0;
   440 	TInt err=KErrNone;
   460 	TInt err=KErrNone;
   533 	}
   553 	}
   534 
   554 
   535 	
   555 	
   536 TInt CServerRepository::HandleReflashofRepositoryL()
   556 TInt CServerRepository::HandleReflashofRepositoryL()
   537 	{
   557 	{
       
   558 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
   559     // A protected repository should not reach this point, due to an earlier check. 
       
   560     __ASSERT_DEBUG( ( iRepository->iSimRep->KeyspaceType() ) == ENonPMAKeyspace, User::Invariant() );
       
   561 #endif
       
   562 
   538 	// for each key in persists repository
   563 	// for each key in persists repository
   539 	TUid uid = iRepository->Uid();
   564 	TUid uid = iRepository->Uid();
   540 
   565 
   541 	CSharedRepository* defaultRepository = 0;
   566 	CSharedRepository* defaultRepository = 0;
   542 	
   567 	
   587 	}
   612 	}
   588 
   613 
   589 
   614 
   590 TInt CServerRepository::ResetAllL()
   615 TInt CServerRepository::ResetAllL()
   591 	{
   616 	{
       
   617 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC    
       
   618 	// A protected repository should never be modified during a reset.
       
   619     if ( ( iRepository->iSimRep->KeyspaceType() ) == EPMAKeyspace )
       
   620         {
       
   621         return KErrNotSupported;
       
   622         }
       
   623 #endif  
       
   624 
   592 	// not yet supported in transactions
   625 	// not yet supported in transactions
   593 	ASSERT(!IsInTransaction());
   626 	ASSERT(!IsInTransaction());
   594 	// fail all sessions' transactions first
   627 	// fail all sessions' transactions first
   595 	iRepository->FailAllTransactions(/*aExcludeTransactor*/NULL);
   628 	iRepository->FailAllTransactions(/*aExcludeTransactor*/NULL);
   596 
   629 
   649 
   682 
   650 // Handle install directory file update. 
   683 // Handle install directory file update. 
   651 void CServerRepository::HandleSWIUpdateL(TUid aUid, TTime aModified, CSessionNotifier &aNotifier)
   684 void CServerRepository::HandleSWIUpdateL(TUid aUid, TTime aModified, CSessionNotifier &aNotifier)
   652 	{		
   685 	{		
   653 	// A file create or update has just occurred in the SWI directory. 
   686 	// A file create or update has just occurred in the SWI directory. 
   654 	// Need to check if this is a new install. 
   687 
   655 	
   688 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC    
       
   689     // A protected repository should never be modified during SWI.
       
   690 	if ( TServerResources::iPMADriveRepositories.FindInOrder( aUid, TLinearOrder<TUid>(TServerResources::CompareUids) ) != KErrNotFound )
       
   691 	    {
       
   692         TServerResources::DeleteCentrepFileL(aUid, EInstall, EIni);
       
   693 	    TServerResources::DeleteCentrepFileL(aUid, EInstall, ECre);
       
   694         User::Leave(KErrNotSupported);
       
   695 	    }
       
   696 #endif
       
   697 	
       
   698 	// Need to check if this is an update to an existing repository.
   656 	if(TServerResources::PersistsFileExistsL(aUid) ||
   699 	if(TServerResources::PersistsFileExistsL(aUid) ||
   657 	   TServerResources::RomFileExistsL(aUid))
   700 	   TServerResources::RomFileExistsL(aUid))
   658 		{	
   701 		{	
   659 		// Create a rep using the ROM or persists file
   702 		// Create a repository using the ROM or persists file.
   660 		OpenL(aUid, aNotifier);
   703 		OpenL(aUid, aNotifier);
       
   704 		
       
   705 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
   706         // Although unlikely, we need to check incase there is a protected
       
   707 		// repository in the ROM, but not in the protected area. 
       
   708         if ( ( iRepository->iSimRep->KeyspaceType() ) == EPMAKeyspace )
       
   709             {
       
   710             Close();
       
   711             TServerResources::DeleteCentrepFileL(aUid, EInstall, EIni);
       
   712             TServerResources::DeleteCentrepFileL(aUid, EInstall, ECre);
       
   713             User::Leave(KErrNotSupported);
       
   714             }
       
   715 #endif
       
   716 		
   661 		if(iRepository->IsTransactionActive())			
   717 		if(iRepository->IsTransactionActive())			
   662 			{
   718 			{
   663 			// Fail transactions on any currently open session
   719 			// Fail transactions on any currently open session
   664 			iRepository->FailAllTransactions(NULL);
   720 			iRepository->FailAllTransactions(NULL);
   665 			}
   721 			}
   666 			
   722 			
   667 		// Create install rep for merging
   723 		// Create install rep for merging
   668  		CSharedRepository *installRep = 0;
   724  		CSharedRepository *installRep = 0;
       
   725  		
       
   726  		// If the repository in the install directory is marked as 'protected',
       
   727  		//  it will be deleted and KErrNotSupported will be returned.
   669  		TRAPD( err, TServerResources::iObserver->LoadRepositoryLC(aUid, ETrue, installRep, CIniFileIn::EInstallOnly); CleanupStack::Pop(installRep) );
   728  		TRAPD( err, TServerResources::iObserver->LoadRepositoryLC(aUid, ETrue, installRep, CIniFileIn::EInstallOnly); CleanupStack::Pop(installRep) );
   670 	
   729 	
   671 		if (err == KErrNone)
   730 		if (err == KErrNone)
   672             {
   731             {
   673             // Perform merge
   732             // Perform merge
   678             delete installRep;
   737             delete installRep;
   679             }
   738             }
   680         Close();
   739         Close();
   681         User::LeaveIfError(err);
   740         User::LeaveIfError(err);
   682 		}
   741 		}
   683 	else	// No ROM or persists
   742 	else	// No ROM or persists repository, installing a new repository.
   684 		{
   743 		{
   685 		// Create install rep for persisting
   744 		// Create install repository for persisting. If the repository in the
       
   745 	    // install directory is marked as 'protected', it will be deleted and
       
   746 	    // return KErrNotSupported. As protected repositories can installed 
       
   747 		// during software install.
   686 		OpenL(aUid, aNotifier);
   748 		OpenL(aUid, aNotifier);
       
   749 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
   750 		__ASSERT_DEBUG(iRepository->iSimRep->KeyspaceType() != EPMAKeyspace, User::Invariant());
       
   751 #endif
   687 		TRAPD(err, iRepository->CommitChangesL());
   752 		TRAPD(err, iRepository->CommitChangesL());
   688 	    Close();
   753 	    Close();
   689 	    User::LeaveIfError(err);
   754 	    User::LeaveIfError(err);
   690 		}
   755 		}
   691 	}
   756 	}
   692 
   757 
   693 
   758 
   694 // Handle install directory file delete 
   759 // Handle install directory file delete 
   695 void CServerRepository::HandleSWIDeleteL(TUid aUid, CSessionNotifier &aNotifier)
   760 void CServerRepository::HandleSWIDeleteL(TUid aUid, CSessionNotifier &aNotifier)
   696 	{			
   761 	{
       
   762 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
   763     // Protected repository files can not be installed, so there should never be
       
   764     // anything to uninstall. 
       
   765     __ASSERT_DEBUG( (TServerResources::iPMADriveRepositories.FindInOrder( aUid, TLinearOrder<TUid>(TServerResources::CompareUids) ) == KErrNotFound), User::Invariant() );
       
   766 #endif
       
   767 
   697 	// A file delete has just occurred in the SWI directory. If there is no ROM file
   768 	// A file delete has just occurred in the SWI directory. If there is no ROM file
   698 	// this is a complete uninstall, so delete persists file.Otherwise, do downgrade
   769 	// this is a complete uninstall, so delete persists file.Otherwise, do downgrade
   699 	// merge.
   770 	// merge.
   700 	
   771 	
   701 	if(TServerResources::RomFileExistsL(aUid))		// ROM file, this is a downgrade uninstall
   772 	if(TServerResources::RomFileExistsL(aUid))		// ROM file, this is a downgrade uninstall
   706 			// original upgrade should have created one.
   777 			// original upgrade should have created one.
   707 			// However if there isn't a persists file, there's nothing to do, so just return
   778 			// However if there isn't a persists file, there's nothing to do, so just return
   708 			return;
   779 			return;
   709 			}
   780 			}
   710 			
   781 			
   711 		// Create a rep using the persists file
   782 		// Create a repository using the persists file.
   712 		OpenL(aUid, aNotifier);
   783 		OpenL(aUid, aNotifier);
   713 		if(iRepository->IsTransactionActive())			
   784 		if(iRepository->IsTransactionActive())			
   714 			{
   785 			{
   715 			// Fail transactions on any currently open session
   786 			// Fail transactions on any currently open session
   716 			iRepository->FailAllTransactions(NULL);
   787 			iRepository->FailAllTransactions(NULL);
   717 			}
   788 			}
   718 		
   789 		
   719 		// Create ROM rep for merging
   790 		// Create a ROM repository for merging.
   720 	 	CSharedRepository *romRep = 0;
   791 	 	CSharedRepository *romRep = 0;
   721 		TRAPD( err, TServerResources::iObserver->LoadRepositoryLC(aUid, ETrue, romRep, CIniFileIn::ERomOnly); CleanupStack::Pop(romRep) );
   792 		TRAPD( err, TServerResources::iObserver->LoadRepositoryLC(aUid, ETrue, romRep, CIniFileIn::ERomOnly); CleanupStack::Pop(romRep) );
   722 
   793 		
   723 		if (err == KErrNone)
   794 		if (err == KErrNone)
   724 		    {
   795 		    {    
   725             // Perform merge
   796 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
   797             // Need to check incase it is a protected repository.
       
   798             if ( romRep->iSimRep->KeyspaceType() == EPMAKeyspace )
       
   799                 {
       
   800                 User::Leave(KErrNotSupported);
       
   801                 }
       
   802 #endif  
       
   803             // Perform merge of the persists and ROM repositories.
   726             TRAP( err, iRepository->HandleDeleteMergeL(*romRep) );
   804             TRAP( err, iRepository->HandleDeleteMergeL(*romRep) );
   727 		    }
   805 		    }
   728 		if (romRep!=NULL)
   806 		if (romRep!=NULL)
   729 		    {
   807 		    {
   730             delete romRep;
   808             delete romRep;
  1006 	}
  1084 	}
  1007 
  1085 
  1008 void CServerRepository::BackupInstallRepositoryL(TUid aUid, CStreamStore& aStore, TStreamId& aSettingStreamId)
  1086 void CServerRepository::BackupInstallRepositoryL(TUid aUid, CStreamStore& aStore, TStreamId& aSettingStreamId)
  1009 	{
  1087 	{
  1010 	TServerResources::iObserver->LoadRepositoryLC(aUid, EFalse, iRepository, CIniFileIn::EInstallOnly);
  1088 	TServerResources::iObserver->LoadRepositoryLC(aUid, EFalse, iRepository, CIniFileIn::EInstallOnly);
  1011 	iUid = aUid;
  1089 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
  1012 	StoreRepositorySettingValuesL(aStore, aSettingStreamId);	
  1090 	// Protected repositories should not be part of Backup and Restore.
  1013 	CleanupStack::PopAndDestroy(iRepository);
  1091     if (iRepository->iSimRep->KeyspaceType() != EPMAKeyspace)
  1014 	iRepository = NULL;
  1092         {
       
  1093 #endif
       
  1094         iUid = aUid;
       
  1095         StoreRepositorySettingValuesL(aStore, aSettingStreamId);  
       
  1096 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC
       
  1097         }  
       
  1098 #endif
       
  1099         CleanupStack::PopAndDestroy(iRepository);
       
  1100         iRepository = NULL;
  1015 	}
  1101 	}
  1016 
  1102 
  1017 TInt CServerRepository::CheckAccessPolicyBeforeMoving(const TClientRequest& aMessage, const TServerSetting* aSourceSetting, 
  1103 TInt CServerRepository::CheckAccessPolicyBeforeMoving(const TClientRequest& aMessage, const TServerSetting* aSourceSetting, 
  1018 				TUint32 aSourceKey, const TServerSetting* aTargetSetting, TUint32 aTargetKey, TUint32& aErrorKey)
  1104 				TUint32 aSourceKey, const TServerSetting* aTargetSetting, TUint32 aTargetKey, TUint32& aErrorKey)
  1019 	{
  1105 	{