upnpharvester/common/dbmanager/src/cmdmsqldbmaintenance.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2008 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:      SQL database maintenance class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include "cmdmsqliteconnection.h"
       
    24 #include "cmdmsqlmaintenanceclauses.h"
       
    25 #include "cmdmsqldbmaintenance.h"
       
    26 #include "cmdmsqlclausedef.h"
       
    27 #include "msdebug.h"
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CCmDmSqlDbMaintenance::NewL
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CCmDmSqlDbMaintenance* CCmDmSqlDbMaintenance::NewL()
       
    34     {
       
    35     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::NewL()"));
       
    36      
       
    37     CCmDmSqlDbMaintenance* self = CCmDmSqlDbMaintenance::NewLC();
       
    38     CleanupStack::Pop( self );
       
    39 
       
    40     return self;
       
    41     }
       
    42  
       
    43 // ---------------------------------------------------------------------------
       
    44 // CCmDmSqlDbMaintenance::NewLC
       
    45 // ---------------------------------------------------------------------------
       
    46 //    
       
    47 CCmDmSqlDbMaintenance* CCmDmSqlDbMaintenance::NewLC()
       
    48     {
       
    49     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::NewLC()"));
       
    50         
       
    51     CCmDmSqlDbMaintenance* self = new ( ELeave ) CCmDmSqlDbMaintenance();
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54 
       
    55     return self;  
       
    56     }    
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CCmDmSqlDbMaintenance::~CCmDmSqlDbMaintenance
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CCmDmSqlDbMaintenance::~CCmDmSqlDbMaintenance()
       
    63     {
       
    64     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::~CCmDmSqlDbMaintenance()"));
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CCmDmSqlDbMaintenance::InitConnection
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 TInt CCmDmSqlDbMaintenance::InitConnection(
       
    72     CCmDmSQLiteConnection& aConnection )
       
    73     {
       
    74     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::InitConnection()"));
       
    75     return aConnection.OpenDb( KCmDatabase );        
       
    76     }    
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CCmDmSqlDbMaintenance::CloseConnection
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CCmDmSqlDbMaintenance::CloseConnection(
       
    83     CCmDmSQLiteConnection& aConnection )
       
    84     {
       
    85     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::CloseConnection()"));
       
    86     aConnection.CloseDb();        
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CCmDmSqlDbMaintenance::CreateDbFile
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 TInt CCmDmSqlDbMaintenance::CreateDbFile( 
       
    94     CCmDmSQLiteConnection& aConnection )
       
    95     {
       
    96     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::CreateDbFile()"));
       
    97     return aConnection.CreateDbFile( KCmDatabase );
       
    98     }
       
    99     
       
   100 // ---------------------------------------------------------------------------
       
   101 // CCmDmSqlDbMaintenance::CreateDb
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CCmDmSqlDbMaintenance::CreateDb( 
       
   105     CCmDmSQLiteConnection& aConnection )
       
   106     {
       
   107     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::CreateDb()"));
       
   108     
       
   109     /// DROP tables
       
   110     TRAP_IGNORE( aConnection.ExecuteL( KDropFillRuleGroup ));
       
   111     TRAP_IGNORE( aConnection.ExecuteL( KDropRules ));
       
   112     TRAP_IGNORE( aConnection.ExecuteL( KDropRuleParams ));
       
   113     TRAP_IGNORE( aConnection.ExecuteL( KDropRuleGroupServers ));
       
   114     TRAP_IGNORE( aConnection.ExecuteL( KDropMediaServers ));
       
   115     TRAP_IGNORE( aConnection.ExecuteL( KDropHashValues ));
       
   116     TRAP_IGNORE( aConnection.ExecuteL( KDropStored ));
       
   117     TRAP_IGNORE( aConnection.ExecuteL( KDropFilled ));
       
   118     TRAP_IGNORE( aConnection.ExecuteL( KDropIDs ));
       
   119     TRAP_IGNORE( aConnection.ExecuteL( KDropStoreRules ));
       
   120     TRAP_IGNORE( aConnection.ExecuteL( KDropStoreRuleParams ));
       
   121     TRAP_IGNORE( aConnection.ExecuteL( KDropStoreRuleServers ));
       
   122     TRAP_IGNORE( aConnection.ExecuteL( KDropFillFiles ));
       
   123     TRAP_IGNORE( aConnection.ExecuteL( KDropStoreFiles ));
       
   124     TRAP_IGNORE( aConnection.ExecuteL( KDropStoreFileServers ));
       
   125     TRAP_IGNORE( aConnection.ExecuteL( KDropImageShrinkingInfo ));
       
   126     TRAP_IGNORE( aConnection.ExecuteL( KDropTransferInfo ));
       
   127     TRAP_IGNORE( aConnection.ExecuteL( KDropSyncTime ));
       
   128     TRAP_IGNORE( aConnection.ExecuteL( KDropProgressInfo ));
       
   129     TRAP_IGNORE( aConnection.ExecuteL( KDropDrivesInfo ));
       
   130      
       
   131     // Create tables
       
   132     TRAP_IGNORE( aConnection.ExecuteL( KCreateFillRuleGroup ) );    
       
   133     TRAP_IGNORE( aConnection.ExecuteL( KCreateRules ) );
       
   134     TRAP_IGNORE( aConnection.ExecuteL( KCreateRuleParams ) );   
       
   135     TRAP_IGNORE( aConnection.ExecuteL( KCreateRuleGroupServers ) );
       
   136     TRAP_IGNORE( aConnection.ExecuteL( KCreateMediaServers ) );
       
   137     TRAP_IGNORE( aConnection.ExecuteL( KCreateHashValues ) );
       
   138     TRAP_IGNORE( aConnection.ExecuteL( KCreateStored ) );   
       
   139     TRAP_IGNORE( aConnection.ExecuteL( KCreateIDs ) );
       
   140     TRAP_IGNORE( aConnection.ExecuteL( KCreateStoreRules ) );
       
   141     TRAP_IGNORE( aConnection.ExecuteL( KCreateStoreRuleParams ) );
       
   142     TRAP_IGNORE( aConnection.ExecuteL( KCreateStoreRuleServers ) );
       
   143     TRAP_IGNORE( aConnection.ExecuteL( KCreateFillFiles ) );
       
   144     TRAP_IGNORE( aConnection.ExecuteL( KCreateStoreFiles ) );
       
   145     TRAP_IGNORE( aConnection.ExecuteL( KCreateStoreFileServers ) );
       
   146     TRAP_IGNORE( aConnection.ExecuteL( KCreateImageShrinkingInfo ) );
       
   147     TRAP_IGNORE( aConnection.ExecuteL( KCreateTransferInfo ) );
       
   148     TRAP_IGNORE( aConnection.ExecuteL( KCreateSyncTime ) );
       
   149     TRAP_IGNORE( aConnection.ExecuteL( KCreateProgressInfo ) );
       
   150     TRAP_IGNORE( aConnection.ExecuteL( KCreateDrivesInfo ));
       
   151     
       
   152     // Init clauses
       
   153     TRAP_IGNORE( aConnection.ExecuteL( KInitShrinkingTime ) );       
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CCmDmSqlDbMaintenance::CreateIndexes
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 void CCmDmSqlDbMaintenance::CreateIndexes( 
       
   161     CCmDmSQLiteConnection& aConnection )
       
   162     {
       
   163     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::CreateIndexes()"));
       
   164     
       
   165     // Drop indexes
       
   166     TRAP_IGNORE( aConnection.ExecuteL( KDropFillListIdIndex ) );
       
   167     TRAP_IGNORE( aConnection.ExecuteL( KDropFillItemRefIndex ) );
       
   168     TRAP_IGNORE( aConnection.ExecuteL( KDropStoreStatusIndex ) );
       
   169     TRAP_IGNORE( aConnection.ExecuteL( KDropFillStatusIndex ) );
       
   170     
       
   171     // Create indexes
       
   172     TRAP_IGNORE( aConnection.ExecuteL( KCreateFillListIdIndex ) );
       
   173     TRAP_IGNORE( aConnection.ExecuteL( KCreateFillItemRefIndex ) );        
       
   174     TRAP_IGNORE( aConnection.ExecuteL( KCreateStoreStatusIndex ) );
       
   175     TRAP_IGNORE( aConnection.ExecuteL( KCreateFillStatusIndex ) );
       
   176     }    
       
   177     
       
   178 // ---------------------------------------------------------------------------
       
   179 // CCmDmSqlDbMaintenance::CCmDmSqlDbMaintenance
       
   180 // ---------------------------------------------------------------------------
       
   181 //    
       
   182 CCmDmSqlDbMaintenance::CCmDmSqlDbMaintenance()
       
   183     {
       
   184     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::CCmDmSqlDbMaintenance()"));
       
   185     }
       
   186  
       
   187 // ---------------------------------------------------------------------------
       
   188 // CCmDmSqlDbMaintenance::ConstructL
       
   189 // ---------------------------------------------------------------------------
       
   190 //   
       
   191 void CCmDmSqlDbMaintenance::ConstructL()
       
   192     {
       
   193     LOG( _L( "[DB MNGR]\t CCmDmSqlDbMaintenance::ConstructL()"));
       
   194     }    
       
   195 
       
   196 // End of file
       
   197