williamr@2: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __CENTRALREPOSITORY_H__ williamr@2: #define __CENTRALREPOSITORY_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: williamr@2: namespace NCentralRepositoryConstants williamr@2: /** Namespace encapsulating the CentralRepository constants. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: williamr@2: /** The maximum number of unicode characters that can be stored in a setting williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: const TInt KMaxUnicodeStringLength = 1024; williamr@2: williamr@2: /** The maximum number of bytes that can be stored in a setting williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2; williamr@2: williamr@2: /** Error key returned by CommitTransaction in case of an error that cannot be williamr@2: attributed to any single or partial key. Also notify value for spurious williamr@2: notifications (eg when a notification is cancelled or several values change at once ) williamr@2: @internalAll williamr@2: @released williamr@2: */ williamr@2: const TUint32 KUnspecifiedKey = 0xffffffffUL; williamr@2: williamr@2: /** Initial buffer size for Find~ API. Initial buffer is used to cut on the number williamr@2: of IPC calls required for each Find~ API call. If the number of settings found is williamr@2: less than or equal to KCentRepFindBufSize then all the settings can be retrieved with williamr@2: a single IPC. williamr@2: @internalAll williamr@2: */ williamr@2: const TInt KCentRepFindBufSize = 16; williamr@2: williamr@2: /** Use KUnspecifiedKey instead of this value. williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: const TUint32 KInvalidNotificationId = KUnspecifiedKey; williamr@2: williamr@2: /** The 8 most significant bits of a setting's meta-data are reserved for internal use. williamr@2: Clients should not make use of the reserved bits (unless it is specifically stated williamr@2: otherwise in Symbian developer documentation). Clients should not rely on the value williamr@2: of the reserved bits. Reserved bits are not guaranteed to be 0 or 1 and are not williamr@2: guaranteed to stay constant from one GetMeta call to the next. williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CRepository::GetMeta williamr@2: @see KMetaUnreserved williamr@2: */ williamr@2: const TUint32 KMetaSymbianReserved = 0xFF000000; williamr@2: williamr@2: /** The 24 least significant bits of a setting's meta-data are available for use. Clients williamr@2: should make use of KMetaUnreserved to mask out the reserved bits following a call williamr@2: to GetMeta. Clients should not rely on the value of the reserved bits. Reserved bits williamr@2: are not guaranteed to be 0 or 1 and are not guaranteed to stay constant from one williamr@2: GetMeta call to the next. williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CRepository::GetMeta williamr@2: @see KMetaSymbianReserved williamr@2: */ williamr@2: const TUint32 KMetaUnreserved = 0x00FFFFFF; williamr@2: williamr@2: } // namespace NCentralRepositoryConstants williamr@2: williamr@2: /** Provides access to a repository. williamr@2: williamr@2: There are potentially 2^32 repositories, each identified by a UID. Within each williamr@2: repository up to 2^32 settings can be stored. Settings within a repository are williamr@2: identified by a 32-bit key and may be of the types integer, real or descriptor. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CRepository : public CBase williamr@2: { williamr@2: public: williamr@2: williamr@2: /** Transaction mode chosen with StartTransaction. williamr@2: @publishedPartner williamr@2: @released */ williamr@2: enum TTransactionMode williamr@2: { williamr@2: /** Standard optimistic non-serialised transaction. Can be started at any time williamr@2: Commit fails with KErrLocked if another client interrupts it by first committing williamr@2: changes: transaction should be repeated until KErrLocked is not returned. */ williamr@2: EConcurrentReadWriteTransaction = 2, williamr@2: /** Pessimistic locking transaction intended for reading consistent values. williamr@2: Can only be started if EReadWriteTransaction is not in progress. williamr@2: Automatically promoted to EReadWriteTransaction on first write operation williamr@2: if no other read transaction is in progress (or fails if not attainable). williamr@2: Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction, williamr@2: and only make changes in an EReadWriteTransaction. */ williamr@2: EReadTransaction = 1, williamr@2: /** Pessimistic locking transaction intended for writing values. Can only be williamr@2: started if no EReadTransaction or EReadWriteTransactions are in progress. williamr@2: Use ONLY if all clients can agree not to use EConcurrentReadWriteTransaction, williamr@2: and only make changes in an EReadWriteTransaction. */ williamr@2: EReadWriteTransaction = 3 williamr@2: }; williamr@2: williamr@2: /** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction. williamr@2: @see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus) williamr@2: @publishedPartner williamr@2: @released williamr@2: */ williamr@2: typedef TPckgBuf TTransactionKeyInfoBuf; williamr@2: williamr@2: IMPORT_C static CRepository* NewL(TUid aRepositoryUid); williamr@2: IMPORT_C static CRepository* NewLC(TUid aRepositoryUid); williamr@2: williamr@2: IMPORT_C virtual ~CRepository(); williamr@2: IMPORT_C TInt Create(TUint32 aKey, TInt aValue); williamr@2: IMPORT_C TInt Create(TUint32 aKey, const TReal& aValue); williamr@2: IMPORT_C TInt Create(TUint32 aKey, const TDesC8& aValue); williamr@2: IMPORT_C TInt Create(TUint32 aKey, const TDesC16& aValue); williamr@2: williamr@2: IMPORT_C TInt Delete(TUint32 aKey); williamr@2: IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32 &aErrorKey) ; williamr@2: williamr@2: IMPORT_C TInt Get(TUint32 aKey, TInt& aValue); williamr@2: IMPORT_C TInt Set(TUint32 aKey, TInt aValue); williamr@2: williamr@2: IMPORT_C TInt Get(TUint32 aKey, TReal& aValue); williamr@2: IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue); williamr@2: williamr@2: IMPORT_C TInt Get(TUint32 aKey, TDes8& aValue); williamr@2: IMPORT_C TInt Get(TUint32 aId, TDes8& aValue, TInt& aActualLength); williamr@2: IMPORT_C TInt Set(TUint32 aKey, const TDesC8& aValue); williamr@2: williamr@2: IMPORT_C TInt Get(TUint32 aKey, TDes16& aValue); williamr@2: IMPORT_C TInt Get(TUint32 aId, TDes16& aValue, TInt& aActualLength); williamr@2: IMPORT_C TInt Set(TUint32 aKey, const TDesC16& aValue); williamr@2: williamr@2: IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta); williamr@2: williamr@2: IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, williamr@2: TUint32 aMask, TUint32 &aErrorKey) ; williamr@2: williamr@2: IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask, williamr@2: RArray& aFoundKeys); williamr@2: williamr@2: IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: TInt aValue, RArray& aFoundKeys); williamr@2: IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: const TReal& aValue, RArray& aFoundKeys); williamr@2: IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: const TDesC8& aValue, RArray& aFoundKeys); williamr@2: IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: const TDesC16& aValue, RArray& aFoundKeys); williamr@2: williamr@2: IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: TInt aValue, RArray& aFoundKeys); williamr@2: IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: const TReal& aValue, RArray& aFoundKeys); williamr@2: IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: const TDesC8& aValue, RArray& aFoundKeys); williamr@2: IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask, williamr@2: const TDesC16& aValue, RArray& aFoundKeys); williamr@2: williamr@2: IMPORT_C TInt NotifyRequest(TUint32 aKey, TRequestStatus& aStatus); williamr@2: IMPORT_C TInt NotifyRequest(TUint32 aPartialKey, TUint32 aMask, williamr@2: TRequestStatus& aStatus); williamr@2: williamr@2: IMPORT_C TInt NotifyCancel(TUint32 aKey); williamr@2: IMPORT_C TInt NotifyCancel(TUint32 aPartialKey, TUint32 aMask); williamr@2: IMPORT_C TInt NotifyCancelAll(); williamr@2: williamr@2: IMPORT_C TInt Reset(); williamr@2: IMPORT_C TInt Reset(TUint32 aKey); williamr@2: williamr@2: IMPORT_C TInt StartTransaction(TTransactionMode aMode); williamr@2: IMPORT_C void StartTransaction(TTransactionMode aMode, TRequestStatus& aStatus); williamr@2: IMPORT_C TInt CommitTransaction(TUint32& aKeyInfo); williamr@2: IMPORT_C void CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus); williamr@2: IMPORT_C void CancelTransaction(); williamr@2: IMPORT_C void CleanupCancelTransactionPushL(); williamr@2: IMPORT_C void FailTransaction(); williamr@2: IMPORT_C void CleanupFailTransactionPushL(); williamr@2: williamr@2: /** Same as CancelTransaction. williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CancelTransaction */ williamr@2: inline void RollbackTransaction() williamr@2: { williamr@2: CancelTransaction(); williamr@2: } williamr@2: williamr@2: /** Same as CleanupCancelTransactionPushL. williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CleanupCancelTransactionPushL */ williamr@2: inline void CleanupRollbackTransactionPushL() williamr@2: { williamr@2: CleanupCancelTransactionPushL(); williamr@2: } williamr@2: williamr@2: IMPORT_C TInt TransactionState(); williamr@2: williamr@2: /** This API is for internal use only and for testing purposes. williamr@2: @internalAll williamr@2: */ williamr@2: IMPORT_C static TInt SetGetParameters(const TIpcArgs& aArgs); williamr@2: }; williamr@2: williamr@2: #endif // __CENTRALREPOSITORY_H__