1 /* |
|
2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CENTRALREPOSITORY_H__ |
|
20 #define __CENTRALREPOSITORY_H__ |
|
21 |
|
22 #include "mussettingskeys.h" |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 |
|
27 namespace NCentralRepositoryConstants |
|
28 /** Namespace encapsulating the CentralRepository constants. |
|
29 @publishedAll |
|
30 @released |
|
31 */ |
|
32 { |
|
33 |
|
34 /** The maximum number of unicode characters that can be stored in a setting |
|
35 @publishedAll |
|
36 @released |
|
37 */ |
|
38 const TInt KMaxUnicodeStringLength = 1024; |
|
39 |
|
40 /** The maximum number of bytes that can be stored in a setting |
|
41 @publishedAll |
|
42 @released |
|
43 */ |
|
44 const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2; |
|
45 |
|
46 /** Error key returned by CommitTransaction in case of an error that cannot be |
|
47 attributed to any single or partial key. Also notify value for spurious |
|
48 notifications (eg when a notification is cancelled or several values change at once ) |
|
49 @internalAll |
|
50 @released |
|
51 */ |
|
52 const TUint32 KUnspecifiedKey = 0xffffffffUL; |
|
53 |
|
54 /** Initial buffer size for Find~ API. Initial buffer is used to cut on the number |
|
55 of IPC calls required for each Find~ API call. If the number of settings found is |
|
56 less than or equal to KCentRepFindBufSize then all the settings can be retrieved with |
|
57 a single IPC. |
|
58 @internalAll |
|
59 */ |
|
60 const TInt KCentRepFindBufSize = 16; |
|
61 |
|
62 /** Use KUnspecifiedKey instead of this value. |
|
63 @publishedAll |
|
64 @deprecated |
|
65 */ |
|
66 const TUint32 KInvalidNotificationId = KUnspecifiedKey; |
|
67 |
|
68 /** The 8 most significant bits of a setting's meta-data are reserved for internal use. |
|
69 Clients should not make use of the reserved bits (unless it is specifically stated |
|
70 otherwise in Symbian developer documentation). Clients should not rely on the value |
|
71 of the reserved bits. Reserved bits are not guaranteed to be 0 or 1 and are not |
|
72 guaranteed to stay constant from one GetMeta call to the next. |
|
73 @publishedPartner |
|
74 @released |
|
75 @see CRepository::GetMeta |
|
76 @see KMetaUnreserved |
|
77 */ |
|
78 const TUint32 KMetaSymbianReserved = 0xFF000000; |
|
79 |
|
80 /** The 24 least significant bits of a setting's meta-data are available for use. Clients |
|
81 should make use of KMetaUnreserved to mask out the reserved bits following a call |
|
82 to GetMeta. Clients should not rely on the value of the reserved bits. Reserved bits |
|
83 are not guaranteed to be 0 or 1 and are not guaranteed to stay constant from one |
|
84 GetMeta call to the next. |
|
85 @publishedPartner |
|
86 @released |
|
87 @see CRepository::GetMeta |
|
88 @see KMetaSymbianReserved |
|
89 */ |
|
90 const TUint32 KMetaUnreserved = 0x00FFFFFF; |
|
91 |
|
92 } // namespace NCentralRepositoryConstants |
|
93 |
|
94 /* |
|
95 class CCRepositoryBehaviorTls : public CBase |
|
96 { |
|
97 public: |
|
98 static void OpenL(); |
|
99 static void Close(); |
|
100 |
|
101 static CCRepositoryBehaviorTls* Storage(); |
|
102 |
|
103 void Reset(); |
|
104 TInt Set(TUint32 aKey, TInt aValue); |
|
105 TInt Get(TUint32 aKey, TInt& aValue); |
|
106 |
|
107 private: |
|
108 |
|
109 CCRepositoryBehaviorTls(); |
|
110 ~CCRepositoryBehaviorTls(); |
|
111 |
|
112 public: |
|
113 RArray<TUint32> iKeys; |
|
114 RArray<TInt> iValues; |
|
115 |
|
116 }; |
|
117 |
|
118 */ |
|
119 /** Provides access to a repository. |
|
120 |
|
121 There are potentially 2^32 repositories, each identified by a UID. Within each |
|
122 repository up to 2^32 settings can be stored. Settings within a repository are |
|
123 identified by a 32-bit key and may be of the types integer, real or descriptor. |
|
124 @publishedAll |
|
125 @released |
|
126 */ |
|
127 class CRepository : public CBase |
|
128 { |
|
129 public: |
|
130 |
|
131 /** Transaction mode chosen with StartTransaction. |
|
132 @publishedPartner |
|
133 @released */ |
|
134 enum TTransactionMode |
|
135 { |
|
136 /** Standard optimistic non-serialised transaction. Can be started at any time |
|
137 Commit fails with KErrLocked if another client interrupts it by first committing |
|
138 changes: transaction should be repeated until KErrLocked is not returned. */ |
|
139 EConcurrentReadWriteTransaction = 2, |
|
140 /** Pessimistic locking transaction intended for reading consistent values. |
|
141 Can only be started if EReadWriteTransaction is not in progress. |
|
142 Automatically promoted to EReadWriteTransaction on first write operation |
|
143 if no other read transaction is in progress (or fails if not attainable). |
|
144 Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction, |
|
145 and only make changes in an EReadWriteTransaction. */ |
|
146 EReadTransaction = 1, |
|
147 /** Pessimistic locking transaction intended for writing values. Can only be |
|
148 started if no EReadTransaction or EReadWriteTransactions are in progress. |
|
149 Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction, |
|
150 and only make changes in an EReadWriteTransaction. */ |
|
151 EReadWriteTransaction = 3 |
|
152 }; |
|
153 |
|
154 /** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction. |
|
155 @see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus) |
|
156 @publishedPartner |
|
157 @released |
|
158 */ |
|
159 typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf; |
|
160 //static void OpenL(); |
|
161 IMPORT_C static CRepository* NewL(TUid aRepositoryUid); |
|
162 IMPORT_C static CRepository* NewLC(TUid aRepositoryUid); |
|
163 |
|
164 IMPORT_C virtual ~CRepository(); |
|
165 |
|
166 |
|
167 IMPORT_C TInt Create(TUint32 aKey, TInt aValue); |
|
168 //IMPORT_C TInt Create(TUint32 aKey, const TReal& aValue); |
|
169 IMPORT_C TInt Create(TUint32 aKey, const TDesC8& aValue); |
|
170 //IMPORT_C TInt Create(TUint32 aKey, const TDesC16& aValue); |
|
171 //IMPORT_C TInt Delete(TUint32 aKey); |
|
172 IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32 &aErrorKey) ; |
|
173 |
|
174 |
|
175 IMPORT_C TInt Get(TUint32 aKey, TInt& aValue); |
|
176 IMPORT_C TInt Set(TUint32 aKey, TInt aValue); |
|
177 |
|
178 /* |
|
179 IMPORT_C TInt Get(TUint32 aKey, TReal& aValue); |
|
180 IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue); |
|
181 */ |
|
182 IMPORT_C TInt Get(TUint32 aKey, TDes8& aValue); |
|
183 //IMPORT_C TInt Get(TUint32 aId, TDes8& aValue, TInt& aActualLength); |
|
184 IMPORT_C TInt Set(TUint32 aKey, const TDesC8& aValue); |
|
185 |
|
186 IMPORT_C TInt Get(TUint32 aKey, TDes16& aValue); |
|
187 IMPORT_C TInt Get(TUint32 aId, TDes16& aValue, TInt& aActualLength); |
|
188 IMPORT_C TInt Set(TUint32 aKey, const TDesC16& aValue); |
|
189 /* |
|
190 IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta); |
|
191 |
|
192 IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, |
|
193 TUint32 aMask, TUint32 &aErrorKey) ; |
|
194 */ |
|
195 IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask, |
|
196 RArray<TUint32>& aFoundKeys); |
|
197 /* |
|
198 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, |
|
199 TInt aValue, RArray<TUint32>& aFoundKeys); |
|
200 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, |
|
201 const TReal& aValue, RArray<TUint32>& aFoundKeys); |
|
202 */ |
|
203 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, |
|
204 const TDesC8& aValue, RArray<TUint32>& aFoundKeys); |
|
205 /* |
|
206 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, |
|
207 const TDesC16& aValue, RArray<TUint32>& aFoundKeys); |
|
208 |
|
209 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, |
|
210 TInt aValue, RArray<TUint32>& aFoundKeys); |
|
211 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, |
|
212 const TReal& aValue, RArray<TUint32>& aFoundKeys); |
|
213 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, |
|
214 const TDesC8& aValue, RArray<TUint32>& aFoundKeys); |
|
215 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, |
|
216 const TDesC16& aValue, RArray<TUint32>& aFoundKeys); |
|
217 |
|
218 IMPORT_C TInt NotifyRequest(TUint32 aKey, TRequestStatus& aStatus); |
|
219 IMPORT_C TInt NotifyRequest(TUint32 aPartialKey, TUint32 aMask, |
|
220 TRequestStatus& aStatus); |
|
221 |
|
222 IMPORT_C TInt NotifyCancel(TUint32 aKey); |
|
223 IMPORT_C TInt NotifyCancel(TUint32 aPartialKey, TUint32 aMask); |
|
224 IMPORT_C TInt NotifyCancelAll(); |
|
225 |
|
226 IMPORT_C TInt Reset(); |
|
227 IMPORT_C TInt Reset(TUint32 aKey); |
|
228 */ |
|
229 |
|
230 IMPORT_C TInt StartTransaction(TTransactionMode aMode); |
|
231 //IMPORT_C void StartTransaction(TTransactionMode aMode, TRequestStatus& aStatus); |
|
232 IMPORT_C TInt CommitTransaction(TUint32& aKeyInfo); |
|
233 //IMPORT_C void CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus); |
|
234 //IMPORT_C void CancelTransaction(); |
|
235 //IMPORT_C void CleanupCancelTransactionPushL(); |
|
236 //IMPORT_C void FailTransaction(); |
|
237 //IMPORT_C void CleanupFailTransactionPushL(); |
|
238 |
|
239 /** Same as CancelTransaction. |
|
240 @publishedPartner |
|
241 @released |
|
242 @see CancelTransaction */ |
|
243 /* |
|
244 inline void RollbackTransaction() |
|
245 { |
|
246 CancelTransaction(); |
|
247 } |
|
248 */ |
|
249 /** Same as CleanupCancelTransactionPushL. |
|
250 @publishedPartner |
|
251 @released |
|
252 @see CleanupCancelTransactionPushL */ |
|
253 /* |
|
254 inline void CleanupRollbackTransactionPushL() |
|
255 { |
|
256 CleanupCancelTransactionPushL(); |
|
257 } |
|
258 */ |
|
259 // IMPORT_C TInt TransactionState(); |
|
260 |
|
261 /** This API is for internal use only and for testing purposes. |
|
262 @internalAll |
|
263 */ |
|
264 // IMPORT_C static TInt SetGetParameters(const TIpcArgs& aArgs); |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 private: // Stub functions |
|
270 |
|
271 CRepository( TUid aRepositoryUid ); |
|
272 static CRepository* Instance(); |
|
273 |
|
274 public: // Stub functios |
|
275 |
|
276 void ResetKeysAndValues(); |
|
277 static void Close(); |
|
278 |
|
279 |
|
280 public: // Stub data |
|
281 |
|
282 static MusSettingsKeys::TOperatorVariant iOperatorVariant; |
|
283 |
|
284 // If the following value is ETrue, CenRep UID KCRUidSIPClientResolverConfig |
|
285 // exists and respository is possible to create with this value. Otherwise |
|
286 // CenRep instantiation leaves with KErrNone. |
|
287 static TBool iEmulateSawfishRepository; |
|
288 |
|
289 TUid iRepositoryUid; |
|
290 |
|
291 }; |
|
292 |
|
293 #endif // __CENTRALREPOSITORY_H__ |
|