os/persistentdata/persistentstorage/centralrepository/cenrepsrv/shrepos.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(const TServerSetting& aSetting)
    17 	{
    18 	return iSimRep->GetReadAccessPolicy(aSetting);
    19 	}
    20 
    21 inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(TUint32 aId)
    22 	{
    23 	return iSimRep->GetReadAccessPolicy(aId);
    24 	}
    25 
    26 inline const TSecurityPolicy& CSharedRepository::GetDefaultReadAccessPolicy()
    27 	{
    28 	return iSimRep->GetDefaultReadAccessPolicy();
    29 	}
    30 
    31 inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(const TServerSetting& aSetting)
    32 	{
    33 	return iSimRep->GetWriteAccessPolicy(aSetting);
    34 	}
    35 
    36 inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(TUint32 aId)
    37 	{
    38 	return iSimRep->GetWriteAccessPolicy(aId);
    39 	}
    40 	
    41 inline const TSecurityPolicy& CSharedRepository::GetDefaultWriteAccessPolicy()
    42 	{
    43 	return iSimRep->GetDefaultWriteAccessPolicy();
    44 	}
    45 
    46 inline void CSharedRepository::WriteBackupStream(RWriteStream& aStream) const
    47 	{
    48 	iSimRep->SettingsArray().WriteBackupStream(aStream) ;
    49 	aStream << iSimRep->Uid() ;
    50 	aStream << iSimRep->Owner() ;
    51 	aStream << iSimRep->TimeStamp().Int64() ;
    52 		
    53 	aStream << iSimRep->RangePolicyArray() ;
    54 	aStream << iSimRep->GetDefaultReadAccessPolicy().Package() ;
    55 	aStream << iSimRep->GetDefaultWriteAccessPolicy().Package() ;
    56 	
    57 	aStream << iSimRep->DefaultMeta() ;
    58 	aStream << iSimRep->RangeMetaArray();
    59 
    60 	// placeholders for 3 booleans that should never have been externalised
    61 	TInt8 dummyBoolValue = 0;
    62 	aStream << dummyBoolValue;
    63 	aStream << dummyBoolValue;
    64 	aStream << dummyBoolValue;	
    65 	}
    66 	
    67 inline void CSharedRepository::WriteDeletedSettingsStream(RWriteStream& aStream) const
    68 	{
    69 	TCardinality numDeletedSettings = iSimRep->DeletedSettingsArray().Count() ;
    70 	aStream << numDeletedSettings ;
    71 	for (TInt i = 0; i < numDeletedSettings; i++)
    72 		{
    73 		aStream << iSimRep->DeletedSettingsArray()[i] ;	
    74 		}	
    75 	}	
    76 
    77 inline void CSharedRepository::InternalizeL(RReadStream& aStream, CRestoredRepository& aRstRepos)
    78 	{
    79  	RSettingsArray mergeArray;
    80 
    81  
    82  	aStream >> mergeArray ;
    83  	// Many keys-value pairs were restored from the backup file to mergeArray. But most of 
    84  	// the pairs are the same as what are currently in the repository. To prevent too many 
    85  	// notifications with no changed values, we only merge the keys whose values are going
    86  	// to be changed by passing EFalse to parameter aKeyOnly. Thus, mergeArray will only 
    87  	// contains the really changed keys after merging.
    88  	
    89 	// For CommsDat repository(KCommsDatUid) and test repository(KTestUid) ,replace all the
    90 	// current settings with the settings from the backup file
    91  	
    92 #ifdef _DEBUG
    93 	if((iSimRep->Uid() == KCommsDatUid) || (iSimRep->Uid() == KTestUid))
    94 #else
    95 	if (iSimRep->Uid() == KCommsDatUid)
    96 #endif					
    97 		{
    98 		User::LeaveIfError(iSimRep->SettingsArray().ReplaceMerge(mergeArray, iSimRep->DeletedSettingsArray()));
    99 		}
   100 	else
   101 		{        
   102 		User::LeaveIfError(iSimRep->SettingsArray().MergeArray(mergeArray, iSimRep->DeletedSettingsArray(), ERestoreMerge));
   103 		}
   104 
   105  	TInt numChanges = mergeArray.Count();
   106 	for (TInt i = 0; i < numChanges; i++)
   107 		{
   108 		aRstRepos.AddKeyL(mergeArray[i].Key());
   109 		}
   110 	TUid repUid;
   111  	aStream >> repUid ;
   112  	iSimRep->SetUid(repUid);
   113  	TUid repOwner;
   114 	aStream >> repOwner ;
   115 	iSimRep->SetOwner(repOwner);
   116 	
   117 	TInt64 timeStampInt ;
   118 	aStream >> timeStampInt ;
   119 	iSimRep->SetTimeStamp(timeStampInt);
   120 
   121 	TInt32 numElements = iSimRep->SettingsArray().Count();
   122 	for (TInt32 count = 0; count < numElements; count++)
   123 		{
   124 		iSimRep->SettingsArray()[count].SetAccessPolicy(GetFallbackAccessPolicy(count));
   125 		}
   126 	iSimRep->RangePolicyArray().Reset();		
   127 	iSimRep->RangePolicyArray().InternalizeL(aStream);
   128 	
   129 	HBufC8* securityPolicyPackage ;
   130 	securityPolicyPackage = HBufC8::NewLC(aStream, 10000) ;
   131 	TSecurityPolicy defaultReadPolicy;
   132 	defaultReadPolicy.Set(securityPolicyPackage->Des()) ;
   133 	CleanupStack::PopAndDestroy(securityPolicyPackage) ;
   134 	securityPolicyPackage = HBufC8::NewLC(aStream, 10000) ;
   135 	TSecurityPolicy defaultWritePolicy;
   136 	defaultWritePolicy.Set(securityPolicyPackage->Des()) ;
   137 	CleanupStack::PopAndDestroy(securityPolicyPackage) ;
   138 	
   139 	iSimRep->SetDefaultPolicy(TSettingsAccessPolicy(defaultReadPolicy,defaultWritePolicy, KUnspecifiedKey));
   140 	
   141 	TUint32 defaultMeta;
   142 	aStream >> defaultMeta ;
   143 	iSimRep->SetDefaultMeta(defaultMeta);
   144 	
   145 	iSimRep->RangeMetaArray().Reset();
   146 	iSimRep->RangeMetaArray().InternalizeL(aStream);
   147 
   148 	// placeholders for 3 booleans that should never have been externalised
   149 	TInt8 dummyBoolValue;
   150 	aStream >> dummyBoolValue;
   151 	aStream >> dummyBoolValue;
   152 	aStream >> dummyBoolValue;
   153 	}
   154 
   155 inline void CSharedRepository::SetSize(TInt aSize) 
   156 	{ 
   157 	iSize=aSize;
   158 	}
   159 
   160 inline TInt CSharedRepository::Size() const 
   161 	{ 
   162 	return iSize;
   163 	}