77 iEntryArray.Close(); |
77 iEntryArray.Close(); |
78 iHarvestEntryArray.ResetAndDestroy(); |
78 iHarvestEntryArray.ResetAndDestroy(); |
79 iHarvestEntryArray.Close(); |
79 iHarvestEntryArray.Close(); |
80 |
80 |
81 delete iMdeSession; |
81 delete iMdeSession; |
82 iMdeSession = NULL; |
|
83 |
82 |
84 Deinitialize(); |
83 Deinitialize(); |
85 |
84 |
86 if (iHEM) |
85 if (iHEM) |
87 { |
86 { |
88 iHEM->ReleaseInstance(); |
87 iHEM->ReleaseInstance(); |
89 } |
88 } |
90 |
89 |
91 delete iMmcFileList; |
90 delete iMmcFileList; |
92 iMmcFileList = NULL; |
|
93 iHdArray.ResetAndDestroy(); |
91 iHdArray.ResetAndDestroy(); |
94 iHdArray.Close(); |
92 iHdArray.Close(); |
95 } |
93 } |
96 |
94 |
97 void CMMCMountTaskAO::SetMonitorObserver( MMonitorPluginObserver& aObserver ) |
95 void CMMCMountTaskAO::SetMonitorObserver( MMonitorPluginObserver& aObserver ) |
108 void CMMCMountTaskAO::SetHarvesterPluginFactory( CHarvesterPluginFactory* aPluginFactory ) |
106 void CMMCMountTaskAO::SetHarvesterPluginFactory( CHarvesterPluginFactory* aPluginFactory ) |
109 { |
107 { |
110 iHarvesterPluginFactory = aPluginFactory; |
108 iHarvesterPluginFactory = aPluginFactory; |
111 } |
109 } |
112 |
110 |
113 void CMMCMountTaskAO::StartMountL( TMountData& aMountData ) |
111 void CMMCMountTaskAO::StartMount( TMountData& aMountData ) |
114 { |
112 { |
115 WRITELOG("CMMCMountTaskAO::StartMount"); |
113 WRITELOG("CMMCMountTaskAO::StartMount"); |
116 |
114 iMountDataQueue.Append( &aMountData ); |
117 // Remove pending mount request for the same drive |
|
118 // if for example USB cable is pluged and unpluged |
|
119 // several times in a row |
|
120 for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- ) |
|
121 { |
|
122 WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending mount notifications" ); |
|
123 TMountData* tempData = iMountDataQueue[i]; |
|
124 if( tempData->iMediaID == aMountData.iMediaID && |
|
125 tempData->iMountType == TMountData::EMount && |
|
126 aMountData.iMountType == TMountData::EMount && |
|
127 tempData->iDrivePath == aMountData.iDrivePath ) |
|
128 { |
|
129 WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite mount notifications" ); |
|
130 iMountDataQueue.Remove(i); |
|
131 delete tempData; |
|
132 tempData = NULL; |
|
133 } |
|
134 } |
|
135 |
|
136 User::LeaveIfError( iMountDataQueue.Append( &aMountData )); |
|
137 |
|
138 if ( iNextRequest == ERequestIdle ) |
115 if ( iNextRequest == ERequestIdle ) |
139 { |
116 { |
140 SetNextRequest( ERequestStartTask ); |
117 SetNextRequest( ERequestStartTask ); |
141 } |
118 } |
142 } |
119 } |
143 |
120 |
144 void CMMCMountTaskAO::StartUnmountL(TMountData& aMountData) |
121 void CMMCMountTaskAO::StartUnmount(TMountData& aMountData) |
145 { |
122 { |
146 WRITELOG("CMMCMountTaskAO::StartUnmount"); |
123 WRITELOG("CMMCMountTaskAO::StartUnmount"); |
147 |
124 |
148 // make sure that drive is not currently mounting |
125 // make sure that drive is not currently mounting |
149 if ( iMountData ) |
126 if ( iMountData ) |
152 { |
129 { |
153 Cancel(); |
130 Cancel(); |
154 Deinitialize(); |
131 Deinitialize(); |
155 } |
132 } |
156 } |
133 } |
157 |
134 |
158 // Remove pending unmount request for the same drive |
135 iMountDataQueue.Append( &aMountData ); |
159 // if for example USB cable is pluged and unpluged |
|
160 // several times in a row |
|
161 for( TInt i = iMountDataQueue.Count() - 1; i >=0; i-- ) |
|
162 { |
|
163 WRITELOG( "CMMCMountTaskAO::StartUnmountL - checking for pending unmount notifications" ); |
|
164 TMountData* tempData = iMountDataQueue[i]; |
|
165 if( tempData->iMediaID == aMountData.iMediaID && |
|
166 tempData->iMountType == TMountData::EUnmount && |
|
167 aMountData.iMountType == TMountData::EUnmount && |
|
168 tempData->iDrivePath == aMountData.iDrivePath ) |
|
169 { |
|
170 WRITELOG( "CMMCMountTaskAO::StartUnmountL - removing obsolite unmount notifications" ); |
|
171 iMountDataQueue.Remove(i); |
|
172 delete tempData; |
|
173 tempData = NULL; |
|
174 } |
|
175 } |
|
176 |
|
177 User::LeaveIfError( iMountDataQueue.Append( &aMountData )); |
|
178 |
|
179 SetNextRequest( ERequestStartTask ); |
136 SetNextRequest( ERequestStartTask ); |
180 } |
137 } |
181 |
138 |
182 void CMMCMountTaskAO::RunL() |
139 void CMMCMountTaskAO::RunL() |
183 { |
140 { |
217 iMountData = iMountDataQueue[0]; |
171 iMountData = iMountDataQueue[0]; |
218 iMountDataQueue.Remove(0); |
172 iMountDataQueue.Remove(0); |
219 |
173 |
220 WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType ); |
174 WRITELOG1( "iMountData.iMountType: %d", iMountData->iMountType ); |
221 WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath ); |
175 WRITELOG1( "iMountData.iDrivePath: %S", &iMountData->iDrivePath ); |
222 WRITELOG1( "iMountData.iMediaID: %u", iMountData->iMediaID ); |
176 WRITELOG1( "iMountData.iMediaID: %d", iMountData->iMediaID ); |
223 |
177 |
224 if ( iMountData->iMountType == TMountData::EMount ) |
178 if ( iMountData->iMountType == TMountData::EMount ) |
225 { |
179 { |
226 SetNextRequest( ERequestMount ); |
180 SetNextRequest( ERequestMount ); |
227 } |
181 } |
249 StartNotifyL(); |
203 StartNotifyL(); |
250 SetNotPresentToMDE(); |
204 SetNotPresentToMDE(); |
251 TRAPD( err, iMmcFileList->BuildFileListL( iFs, iMountData->iDrivePath, iEntryArray )); |
205 TRAPD( err, iMmcFileList->BuildFileListL( iFs, iMountData->iDrivePath, iEntryArray )); |
252 if ( err == KErrNoMemory ) |
206 if ( err == KErrNoMemory ) |
253 { |
207 { |
254 if( iMountDataQueue.Insert( iMountData, 0 ) != KErrNone) |
208 iMountDataQueue.Insert( iMountData, 0 ); |
255 { |
|
256 delete iMountData; |
|
257 } |
|
258 |
|
259 iMountData = NULL; |
209 iMountData = NULL; |
260 Deinitialize(); |
210 Deinitialize(); |
261 SetNextRequest( ERequestStartTask ); |
211 SetNextRequest( ERequestStartTask ); |
262 break; |
212 break; |
263 } |
213 } |
332 iHarvestEntryArray, iMountData->iMediaID, iHarvesterPluginFactory )); |
282 iHarvestEntryArray, iMountData->iMediaID, iHarvesterPluginFactory )); |
333 if ( err != KErrNone ) |
283 if ( err != KErrNone ) |
334 { |
284 { |
335 if( err == KErrNoMemory ) |
285 if( err == KErrNoMemory ) |
336 { |
286 { |
337 if(iMountDataQueue.Insert( iMountData, 0 ) != KErrNone) |
287 iMountDataQueue.Insert( iMountData, 0 ); |
338 { |
|
339 delete iMountData; |
|
340 } |
|
341 |
|
342 iMountData = NULL; |
288 iMountData = NULL; |
343 } |
289 } |
344 |
|
345 Deinitialize(); |
290 Deinitialize(); |
346 SetNextRequest( ERequestStartTask ); |
291 SetNextRequest( ERequestStartTask ); |
347 break; |
292 break; |
348 } |
293 } |
349 |
294 |
491 ei->PresentState() == EMdsModified ) |
436 ei->PresentState() == EMdsModified ) |
492 { |
437 { |
493 hd->SetEventType( EHarvesterEdit ); |
438 hd->SetEventType( EHarvesterEdit ); |
494 hd->SetObjectType( ENormal ); |
439 hd->SetObjectType( ENormal ); |
495 delete ei; |
440 delete ei; |
496 ei = NULL; |
|
497 } |
441 } |
498 else |
442 else |
499 { |
443 { |
500 hd->SetEventType( EHarvesterAdd ); |
444 hd->SetEventType( EHarvesterAdd ); |
501 hd->SetObjectType( EPlaceholder ); |
445 hd->SetObjectType( EPlaceholder ); |
502 hd->SetClientData( ei ); |
446 hd->SetClientData( ei ); |
503 } |
447 } |
504 |
448 |
505 if(iHdArray.Append( hd ) != KErrNone ) |
449 iHdArray.Append( hd ); |
506 { |
|
507 delete hd; |
|
508 hd = NULL; |
|
509 } |
|
510 |
|
511 aArray.Remove( i ); |
450 aArray.Remove( i ); |
512 } |
451 } |
513 |
452 |
514 if( aArray.Count() == 0 ) |
453 if( aArray.Count() == 0 ) |
515 { |
454 { |
618 if ( driveInfo.iType == EMediaHardDisk ) |
557 if ( driveInfo.iType == EMediaHardDisk ) |
619 { |
558 { |
620 // check if disk is internal |
559 // check if disk is internal |
621 TUint driveStatus; |
560 TUint driveStatus; |
622 const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus ); |
561 const TInt err = DriveInfo::GetDriveStatus( iFs, i, driveStatus ); |
623 if ( ( err == KErrNone ) && |
562 if ( (err == KErrNone ) && ( driveStatus & DriveInfo::EDriveInternal ) ) |
624 ( driveStatus & DriveInfo::EDriveInternal )) |
|
625 { |
563 { |
626 // get media id |
564 // get media id |
627 hdMediaId = FSUtil::MediaID( iFs, i ); |
565 hdMediaId = FSUtil::MediaID( iFs, i ); |
628 if( driveStatus & DriveInfo::EDrivePresent ) |
|
629 { |
|
630 aPresent = ETrue; |
|
631 } |
|
632 break; |
566 break; |
633 } |
567 } |
634 } |
568 } |
635 } |
569 } |
636 } |
570 } |