|
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 #ifndef SETTING_H |
|
17 #define SETTING_H |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <s32strm.h> |
|
21 |
|
22 #include "centralrepository.h" |
|
23 #include "srvdefs.h" |
|
24 |
|
25 class TSettingsAccessPolicy; |
|
26 |
|
27 /** |
|
28 @internalTechnology |
|
29 */ |
|
30 class TServerSetting |
|
31 { |
|
32 friend class RSettingsArray; |
|
33 #if defined(SYMBIAN_CENTREP_SUPPORT_MULTIROFS) && defined(CENTRAL_REPOSITORY_SERVER_TESTING) |
|
34 friend class CenrepSrvOOMTest; |
|
35 #endif |
|
36 public: |
|
37 enum TType { EInt = 0x00000000, |
|
38 EReal = 0x10000000, |
|
39 EString = 0x20000000, |
|
40 EDeleted = 0x30000000 }; |
|
41 |
|
42 inline TServerSetting(); |
|
43 inline TServerSetting(TUint32 aKey); |
|
44 |
|
45 inline TInt ReplaceTypeAndValue(const TServerSetting& source); |
|
46 inline TInt Replace(const TServerSetting& source); |
|
47 inline TInt Transfer(TServerSetting& source); |
|
48 |
|
49 inline TUint32 Key() const; |
|
50 inline void SetKey(TUint32 aKey); |
|
51 inline TUint32 Meta() const; |
|
52 inline void SetMeta(const TUint32 aMeta); |
|
53 inline TBool IsClean(){return(iMeta & KMetaDefaultValue);}; |
|
54 inline void SetClean(){iMeta |= KMetaDefaultValue;}; |
|
55 inline void SetNotClean(){iMeta &=~KMetaDefaultValue;}; |
|
56 inline TUint32 Type() const; |
|
57 inline void SetType(const TUint32 aType); |
|
58 |
|
59 inline TInt GetIntValue() const; |
|
60 inline const TReal& GetRealValue() const; |
|
61 inline const HBufC8* GetStrValue() const; |
|
62 |
|
63 inline void SetIntValue(TInt aVal); |
|
64 inline void SetRealValue(const TReal* aVal); |
|
65 inline void SetStrValue(const HBufC8* aVal); |
|
66 |
|
67 inline void SetDeleted(); |
|
68 |
|
69 inline void CopyValueL(TInt aVal); |
|
70 inline void CopyValueL(const TReal& aVal); |
|
71 inline void CopyValueL(const TDesC8& aVal); |
|
72 |
|
73 inline TInt CopyValue(TInt aVal); |
|
74 inline TInt CopyValue(const TReal& aVal); |
|
75 inline TInt CopyValue(const TDesC8& aVal); |
|
76 |
|
77 inline TInt AssignValueTo(TInt& aVal) const; |
|
78 inline TInt AssignValueTo(TReal& aVal) const; |
|
79 inline TInt AssignValueTo(TDes8& aVal) const; |
|
80 |
|
81 inline TInt AssignValueFrom(TInt aVal); |
|
82 inline TInt AssignValueFrom(const TReal& aVal); |
|
83 inline TInt AssignValueFrom(const TDesC8& aVal); |
|
84 |
|
85 inline void PushL() const; |
|
86 inline void Pop() const; |
|
87 inline void PopAndDestroy() const; |
|
88 |
|
89 inline void Reset(); |
|
90 inline void ResetValue(); |
|
91 |
|
92 inline TInt operator==(const TServerSetting& aSetting) const; |
|
93 inline TInt operator==(TInt aVal) const; |
|
94 inline TInt operator==(const TReal& aVal) const; |
|
95 inline TInt operator==(const TDesC8& aVal) const; |
|
96 |
|
97 template <class T> |
|
98 inline TInt operator!=(const T& aVal) const |
|
99 { |
|
100 return !operator==(aVal); |
|
101 } |
|
102 |
|
103 inline TSettingsAccessPolicy* AccessPolicy() const; |
|
104 inline void SetAccessPolicy(TSettingsAccessPolicy* aPolicy); |
|
105 inline const TSecurityPolicy* GetReadAccessPolicy() const; |
|
106 inline const TSecurityPolicy* GetWriteAccessPolicy() const; |
|
107 inline TBool HasAccessPolicy() const; |
|
108 |
|
109 inline void ExternalizeL(RWriteStream& aStream) const; |
|
110 inline void InternalizeL(RReadStream& aStream); |
|
111 inline void ExternalizeMetaL(RWriteStream& aStream) const; |
|
112 inline void InternalizeMetaL(RReadStream& aStream); |
|
113 |
|
114 inline TBool IsType(const TInt&) const; |
|
115 inline TBool IsType(const TReal&) const; |
|
116 inline TBool IsType(const TDesC8&) const; |
|
117 inline TBool IsType(const TDesC16&) const; |
|
118 |
|
119 inline TBool IsInt() const; |
|
120 inline TBool IsReal() const; |
|
121 inline TBool IsStr() const; |
|
122 inline TBool IsDeleted() const; |
|
123 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
124 inline TInt CopyTypeValue(const TServerSetting& source); |
|
125 inline void SetIndividualMeta(TBool aIndividualSettingMeta); |
|
126 inline TBool IsIndividualMeta() const {return (iMeta & KMetaIndividual);}; |
|
127 #endif |
|
128 |
|
129 private: |
|
130 TUint32 iKey; |
|
131 TUint32 iMeta; |
|
132 union TValue { TInt i; TReal* r; HBufC8* s; } iValue; |
|
133 |
|
134 // A bit of dilemma how to store TSecurePolicy for read/write access... |
|
135 // If we were implementing a list of policies per an entry then RArray would be an obvious choice, |
|
136 // but even then when no policy is specified each entry would have RArray (in compressed state 24B) |
|
137 // Or we could have two instances of TSecurePolicy (6B each) |
|
138 // so lets go for a link to a separate array of policies allocated only when needed |
|
139 |
|
140 TSettingsAccessPolicy* iAccessPolicy; |
|
141 }; |
|
142 |
|
143 /** |
|
144 @internalTechnology |
|
145 */ |
|
146 class TSettingsAccessPolicy |
|
147 { |
|
148 friend class CSharedRepository; |
|
149 friend class CHeapRepository; |
|
150 friend class CIniFileOut; |
|
151 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
152 friend class CObservable; |
|
153 #endif |
|
154 public: |
|
155 // Single entry type is maintained in a separate array |
|
156 // then the range type... to avoid duplicities |
|
157 enum {ESingleSettingPolicy,ERangeSettingsPolicy}; |
|
158 |
|
159 inline TSettingsAccessPolicy(TSecurityPolicy& aReadPolicy,TSecurityPolicy& aWritePolicy, |
|
160 TUint32 aLowKey, TUint32 aHighKey, TUint32 aKeyMask=0); |
|
161 inline TSettingsAccessPolicy(TSecurityPolicy& aReadPolicy,TSecurityPolicy& aWritePolicy, |
|
162 TUint32 aKey); |
|
163 |
|
164 |
|
165 inline TBool IsInRange(TUint32 aKey) const; |
|
166 inline const TSecurityPolicy* GetReadAccessPolicy() const; |
|
167 inline const TSecurityPolicy* GetWriteAccessPolicy() const; |
|
168 |
|
169 inline void ExternalizeL(RWriteStream& aStream) const; |
|
170 inline void InternalizeL(RReadStream& aStream) ; |
|
171 inline TSettingsAccessPolicy(); |
|
172 inline TUint32 LowKey() const; |
|
173 inline TUint32 HighKey() const; |
|
174 inline TUint32 KeyMask() const; |
|
175 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
176 inline TBool operator==(const TSettingsAccessPolicy& aPolicy) const |
|
177 { |
|
178 return Mem::Compare((TUint8*)this,sizeof(TSettingsAccessPolicy),(TUint8*)(&aPolicy),sizeof(TSettingsAccessPolicy)); |
|
179 } |
|
180 #endif |
|
181 private: |
|
182 inline TSettingsAccessPolicy(TUint32 key); |
|
183 private: |
|
184 // we can have 'duplicites' where a single policy would have the same key |
|
185 // as 'range' policy with the low key... |
|
186 TUint32 iLowKey; // used as a key for single policy as well |
|
187 /** |
|
188 for single key this is used to indicate whether read policy is specified or is default |
|
189 note this is only applies to single policy when SYMBIAN_CENTREP_SUPPORT_MULTIROFS is defined |
|
190 */ |
|
191 TUint32 iHighKey; // only used for Range |
|
192 /** |
|
193 for single key this is used to indicate whether write policy is specified or is default |
|
194 note this is only applies to single policy when SYMBIAN_CENTREP_SUPPORT_MULTIROFS is defined |
|
195 */ |
|
196 TUint32 iKeyMask; // only used for Range |
|
197 |
|
198 |
|
199 TSecurityPolicy iReadAccessPolicy; |
|
200 TSecurityPolicy iWriteAccessPolicy; |
|
201 |
|
202 }; |
|
203 |
|
204 /** |
|
205 @internalTechnology |
|
206 */ |
|
207 class TSettingsDefaultMeta |
|
208 { |
|
209 friend class CSharedRepository; |
|
210 public: |
|
211 inline TSettingsDefaultMeta(TUint32 aValue, TUint32 aLowKey, |
|
212 TUint32 aHighKey, TUint32 aKeyMask=0); |
|
213 |
|
214 inline TBool IsInRange(TUint32 aKey) const; |
|
215 inline TSettingsDefaultMeta(); |
|
216 |
|
217 inline TUint32 GetDefaultMetadata() const |
|
218 { |
|
219 return iDefaultMetaData ; |
|
220 }; |
|
221 |
|
222 inline void ExternalizeL(RWriteStream& aStream) const; |
|
223 inline void InternalizeL(RReadStream& aStream) ; |
|
224 |
|
225 inline TUint32 LowKey() const; |
|
226 inline TUint32 HighKey() const; |
|
227 inline TUint32 KeyMask() const; |
|
228 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
229 inline TBool operator==(const TSettingsDefaultMeta& aMeta) const |
|
230 { |
|
231 return Mem::Compare((TUint8*)this,sizeof(TSettingsDefaultMeta),(TUint8*)(&aMeta),sizeof(TSettingsDefaultMeta)); |
|
232 } |
|
233 #endif |
|
234 private: |
|
235 TUint32 iLowKey; |
|
236 TUint32 iHighKey; |
|
237 TUint32 iKeyMask; |
|
238 TUint32 iDefaultMetaData; |
|
239 }; |
|
240 |
|
241 /** |
|
242 @internalTechnology |
|
243 */ |
|
244 class TSettingSingleMeta |
|
245 { |
|
246 public: |
|
247 inline TSettingSingleMeta(TUint32 aKey, TUint32 aMeta); |
|
248 inline TUint32 GetKey() const { return iKey; } |
|
249 inline TUint32 GetMeta() const { return iMeta; } |
|
250 |
|
251 private: |
|
252 TUint32 iKey; |
|
253 TUint32 iMeta; |
|
254 }; |
|
255 |
|
256 #include "setting.inl" |
|
257 |
|
258 #endif // SETTING_H |