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