metadataengine/server/src/mdsmaintenanceengine.cpp
changeset 23 33ae025ac1e8
parent 21 50bf9db68373
child 30 3e156c80c15d
equal deleted inserted replaced
21:50bf9db68373 23:33ae025ac1e8
   117 void CMdSMaintenanceEngine::InstallL( CMdSManipulationEngine& aManipulate, CMdsSchema& aSchema )
   117 void CMdSMaintenanceEngine::InstallL( CMdSManipulationEngine& aManipulate, CMdsSchema& aSchema )
   118     {
   118     {
   119     __LOG1( ELogAlways, "Trying to validate MDS DB, error expected if not created(first boot): %d", 0 );
   119     __LOG1( ELogAlways, "Trying to validate MDS DB, error expected if not created(first boot): %d", 0 );
   120     if ( !(iMaintenance->ValidateL( ) ) )
   120     if ( !(iMaintenance->ValidateL( ) ) )
   121         {
   121         {
       
   122         // Pump up priority to load the MDS DB up as fast as possible to
       
   123         // enable client side session connections
       
   124         RProcess process;
       
   125         process.SetPriority( EPriorityForeground );
       
   126     
       
   127         __LOG1( ELogAlways, "MDS DB not valid, creating tables: %d", 0 );
   122         // first-time init: re-form the database completely
   128         // first-time init: re-form the database completely
   123     	iMaintenance->CreateDatabaseL( );
   129     	iMaintenance->CreateDatabaseL( );
   124 		const TUint KMdSServerUid = 0x0320e65f; // temporal uid
   130 		const TUint KMdSServerUid = 0x0320e65f; // temporal uid
   125 
   131 
   126 		// try to read schema file from C drive
   132 		// try to read schema file from C drive
   154        		// if default import file is not found, try to read from rom (Z) drive
   160        		// if default import file is not found, try to read from rom (Z) drive
   155        		// and ignore errors
   161        		// and ignore errors
   156        		TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) );
   162        		TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) );
   157        		}
   163        		}
   158        	
   164        	
       
   165        	__LOG1( ELogAlways, "MDS DB tables created %d", 0 );
       
   166 
       
   167         // Revert back to default MDS server priority when server is up and running
       
   168         process.SetPriority( EPriorityBackground );
       
   169         process.Close();
       
   170        	
   159        	StoreDriveMediaIdsL();
   171        	StoreDriveMediaIdsL();
   160         }
   172         }
   161     else
   173     else
   162         {
   174         {
   163         TRAPD( err, LoadSchemaL( aSchema ) );
   175         TRAPD( err, LoadSchemaL( aSchema ) );
   166         	{ 
   178         	{ 
   167 			DeleteDatabase();
   179 			DeleteDatabase();
   168 			User::Leave( err );
   180 			User::Leave( err );
   169         	}
   181         	}
   170         }
   182         }
       
   183     __LOG1( ELogAlways, "CMdSMaintenanceEngine::InstallL complete: %d", 0 );
   171     }
   184     }
   172 
   185 
   173 // ------------------------------------------------
   186 // ------------------------------------------------
   174 // LoadSchemaL
   187 // LoadSchemaL
   175 // ------------------------------------------------
   188 // ------------------------------------------------
   245     TInt drive( -1 );
   258     TInt drive( -1 );
   246     TInt massStorageError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ) );
   259     TInt massStorageError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ) );
   247     if( massStorageError == KErrNone )
   260     if( massStorageError == KErrNone )
   248         {
   261         {
   249         TVolumeInfo massStorageVolumeInfo;
   262         TVolumeInfo massStorageVolumeInfo;
   250         User::LeaveIfError( fs.Volume( massStorageVolumeInfo, drive ) );
   263         massStorageError = fs.Volume( massStorageVolumeInfo, drive );
   251         const TUint32 massStorageMediaId( massStorageVolumeInfo.iUniqueID );
       
   252         massStorageError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
       
   253         if( massStorageError == KErrNone )
   264         if( massStorageError == KErrNone )
   254             {
   265             {
   255             User::LeaveIfError( fs.Volume( massStorageVolumeInfo, drive ) );
   266             const TUint32 massStorageMediaId( massStorageVolumeInfo.iUniqueID );
   256             // Update mass storage media id if the mass storage is not memory card
   267             massStorageError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
   257             if( massStorageVolumeInfo.iUniqueID != massStorageMediaId && massStorageMediaId != 0 )
   268             if( massStorageError == KErrNone )
   258                 {
   269                 {
   259                 MMdsPreferences::InsertL( KMassStorageMediaIdKey, MMdsPreferences::EPreferenceValueSet,
   270                 massStorageError = fs.Volume( massStorageVolumeInfo, drive );
   260                         (TUint32) massStorageMediaId );
   271                 // Update mass storage media id if the mass storage is not memory card
       
   272                 if( massStorageError == KErrNone &&
       
   273                     massStorageVolumeInfo.iUniqueID != massStorageMediaId &&
       
   274                     massStorageMediaId != 0 )
       
   275                     {
       
   276                     MMdsPreferences::InsertL( KMassStorageMediaIdKey, MMdsPreferences::EPreferenceValueSet,
       
   277                             (TUint32) massStorageMediaId );
       
   278                     }        
   261                 }
   279                 }
   262             }
   280             }
   263         }
   281         }
   264     
   282     
   265     CleanupStack::PopAndDestroy( &fs );
   283     CleanupStack::PopAndDestroy( &fs );