197 EXPORT_C TBool CFeedEngine::UpdateFeedL(TUint aFeedUid) |
198 EXPORT_C TBool CFeedEngine::UpdateFeedL(TUint aFeedUid) |
198 { |
199 { |
199 DP("FeedEngine::UpdateFeedL BEGIN"); |
200 DP("FeedEngine::UpdateFeedL BEGIN"); |
200 iActiveFeed = GetFeedInfoByUid(aFeedUid); |
201 iActiveFeed = GetFeedInfoByUid(aFeedUid); |
201 iCatchupCounter = 0; |
202 iCatchupCounter = 0; |
|
203 iCancelRequested = EFalse; |
202 |
204 |
203 if (iActiveFeed->LastUpdated() == 0) |
205 if (iActiveFeed->LastUpdated() == 0) |
204 { |
206 { |
205 iCatchupMode = ETrue; |
207 iCatchupMode = ETrue; |
206 } |
208 } |
207 |
209 |
|
210 iActiveFeed->SetLastError(KErrNone); |
|
211 DBUpdateFeedL(*iActiveFeed); |
|
212 |
208 iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ()); |
213 iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ()); |
209 _LIT(KFileNameFormat, "%lu.xml"); |
214 _LIT(KFileNameFormat, "%lu.xml"); |
210 iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid); |
215 iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid); |
211 |
216 |
212 if(iFeedClient->GetL(iActiveFeed->Url(), iUpdatingFeedFileName, iPodcastModel.SettingsEngine().SpecificIAP())) |
217 if(iFeedClient->GetL(iActiveFeed->Url(), iUpdatingFeedFileName, iPodcastModel.SettingsEngine().SpecificIAP())) |
531 case KErrCouldNotConnect: |
536 case KErrCouldNotConnect: |
532 iFeedsUpdating.Reset(); |
537 iFeedsUpdating.Reset(); |
533 break; |
538 break; |
534 default: |
539 default: |
535 { |
540 { |
536 iActiveFeed->SetLastError(aError); |
541 if (!iCancelRequested) { |
537 TTime time; |
542 iActiveFeed->SetLastError(aError); |
538 time.HomeTime(); |
543 TTime time; |
539 iActiveFeed->SetLastUpdated(time); |
544 time.HomeTime(); |
540 |
545 iActiveFeed->SetLastUpdated(time); |
541 if( aError == KErrNone) |
546 |
542 { |
547 if( aError == KErrNone) |
543 TRAPD(parserErr, iParser->ParseFeedL(iUpdatingFeedFileName, iActiveFeed, iPodcastModel.SettingsEngine().MaxListItems())); |
548 { |
544 |
549 TRAPD(parserErr, iParser->ParseFeedL(iUpdatingFeedFileName, iActiveFeed, iPodcastModel.SettingsEngine().MaxListItems())); |
545 if(parserErr) |
550 |
546 { |
551 if(parserErr) |
547 // we do not need to any special action on this error. |
|
548 iActiveFeed->SetLastError(parserErr); |
|
549 DP1("CFeedEngine::Complete()\t Failed to parse feed. Leave with error code=%d", parserErr); |
|
550 } |
|
551 else |
|
552 { |
|
553 iPodcastModel.ShowEngine().DeleteOldShowsByFeed(iActiveFeed->Uid()); |
|
554 } |
|
555 |
|
556 // delete the downloaded XML file as it is no longer needed |
|
557 BaflUtils::DeleteFile(iPodcastModel.FsSession(),iUpdatingFeedFileName); |
|
558 |
|
559 // if the feed has specified a image url. download it if we dont already have it |
|
560 if((iActiveFeed->ImageUrl().Length() > 0)) |
|
561 { |
|
562 if ( (iActiveFeed->ImageFileName().Length() == 0) || |
|
563 (iActiveFeed->ImageFileName().Length() > 0 && |
|
564 !BaflUtils::FileExists(iPodcastModel.FsSession(), |
|
565 iActiveFeed->ImageFileName()) ) |
|
566 ) |
|
567 { |
552 { |
568 TRAPD(error, GetFeedImageL(iActiveFeed)); |
553 // we do not need to any special action on this error. |
569 if (error) |
554 iActiveFeed->SetLastError(parserErr); |
|
555 DP1("CFeedEngine::Complete()\t Failed to parse feed. Leave with error code=%d", parserErr); |
|
556 } |
|
557 else |
|
558 { |
|
559 iPodcastModel.ShowEngine().DeleteOldShowsByFeed(iActiveFeed->Uid()); |
|
560 } |
|
561 |
|
562 // delete the downloaded XML file as it is no longer needed |
|
563 BaflUtils::DeleteFile(iPodcastModel.FsSession(),iUpdatingFeedFileName); |
|
564 |
|
565 // if the feed has specified a image url. download it if we dont already have it |
|
566 if((iActiveFeed->ImageUrl().Length() > 0)) |
|
567 { |
|
568 if ( (iActiveFeed->ImageFileName().Length() == 0) || |
|
569 (iActiveFeed->ImageFileName().Length() > 0 && |
|
570 !BaflUtils::FileExists(iPodcastModel.FsSession(), |
|
571 iActiveFeed->ImageFileName()) ) |
|
572 ) |
570 { |
573 { |
571 // we have failed in a very early stage to fetch the image. |
574 TRAPD(error, GetFeedImageL(iActiveFeed)); |
572 // continue with next Feed update |
575 if (error) |
573 iActiveFeed->SetLastError(parserErr); |
576 { |
574 iClientState = EIdle; |
577 // we have failed in a very early stage to fetch the image. |
575 } |
578 // continue with next Feed update |
576 } |
579 iActiveFeed->SetLastError(parserErr); |
|
580 iClientState = EIdle; |
|
581 } |
|
582 } |
|
583 } |
577 } |
584 } |
578 } |
585 } |
|
586 iCancelRequested = EFalse; |
579 }break; |
587 }break; |
580 } |
588 } |
581 |
589 |
582 NotifyFeedUpdateCompleteL(aError); |
590 NotifyFeedUpdateCompleteL(aError); |
583 |
591 |