iptel_plat/richcallsettingsengine_api/inc/rcseregistrybase.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  Base class for RCSE registry classes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CRCSEREGISTRYBASE_H
       
    20 #define CRCSEREGISTRYBASE_H
       
    21 
       
    22 //#include <centralrepository.h>
       
    23 #include <e32base.h>
       
    24 #include <d32dbms.h>
       
    25 #include <mrcsebackupobserver.h>
       
    26 
       
    27 #include <cenrepdatabaseutil.h>
       
    28 const TInt KMaxNameLength = 100;
       
    29 
       
    30 
       
    31 class CRCSEBackupObserver;
       
    32 
       
    33 /**
       
    34  *  Base class for RCSE registry classes
       
    35  *
       
    36  *  Encapsules settings repository connections and handles backup events.
       
    37  *
       
    38  *  @lib rcse.lib
       
    39  *  @since S60 v3.0
       
    40  */
       
    41 class CRCSERegistryBase : public CBase, public MRCSEBackupObserver
       
    42     {
       
    43 protected:
       
    44 
       
    45     /**  Registry type */
       
    46     enum TRCSERegistryType
       
    47         {
       
    48         EUnknown,
       
    49         EVoIPProfile,
       
    50         ESIPSetting,        // Not supported
       
    51         EAudioCodecSetting,
       
    52         ESCCPProfile        // Not supported
       
    53         };
       
    54 
       
    55     /**  Item types in settings table */
       
    56     enum TItemType
       
    57         {
       
    58         EItemUnknown    = 0,            // Unknown item
       
    59         EItemDeleted    = 1,            // Row (item) deleted
       
    60         EItemVoIPEntry  = 2,            // VoIP profile entry
       
    61         EItemCodecEntry = 3,            // Audio codec entry
       
    62         EItemAttribute  = 4,            // Attribute of entry
       
    63         };
       
    64 
       
    65 
       
    66 public:
       
    67 
       
    68     virtual ~CRCSERegistryBase();
       
    69 
       
    70     /**
       
    71      * From MRCSEBackupObserver.
       
    72      * Handle backup observer event.
       
    73      *
       
    74      * @since S60 v3.0
       
    75      */
       
    76     void HandleBackupOperationEventL();
       
    77 
       
    78 protected:
       
    79 
       
    80     CRCSERegistryBase( TRCSERegistryType aType );
       
    81 
       
    82     void BaseConstructL();
       
    83 
       
    84     /**
       
    85     * Prepares operation. Checks that there is not backup/restore
       
    86     * opearation ongoing and begins transaction.
       
    87     *    
       
    88     * @since S60 v3.2
       
    89     * @leave KErrNotReady if there is backuoperation ongoing.
       
    90     * @leave KErrLocked if there is write operation already ongoing.
       
    91     */
       
    92     void BeginL();
       
    93 
       
    94     /**
       
    95     * Ends user operations. Commits transaction.
       
    96     *
       
    97     * @since S60 v3.2
       
    98     * @param aType Type of performed operation
       
    99     */
       
   100     void EndL();
       
   101 
       
   102     /**
       
   103     * Helper method that converts TInt32 type to descriptor.
       
   104     *
       
   105     * @since S60 v3.2
       
   106     * @param aFrom TInt32 value to be converted.
       
   107     * @param aTo Descriptor containing the converted value.
       
   108     * @return Reference to descriptor containing the converted value.
       
   109     */
       
   110     TDesC& ToDes( TInt32 aFrom, TDes& aTo );
       
   111 
       
   112     /**
       
   113     * Helper method that converts TUint32 type to descriptor.
       
   114     *
       
   115     * @since S60 v3.2
       
   116     * @param aFrom TUint32 value to be converted.
       
   117     * @param aTo Descriptor containing the converted value.
       
   118     * @return Reference to descriptor containing the converted value.
       
   119     */
       
   120     TDesC& ToDes( TUint32 aFrom, TDes& aTo );
       
   121 
       
   122     /**
       
   123     * Helper method that converts descriptor type to TInt32.
       
   124     *
       
   125     * @since S60 v3.2
       
   126     * @param aFrom Descriptor to be converted.
       
   127     * @return Converted TInt32 value.
       
   128     */
       
   129     TInt32 ToTInt32L( const TDesC& aFrom );
       
   130 
       
   131     /**
       
   132     * Helper method that converts descriptor type to TUint32.
       
   133     *
       
   134     * @since S60 v3.2
       
   135     * @param aFrom Descriptor to be converted.
       
   136     * @return Converted TUint32 value.
       
   137     */
       
   138     TUint32 ToTUint32L( const TDesC& aFrom );
       
   139 
       
   140     /**
       
   141     * Imports rcse settings from restored database file 
       
   142     *
       
   143     * @since S60 v3.2
       
   144     */
       
   145     void ImportSettingsL();
       
   146 
       
   147     /**
       
   148     * Create CenRep db property to given property array.
       
   149     *
       
   150     * @since S60 v3.2
       
   151     * @param aPropertyName Name of created property.
       
   152     * @param aPropertyValue Value of created property.
       
   153     * @param aPropertyArray Container of properties.
       
   154     */
       
   155     void CreatePropertyL( TUint aPropertyName,
       
   156                           const TDesC& aPropertyValue,
       
   157                           RIpAppPropArray& aPropertyArray );
       
   158 
       
   159     /**
       
   160     * Find value of property from given property array.
       
   161     *
       
   162     * @since S60 v3.2
       
   163     * @param aPropertyName Name of requested property.
       
   164     * @param aPropertyValue Value of requested property.
       
   165     * @param aPropertyArray Container of properties.
       
   166     */
       
   167     void GetPropertyValueL( TUint aPropertyName,
       
   168                             TDes& aPropertyValue,
       
   169                             RIpAppPropArray& aPropertyArray );
       
   170 
       
   171     /**
       
   172     * Create CenRep db property to given property array.
       
   173     *
       
   174     * @since S60 v3.2
       
   175     * @param aPropertyName Searh criteria.
       
   176     * @param aPropertyValue Searh criteria.
       
   177     * @param aIdArray Contains all found entry IDs.
       
   178     */
       
   179     void FindIdsByValueL( TUint aPropertyName,
       
   180                           const TDesC& aPropertyValue,
       
   181                           RArray<TUint32>& aIdArray );
       
   182 
       
   183     /**
       
   184     * Search all entry IDs from CenRep database.
       
   185     *
       
   186     * @since S60 v3.2
       
   187     * @param aIdArray Contains all found entry IDs.
       
   188     */
       
   189     void FindAllIdsL( RArray<TUint32>& aIdArray );
       
   190 
       
   191     /**
       
   192      * Custom cleanup for cenrep db property array.
       
   193      *
       
   194      * @since S60 v3.2
       
   195      * @param aPointer Array pointer
       
   196      */
       
   197     static void CleanupDbPropArray( TAny* aPointer );
       
   198 
       
   199 
       
   200 protected: // data
       
   201 
       
   202     /**
       
   203      * Registry type of this object
       
   204      */
       
   205     TRCSERegistryType iType;
       
   206 
       
   207     /**
       
   208      * Backup observer
       
   209      * Own.
       
   210      */
       
   211     CRCSEBackupObserver* iBackupObserver;
       
   212 
       
   213     /**
       
   214      * Backup flag
       
   215      */
       
   216     TBool iBackupActive;
       
   217 
       
   218     /**
       
   219      * Interface to RCSE's settings storage
       
   220      * Own.
       
   221      */
       
   222     CCenRepDatabaseUtil* iCenRepDb;
       
   223 
       
   224 
       
   225     // For testing
       
   226     #ifdef TEST_EUNIT
       
   227         friend class UT_CRCSERegistryBase;
       
   228     #endif                                  
       
   229 
       
   230     };
       
   231 
       
   232 #endif // CRCSEREGISTRYBASE_H