upnpharvester/cdssync/cdssynclib/inc/cdssyncsqlao.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2009 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:      Cds Sync Active Object header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef CDSSYNCSQLAO_H
       
    24 #define CDSSYNCSQLAO_H
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MCmSqlMain;
       
    28 class CCdsSyncImpl;
       
    29 class CCmSqlBaseItem;
       
    30 class CCmSqlGenericItem;
       
    31 
       
    32 /**
       
    33  * CCdsSyncSqlAo class
       
    34  *
       
    35  * @lib cdssync.lib
       
    36  *
       
    37  * @since S60 v3.1
       
    38  */
       
    39 class CCdsSyncSqlAo : public CActive 
       
    40     {         
       
    41 public:
       
    42     // active object states
       
    43     enum TCdsSyncSqlAoState 
       
    44         {
       
    45         ECdsSyncSqlAoIdle = 0,
       
    46         ECdsSyncSqlAoAdding,
       
    47         ECdsSyncSqlAoDeleting,
       
    48         ECdsSyncSqlAoInitializing    
       
    49         };
       
    50         
       
    51     /**
       
    52      * Two-phased constructor.
       
    53      *
       
    54      * @param aSqlDb, Database handler instance
       
    55      * @param aSync, CdsSync implementation instance
       
    56      * @param aItemsToAdd, array of items to be added
       
    57      * @param aItemsToAdd, array of items to be deleted
       
    58      * @param aAddGranularity, count of items added at a time
       
    59      */
       
    60     static CCdsSyncSqlAo* NewL( MCmSqlMain& aSqlDb,
       
    61                                 CCdsSyncImpl& aSync,
       
    62                                 RPointerArray<CCmSqlGenericItem>& aItemsToAdd,
       
    63                                 RPointerArray<CCmSqlBaseItem>& aItemsToDelete,
       
    64                                 TInt aAddGranularity );
       
    65 
       
    66     /**
       
    67      * Two-phased constructor.
       
    68      *
       
    69      * @param aSqlDb, Database handler instance
       
    70      * @param aSync, CdsSync implementation instance
       
    71      * @param aItemsToAdd, array of items to be added
       
    72      * @param aItemsToAdd, array of items to be deleted
       
    73      * @param aAddGranularity, count of items added at a time     
       
    74      */
       
    75     static CCdsSyncSqlAo* NewLC( 
       
    76         MCmSqlMain& aSqlDb,
       
    77         CCdsSyncImpl& aSync,
       
    78         RPointerArray<CCmSqlGenericItem>& aItemsToAdd,
       
    79         RPointerArray<CCmSqlBaseItem>& aItemsToDelete,
       
    80         TInt aAddGranularity );
       
    81 
       
    82     /**
       
    83      * Destructor.
       
    84      */
       
    85     virtual ~CCdsSyncSqlAo();
       
    86  
       
    87     /**
       
    88      * NotifyItemsAddedL
       
    89      *
       
    90      * @since S60 v3.1
       
    91      * @param aSourceDataComplete, indicates if all source data is added     
       
    92      */
       
    93     void NotifyItemsAddedL( TBool aSourceDataComplete = EFalse );
       
    94 
       
    95     /**
       
    96      * Activate
       
    97      *
       
    98      * @since S60 v3.1
       
    99      */
       
   100     void Activate();
       
   101  
       
   102  protected:
       
   103  
       
   104 // From base class CActive
       
   105 
       
   106     /**
       
   107      * From CActive
       
   108      * See base class definition
       
   109      */       
       
   110     void RunL();
       
   111 
       
   112     /**
       
   113      * From CActive
       
   114      * See base class definition
       
   115      */
       
   116     void DoCancel();
       
   117         
       
   118 private:
       
   119 
       
   120     /**
       
   121      * Performs the first phase of two phase construction.
       
   122      *
       
   123      * @param aSqlDb, Database handler instance
       
   124      * @param aSync, CdsSync implementation instance
       
   125      * @param aItemsToAdd, array of items to be added
       
   126      * @param aItemsToAdd, array of items to be deleted
       
   127      * @param aAddGranularity, count of items added at a time     
       
   128      */   
       
   129     CCdsSyncSqlAo( MCmSqlMain& aSqlDb,
       
   130                    CCdsSyncImpl& aSync,
       
   131                    RPointerArray<CCmSqlGenericItem>& aItemsToAdd,
       
   132                    RPointerArray<CCmSqlBaseItem>& aItemsToDelete,
       
   133                    TInt aAddGranularity );
       
   134 
       
   135     /**
       
   136      * Performs the second phase construction.
       
   137      */  
       
   138     void ConstructL();    
       
   139 
       
   140     /**
       
   141      * Checks metadata amouts and removes overhead items
       
   142      *
       
   143      * @since S60 v5.1
       
   144      */        
       
   145     void IfOverLimitDeleteMediaItems();                  
       
   146         
       
   147 public:
       
   148 
       
   149     /**
       
   150      * Active object state 
       
   151      */
       
   152     TCdsSyncSqlAoState                  iState;
       
   153   
       
   154 private:
       
   155 
       
   156     /**
       
   157      * Database handler
       
   158      */  
       
   159     MCmSqlMain&                         iSqlDb;
       
   160 
       
   161     /**
       
   162      * Cds sync implementation reference
       
   163      */
       
   164     CCdsSyncImpl&                       iSync;
       
   165     
       
   166     /**
       
   167      * Array of items to be added
       
   168      */
       
   169     RPointerArray<CCmSqlGenericItem>&   iItemsToAdd;
       
   170     
       
   171     /**
       
   172      * Array of items to be deleted
       
   173      */
       
   174     RPointerArray<CCmSqlBaseItem>&      iItemsToDelete;
       
   175 
       
   176     /**
       
   177      * Amount of files to be added at a time
       
   178      */
       
   179     TInt                                iAddGranularity;
       
   180     /**
       
   181      * Flag for indicating that source data is ready
       
   182      */
       
   183     TBool                               iSourceDataComplete;
       
   184 
       
   185     /**
       
   186      * Count of items to be added
       
   187      */
       
   188     TInt                                iItemsInAddition;        
       
   189 
       
   190 #ifdef _DEBUG
       
   191     /**
       
   192      * Time stamps for logging
       
   193      */
       
   194     TTime iOperationTime;
       
   195 #endif // _DEBUG
       
   196 
       
   197 };
       
   198 
       
   199 #endif // CDSSYNCSQLAO_H