phonesrv_plat/cenrep_database_api/inc/cenrepdatabaseutil.h
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
    79         * Destructor.
    79         * Destructor.
    80         */
    80         */
    81         IMPORT_C virtual ~CCenRepDatabaseUtil();
    81         IMPORT_C virtual ~CCenRepDatabaseUtil();
    82         
    82         
    83     public: 
    83     public: 
    84         /**
    84 	    /**
    85          * Start transaction in repository. 
    85 	     * Start transaction in repository. 
    86          * Note. Function leaves two cleanup items to cleanupstack and those
    86 	     * Note. Function leaves two cleanup items to cleanupstack and those
    87          * are freed when CommitTransaction or RollbackTransaction is called.
    87 	     * are freed when CommitTransaction or RollbackTransaction is called.
    88          *
    88 	     *
    89          * @since S60 v3.2
    89 	     * @since S60 v3.2
    90          */
    90 	     */
    91         IMPORT_C void BeginTransactionL();
    91 	    IMPORT_C void BeginTransactionL();
    92 
    92 
    93         /**
    93 	    /**
    94          * Commit changes in repository
    94 	     * Commit changes in repository
    95          *
    95 	     *
    96          * @since S60 v3.2
    96 	     * @since S60 v3.2
    97          * @return An error code
    97 	     * @return An error code
    98          */
    98 	     */
    99         IMPORT_C TInt CommitTransaction();
    99 	    IMPORT_C TInt CommitTransaction();
   100         
   100 	    
   101         /**
   101 	    /**
   102          * Rollback changes in repository
   102 	     * Rollback changes in repository
   103          *
   103 	     *
   104          * @since S60 v3.2
   104 	     * @since S60 v3.2
   105          */
   105 	     */
   106         IMPORT_C void RollbackTransaction();
   106 	    IMPORT_C void RollbackTransaction();
   107         
   107 	    
   108         /**
   108 	    /**
   109          * Store new entry to table.
   109 	     * Store new entry to table.
   110          *
   110 	     *
   111          * @since S60 v3.2
   111 	     * @since S60 v3.2
   112          * @param aEntryId Contains new ID when returns.
   112 	     * @param aEntryId Contains new ID when returns.
   113          * @param aArray Container for properties of this entry.
   113 	     * @param aArray Container for properties of this entry.
   114          */
   114 	     */
   115         IMPORT_C void AddEntryL(  TInt& aEntryId, const RIpAppPropArray& aArray );
   115 	    IMPORT_C void AddEntryL(  TInt& aEntryId, const RIpAppPropArray& aArray );
   116 
   116 
   117         /**
   117 	    /**
   118          * Search entry by entry ID. 
   118 	     * Search entry by entry ID. 
   119          *
   119 	     *
   120          * @since S60 v3.2
   120 	     * @since S60 v3.2
   121          * @param aEntryId Id of requested entry
   121 	     * @param aEntryId Id of requested entry
   122          * @param aArray on return, property array.
   122 	     * @param aArray on return, property array.
       
   123 	     * @return error code, KErrNotFound if unknown entry.
       
   124 	     */
       
   125 	    IMPORT_C TInt FindEntryL( TInt aEntryId, RIpAppPropArray& aArray );
       
   126 
       
   127 	    /**
       
   128 	     * Updates entry to central repository
       
   129 	     *
       
   130 	     * @since S60 v3.2
       
   131 	     * @param aEntryId Id of requested entry
       
   132 	     * @param aArray Updated properties of entry
       
   133 	     * @return error code, KErrNotFound if unknown entry.
       
   134 	     */
       
   135 	    IMPORT_C TInt UpdateEntryL( TInt aEntryId, 
       
   136 	                                const RIpAppPropArray& aArray );
       
   137 
       
   138 	    /**
       
   139 	     * Deletes settings entry from storage by entry ID.
       
   140 	     *
       
   141 	     * @since S60 v3.2
       
   142 	     * @param aEntryId Id of entry which is going to be deleted
       
   143 	     * @return error code, KErrNone if delete succeeded, otherwise system wide error code
       
   144 	     */
       
   145 	    IMPORT_C TInt DeleteEntryL( TInt aEntryId );
       
   146 
       
   147 	    /**
       
   148 	     * Search property of entry from storage.
       
   149 	     *
       
   150 	     * @since S60 v3.2
       
   151 	     * @param aEntryId The entry ID of requested entry
       
   152 	     * @param aPropertyName property name to be found
       
   153 	     * @param aProperty on return, requested property
       
   154 	     * @return error code, KErrNone if succeeded, otherwise system wide error code
       
   155 	     */
       
   156 	    IMPORT_C TInt FindPropertyL( TInt aEntryId, 
       
   157          	                         TUint32 aPropertyName,
       
   158 	                                 CCenRepDatabaseProperty& aProperty );
       
   159 
       
   160 	    /**
       
   161 	     * Add or update properties of entry in table.
       
   162 	     * Values of existing properties are overwritten.
       
   163 	     *
       
   164 	     * @since S60 v3.2
       
   165 	     * @param aEntryId The ID of updated entry
       
   166 	     * @param aArray new properties to be added or updated
   123          * @return error code, KErrNotFound if unknown entry.
   167          * @return error code, KErrNotFound if unknown entry.
   124          */
   168 	     */
   125         IMPORT_C TInt FindEntryL( TInt aEntryId, RIpAppPropArray& aArray );
   169 	    IMPORT_C TInt AddOrUpdatePropertiesL( TInt aEntryId, 
   126 
   170 	                                          const RIpAppPropArray& aArray );
   127         /**
   171 
   128          * Updates entry to central repository
   172 
   129          *
   173 	    /**
   130          * @since S60 v3.2
   174 	     * Delete properties of entry in table.
   131          * @param aEntryId Id of requested entry
   175 	     *
   132          * @param aArray Updated properties of entry
   176 	     * @since S60 v3.2
   133          * @return error code, KErrNotFound if unknown entry.
   177 	     * @param aEntryId The entry ID of requested entry
   134          */
   178 	     * @param aNameArray name of properties to be deleted
   135         IMPORT_C TInt UpdateEntryL( TInt aEntryId, 
   179 	     * @return error code, KErrNotFound if unknown entry.
   136                                     const RIpAppPropArray& aArray );
   180 	     */
   137 
   181 	    IMPORT_C TInt DeletePropertiesL( TInt aEntryId,
   138         /**
   182 	                                     const RArray<TUint32>& aNameArray );
   139          * Deletes settings entry from storage by entry ID.
   183 
   140          *
   184 	    /**
   141          * @since S60 v3.2
   185 	     * Return count of entries in table.
   142          * @param aEntryId Id of entry which is going to be deleted
   186 	     *
   143          * @return error code, KErrNone if delete succeeded, otherwise system wide error code
   187 	     * @since S60 v3.2
   144          */
   188 	     * @return Count of stored settings.
   145         IMPORT_C TInt DeleteEntryL( TInt aEntryId );
   189 	     */
   146 
   190 	    IMPORT_C TInt EntryCountL( TInt& aCount );
   147         /**
   191 
   148          * Search property of entry from storage.
   192 	    /**
   149          *
   193 	     * Search all entry IDs from storage
   150          * @since S60 v3.2
   194 	     *
   151          * @param aEntryId The entry ID of requested entry
   195 	     * @since S60 v3.2
   152          * @param aPropertyName property name to be found
   196 	     * @param aEntryIds An array containing returned entry IDs
   153          * @param aProperty on return, requested property
   197 	     * @return error code
   154          * @return error code, KErrNone if succeeded, otherwise system wide error code
   198 	     */
   155          */
   199 	    IMPORT_C TInt FindEntryIdsL( RArray<TInt>& aEntryIds );
   156         IMPORT_C TInt FindPropertyL( TInt aEntryId, 
       
   157                                      TUint32 aPropertyName,
       
   158                                      CCenRepDatabaseProperty& aProperty );
       
   159 
       
   160         /**
       
   161          * Add or update properties of entry in table.
       
   162          * Values of existing properties are overwritten.
       
   163          *
       
   164          * @since S60 v3.2
       
   165          * @param aEntryId The ID of updated entry
       
   166          * @param aArray new properties to be added or updated
       
   167          * @return error code, KErrNotFound if unknown entry.
       
   168          */
       
   169         IMPORT_C TInt AddOrUpdatePropertiesL( TInt aEntryId, 
       
   170                                               const RIpAppPropArray& aArray );
       
   171 
       
   172 
       
   173         /**
       
   174          * Delete properties of entry in table.
       
   175          *
       
   176          * @since S60 v3.2
       
   177          * @param aEntryId The entry ID of requested entry
       
   178          * @param aNameArray name of properties to be deleted
       
   179          * @return error code, KErrNotFound if unknown entry.
       
   180          */
       
   181         IMPORT_C TInt DeletePropertiesL( TInt aEntryId,
       
   182                                          const RArray<TUint32>& aNameArray );
       
   183 
       
   184         /**
       
   185          * Return count of entries in table.
       
   186          *
       
   187          * @since S60 v3.2
       
   188          * @return Count of stored settings.
       
   189          */
       
   190         IMPORT_C TInt EntryCountL( TInt& aCount );
       
   191 
       
   192         /**
       
   193          * Search all entry IDs from storage
       
   194          *
       
   195          * @since S60 v3.2
       
   196          * @param aEntryIds An array containing returned entry IDs
       
   197          * @return error code
       
   198          */
       
   199         IMPORT_C TInt FindEntryIdsL( RArray<TInt>& aEntryIds );
       
   200                                    
   200                                    
   201         /**
   201 	    /**
   202          * Find entry IDs with same properties
   202 	     * Find entry IDs with same properties
   203          *
   203 	     *
   204          * @since S60 v3.2
   204 	     * @since S60 v3.2
   205          * @param aPropertyArray property array
   205 	     * @param aPropertyArray property array
   206          * @param aEntryIds on return, entry Ids with same properties
   206 	     * @param aEntryIds on return, entry Ids with same properties
   207          * @return error code
   207 	     * @return error code
   208          */
   208 	     */
   209         IMPORT_C TInt FindEntryIdsFromPropertiesL( const RIpAppPropArray& aPropertyArray, 
   209 	    IMPORT_C TInt FindEntryIdsFromPropertiesL( const RIpAppPropArray& aPropertyArray, 
   210                                                    RArray<TInt>& aEntryIds );
   210 	                                               RArray<TInt>& aEntryIds );
   211         
   211 	    
   212         
   212         
   213     private:
   213     private:
   214 
   214 
   215         /**
   215         /**
   216          * C++ default constructor.
   216          * C++ default constructor.
   224         /**
   224         /**
   225          * By default Symbian 2nd phase constructor is private.
   225          * By default Symbian 2nd phase constructor is private.
   226          */
   226          */
   227         void ConstructL( TUid aUid );
   227         void ConstructL( TUid aUid );
   228 
   228 
   229         /**
   229 	    /**
   230          * Release semaphore, this function is used in custom cleanup
   230 	     * Release semaphore, this function is used in custom cleanup
   231          * 
   231 	     * 
   232          * @since S60 v3.2
   232 	     * @since S60 v3.2
   233          * @param aPtr Pointer to an object which is the target of the cleanup operation
   233 	     * @param aPtr Pointer to an object which is the target of the cleanup operation
   234          */
   234 	     */
   235         static void ReleaseSemaphore( TAny* aPtr );
   235         static void ReleaseSemaphore( TAny* aPtr );
   236 
   236 
   237         /**
   237 	    /**
   238          * Release semaphore
   238 	     * Release semaphore
   239          * 
   239 	     * 
   240          * @since S60 v3.2
   240 	     * @since S60 v3.2
   241          */
   241 	     */
   242         void DoReleaseSemaphore();
   242         void DoReleaseSemaphore();
   243 
   243 
   244         /**
   244 	    /**
   245          * Set new value for given key. Creates the key if it doesn't exists.
   245 	     * Set new value for given key. Creates the key if it doesn't exists.
   246          *
   246 	     *
   247          * @since S60 v3.2
   247 	     * @since S60 v3.2
   248          * @param aKey
   248 	     * @param aKey
   249          * @param aValue
   249 	     * @param aValue
   250          */
   250 	     */
   251         template<class T> void SetOrCreateKeyL( TUint32 aKey, 
   251         template<class T> void SetOrCreateKeyL( TUint32 aKey, 
   252                                                 const T& aValue );
   252                                                 const T& aValue );
   253                                                 
   253                                                 
   254         /**
   254 	    /**
   255          * Create new ID for entry.
   255 	     * Create new ID for entry.
   256          *
   256 	     *
   257          * @since S60 v3.2
   257 	     * @since S60 v3.2
   258          * @param aNewId Contains new ID when return.
   258 	     * @param aNewId Contains new ID when return.
   259          */
   259 	     */
   260         void CreateEntryIdL( TInt& aNewId );
   260         void CreateEntryIdL( TInt& aNewId );
   261         
   261         
   262         /**
   262 	    /**
   263          * Defines next available key for ID.
   263 	     * Defines next available key for ID.
   264          *
   264 	     *
   265          * @since S60 v3.2
   265 	     * @since S60 v3.2
   266          * @return New key for ID
   266 	     * @return New key for ID
   267          */
   267 	     */
   268         TUint32 GetNewIdKeyL( );
   268         TUint32 GetNewIdKeyL( );
   269         
   269         
   270         /**
   270 	    /**
   271          * Update given properties of entry.
   271 	     * Update given properties of entry.
   272          *
   272 	     *
   273          * @since S60 v3.2
   273 	     * @since S60 v3.2
   274          * @param aIdKey
   274 	     * @param aIdKey
   275          * @param Array Contains updated properties and values
   275 	     * @param Array Contains updated properties and values
   276          */
   276 	     */
   277         void UpdatePropertiesL( TUint32 aIdKey, const RIpAppPropArray& aArray );
   277         void UpdatePropertiesL( TUint32 aIdKey, const RIpAppPropArray& aArray );
   278         
   278         
   279         /**
   279 	    /**
   280          * Check if entry has given properties.
   280 	     * Check if entry has given properties.
   281          *
   281 	     *
   282          * @since S60 v3.2
   282 	     * @since S60 v3.2
   283          * @param aEntryId Id of entry.
   283 	     * @param aEntryId Id of entry.
   284          * @param aPropertyArray Properties to be checked.
   284 	     * @param aPropertyArray Properties to be checked.
   285              * @param aOk Result
   285              * @param aOk Result
   286          */
   286 	     */
   287         void CheckEntryHasPropertiesL( TInt aEntryId, const RIpAppPropArray& aPropertyArray, TBool& aOk );
   287         void CheckEntryHasPropertiesL( TInt aEntryId, const RIpAppPropArray& aPropertyArray, TBool& aOk );
   288         
   288         
   289         /**
   289 	    /**
   290          * Custom cleanup for array.
   290 	     * Custom cleanup for array.
   291          *
   291 	     *
   292          * @since S60 v3.2
   292 	     * @since S60 v3.2
   293          * @param aPointer
   293 	     * @param aPointer
   294          */
   294 	     */
   295         static void CleanupPointerArray( TAny* aPointer );
   295         static void CleanupPointerArray( TAny* aPointer );
   296         
   296         
   297         
   297         
   298     private: // data
   298     private: // data
   299     
   299     
   300         /**
   300 	    /**
   301          * Central Repository object.
   301 	     * Central Repository object.
   302          * Own.
   302 	     * Own.
   303          */
   303 	     */
   304         CRepository* iRepository;
   304 	    CRepository* iRepository;
   305         
   305 	    
   306         /**
   306 	    /**
   307          * RSemaphore object.
   307 	     * RSemaphore object.
   308          * Own.
   308 	     * Own.
   309          */
   309 	     */
   310         RSemaphore iSemaphore;
   310 	    RSemaphore iSemaphore;
   311         
   311 	    
   312         /**
   312 	    /**
   313          * Start key in first column( Id column )
   313 	     * Start key in first column( Id column )
   314          */
   314 	     */
   315         TUint32 iStartKey;
   315 	    TUint32 iStartKey;
   316 
   316 
   317         /**
   317 	    /**
   318          * Column increment
   318 	     * Column increment
   319          */
   319 	     */
   320         TUint32 iColIncrement;
   320 	    TUint32 iColIncrement;
   321 
   321 
   322         /**
   322 	    /**
   323          * Column mask
   323 	     * Column mask
   324          */
   324 	     */
   325         TUint32 iColMask;
   325 	    TUint32 iColMask;
   326         
   326 	    
   327         /**
   327 	    /**
   328          * Id counter key
   328 	     * Id counter key
   329          */
   329 	     */
   330         TUint32 iIdCounterKey;
   330 	    TUint32 iIdCounterKey;
   331         
   331 	    
   332         /**
   332 	    /**
   333          * Column count
   333 	     * Column count
   334          */
   334 	     */
   335         TInt iColCount;
   335 	    TInt iColCount;
   336 
   336 
   337     private: // For testing
   337     private: // For testing
   338         #ifdef TEST_EUNIT
   338         #ifdef TEST_EUNIT
   339             friend class UT_CCenRepDatabaseUtil;
   339             friend class UT_CCenRepDatabaseUtil;
   340         #endif
   340         #endif