1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/cenrepsrv/shrepos.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,163 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(const TServerSetting& aSetting)
1.20 + {
1.21 + return iSimRep->GetReadAccessPolicy(aSetting);
1.22 + }
1.23 +
1.24 +inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(TUint32 aId)
1.25 + {
1.26 + return iSimRep->GetReadAccessPolicy(aId);
1.27 + }
1.28 +
1.29 +inline const TSecurityPolicy& CSharedRepository::GetDefaultReadAccessPolicy()
1.30 + {
1.31 + return iSimRep->GetDefaultReadAccessPolicy();
1.32 + }
1.33 +
1.34 +inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(const TServerSetting& aSetting)
1.35 + {
1.36 + return iSimRep->GetWriteAccessPolicy(aSetting);
1.37 + }
1.38 +
1.39 +inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(TUint32 aId)
1.40 + {
1.41 + return iSimRep->GetWriteAccessPolicy(aId);
1.42 + }
1.43 +
1.44 +inline const TSecurityPolicy& CSharedRepository::GetDefaultWriteAccessPolicy()
1.45 + {
1.46 + return iSimRep->GetDefaultWriteAccessPolicy();
1.47 + }
1.48 +
1.49 +inline void CSharedRepository::WriteBackupStream(RWriteStream& aStream) const
1.50 + {
1.51 + iSimRep->SettingsArray().WriteBackupStream(aStream) ;
1.52 + aStream << iSimRep->Uid() ;
1.53 + aStream << iSimRep->Owner() ;
1.54 + aStream << iSimRep->TimeStamp().Int64() ;
1.55 +
1.56 + aStream << iSimRep->RangePolicyArray() ;
1.57 + aStream << iSimRep->GetDefaultReadAccessPolicy().Package() ;
1.58 + aStream << iSimRep->GetDefaultWriteAccessPolicy().Package() ;
1.59 +
1.60 + aStream << iSimRep->DefaultMeta() ;
1.61 + aStream << iSimRep->RangeMetaArray();
1.62 +
1.63 + // placeholders for 3 booleans that should never have been externalised
1.64 + TInt8 dummyBoolValue = 0;
1.65 + aStream << dummyBoolValue;
1.66 + aStream << dummyBoolValue;
1.67 + aStream << dummyBoolValue;
1.68 + }
1.69 +
1.70 +inline void CSharedRepository::WriteDeletedSettingsStream(RWriteStream& aStream) const
1.71 + {
1.72 + TCardinality numDeletedSettings = iSimRep->DeletedSettingsArray().Count() ;
1.73 + aStream << numDeletedSettings ;
1.74 + for (TInt i = 0; i < numDeletedSettings; i++)
1.75 + {
1.76 + aStream << iSimRep->DeletedSettingsArray()[i] ;
1.77 + }
1.78 + }
1.79 +
1.80 +inline void CSharedRepository::InternalizeL(RReadStream& aStream, CRestoredRepository& aRstRepos)
1.81 + {
1.82 + RSettingsArray mergeArray;
1.83 +
1.84 +
1.85 + aStream >> mergeArray ;
1.86 + // Many keys-value pairs were restored from the backup file to mergeArray. But most of
1.87 + // the pairs are the same as what are currently in the repository. To prevent too many
1.88 + // notifications with no changed values, we only merge the keys whose values are going
1.89 + // to be changed by passing EFalse to parameter aKeyOnly. Thus, mergeArray will only
1.90 + // contains the really changed keys after merging.
1.91 +
1.92 + // For CommsDat repository(KCommsDatUid) and test repository(KTestUid) ,replace all the
1.93 + // current settings with the settings from the backup file
1.94 +
1.95 +#ifdef _DEBUG
1.96 + if((iSimRep->Uid() == KCommsDatUid) || (iSimRep->Uid() == KTestUid))
1.97 +#else
1.98 + if (iSimRep->Uid() == KCommsDatUid)
1.99 +#endif
1.100 + {
1.101 + User::LeaveIfError(iSimRep->SettingsArray().ReplaceMerge(mergeArray, iSimRep->DeletedSettingsArray()));
1.102 + }
1.103 + else
1.104 + {
1.105 + User::LeaveIfError(iSimRep->SettingsArray().MergeArray(mergeArray, iSimRep->DeletedSettingsArray(), ERestoreMerge));
1.106 + }
1.107 +
1.108 + TInt numChanges = mergeArray.Count();
1.109 + for (TInt i = 0; i < numChanges; i++)
1.110 + {
1.111 + aRstRepos.AddKeyL(mergeArray[i].Key());
1.112 + }
1.113 + TUid repUid;
1.114 + aStream >> repUid ;
1.115 + iSimRep->SetUid(repUid);
1.116 + TUid repOwner;
1.117 + aStream >> repOwner ;
1.118 + iSimRep->SetOwner(repOwner);
1.119 +
1.120 + TInt64 timeStampInt ;
1.121 + aStream >> timeStampInt ;
1.122 + iSimRep->SetTimeStamp(timeStampInt);
1.123 +
1.124 + TInt32 numElements = iSimRep->SettingsArray().Count();
1.125 + for (TInt32 count = 0; count < numElements; count++)
1.126 + {
1.127 + iSimRep->SettingsArray()[count].SetAccessPolicy(GetFallbackAccessPolicy(count));
1.128 + }
1.129 + iSimRep->RangePolicyArray().Reset();
1.130 + iSimRep->RangePolicyArray().InternalizeL(aStream);
1.131 +
1.132 + HBufC8* securityPolicyPackage ;
1.133 + securityPolicyPackage = HBufC8::NewLC(aStream, 10000) ;
1.134 + TSecurityPolicy defaultReadPolicy;
1.135 + defaultReadPolicy.Set(securityPolicyPackage->Des()) ;
1.136 + CleanupStack::PopAndDestroy(securityPolicyPackage) ;
1.137 + securityPolicyPackage = HBufC8::NewLC(aStream, 10000) ;
1.138 + TSecurityPolicy defaultWritePolicy;
1.139 + defaultWritePolicy.Set(securityPolicyPackage->Des()) ;
1.140 + CleanupStack::PopAndDestroy(securityPolicyPackage) ;
1.141 +
1.142 + iSimRep->SetDefaultPolicy(TSettingsAccessPolicy(defaultReadPolicy,defaultWritePolicy, KUnspecifiedKey));
1.143 +
1.144 + TUint32 defaultMeta;
1.145 + aStream >> defaultMeta ;
1.146 + iSimRep->SetDefaultMeta(defaultMeta);
1.147 +
1.148 + iSimRep->RangeMetaArray().Reset();
1.149 + iSimRep->RangeMetaArray().InternalizeL(aStream);
1.150 +
1.151 + // placeholders for 3 booleans that should never have been externalised
1.152 + TInt8 dummyBoolValue;
1.153 + aStream >> dummyBoolValue;
1.154 + aStream >> dummyBoolValue;
1.155 + aStream >> dummyBoolValue;
1.156 + }
1.157 +
1.158 +inline void CSharedRepository::SetSize(TInt aSize)
1.159 + {
1.160 + iSize=aSize;
1.161 + }
1.162 +
1.163 +inline TInt CSharedRepository::Size() const
1.164 + {
1.165 + return iSize;
1.166 + }