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