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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(const TServerSetting& aSetting)
18 return iSimRep->GetReadAccessPolicy(aSetting);
21 inline const TSecurityPolicy& CSharedRepository::GetReadAccessPolicy(TUint32 aId)
23 return iSimRep->GetReadAccessPolicy(aId);
26 inline const TSecurityPolicy& CSharedRepository::GetDefaultReadAccessPolicy()
28 return iSimRep->GetDefaultReadAccessPolicy();
31 inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(const TServerSetting& aSetting)
33 return iSimRep->GetWriteAccessPolicy(aSetting);
36 inline const TSecurityPolicy& CSharedRepository::GetWriteAccessPolicy(TUint32 aId)
38 return iSimRep->GetWriteAccessPolicy(aId);
41 inline const TSecurityPolicy& CSharedRepository::GetDefaultWriteAccessPolicy()
43 return iSimRep->GetDefaultWriteAccessPolicy();
46 inline void CSharedRepository::WriteBackupStream(RWriteStream& aStream) const
48 iSimRep->SettingsArray().WriteBackupStream(aStream) ;
49 aStream << iSimRep->Uid() ;
50 aStream << iSimRep->Owner() ;
51 aStream << iSimRep->TimeStamp().Int64() ;
53 aStream << iSimRep->RangePolicyArray() ;
54 aStream << iSimRep->GetDefaultReadAccessPolicy().Package() ;
55 aStream << iSimRep->GetDefaultWriteAccessPolicy().Package() ;
57 aStream << iSimRep->DefaultMeta() ;
58 aStream << iSimRep->RangeMetaArray();
60 // placeholders for 3 booleans that should never have been externalised
61 TInt8 dummyBoolValue = 0;
62 aStream << dummyBoolValue;
63 aStream << dummyBoolValue;
64 aStream << dummyBoolValue;
67 inline void CSharedRepository::WriteDeletedSettingsStream(RWriteStream& aStream) const
69 TCardinality numDeletedSettings = iSimRep->DeletedSettingsArray().Count() ;
70 aStream << numDeletedSettings ;
71 for (TInt i = 0; i < numDeletedSettings; i++)
73 aStream << iSimRep->DeletedSettingsArray()[i] ;
77 inline void CSharedRepository::InternalizeL(RReadStream& aStream, CRestoredRepository& aRstRepos)
79 RSettingsArray mergeArray;
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.
89 // For CommsDat repository(KCommsDatUid) and test repository(KTestUid) ,replace all the
90 // current settings with the settings from the backup file
93 if((iSimRep->Uid() == KCommsDatUid) || (iSimRep->Uid() == KTestUid))
95 if (iSimRep->Uid() == KCommsDatUid)
98 User::LeaveIfError(iSimRep->SettingsArray().ReplaceMerge(mergeArray, iSimRep->DeletedSettingsArray()));
102 User::LeaveIfError(iSimRep->SettingsArray().MergeArray(mergeArray, iSimRep->DeletedSettingsArray(), ERestoreMerge));
105 TInt numChanges = mergeArray.Count();
106 for (TInt i = 0; i < numChanges; i++)
108 aRstRepos.AddKeyL(mergeArray[i].Key());
112 iSimRep->SetUid(repUid);
114 aStream >> repOwner ;
115 iSimRep->SetOwner(repOwner);
117 TInt64 timeStampInt ;
118 aStream >> timeStampInt ;
119 iSimRep->SetTimeStamp(timeStampInt);
121 TInt32 numElements = iSimRep->SettingsArray().Count();
122 for (TInt32 count = 0; count < numElements; count++)
124 iSimRep->SettingsArray()[count].SetAccessPolicy(GetFallbackAccessPolicy(count));
126 iSimRep->RangePolicyArray().Reset();
127 iSimRep->RangePolicyArray().InternalizeL(aStream);
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) ;
139 iSimRep->SetDefaultPolicy(TSettingsAccessPolicy(defaultReadPolicy,defaultWritePolicy, KUnspecifiedKey));
142 aStream >> defaultMeta ;
143 iSimRep->SetDefaultMeta(defaultMeta);
145 iSimRep->RangeMetaArray().Reset();
146 iSimRep->RangeMetaArray().InternalizeL(aStream);
148 // placeholders for 3 booleans that should never have been externalised
149 TInt8 dummyBoolValue;
150 aStream >> dummyBoolValue;
151 aStream >> dummyBoolValue;
152 aStream >> dummyBoolValue;
155 inline void CSharedRepository::SetSize(TInt aSize)
160 inline TInt CSharedRepository::Size() const