metadataengine/server/src/mdsmaintenanceengine.cpp
branchRCL_3
changeset 19 b73252188534
parent 14 3e156c80c15d
child 20 f23c07ec56e2
equal deleted inserted replaced
18:63c982fb92f2 19:b73252188534
    14 * Description:  Class for database import/export and maintenance
    14 * Description:  Class for database import/export and maintenance
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include <driveinfo.h>
       
    20 
       
    21 #include "mdsmaintenanceengine.h"
    19 #include "mdsmaintenanceengine.h"
    22 #include "mdslogger.h"
    20 #include "mdslogger.h"
    23 #include "mdsmanipulationengine.h"
    21 #include "mdsmanipulationengine.h"
    24 #include "mdcserializationbuffer.h"
    22 #include "mdcserializationbuffer.h"
    25 #include "mdsimportexport.h"
    23 #include "mdsimportexport.h"
    77 // ------------------------------------------------
    75 // ------------------------------------------------
    78 //
    76 //
    79 CMdSMaintenanceEngine::~CMdSMaintenanceEngine()
    77 CMdSMaintenanceEngine::~CMdSMaintenanceEngine()
    80     {
    78     {
    81     delete iMaintenance;
    79     delete iMaintenance;
       
    80     iMaintenance = NULL;
    82     }
    81     }
    83 
    82 
    84 // ------------------------------------------------
    83 // ------------------------------------------------
    85 // InitConnectionL
    84 // InitConnectionL
    86 // ------------------------------------------------
    85 // ------------------------------------------------
   115 // ------------------------------------------------
   114 // ------------------------------------------------
   116 //
   115 //
   117 void CMdSMaintenanceEngine::InstallL( CMdSManipulationEngine& aManipulate, CMdsSchema& aSchema )
   116 void CMdSMaintenanceEngine::InstallL( CMdSManipulationEngine& aManipulate, CMdsSchema& aSchema )
   118     {
   117     {
   119     __LOG1( ELogAlways, "Trying to validate MDS DB, error expected if not created(first boot): %d", 0 );
   118     __LOG1( ELogAlways, "Trying to validate MDS DB, error expected if not created(first boot): %d", 0 );
   120     if ( !(iMaintenance->ValidateL( ) ) )
   119 	
       
   120     TBool isValid(EFalse);
       
   121     TRAPD(err, isValid = iMaintenance->ValidateL( ));
       
   122     
       
   123     if(err == KErrCorrupt)
       
   124         {
       
   125         DeleteDatabase();
       
   126         User::Leave( err );
       
   127         }
       
   128     
       
   129     else if ( !isValid )
   121         {
   130         {
   122         // Pump up priority to load the MDS DB up as fast as possible to
   131         // Pump up priority to load the MDS DB up as fast as possible to
   123         // enable client side session connections
   132         // enable client side session connections
   124         RProcess process;
   133         RProcess process;
   125         process.SetPriority( EPriorityForeground );
   134         process.SetPriority( EPriorityForeground );
   270     CleanupClosePushL( fs );
   279     CleanupClosePushL( fs );
   271     TVolumeInfo volumeInfo;
   280     TVolumeInfo volumeInfo;
   272     User::LeaveIfError( fs.Volume( volumeInfo, EDriveC ) );
   281     User::LeaveIfError( fs.Volume( volumeInfo, EDriveC ) );
   273     MMdsPreferences::InsertL( KCMediaIdKey, MMdsPreferences::EPreferenceValueSet,
   282     MMdsPreferences::InsertL( KCMediaIdKey, MMdsPreferences::EPreferenceValueSet,
   274     		(TUint32) volumeInfo.iUniqueID );
   283     		(TUint32) volumeInfo.iUniqueID );
   275 
       
   276     TInt drive( -1 );
       
   277     TInt massStorageError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ) );
       
   278     if( massStorageError == KErrNone )
       
   279         {
       
   280         TVolumeInfo massStorageVolumeInfo;
       
   281         massStorageError = fs.Volume( massStorageVolumeInfo, drive );
       
   282         if( massStorageError == KErrNone )
       
   283             {
       
   284             const TUint32 massStorageMediaId( massStorageVolumeInfo.iUniqueID );
       
   285             massStorageError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
       
   286             if( massStorageError == KErrNone )
       
   287                 {
       
   288                 massStorageError = fs.Volume( massStorageVolumeInfo, drive );
       
   289                 // Update mass storage media id if the mass storage is not memory card
       
   290                 if( massStorageError == KErrNone &&
       
   291                     massStorageVolumeInfo.iUniqueID != massStorageMediaId &&
       
   292                     massStorageMediaId != 0 )
       
   293                     {
       
   294                     MMdsPreferences::InsertL( KMassStorageMediaIdKey, MMdsPreferences::EPreferenceValueSet,
       
   295                             (TUint32) massStorageMediaId );
       
   296                     }        
       
   297                 }
       
   298             }
       
   299         }
       
   300     
   284     
   301     CleanupStack::PopAndDestroy( &fs );
   285     CleanupStack::PopAndDestroy( &fs );
   302 	}
   286 	}
   303 
   287