sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(const TServerSetting& aSetting) sl@0: { sl@0: return iSimRep->GetReadAccessPolicy(aSetting); sl@0: } sl@0: sl@0: inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(TUint32 aId) sl@0: { sl@0: return iSimRep->GetReadAccessPolicy(aId); sl@0: } sl@0: sl@0: inline const TSecurityPolicy& CSharedRepository::GetDefaultReadAccessPolicy() sl@0: { sl@0: return iSimRep->GetDefaultReadAccessPolicy(); sl@0: } sl@0: sl@0: inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(const TServerSetting& aSetting) sl@0: { sl@0: return iSimRep->GetWriteAccessPolicy(aSetting); sl@0: } sl@0: sl@0: inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(TUint32 aId) sl@0: { sl@0: return iSimRep->GetWriteAccessPolicy(aId); sl@0: } sl@0: sl@0: inline const TSecurityPolicy& CSharedRepository::GetDefaultWriteAccessPolicy() sl@0: { sl@0: return iSimRep->GetDefaultWriteAccessPolicy(); sl@0: } sl@0: sl@0: inline void CSharedRepository::WriteBackupStream(RWriteStream& aStream) const sl@0: { sl@0: iSimRep->SettingsArray().WriteBackupStream(aStream) ; sl@0: aStream << iSimRep->Uid() ; sl@0: aStream << iSimRep->Owner() ; sl@0: aStream << iSimRep->TimeStamp().Int64() ; sl@0: sl@0: aStream << iSimRep->RangePolicyArray() ; sl@0: aStream << iSimRep->GetDefaultReadAccessPolicy().Package() ; sl@0: aStream << iSimRep->GetDefaultWriteAccessPolicy().Package() ; sl@0: sl@0: aStream << iSimRep->DefaultMeta() ; sl@0: aStream << iSimRep->RangeMetaArray(); sl@0: sl@0: // placeholders for 3 booleans that should never have been externalised sl@0: TInt8 dummyBoolValue = 0; sl@0: aStream << dummyBoolValue; sl@0: aStream << dummyBoolValue; sl@0: aStream << dummyBoolValue; sl@0: } sl@0: sl@0: inline void CSharedRepository::WriteDeletedSettingsStream(RWriteStream& aStream) const sl@0: { sl@0: TCardinality numDeletedSettings = iSimRep->DeletedSettingsArray().Count() ; sl@0: aStream << numDeletedSettings ; sl@0: for (TInt i = 0; i < numDeletedSettings; i++) sl@0: { sl@0: aStream << iSimRep->DeletedSettingsArray()[i] ; sl@0: } sl@0: } sl@0: sl@0: inline void CSharedRepository::InternalizeL(RReadStream& aStream, CRestoredRepository& aRstRepos) sl@0: { sl@0: RSettingsArray mergeArray; sl@0: sl@0: sl@0: aStream >> mergeArray ; sl@0: // Many keys-value pairs were restored from the backup file to mergeArray. But most of sl@0: // the pairs are the same as what are currently in the repository. To prevent too many sl@0: // notifications with no changed values, we only merge the keys whose values are going sl@0: // to be changed by passing EFalse to parameter aKeyOnly. Thus, mergeArray will only sl@0: // contains the really changed keys after merging. sl@0: sl@0: // For CommsDat repository(KCommsDatUid) and test repository(KTestUid) ,replace all the sl@0: // current settings with the settings from the backup file sl@0: sl@0: #ifdef _DEBUG sl@0: if((iSimRep->Uid() == KCommsDatUid) || (iSimRep->Uid() == KTestUid)) sl@0: #else sl@0: if (iSimRep->Uid() == KCommsDatUid) sl@0: #endif sl@0: { sl@0: User::LeaveIfError(iSimRep->SettingsArray().ReplaceMerge(mergeArray, iSimRep->DeletedSettingsArray())); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iSimRep->SettingsArray().MergeArray(mergeArray, iSimRep->DeletedSettingsArray(), ERestoreMerge)); sl@0: } sl@0: sl@0: TInt numChanges = mergeArray.Count(); sl@0: for (TInt i = 0; i < numChanges; i++) sl@0: { sl@0: aRstRepos.AddKeyL(mergeArray[i].Key()); sl@0: } sl@0: TUid repUid; sl@0: aStream >> repUid ; sl@0: iSimRep->SetUid(repUid); sl@0: TUid repOwner; sl@0: aStream >> repOwner ; sl@0: iSimRep->SetOwner(repOwner); sl@0: sl@0: TInt64 timeStampInt ; sl@0: aStream >> timeStampInt ; sl@0: iSimRep->SetTimeStamp(timeStampInt); sl@0: sl@0: TInt32 numElements = iSimRep->SettingsArray().Count(); sl@0: for (TInt32 count = 0; count < numElements; count++) sl@0: { sl@0: iSimRep->SettingsArray()[count].SetAccessPolicy(GetFallbackAccessPolicy(count)); sl@0: } sl@0: iSimRep->RangePolicyArray().Reset(); sl@0: iSimRep->RangePolicyArray().InternalizeL(aStream); sl@0: sl@0: HBufC8* securityPolicyPackage ; sl@0: securityPolicyPackage = HBufC8::NewLC(aStream, 10000) ; sl@0: TSecurityPolicy defaultReadPolicy; sl@0: defaultReadPolicy.Set(securityPolicyPackage->Des()) ; sl@0: CleanupStack::PopAndDestroy(securityPolicyPackage) ; sl@0: securityPolicyPackage = HBufC8::NewLC(aStream, 10000) ; sl@0: TSecurityPolicy defaultWritePolicy; sl@0: defaultWritePolicy.Set(securityPolicyPackage->Des()) ; sl@0: CleanupStack::PopAndDestroy(securityPolicyPackage) ; sl@0: sl@0: iSimRep->SetDefaultPolicy(TSettingsAccessPolicy(defaultReadPolicy,defaultWritePolicy, KUnspecifiedKey)); sl@0: sl@0: TUint32 defaultMeta; sl@0: aStream >> defaultMeta ; sl@0: iSimRep->SetDefaultMeta(defaultMeta); sl@0: sl@0: iSimRep->RangeMetaArray().Reset(); sl@0: iSimRep->RangeMetaArray().InternalizeL(aStream); sl@0: sl@0: // placeholders for 3 booleans that should never have been externalised sl@0: TInt8 dummyBoolValue; sl@0: aStream >> dummyBoolValue; sl@0: aStream >> dummyBoolValue; sl@0: aStream >> dummyBoolValue; sl@0: } sl@0: sl@0: inline void CSharedRepository::SetSize(TInt aSize) sl@0: { sl@0: iSize=aSize; sl@0: } sl@0: sl@0: inline TInt CSharedRepository::Size() const sl@0: { sl@0: return iSize; sl@0: }