os/persistentdata/persistentstorage/centralrepository/pccenrep/include/centralrepository.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/pccenrep/include/centralrepository.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,226 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __CENTRALREPOSITORY_H__
1.20 +#define __CENTRALREPOSITORY_H__
1.21 +
1.22 +#include <e32base.h>
1.23 +#include <f32file.h>
1.24 +
1.25 +
1.26 +namespace NCentralRepositoryConstants
1.27 +/** Namespace encapsulating the CentralRepository constants.
1.28 +@internalAll
1.29 +@prototype
1.30 +*/
1.31 +{
1.32 +
1.33 +/** The maximum number of unicode characters that can be stored in a setting
1.34 +@internalAll
1.35 +@prototype
1.36 +*/
1.37 +const TInt KMaxUnicodeStringLength = 1024;
1.38 +
1.39 +/** The maximum number of bytes that can be stored in a setting
1.40 +@internalAll
1.41 +@prototype
1.42 +*/
1.43 +const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2;
1.44 +
1.45 +/** Error key returned by CommitTransaction in case of an error that cannot be
1.46 +attributed to any single or partial key. Also notify value for spurious
1.47 +notifications (eg when a notification is cancelled or several values change at once )
1.48 +@internalAll
1.49 +@prototype
1.50 +*/
1.51 +const TUint32 KUnspecifiedKey = 0xffffffffUL;
1.52 +
1.53 +/** The maximum key can be used in repository
1.54 +@internalAll
1.55 +@prototype
1.56 +*/
1.57 +const TInt KMaximumKey = 0xfffffffeUL;
1.58 +
1.59 +/** Initial buffer size for Find~ API. Initial buffer is used to cut on the number
1.60 +of IPC calls required for each Find~ API call. If the number of settings found is
1.61 +less than or equal to KCentRepFindBufSize then all the settings can be retrieved with
1.62 +a single IPC.
1.63 +@internalAll
1.64 +@prototype
1.65 +*/
1.66 +const TInt KCentRepFindBufSize = 16;
1.67 +
1.68 +/** Use KUnspecifiedKey instead of this value.
1.69 +@internalAll
1.70 +@prototype
1.71 +*/
1.72 +const TUint32 KInvalidNotificationId = KUnspecifiedKey;
1.73 +
1.74 +/** The 8 most significant bits of a setting's meta-data are reserved for internal use.
1.75 +Clients should not make use of the reserved bits (unless it is specifically stated
1.76 +otherwise in Symbian developer documentation). Clients should not rely on the value
1.77 +of the reserved bits. Reserved bits are not guaranteed to be 0 or 1 and are not
1.78 +guaranteed to stay constant from one GetMeta call to the next.
1.79 +@internalAll
1.80 +@prototype
1.81 +@see CRepository::GetMeta
1.82 +@see KMetaUnreserved
1.83 +*/
1.84 +const TUint32 KMetaSymbianReserved = 0xFF000000;
1.85 +
1.86 +/** The 24 least significant bits of a setting's meta-data are available for use. Clients
1.87 +should make use of KMetaUnreserved to mask out the reserved bits following a call
1.88 +to GetMeta. Clients should not rely on the value of the reserved bits. Reserved bits
1.89 +are not guaranteed to be 0 or 1 and are not guaranteed to stay constant from one
1.90 +GetMeta call to the next.
1.91 +@internalAll
1.92 +@prototype
1.93 +@see CRepository::GetMeta
1.94 +@see KMetaSymbianReserved
1.95 +*/
1.96 +const TUint32 KMetaUnreserved = 0x00FFFFFF;
1.97 +
1.98 +} // namespace NCentralRepositoryConstants
1.99 +
1.100 +class CPcRepImpl;
1.101 +/** Provides access to a repository.
1.102 +
1.103 +There are potentially 2^32 repositories, each identified by a UID. Within each
1.104 +repository up to 2^32 settings can be stored. Settings within a repository are
1.105 +identified by a 32-bit key and may be of the types integer, real or descriptor.
1.106 +@internalAll
1.107 +@prototype
1.108 +*/
1.109 +class CRepository : public CBase
1.110 + {
1.111 +public:
1.112 +
1.113 + /** Transaction mode chosen with StartTransaction.
1.114 + @internalAll
1.115 + @prototype*/
1.116 + enum TTransactionMode
1.117 + {
1.118 + /** Standard optimistic non-serialised transaction. Can be started at any time
1.119 + Commit fails with KErrLocked if another client interrupts it by first committing
1.120 + changes: transaction should be repeated until KErrLocked is not returned. */
1.121 + EConcurrentReadWriteTransaction = 2,
1.122 + /** Pessimistic locking transaction intended for reading consistent values.
1.123 + Can only be started if EReadWriteTransaction is not in progress.
1.124 + Automatically promoted to EReadWriteTransaction on first write operation
1.125 + if no other read transaction is in progress (or fails if not attainable).
1.126 + Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction,
1.127 + and only make changes in an EReadWriteTransaction. */
1.128 + EReadTransaction = 1,
1.129 + /** Pessimistic locking transaction intended for writing values. Can only be
1.130 + started if no EReadTransaction or EReadWriteTransactions are in progress.
1.131 + Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction,
1.132 + and only make changes in an EReadWriteTransaction. */
1.133 + EReadWriteTransaction = 3
1.134 + };
1.135 +
1.136 + /** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction.
1.137 + @see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus)
1.138 + @internalAll
1.139 + @prototype
1.140 + */
1.141 + typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf;
1.142 +
1.143 + IMPORT_C static CRepository* NewL(TUid aRepositoryUid);
1.144 + IMPORT_C static CRepository* NewLC(TUid aRepositoryUid);
1.145 + IMPORT_C static CRepository* NewL(const TDesC& aInputRepositoryFile,const TDesC& aOutputRepositoryFile);
1.146 + IMPORT_C static CRepository* NewLC(const TDesC& aInputRepositoryFile,const TDesC& aOutputRepositoryFile);
1.147 +
1.148 + IMPORT_C TInt Flush();
1.149 +
1.150 + IMPORT_C virtual ~CRepository();
1.151 + IMPORT_C TInt Create(TUint32 aKey, TInt aValue);
1.152 + IMPORT_C TInt Create(TUint32 aKey, const TReal& aValue);
1.153 + IMPORT_C TInt Create(TUint32 aKey, const TDesC8& aValue);
1.154 + IMPORT_C TInt Create(TUint32 aKey, const TDesC16& aValue);
1.155 +
1.156 + IMPORT_C TInt Delete(TUint32 aKey);
1.157 + IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32& aErrorKey) ;
1.158 +
1.159 + IMPORT_C TInt Get(TUint32 aKey, TInt& aValue);
1.160 + IMPORT_C TInt Set(TUint32 aKey, TInt aValue);
1.161 +
1.162 + IMPORT_C TInt Get(TUint32 aKey, TReal& aValue);
1.163 + IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue);
1.164 +
1.165 + IMPORT_C TInt Get(TUint32 aKey, TDes8& aValue);
1.166 + IMPORT_C TInt Get(TUint32 aId, TDes8& aValue, TInt& aActualLength);
1.167 + IMPORT_C TInt Set(TUint32 aKey, const TDesC8& aValue);
1.168 +
1.169 + IMPORT_C TInt Get(TUint32 aKey, TDes16& aValue);
1.170 + IMPORT_C TInt Get(TUint32 aId, TDes16& aValue, TInt& aActualLength);
1.171 + IMPORT_C TInt Set(TUint32 aKey, const TDesC16& aValue);
1.172 +
1.173 + IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta);
1.174 +
1.175 + IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey,
1.176 + TUint32 aMask, TUint32& aErrorKey) ;
1.177 +
1.178 + IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask,
1.179 + RArray<TUint32>& aFoundKeys);
1.180 +
1.181 + IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
1.182 + TInt aValue, RArray<TUint32>& aFoundKeys);
1.183 + IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
1.184 + const TReal& aValue, RArray<TUint32>& aFoundKeys);
1.185 + IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
1.186 + const TDesC8& aValue, RArray<TUint32>& aFoundKeys);
1.187 + IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
1.188 + const TDesC16& aValue, RArray<TUint32>& aFoundKeys);
1.189 +
1.190 + IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
1.191 + TInt aValue, RArray<TUint32>& aFoundKeys);
1.192 + IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
1.193 + const TReal& aValue, RArray<TUint32>& aFoundKeys);
1.194 + IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
1.195 + const TDesC8& aValue, RArray<TUint32>& aFoundKeys);
1.196 + IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
1.197 + const TDesC16& aValue, RArray<TUint32>& aFoundKeys);
1.198 +
1.199 + IMPORT_C TInt StartTransaction(TTransactionMode aMode);
1.200 + IMPORT_C void StartTransaction(TTransactionMode aMode, TRequestStatus& aStatus);
1.201 + IMPORT_C TInt CommitTransaction(TUint32& aKeyInfo);
1.202 + IMPORT_C void CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus);
1.203 + IMPORT_C void CancelTransaction();
1.204 + IMPORT_C void CleanupCancelTransactionPushL();
1.205 + IMPORT_C void FailTransaction();
1.206 + IMPORT_C void CleanupFailTransactionPushL();
1.207 +
1.208 + /** Same as CancelTransaction.
1.209 + @see CancelTransaction */
1.210 + inline void RollbackTransaction()
1.211 + {
1.212 + CancelTransaction();
1.213 + }
1.214 +
1.215 + /** Same as CleanupCancelTransactionPushL.
1.216 + @see CleanupCancelTransactionPushL */
1.217 + inline void CleanupRollbackTransactionPushL()
1.218 + {
1.219 + CleanupCancelTransactionPushL();
1.220 + }
1.221 +private:
1.222 + CRepository(){};
1.223 + void ConstructL(TUid aRepositoryUid,const TDesC& aInFileName,const TDesC& aOutFileName,TBool aAutoLoading);
1.224 +
1.225 +private:
1.226 + CPcRepImpl* iImpl;
1.227 + };
1.228 +
1.229 +#endif // __CENTRALREPOSITORY_H__