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