114 |
109 |
115 TChar driveLetter( 0 ); |
110 TChar driveLetter( 0 ); |
116 TBool presentState( EFalse ); |
111 TBool presentState( EFalse ); |
117 |
112 |
118 TUint32 hdMediaId( 0 ); |
113 TUint32 hdMediaId( 0 ); |
119 TBool hdPresent( EFalse ); |
114 hdMediaId = iMountTask->GetInternalDriveMediaId(); |
120 hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent ); |
|
121 |
115 |
122 for( TInt i = medias.Count() - 1; i >=0; i-- ) |
116 for( TInt i = medias.Count() - 1; i >=0; i-- ) |
123 { |
117 { |
124 TRAP_IGNORE( iMdEClient->GetMediaL( medias[i].iMediaId, driveLetter, presentState ) ); |
118 TRAP_IGNORE( iMdEClient->GetMediaL( medias[i].iMediaId, driveLetter, presentState ) ); |
125 |
119 |
136 TRAP_IGNORE( iMmcScanner = CMmcScannerAO::NewL( medias[i].iMediaId, iMdEClient, iObserver, |
130 TRAP_IGNORE( iMmcScanner = CMmcScannerAO::NewL( medias[i].iMediaId, iMdEClient, iObserver, |
137 aHarvesterPluginFactory, CActive::EPriorityUserInput ) ); |
131 aHarvesterPluginFactory, CActive::EPriorityUserInput ) ); |
138 } |
132 } |
139 } |
133 } |
140 |
134 |
141 if( hdMediaId == 0 || !hdPresent ) |
135 if( hdMediaId == 0 ) |
142 { |
136 { |
143 // Try to fetch internall mass storage media id again if it was not mounted |
137 // Try to fetch internall mass storage media id again if it was not mounted |
144 hdMediaId = iMountTask->GetInternalDriveMediaId( hdPresent ); |
138 hdMediaId = iMountTask->GetInternalDriveMediaId(); |
145 } |
139 } |
146 |
140 |
147 // scan mass storage to catch all chances even if battery dies during operation that should be catched |
141 // scan mass storage to catch all chances even if battery dies during operation that should be catched |
148 if( hdMediaId ) |
142 if( hdMediaId ) |
149 { |
143 { |
150 TBool exists( EFalse ); |
144 TBool exists( EFalse ); |
151 TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) ); |
145 TRAP_IGNORE( exists= iMdEClient->GetMediaL( hdMediaId, driveLetter, presentState ) ); |
152 |
146 |
153 if ( exists && hdPresent ) |
147 if ( exists ) |
154 { |
148 { |
155 WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan"); |
149 WRITELOG("CMMCMonitorPlugin::StartMonitoring - start mass storage scan"); |
156 |
150 |
157 TMdEMediaInfo hdInfo; |
151 TMdEMediaInfo hdInfo; |
158 hdInfo.iMediaId = hdMediaId; |
152 hdInfo.iMediaId = hdMediaId; |
253 { |
246 { |
254 case EMounted: |
247 case EMounted: |
255 { |
248 { |
256 WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EMounted" ); |
249 WRITELOG( "CMMCMonitorPlugin::MountEvent with parameter EMounted" ); |
257 mountData->iMountType = TMountData::EMount; |
250 mountData->iMountType = TMountData::EMount; |
258 |
251 iMountTask->StartMount( *mountData ); |
259 // If mass storage mounting was delayed in boot so that mount event |
|
260 // occures in mmc monitor, update the mass storage media id in the |
|
261 // db in case factory settings were reseted and mass storage formatted |
|
262 TInt drive( -1 ); |
|
263 TInt internalMassStorageError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ) ); |
|
264 if( internalMassStorageError == KErrNone ) |
|
265 { |
|
266 TVolumeInfo internalMassStorageVolumeInfo; |
|
267 internalMassStorageError = iFs.Volume( internalMassStorageVolumeInfo, drive ); |
|
268 if( internalMassStorageError == KErrNone ) |
|
269 { |
|
270 const TUint32 massStorageMediaId( internalMassStorageVolumeInfo.iUniqueID ); |
|
271 if( massStorageMediaId == aMediaID && |
|
272 massStorageMediaId != 0 ) |
|
273 { |
|
274 TUint32 mmcMediaId( 0 ); |
|
275 TInt mmcDrive( -1 ); |
|
276 TInt mmcError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) ); |
|
277 if( mmcError == KErrNone ) |
|
278 { |
|
279 if( drive != mmcDrive ) |
|
280 { |
|
281 TVolumeInfo mmcVolumeInfo; |
|
282 mmcError = iFs.Volume( mmcVolumeInfo, mmcDrive ); |
|
283 if( mmcError == KErrNone ) |
|
284 { |
|
285 mmcMediaId = mmcVolumeInfo.iUniqueID; |
|
286 } |
|
287 } |
|
288 else |
|
289 { |
|
290 mmcMediaId = massStorageMediaId; |
|
291 } |
|
292 } |
|
293 |
|
294 // If removable storage is not found, assume internal mass storage was mounted |
|
295 if( mmcError ) |
|
296 { |
|
297 iMdEClient->CheckMassStorageMediaId( massStorageMediaId ); |
|
298 } |
|
299 else if( massStorageMediaId != mmcMediaId ) |
|
300 { |
|
301 iMdEClient->CheckMassStorageMediaId( massStorageMediaId ); |
|
302 } |
|
303 } |
|
304 } |
|
305 } |
|
306 |
|
307 TRAPD(err, iMountTask->StartMountL( *mountData )) |
|
308 |
|
309 if(err != KErrNone ) |
|
310 { |
|
311 delete mountData; |
|
312 mountData = NULL; |
|
313 } |
|
314 } |
252 } |
315 break; |
253 break; |
316 |
254 |
317 case EDismounted: |
255 case EDismounted: |
318 { |
256 { |