os/persistentdata/persistentstorage/centralrepository/pccenrep/include/centralrepository.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __CENTRALREPOSITORY_H__
    17 #define __CENTRALREPOSITORY_H__
    18 
    19 #include <e32base.h>
    20 #include <f32file.h>
    21 
    22 
    23 namespace NCentralRepositoryConstants
    24 /** Namespace encapsulating the CentralRepository constants.
    25 @internalAll
    26 @prototype
    27 */
    28 {
    29 	
    30 /** The maximum number of unicode characters that can be stored in a setting
    31 @internalAll
    32 @prototype
    33 */
    34 const TInt KMaxUnicodeStringLength = 1024;
    35 
    36 /** The maximum number of bytes that can be stored in a setting
    37 @internalAll
    38 @prototype
    39 */
    40 const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2;
    41 
    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 )
    45 @internalAll
    46 @prototype
    47 */
    48 const TUint32 KUnspecifiedKey = 0xffffffffUL;
    49 
    50 /** The maximum key can be used in repository
    51 @internalAll 
    52 @prototype
    53 */ 
    54 const TInt KMaximumKey = 0xfffffffeUL;
    55 
    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
    59 a single IPC.
    60 @internalAll
    61 @prototype
    62 */
    63 const TInt KCentRepFindBufSize = 16;
    64 
    65 /** Use KUnspecifiedKey instead of this value.
    66 @internalAll
    67 @prototype
    68 */
    69 const TUint32 KInvalidNotificationId = KUnspecifiedKey;
    70 
    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.
    76 @internalAll
    77 @prototype
    78 @see CRepository::GetMeta
    79 @see KMetaUnreserved
    80 */
    81 const TUint32 KMetaSymbianReserved = 0xFF000000; 
    82 
    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.
    88 @internalAll
    89 @prototype
    90 @see CRepository::GetMeta
    91 @see KMetaSymbianReserved 
    92 */
    93 const TUint32 KMetaUnreserved = 0x00FFFFFF; 
    94 
    95 } // namespace NCentralRepositoryConstants
    96 
    97 class CPcRepImpl;
    98 /** Provides access to a repository.
    99 
   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.
   103 @internalAll
   104 @prototype
   105 */
   106 class CRepository : public CBase
   107 	{
   108 public:
   109 
   110 	/**	Transaction mode chosen with StartTransaction.
   111 	@internalAll
   112 	@prototype*/
   113 	enum TTransactionMode
   114 		{
   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
   131 		};
   132 
   133 	/** Buffer type for aKeyInfo parameter to asynchronous CommitTransaction.
   134 	@see CRepository::CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus)
   135 	@internalAll
   136 	@prototype
   137 	*/
   138 	typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf;
   139 
   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);
   144 
   145 	IMPORT_C TInt Flush();
   146 
   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);
   152 
   153 	IMPORT_C TInt Delete(TUint32 aKey);
   154 	IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32& aErrorKey) ;
   155 
   156 	IMPORT_C TInt Get(TUint32 aKey, TInt& aValue);
   157 	IMPORT_C TInt Set(TUint32 aKey, TInt aValue);
   158 	
   159 	IMPORT_C TInt Get(TUint32 aKey, TReal& aValue);
   160 	IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue);
   161 
   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);
   165 
   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);
   169 
   170 	IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta);
   171 
   172 	IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, 
   173 	                    TUint32 aMask, TUint32& aErrorKey) ;
   174 
   175 	IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask,
   176 		RArray<TUint32>& aFoundKeys);
   177 
   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);
   186 
   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);
   195 
   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();
   204 	
   205 	/** Same as CancelTransaction.
   206 	@see CancelTransaction */
   207 	inline void RollbackTransaction() 
   208 		{
   209 		CancelTransaction();
   210 		}
   211 
   212 	/** Same as CleanupCancelTransactionPushL.
   213 	@see CleanupCancelTransactionPushL */
   214 	inline void CleanupRollbackTransactionPushL()
   215 		{
   216 		CleanupCancelTransactionPushL();
   217 		}
   218 private:
   219 	CRepository(){};
   220 	void ConstructL(TUid aRepositoryUid,const TDesC& aInFileName,const TDesC& aOutFileName,TBool aAutoLoading);
   221 	
   222 private:
   223 	CPcRepImpl* iImpl;
   224 	};
   225 
   226 #endif // __CENTRALREPOSITORY_H__