tsrc/centralrepositorystub/inc/centralrepository.h
changeset 22 496ad160a278
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CENTRALREPOSITORY_H__
       
    20 #define __CENTRALREPOSITORY_H__
       
    21 
       
    22 // Stub includes
       
    23 #include "mussettingskeys.h"
       
    24 // Stub forward declarations
       
    25 class CDesC8ArrayFlat;
       
    26 
       
    27 #include <e32base.h>
       
    28 
       
    29 const TInt KCenRepStubGlobalKeyValueMaxLen = 20; // stub stuff
       
    30 
       
    31 namespace NCentralRepositoryConstants
       
    32 /** Namespace encapsulating the CentralRepository constants.
       
    33 @publishedAll
       
    34 @released
       
    35 */
       
    36 {
       
    37 	
       
    38 /** The maximum number of unicode characters that can be stored in a setting
       
    39 @publishedAll
       
    40 @released
       
    41 */
       
    42 const TInt KMaxUnicodeStringLength = 1024;
       
    43 
       
    44 /** The maximum number of bytes that can be stored in a setting
       
    45 @publishedAll
       
    46 @released
       
    47 */
       
    48 const TInt KMaxBinaryLength = KMaxUnicodeStringLength*2;
       
    49 
       
    50 /** Error key returned by CommitTransaction in case of an error that cannot be
       
    51 attributed to any single or partial key. Also notify value for spurious 
       
    52 notifications (eg when a notification is cancelled or several values change at once )
       
    53 @internalAll
       
    54 @released
       
    55 */
       
    56 const TUint32 KUnspecifiedKey = 0xffffffffUL;
       
    57 
       
    58 /** Initial buffer size for Find~ API. Initial buffer is used to cut on the number
       
    59 of IPC calls required for each Find~ API call. If the number of settings found is 
       
    60 less than or equal to KCentRepFindBufSize then all the settings can be retrieved with
       
    61 a single IPC.
       
    62 @internalAll
       
    63 */
       
    64 const TInt KCentRepFindBufSize = 16;
       
    65 
       
    66 /** Use KUnspecifiedKey instead of this value.
       
    67 @publishedAll
       
    68 @deprecated
       
    69 */
       
    70 const TUint32 KInvalidNotificationId = KUnspecifiedKey;
       
    71 
       
    72 /** The 8 most significant bits of a setting's meta-data are reserved for internal use.
       
    73 Clients should not make use of the reserved bits (unless it is specifically stated
       
    74 otherwise in Symbian developer documentation).  Clients should not rely on the value
       
    75 of the reserved bits.  Reserved bits are not guaranteed to be 0 or 1 and are not
       
    76 guaranteed to stay constant from one GetMeta call to the next.
       
    77 @publishedPartner
       
    78 @released
       
    79 @see CRepository::GetMeta
       
    80 @see KMetaUnreserved
       
    81 */
       
    82 const TUint32 KMetaSymbianReserved = 0xFF000000; 
       
    83 
       
    84 /** The 24 least significant bits of a setting's meta-data are available for use. Clients
       
    85 should make use of KMetaUnreserved to mask out the reserved bits following a call
       
    86 to GetMeta.  Clients should not rely on the value of the reserved bits.  Reserved bits
       
    87 are not guaranteed to be 0 or 1 and are not guaranteed to stay constant from one
       
    88 GetMeta call to the next.
       
    89 @publishedPartner
       
    90 @released
       
    91 @see CRepository::GetMeta
       
    92 @see KMetaSymbianReserved 
       
    93 */
       
    94 const TUint32 KMetaUnreserved = 0x00FFFFFF; 
       
    95 
       
    96 } // namespace NCentralRepositoryConstants
       
    97 
       
    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 @publishedAll
       
   104 @released
       
   105 */
       
   106 class CRepository : public CBase
       
   107 	{
       
   108 public:
       
   109 
       
   110 	/**	Transaction mode chosen with StartTransaction.
       
   111 	@publishedPartner
       
   112 	@released */
       
   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 	@publishedPartner
       
   136 	@released
       
   137 	*/
       
   138 	typedef TPckgBuf<TUint32> TTransactionKeyInfoBuf;
       
   139 
       
   140 	IMPORT_C static CRepository* NewL(TUid aRepositoryUid);
       
   141 	IMPORT_C static CRepository* NewLC(TUid aRepositoryUid);
       
   142 
       
   143 	IMPORT_C virtual ~CRepository();
       
   144 
       
   145 	
       
   146 	IMPORT_C TInt Create(TUint32 aKey, TInt aValue);
       
   147 	//IMPORT_C TInt Create(TUint32 aKey, const TReal& aValue);
       
   148 	IMPORT_C TInt Create(TUint32 aKey, const TDesC8& aValue);
       
   149 	//IMPORT_C TInt Create(TUint32 aKey, const TDesC16& aValue);
       
   150 	//IMPORT_C TInt Delete(TUint32 aKey);
       
   151 	IMPORT_C TInt Delete(TUint32 aPartialKey, TUint32 aMask, TUint32 &aErrorKey) ;
       
   152 
       
   153 
       
   154 	IMPORT_C TInt Get(TUint32 aKey, TInt& aValue);
       
   155 	IMPORT_C TInt Set(TUint32 aKey, TInt aValue);
       
   156 
       
   157 /*	
       
   158 	IMPORT_C TInt Get(TUint32 aKey, TReal& aValue);
       
   159 	IMPORT_C TInt Set(TUint32 aKey, const TReal& aValue);
       
   160 */
       
   161 	IMPORT_C TInt Get(TUint32 aKey, TDes8& aValue);
       
   162 	//IMPORT_C TInt Get(TUint32 aId, TDes8& aValue, TInt& aActualLength);
       
   163 	IMPORT_C TInt Set(TUint32 aKey, const TDesC8& aValue);
       
   164 
       
   165 	IMPORT_C TInt Get(TUint32 aKey, TDes16& aValue);
       
   166 	//IMPORT_C TInt Get(TUint32 aId, TDes16& aValue, TInt& aActualLength);
       
   167 	IMPORT_C TInt Set(TUint32 aKey, const TDesC16& aValue);
       
   168 /*
       
   169 	IMPORT_C TInt GetMeta(TUint32 aKey, TUint32& aMeta);
       
   170 
       
   171 	IMPORT_C TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, 
       
   172 	                    TUint32 aMask, TUint32 &aErrorKey) ;
       
   173 */
       
   174 	IMPORT_C TInt FindL(TUint32 aPartialKey, TUint32 aMask,
       
   175 		RArray<TUint32>& aFoundKeys);
       
   176 /*
       
   177 	IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
       
   178 		TInt aValue, RArray<TUint32>& aFoundKeys);
       
   179 	IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
       
   180 		const TReal& aValue, RArray<TUint32>& aFoundKeys);
       
   181 */
       
   182 	IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
       
   183 		const TDesC8& aValue, RArray<TUint32>& aFoundKeys);
       
   184 /*
       
   185 	IMPORT_C TInt FindEqL(TUint32 aPartialKey, TUint32 aMask,
       
   186 		const TDesC16& aValue, RArray<TUint32>& aFoundKeys);
       
   187 
       
   188 	IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
       
   189 		TInt aValue, RArray<TUint32>& aFoundKeys);
       
   190 	IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
       
   191 		const TReal& aValue, RArray<TUint32>& aFoundKeys);
       
   192 	IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
       
   193 		const TDesC8& aValue, RArray<TUint32>& aFoundKeys);
       
   194 	IMPORT_C TInt FindNeqL(TUint32 aPartialKey, TUint32 aMask,
       
   195 		const TDesC16& aValue, RArray<TUint32>& aFoundKeys);
       
   196 
       
   197 	IMPORT_C TInt NotifyRequest(TUint32 aKey, TRequestStatus& aStatus);
       
   198 	IMPORT_C TInt NotifyRequest(TUint32 aPartialKey, TUint32 aMask,
       
   199 		TRequestStatus& aStatus);
       
   200 
       
   201 	IMPORT_C TInt NotifyCancel(TUint32 aKey);
       
   202 	IMPORT_C TInt NotifyCancel(TUint32 aPartialKey, TUint32 aMask);
       
   203 	IMPORT_C TInt NotifyCancelAll();
       
   204 
       
   205 	IMPORT_C TInt Reset();
       
   206 	IMPORT_C TInt Reset(TUint32 aKey);
       
   207 */
       
   208 
       
   209 	IMPORT_C TInt StartTransaction(TTransactionMode aMode);
       
   210 	//IMPORT_C void StartTransaction(TTransactionMode aMode, TRequestStatus& aStatus);
       
   211 	IMPORT_C TInt CommitTransaction(TUint32& aKeyInfo);
       
   212 	//IMPORT_C void CommitTransaction(TDes8& aKeyInfo, TRequestStatus& aStatus);
       
   213 	//IMPORT_C void CancelTransaction();
       
   214 	//IMPORT_C void CleanupCancelTransactionPushL();
       
   215 	//IMPORT_C void FailTransaction();
       
   216 	//IMPORT_C void CleanupFailTransactionPushL();
       
   217 
       
   218 	/** Same as CancelTransaction.
       
   219 	@publishedPartner
       
   220 	@released
       
   221 	@see CancelTransaction */
       
   222 /*
       
   223 	inline void RollbackTransaction() 
       
   224 		{
       
   225 		CancelTransaction();
       
   226 		}
       
   227 */
       
   228 	/** Same as CleanupCancelTransactionPushL.
       
   229 	@publishedPartner
       
   230 	@released
       
   231 	@see CleanupCancelTransactionPushL */
       
   232 /*
       
   233 	inline void CleanupRollbackTransactionPushL()
       
   234 		{
       
   235 		CleanupCancelTransactionPushL();
       
   236 		}
       
   237 */
       
   238 //	IMPORT_C TInt TransactionState();
       
   239 
       
   240 	/** This API is for internal use only and for testing purposes.
       
   241 	@internalAll
       
   242 	*/
       
   243 //	IMPORT_C static TInt SetGetParameters(const TIpcArgs& aArgs);
       
   244 
       
   245 
       
   246  
       
   247 
       
   248 private: // Stub functions
       
   249 
       
   250     CRepository( TUid aRepositoryUid );
       
   251 
       
   252 public: // Stub functios
       
   253     
       
   254     void ResetKeysAndValues();
       
   255     // Setter for static variable staticAvcConfigKeys. Reserves heap.
       
   256     static void SetStubAvcConfigKeysL( const TDesC8& aConfigKeys );
       
   257     // Deletes heap reserved by previous function.
       
   258     static void DeleteStubAvcConfigKeys();
       
   259     
       
   260     // Setter for static cenrep val, note amount of globals is limited
       
   261     static TInt SetStubGlobal(TUint32 aKey, TInt aValue);
       
   262     static void ResetStubGlobal();
       
   263     
       
   264 
       
   265 public: // Stub data
       
   266 
       
   267     static MusSettingsKeys::TOperatorVariant iOperatorVariant;
       
   268     
       
   269     // If the following value is ETrue, CenRep UID KCRUidSIPClientResolverConfig
       
   270     // exists and respository is possible to create with this value. Otherwise
       
   271     // CenRep instantiation leaves with KErrNone.
       
   272     static TBool iEmulateSawfishRepository;
       
   273 
       
   274     RArray<TUint32> iKeys;
       
   275     RArray<TInt> iValues;
       
   276     RArray<TUint32> iDesC8Keys;
       
   277     CDesC8ArrayFlat* iDesC8Values;
       
   278     
       
   279     static TInt iForceFailWithCode;
       
   280     
       
   281     static HBufC8* iStaticAvcConfigKeys;
       
   282     static TBool iStaticWriteAvcKeysToStaticData;
       
   283     
       
   284     static TInt iStaticEncoderUid;
       
   285     
       
   286     class TCenRepStubKeyValueEntry
       
   287         {
       
   288     public:
       
   289         TUint iKey;
       
   290         TInt iVal;
       
   291         };
       
   292         
       
   293     static TCenRepStubKeyValueEntry iGlobalKeyVals[ KCenRepStubGlobalKeyValueMaxLen ];
       
   294     static TInt iGlobalKeyValsTop;
       
   295     
       
   296     TUid iRepositoryUid;
       
   297     
       
   298     
       
   299         
       
   300 	};
       
   301 
       
   302 #endif // __CENTRALREPOSITORY_H__