richcallsettingsengine/rcse2/inc/rcsedbimporter.h
branchRCL_3
changeset 21 f742655b05bf
parent 20 65a3ef1d5bd0
child 22 d38647835c2e
equal deleted inserted replaced
20:65a3ef1d5bd0 21:f742655b05bf
     1 /*
       
     2 * Copyright (c) 2007-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:  RCSE Settings Import from DBMS
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_RCSEDBIMPORTER_H
       
    21 #define C_RCSEDBIMPORTER_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <d32dbms.h>
       
    26 
       
    27 #include "crcseprofileentry.h"
       
    28 #include "crcseaudiocodecentry.h"
       
    29 
       
    30 
       
    31 /**  Struct for mapping old and new ids of entries */
       
    32 class TRCSEIdPair
       
    33     {
       
    34 public:
       
    35     TUint32 iOldId;
       
    36     TUint32 iNewId;
       
    37     };
       
    38 
       
    39 /**
       
    40  *  Utility class that imports rcse settings from database and
       
    41  *  stores them to central repository.
       
    42  *
       
    43  *  Enables the restoring of voip settings from previous SW versions.
       
    44  *
       
    45  *  @code
       
    46  *   if ( CRCSEDbImporter::ImportExists() && 
       
    47           !CRCSEDbImporter::IsImportRunning() )
       
    48         {
       
    49         CRCSEDbImporter* importer = CRCSEDbImporter::NewLC();
       
    50         importer->ImportAndStoreL();
       
    51         CleanupStack::PopAndDestroy( importer );
       
    52         }
       
    53 
       
    54  *  @endcode
       
    55  *
       
    56  *  @lib rcse.lib
       
    57  *  @since S60 v3.2
       
    58  */
       
    59 class CRCSEDbImporter : public CBase
       
    60     {
       
    61 
       
    62 public:
       
    63 
       
    64     static CRCSEDbImporter* NewL();
       
    65 
       
    66     static CRCSEDbImporter* NewLC();
       
    67 
       
    68     /**
       
    69     * Destructor.
       
    70     */
       
    71     virtual ~CRCSEDbImporter();
       
    72 
       
    73     /**
       
    74      * Check if there is imported (restored) rcse database file.
       
    75      *
       
    76      * @since S60 v3.2
       
    77      * @return ETrue if imported db file found
       
    78      */
       
    79     static TBool ImportExists();
       
    80 
       
    81     /**
       
    82      * Check if there is import operation already started.
       
    83      *
       
    84      * @since S60 v3.2
       
    85      * @return ETrue if import is already ongoing
       
    86      */
       
    87     static TBool IsImportRunning();
       
    88 
       
    89     /**
       
    90      * Imports rcse entries from database and stores them to repository.
       
    91      *
       
    92      * @since S60 v3.2
       
    93      */
       
    94     void ImportAndStoreL();
       
    95 
       
    96 private:
       
    97 
       
    98     CRCSEDbImporter();
       
    99 
       
   100     void ConstructL();
       
   101 
       
   102     /**
       
   103      * Sets lock that prevents other instances to start import operation.
       
   104      *
       
   105      * @since S60 v3.2
       
   106      */
       
   107     void SetImportLock();
       
   108     
       
   109     /**
       
   110      * Release import lock.
       
   111      *
       
   112      * @since S60 v3.2
       
   113      */
       
   114     void ReleaseImportLock();
       
   115 
       
   116     /**
       
   117      * Imports RCSE profile entries from database to the iProfiles array.
       
   118      *
       
   119      * @since S60 v3.2
       
   120      */
       
   121     void ImportVoIPProfilesL();
       
   122 
       
   123     /**
       
   124      * Imports RCSE audio codec entries from database to the iCodecs array.
       
   125      *
       
   126      * @since S60 v3.2
       
   127      */
       
   128     void ImportAudioCodecsL();
       
   129 
       
   130     /**
       
   131      * Deletes all imported db files
       
   132      *
       
   133      * @since S60 v3.2
       
   134      */
       
   135     void DeleteImports();
       
   136 
       
   137     /**
       
   138      * Maps data from database query to profile entry.
       
   139      *
       
   140      * @since S60 v3.2
       
   141      * @param aColumnIndex Column that is mappped.
       
   142      * @param aView Query results.
       
   143      * @param aEntry Data from requested column is mapped and
       
   144      *               stored to this entry.
       
   145      */
       
   146     void MapColumnToEntryL( TInt aColumnIndex, 
       
   147                             const RDbView& aView, 
       
   148                             CRCSEProfileEntry& aEntry );
       
   149 
       
   150     /**
       
   151      * Maps data from database query to audio codec entry.
       
   152      *
       
   153      * @since S60 v3.2
       
   154      * @param aColumnIndex Column that is mappped.
       
   155      * @param aView Query results.
       
   156      * @param aEntry Data from requested column is mapped and
       
   157      *               stored to this entry.
       
   158      */
       
   159     void MapColumnToEntryL( TInt aColumnIndex, 
       
   160                             const RDbView& aView, 
       
   161                             CRCSEAudioCodecEntry& aEntry );
       
   162 
       
   163 
       
   164     /**
       
   165      * Reads TSettingIds structs from given descriptor to array.
       
   166      *
       
   167      * @since S60 v3.2
       
   168      * @param aNumbers Descriptor containing TSettingIds structs.
       
   169      * @param aArray Container for TSettingIds structs.
       
   170      */
       
   171     void GetProfileIdsFromDescriptorL( const TDesC& aNumbers,
       
   172                                        RArray<TSettingIds>& aArray );
       
   173 
       
   174 
       
   175 
       
   176     /**
       
   177      * Reads IDs from given descriptor to array.
       
   178      *
       
   179      * @since S60 v3.2
       
   180      * @param aNumbers Descriptor containing list of IDs.
       
   181      * @param aArray Container for IDs.
       
   182      */
       
   183     template<class T>
       
   184     void GetNumbersFromDescriptorL( const TDesC& aNumbers,
       
   185                                     RArray<T>& aArray );
       
   186 
       
   187 
       
   188     /**
       
   189      * Updates new preferred audio codec IDs to imported VoIP 
       
   190      * profile entries.
       
   191      *
       
   192      * @since S60 v3.2
       
   193      */
       
   194     void UpdatePreferredCodecs();
       
   195 
       
   196     /**
       
   197      * Stores imported voip profiles.
       
   198      *
       
   199      * @since S60 v3.2
       
   200      */
       
   201     void StoreVoIPProfilesL();
       
   202 
       
   203     /**
       
   204      * Stores imported audio codecs.
       
   205      *
       
   206      * @since S60 v3.2
       
   207      */
       
   208     void StoreAudioCodecsL();
       
   209 
       
   210 
       
   211 
       
   212 private: // data
       
   213 
       
   214     /**
       
   215      * Database object.
       
   216      * Own.
       
   217      */
       
   218     RDbNamedDatabase iDb;
       
   219 
       
   220     /**
       
   221      * Database session.
       
   222      * Own.
       
   223      */
       
   224     RDbs iDbSession;
       
   225 
       
   226     /**
       
   227      * Container for imported VoIP profiles.
       
   228      * Own.
       
   229      */
       
   230     RPointerArray<CRCSEProfileEntry> iProfiles;
       
   231 
       
   232     /**
       
   233      * Container for imported Audio Codecs.
       
   234      * Own.
       
   235      */
       
   236     RPointerArray<CRCSEAudioCodecEntry> iCodecs;
       
   237 
       
   238     /**
       
   239      * An array for pairs of old and new codec IDs
       
   240      * Own.
       
   241      */
       
   242     RArray<TRCSEIdPair> iCodecIds;
       
   243 
       
   244 private:
       
   245     // For testing
       
   246     #ifdef TEST_EUNIT
       
   247         friend class UT_CRCSEDbImporter;
       
   248     #endif                                  
       
   249 
       
   250 
       
   251 
       
   252     };
       
   253 
       
   254 
       
   255 
       
   256 #endif // C_RCSEDBIMPORTER_H