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