os/persistentdata/persistentstorage/centralrepository/pccenrep/include/centralrepository.h
Update contrib.
1 // Copyright (c) 2008-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__
23 namespace NCentralRepositoryConstants
24 /** Namespace encapsulating the CentralRepository constants.
30 /** The maximum number of unicode characters that can be stored in a setting
34 const TInt KMaxUnicodeStringLength = 1024;
36 /** The maximum number of bytes that can be stored in a setting
40 const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2;
42 /** Error key returned by CommitTransaction in case of an error that cannot be
43 attributed to any single or partial key. Also notify value for spurious
44 notifications (eg when a notification is cancelled or several values change at once )
48 const TUint32 KUnspecifiedKey = 0xffffffffUL;
50 /** The maximum key can be used in repository
54 const TInt KMaximumKey = 0xfffffffeUL;
56 /** Initial buffer size for Find~ API. Initial buffer is used to cut on the number
57 of IPC calls required for each Find~ API call. If the number of settings found is
58 less than or equal to KCentRepFindBufSize then all the settings can be retrieved with
63 const TInt KCentRepFindBufSize = 16;
65 /** Use KUnspecifiedKey instead of this value.
69 const TUint32 KInvalidNotificationId = KUnspecifiedKey;
71 /** The 8 most significant bits of a setting's meta-data are reserved for internal use.
72 Clients should not make use of the reserved bits (unless it is specifically stated
73 otherwise in Symbian developer documentation). Clients should not rely on the value
74 of the reserved bits. Reserved bits are not guaranteed to be 0 or 1 and are not
75 guaranteed to stay constant from one GetMeta call to the next.
78 @see CRepository::GetMeta
81 const TUint32 KMetaSymbianReserved = 0xFF000000;
83 /** The 24 least significant bits of a setting's meta-data are available for use. Clients
84 should make use of KMetaUnreserved to mask out the reserved bits following a call
85 to GetMeta. Clients should not rely on the value of the reserved bits. Reserved bits
86 are not guaranteed to be 0 or 1 and are not guaranteed to stay constant from one
87 GetMeta call to the next.
90 @see CRepository::GetMeta
91 @see KMetaSymbianReserved
93 const TUint32 KMetaUnreserved = 0x00FFFFFF;
95 } // namespace NCentralRepositoryConstants
98 /** Provides access to a repository.
100 There are potentially 2^32 repositories, each identified by a UID. Within each
101 repository up to 2^32 settings can be stored. Settings within a repository are
102 identified by a 32-bit key and may be of the types integer, real or descriptor.
106 class CRepository : public CBase
110 /** Transaction mode chosen with StartTransaction.
113 enum TTransactionMode
115 /** Standard optimistic non-serialised transaction. Can be started at any time
116 Commit fails with KErrLocked if another client interrupts it by first committing
117 changes: transaction should be repeated until KErrLocked is not returned. */
118 EConcurrentReadWriteTransaction = 2,
119 /** Pessimistic locking transaction intended for reading consistent values.
120 Can only be started if EReadWriteTransaction is not in progress.
121 Automatically promoted to EReadWriteTransaction on first write operation
122 if no other read transaction is in progress (or fails if not attainable).
123 Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction,
124 and only make changes in an EReadWriteTransaction. */
125 EReadTransaction = 1,
126 /** Pessimistic locking transaction intended for writing values. Can only be
127 started if no EReadTransaction or EReadWriteTransactions are in progress.
128 Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction,
129 and only make changes in an EReadWriteTransaction. */
130 EReadWriteTransaction = 3
133 /** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction.
134 @see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus)
138 typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf;
140 IMPORT_C static CRepository* NewL(TUid aRepositoryUid);
141 IMPORT_C static CRepository* NewLC(TUid aRepositoryUid);
142 IMPORT_C static CRepository* NewL(const TDesC& aInputRepositoryFile,const TDesC& aOutputRepositoryFile);
143 IMPORT_C static CRepository* NewLC(const TDesC& aInputRepositoryFile,const TDesC& aOutputRepositoryFile);
145 IMPORT_C TInt Flush();
147 IMPORT_C virtual ~CRepository();
148 IMPORT_C TInt Create(TUint32 aKey, TInt aValue);
149 IMPORT_C TInt Create(TUint32 aKey, const TReal& aValue);
150 IMPORT_C TInt Create(TUint32 aKey, const TDesC8& aValue);
151 IMPORT_C TInt Create(TUint32 aKey, const TDesC16& aValue);
153 IMPORT_C TInt Delete(TUint32 aKey);
154 IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32& aErrorKey) ;
156 IMPORT_C TInt Get(TUint32 aKey, TInt& aValue);
157 IMPORT_C TInt Set(TUint32 aKey, TInt aValue);
159 IMPORT_C TInt Get(TUint32 aKey, TReal& aValue);
160 IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue);
162 IMPORT_C TInt Get(TUint32 aKey, TDes8& aValue);
163 IMPORT_C TInt Get(TUint32 aId, TDes8& aValue, TInt& aActualLength);
164 IMPORT_C TInt Set(TUint32 aKey, const TDesC8& aValue);
166 IMPORT_C TInt Get(TUint32 aKey, TDes16& aValue);
167 IMPORT_C TInt Get(TUint32 aId, TDes16& aValue, TInt& aActualLength);
168 IMPORT_C TInt Set(TUint32 aKey, const TDesC16& aValue);
170 IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta);
172 IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,
173 TUint32 aMask, TUint32& aErrorKey) ;
175 IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask,
176 RArray<TUint32>& aFoundKeys);
178 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
179 TInt aValue, RArray<TUint32>& aFoundKeys);
180 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
181 const TReal& aValue, RArray<TUint32>& aFoundKeys);
182 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
183 const TDesC8& aValue, RArray<TUint32>& aFoundKeys);
184 IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
185 const TDesC16& aValue, RArray<TUint32>& aFoundKeys);
187 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
188 TInt aValue, RArray<TUint32>& aFoundKeys);
189 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
190 const TReal& aValue, RArray<TUint32>& aFoundKeys);
191 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
192 const TDesC8& aValue, RArray<TUint32>& aFoundKeys);
193 IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
194 const TDesC16& aValue, RArray<TUint32>& aFoundKeys);
196 IMPORT_C TInt StartTransaction(TTransactionMode aMode);
197 IMPORT_C void StartTransaction(TTransactionMode aMode, TRequestStatus& aStatus);
198 IMPORT_C TInt CommitTransaction(TUint32& aKeyInfo);
199 IMPORT_C void CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus);
200 IMPORT_C void CancelTransaction();
201 IMPORT_C void CleanupCancelTransactionPushL();
202 IMPORT_C void FailTransaction();
203 IMPORT_C void CleanupFailTransactionPushL();
205 /** Same as CancelTransaction.
206 @see CancelTransaction */
207 inline void RollbackTransaction()
212 /** Same as CleanupCancelTransactionPushL.
213 @see CleanupCancelTransactionPushL */
214 inline void CleanupRollbackTransactionPushL()
216 CleanupCancelTransactionPushL();
220 void ConstructL(TUid aRepositoryUid,const TDesC& aInFileName,const TDesC& aOutFileName,TBool aAutoLoading);
226 #endif // __CENTRALREPOSITORY_H__