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