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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __CENTRALREPOSITORY_H__
17 #define __CENTRALREPOSITORY_H__
21 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
22 #include <centralrepositoryinternal.h>
25 namespace NCentralRepositoryConstants
26 /** Namespace encapsulating the CentralRepository constants.
32 /** The maximum number of unicode characters that can be stored in a setting
36 const TInt KMaxUnicodeStringLength = 1024;
38 /** The maximum number of bytes that can be stored in a setting
42 const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2;
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 )
50 const TUint32 KUnspecifiedKey = 0xffffffffUL;
52 /** Use KUnspecifiedKey instead of this value.
56 const TUint32 KInvalidNotificationId = KUnspecifiedKey;
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.
64 @see CRepository::GetMeta
67 const TUint32 KMetaSymbianReserved = 0xFF000000;
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.
75 @see CRepository::GetMeta
76 @see KMetaSymbianReserved
78 const TUint32 KMetaUnreserved = 0x00FFFFFF;
80 } // namespace NCentralRepositoryConstants
82 /** Provides access to a repository.
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.
90 class CRepository : public CBase
94 /** Transaction mode chosen with StartTransaction.
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.
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.
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.
116 EReadWriteTransaction = 3
119 /** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction.
120 @see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus)
122 typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf;
124 IMPORT_C static CRepository* NewL(TUid aRepositoryUid);
125 IMPORT_C static CRepository* NewLC(TUid aRepositoryUid);
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);
133 IMPORT_C TInt Delete(TUint32 aKey);
134 IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32 &aErrorKey) ;
136 IMPORT_C TInt Get(TUint32 aKey, TInt& aValue);
137 IMPORT_C TInt Set(TUint32 aKey, TInt aValue);
139 IMPORT_C TInt Get(TUint32 aKey, TReal& aValue);
140 IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue);
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);
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);
150 IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta);
152 IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,
153 TUint32 aMask, TUint32 &aErrorKey) ;
155 IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask,
156 RArray<TUint32>& aFoundKeys);
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);
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);
176 IMPORT_C TInt NotifyRequest(TUint32 aKey, TRequestStatus& aStatus);
177 IMPORT_C TInt NotifyRequest(TUint32 aPartialKey, TUint32 aMask,
178 TRequestStatus& aStatus);
180 IMPORT_C TInt NotifyCancel(TUint32 aKey);
181 IMPORT_C TInt NotifyCancel(TUint32 aPartialKey, TUint32 aMask);
182 IMPORT_C TInt NotifyCancelAll();
184 IMPORT_C TInt Reset();
185 IMPORT_C TInt Reset(TUint32 aKey);
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();
196 /** Same as CancelTransaction.
197 @see CancelTransaction
199 inline void RollbackTransaction()
204 /** Same as CleanupCancelTransactionPushL.
205 @see CleanupCancelTransactionPushL
207 inline void CleanupRollbackTransactionPushL()
209 CleanupCancelTransactionPushL();
213 #endif // __CENTRALREPOSITORY_H__