persistentstorage/centralrepository/cenrepsrv/srvrepos_noc.cpp
branchRCL_3
changeset 8 fa9941cf3867
parent 1 c084286672be
child 23 26645d81f48d
equal deleted inserted replaced
6:5ffdb8f2067f 8:fa9941cf3867
    78 	}
    78 	}
    79 	
    79 	
    80 /**
    80 /**
    81 Attempt to reset a single key to it's value in the file in the given location. Routine
    81 Attempt to reset a single key to it's value in the file in the given location. Routine
    82 attempts to find a .cre file first. If ( and only if ) a cre file doesn't exist the 
    82 attempts to find a .cre file first. If ( and only if ) a cre file doesn't exist the 
       
    83 routine attempts to find a txt file. In the presence of multi rofs, it needs to perform
       
    84 merging of all the rom keyspaces first before doing a reset, hence we are not able to perform
       
    85 the reading line by line for efficiency purpose.
       
    86 */
       
    87 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS	
       
    88 void CServerRepository::ResetFromIniFileL(TUint32 aId, 
       
    89 										  CIniFileIn::TIniFileOpenMode aIniFileOpenMode,
       
    90 										  TBool& aKeyFound)
       
    91 	{
       
    92 	aKeyFound=EFalse;
       
    93 
       
    94 	CSharedRepository* rep=NULL;
       
    95 	// Attempt to reset key to the aLocation if exist
       
    96 	//dont fail if repository not found
       
    97 	TServerResources::iObserver->LoadRepositoryLC(iRepository->Uid(),EFalse,rep,aIniFileOpenMode);
       
    98 	
       
    99 	if (rep)
       
   100 		{
       
   101 		TServerSetting* s = rep->GetSettings().Find(aId);					
       
   102 		if(s)
       
   103 			{
       
   104 			aKeyFound=ETrue;
       
   105 			// Mark the setting as default again
       
   106 			s->SetClean();
       
   107 			iRepository->ResetAndPersistL(*s);
       
   108 			s->SetAccessPolicy(GetFallbackAccessPolicy(aId));
       
   109 			}
       
   110 		}
       
   111 	CleanupStack::PopAndDestroy(rep);
       
   112 	}
       
   113 #else
       
   114 /**
       
   115 Attempt to reset a single key to it's value in the file in the given location. Routine
       
   116 attempts to find a .cre file first. If ( and only if ) a cre file doesn't exist the 
    83 routine attempts to find a txt file.
   117 routine attempts to find a txt file.
    84 Note that it would be possible to use LoadRepositoryLC here but for the txt file
   118 Note that it would be possible to use LoadRepositoryLC here but for the txt file
    85 that would take longer. This is because in LoadRepositoryLC the txt file is 
   119 that would take longer. This is because in LoadRepositoryLC the txt file is 
    86 completely processed. The Reset specific txt file opening code below is quicker because 
   120 completely processed. The Reset specific txt file opening code below is quicker because 
    87 it is just attempting to find the reset key.
   121 it is just attempting to find the reset key.
    88 */
   122 */
    89 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS	
       
    90 void CServerRepository::ResetFromIniFileL(TUint32 aId, 
       
    91 										  CIniFileIn::TIniFileOpenMode aIniFileOpenMode,
       
    92 										  TBool& aKeyFound)
       
    93 	{
       
    94 	aKeyFound=EFalse;
       
    95 
       
    96 	CSharedRepository* rep=NULL;
       
    97 	// Attempt to reset key to the aLocation if exist
       
    98 	//dont fail if repository not found
       
    99 	TServerResources::iObserver->LoadRepositoryLC(iRepository->Uid(),EFalse,rep,aIniFileOpenMode);
       
   100 	
       
   101 	if (rep)
       
   102 		{
       
   103 		TServerSetting* s = rep->GetSettings().Find(aId);					
       
   104 		if(s)
       
   105 			{
       
   106 			aKeyFound=ETrue;
       
   107 			// Mark the setting as default again
       
   108 			s->SetClean();
       
   109 			iRepository->ResetAndPersistL(*s);
       
   110 			s->SetAccessPolicy(GetFallbackAccessPolicy(aId));
       
   111 			}
       
   112 		}
       
   113 	CleanupStack::PopAndDestroy(rep);
       
   114 	}
       
   115 #else
       
   116 void CServerRepository::ResetFromIniFileL(TUint32 aId, 
   123 void CServerRepository::ResetFromIniFileL(TUint32 aId, 
   117 										  TCentRepLocation aLocation,
   124 										  TCentRepLocation aLocation,
   118 										  TBool& aKeyFound)
   125 										  TBool& aKeyFound)
   119 	{
   126 	{
   120 	aKeyFound=EFalse;
   127 	aKeyFound=EFalse;
   446 		{		
   453 		{		
   447 		// Reset against install repository if only the install file exists
   454 		// Reset against install repository if only the install file exists
   448 		TServerResources::iObserver->LoadRepositoryLC(uid, ETrue, defaultRepository, CIniFileIn::EInstallOnly);		
   455 		TServerResources::iObserver->LoadRepositoryLC(uid, ETrue, defaultRepository, CIniFileIn::EInstallOnly);		
   449 		}
   456 		}
   450 	else
   457 	else
   451 		{	
   458 		{
       
   459         // The repository must exist in the ROM or install directory (or both). 
       
   460         ASSERT(romExists || installExists);
   452 		// Reset against empty repository if neither ROM or install file are found
   461 		// Reset against empty repository if neither ROM or install file are found
   453 		defaultRepository = CSharedRepository::NewL(uid);
   462 		defaultRepository = CSharedRepository::NewL(uid);
   454 		CleanupStack::PushL(defaultRepository);
   463 		CleanupStack::PushL(defaultRepository);
   455 		}
   464 		}
   456 
   465