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 |
19 #include "mdsmaintenanceengine.h" |
21 #include "mdsmaintenanceengine.h" |
20 #include "mdslogger.h" |
22 #include "mdslogger.h" |
21 #include "mdsmanipulationengine.h" |
23 #include "mdsmanipulationengine.h" |
22 #include "mdcserializationbuffer.h" |
24 #include "mdcserializationbuffer.h" |
23 #include "mdsimportexport.h" |
25 #include "mdsimportexport.h" |
118 __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 ); |
119 |
120 |
120 TBool isValid(EFalse); |
121 TBool isValid(EFalse); |
121 TRAPD(err, isValid = iMaintenance->ValidateL( )); |
122 TRAPD(err, isValid = iMaintenance->ValidateL( )); |
122 |
123 |
123 if( err == KErrCorrupt ) |
124 if(err == KErrCorrupt) |
124 { |
125 { |
125 DeleteDatabase(); |
126 DeleteDatabase(); |
126 User::Leave( err ); |
127 User::Leave( err ); |
127 } |
128 } |
128 |
129 |
172 __LOG1( ELogAlways, "Schema reading error: %d", schemaError ); |
173 __LOG1( ELogAlways, "Schema reading error: %d", schemaError ); |
173 DeleteDatabase(); |
174 DeleteDatabase(); |
174 User::Leave( schemaError ); |
175 User::Leave( schemaError ); |
175 } |
176 } |
176 } |
177 } |
|
178 |
|
179 if ( FailedImports() != 0 ) |
|
180 { |
|
181 User::Leave( KErrBadName ); |
|
182 } |
177 |
183 |
178 // try to read default import file from C drive |
184 // try to read default import file from C drive |
179 TRAPD( err, ImportMetadataL( aManipulate, aSchema, KMdsDefaultImportFile ) ); |
185 TRAPD( err, ImportMetadataL( aManipulate, aSchema, KMdsDefaultImportFile ) ); |
180 if ( err == KErrNotFound || err == KErrPathNotFound ) |
186 if ( err == KErrNotFound || err == KErrPathNotFound ) |
181 { |
187 { |
182 // if default import file is not found, try to read from rom (Z) drive |
188 // if default import file is not found, try to read from rom (Z) drive |
183 // and ignore errors |
189 // and ignore errors |
184 TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) ); |
190 TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) ); |
185 } |
191 } |
186 |
|
187 #ifdef _DEBUG |
|
188 if ( FailedImports() != 0 ) |
|
189 { |
|
190 User::Leave( KErrBadName ); |
|
191 } |
|
192 #endif |
|
193 |
192 |
194 __LOG1( ELogAlways, "MDS DB tables created %d", 0 ); |
193 __LOG1( ELogAlways, "MDS DB tables created %d", 0 ); |
195 |
194 |
196 // Revert back to default MDS server priority when server is up and running |
195 // Revert back to default MDS server priority when server is up and running |
197 process.SetPriority( EPriorityBackground ); |
196 process.SetPriority( EPriorityBackground ); |
206 if( err != KErrNone ) |
205 if( err != KErrNone ) |
207 { |
206 { |
208 DeleteDatabase(); |
207 DeleteDatabase(); |
209 User::Leave( err ); |
208 User::Leave( err ); |
210 } |
209 } |
211 |
|
212 if( !iMaintenance->CheckForCorruptionL() ) |
|
213 { |
|
214 DeleteDatabase(); |
|
215 User::Leave( KErrCorrupt ); |
|
216 } |
|
217 } |
210 } |
218 __LOG1( ELogAlways, "CMdSMaintenanceEngine::InstallL complete: %d", 0 ); |
211 __LOG1( ELogAlways, "CMdSMaintenanceEngine::InstallL complete: %d", 0 ); |
219 } |
212 } |
220 |
213 |
221 // ------------------------------------------------ |
214 // ------------------------------------------------ |
287 CleanupClosePushL( fs ); |
280 CleanupClosePushL( fs ); |
288 TVolumeInfo volumeInfo; |
281 TVolumeInfo volumeInfo; |
289 User::LeaveIfError( fs.Volume( volumeInfo, EDriveC ) ); |
282 User::LeaveIfError( fs.Volume( volumeInfo, EDriveC ) ); |
290 MMdsPreferences::InsertL( KCMediaIdKey, MMdsPreferences::EPreferenceValueSet, |
283 MMdsPreferences::InsertL( KCMediaIdKey, MMdsPreferences::EPreferenceValueSet, |
291 (TUint32) volumeInfo.iUniqueID ); |
284 (TUint32) volumeInfo.iUniqueID ); |
|
285 |
|
286 TInt drive( -1 ); |
|
287 TInt massStorageError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ) ); |
|
288 if( massStorageError == KErrNone ) |
|
289 { |
|
290 TVolumeInfo massStorageVolumeInfo; |
|
291 massStorageError = fs.Volume( massStorageVolumeInfo, drive ); |
|
292 if( massStorageError == KErrNone ) |
|
293 { |
|
294 const TUint32 massStorageMediaId( massStorageVolumeInfo.iUniqueID ); |
|
295 massStorageError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ); |
|
296 if( massStorageError == KErrNone ) |
|
297 { |
|
298 massStorageError = fs.Volume( massStorageVolumeInfo, drive ); |
|
299 // Update mass storage media id if the mass storage is not memory card |
|
300 if( massStorageError == KErrNone && |
|
301 massStorageVolumeInfo.iUniqueID != massStorageMediaId && |
|
302 massStorageMediaId != 0 ) |
|
303 { |
|
304 MMdsPreferences::InsertL( KMassStorageMediaIdKey, MMdsPreferences::EPreferenceValueSet, |
|
305 (TUint32) massStorageMediaId ); |
|
306 } |
|
307 } |
|
308 } |
|
309 } |
292 |
310 |
293 CleanupStack::PopAndDestroy( &fs ); |
311 CleanupStack::PopAndDestroy( &fs ); |
294 } |
312 } |
295 |
313 |