203 // |
203 // |
204 void CFsComposerFetchLogic::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart ) |
204 void CFsComposerFetchLogic::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart ) |
205 { |
205 { |
206 FUNC_LOG; |
206 FUNC_LOG; |
207 |
207 |
208 if ( !iError && aEvent.iError ) |
208 // Ignore all responses when cancelling is in progress. |
209 { |
209 if ( !iFetchingCancelGoingOn ) |
210 // Cancel all fetching when first error occurs |
210 { |
211 iError = aEvent.iError; |
211 if ( !iError && aEvent.iError ) |
212 if(!iFetchingCancelGoingOn) //<cmail> if cancelling not going on, start now |
212 { |
|
213 // Cancel all fetching when first error occurs |
|
214 iError = aEvent.iError; |
213 CancelFetchings(); |
215 CancelFetchings(); |
214 } |
216 } |
215 |
217 else if ( TFsEmailUiUtility::IsCompleteOrCancelEvent( aEvent ) ) |
216 if ( TFsEmailUiUtility::IsCompleteOrCancelEvent( aEvent ) ) |
218 { |
217 { |
219 // Remove the completed/failed download item |
218 // Remove the completed/failed download item |
220 for ( TInt i=0; i<iParts.Count(); i++ ) |
219 for ( TInt i=0; i<iParts.Count(); i++ ) |
221 { |
220 { |
222 if ( iParts[i] == aPart ) |
221 if ( iParts[i] == aPart ) |
223 { |
222 { |
224 iParts.Remove( i ); |
223 iParts.Remove( i ); |
225 break; |
224 break; |
226 } |
225 } |
227 } |
226 } |
228 |
227 |
229 // If last part just got removed, then move on |
228 // If last part just got removed, then move on |
230 if ( !iParts.Count() ) |
229 if ( !iParts.Count() ) |
231 { |
230 { |
232 Complete(); |
231 Complete(); |
233 } |
232 } |
234 } |
233 } |
235 } |
234 } |
236 } |
235 |
237 |
236 |
238 |
237 // ----------------------------------------------------------------------------- |
239 // ----------------------------------------------------------------------------- |
238 // CFsComposerFetchLogic::StepL |
240 // CFsComposerFetchLogic::StepL |
239 // ----------------------------------------------------------------------------- |
241 // ----------------------------------------------------------------------------- |
576 iFetchingBody = EFalse; |
578 iFetchingBody = EFalse; |
577 } |
579 } |
578 } |
580 } |
579 |
581 |
580 // message part downloads |
582 // message part downloads |
581 //<cmail> during consecutive calls to CancelDownloadL, iParts contents don't remain same. |
583 if ( iAppUi.DownloadInfoMediator() ) |
582 // changing this so that it works even with varying contents in iParts |
584 { |
583 TInt count = iParts.Count(); |
585 // Note that we don't bother removing anything from iParts now; they |
584 TInt currentCount = count; |
586 // will be cleaned up later. |
585 while (count) |
587 for ( TInt i = iParts.Count() - 1; i >= 0; i-- ) |
586 { |
588 { |
587 TInt error( KErrNone ); |
589 TRAP_IGNORE( iAppUi.DownloadInfoMediator()->CancelDownloadL( iParts[i].iMessagePartId ) ); |
588 if ( iAppUi.DownloadInfoMediator() ) |
590 } |
589 { |
591 } |
590 TRAP( error, iAppUi.DownloadInfoMediator()->CancelDownloadL( iParts[0].iMessagePartId ) ); |
592 |
591 currentCount = iParts.Count(); |
|
592 if(currentCount>=count) |
|
593 iParts.Remove(0); |
|
594 count = currentCount; |
|
595 //</cmail> |
|
596 } |
|
597 if ( error ) |
|
598 { |
|
599 } |
|
600 } |
|
601 //<cmail> |
593 //<cmail> |
602 if(!iRequestCompleted) |
594 if( !iRequestCompleted ) |
603 { |
595 { |
604 iObserver.FetchLogicComplete( iState, KErrCancel ); |
596 if ( iObserver.FetchLogicComplete( iState, KErrCancel )) |
|
597 { |
|
598 // If the observer deleted this object, don't try to do anything |
|
599 // else. |
|
600 return; |
|
601 } |
605 iRequestCompleted = ETrue; //so that no stray events from plugins can cause panic |
602 iRequestCompleted = ETrue; //so that no stray events from plugins can cause panic |
606 } |
603 } |
|
604 |
607 iFetchingCancelGoingOn = EFalse; |
605 iFetchingCancelGoingOn = EFalse; |
608 //</cmail> |
606 //</cmail> |
609 } |
607 } |
610 |
608 |
611 // ----------------------------------------------------------------------------- |
609 // ----------------------------------------------------------------------------- |