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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __CENTRALREPOSITORY_H__
17 #define __CENTRALREPOSITORY_H__
22 namespace NCentralRepositoryConstants
23 /** Namespace encapsulating the CentralRepository constants.
29 /** The maximum number of unicode characters that can be stored in a setting
33 const TInt KMaxUnicodeStringLength = 1024;
35 /** The maximum number of bytes that can be stored in a setting
39 const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2;
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 )
47 const TUint32 KUnspecifiedKey = 0xffffffffUL;
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
55 const TInt KCentRepFindBufSize = 16;
57 /** Use KUnspecifiedKey instead of this value.
61 const TUint32 KInvalidNotificationId = KUnspecifiedKey;
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.
70 @see CRepository::GetMeta
73 const TUint32 KMetaSymbianReserved = 0xFF000000;
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.
82 @see CRepository::GetMeta
83 @see KMetaSymbianReserved
85 const TUint32 KMetaUnreserved = 0x00FFFFFF;
87 } // namespace NCentralRepositoryConstants
89 /** Provides access to a repository.
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.
97 class CRepository : public CBase
101 /** Transaction mode chosen with StartTransaction.
104 enum TTransactionMode
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
124 /** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction.
125 @see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus)
129 typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf;
131 IMPORT_C static CRepository* NewL(TUid aRepositoryUid);
132 IMPORT_C static CRepository* NewLC(TUid aRepositoryUid);
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);
140 IMPORT_C TInt Delete(TUint32 aKey);
141 IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32 &aErrorKey) ;
143 IMPORT_C TInt Get(TUint32 aKey, TInt& aValue);
144 IMPORT_C TInt Set(TUint32 aKey, TInt aValue);
146 IMPORT_C TInt Get(TUint32 aKey, TReal& aValue);
147 IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue);
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);
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);
157 IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta);
159 IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,
160 TUint32 aMask, TUint32 &aErrorKey) ;
162 IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask,
163 RArray<TUint32>& aFoundKeys);
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);
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);
183 IMPORT_C TInt NotifyRequest(TUint32 aKey, TRequestStatus& aStatus);
184 IMPORT_C TInt NotifyRequest(TUint32 aPartialKey, TUint32 aMask,
185 TRequestStatus& aStatus);
187 IMPORT_C TInt NotifyCancel(TUint32 aKey);
188 IMPORT_C TInt NotifyCancel(TUint32 aPartialKey, TUint32 aMask);
189 IMPORT_C TInt NotifyCancelAll();
191 IMPORT_C TInt Reset();
192 IMPORT_C TInt Reset(TUint32 aKey);
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();
203 /** Same as CancelTransaction.
206 @see CancelTransaction */
207 inline void RollbackTransaction()
212 /** Same as CleanupCancelTransactionPushL.
215 @see CleanupCancelTransactionPushL */
216 inline void CleanupRollbackTransactionPushL()
218 CleanupCancelTransactionPushL();
221 IMPORT_C TInt TransactionState();
223 /** This API is for internal use only and for testing purposes.
226 IMPORT_C static TInt SetGetParameters(const TIpcArgs& aArgs);
229 #endif // __CENTRALREPOSITORY_H__