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