# HG changeset patch # User teknolog # Date 1267660565 0 # Node ID 26a3f2dfba086c6e4e2390c4147f9797aedd7b56 # Parent 8a5ead064c4ffb95db19cc056d659c6192b82047 Fix for bug where we always load the feed icon a large number of times diff -r 8a5ead064c4f -r 26a3f2dfba08 application/inc/PodcastFeedView.h --- a/application/inc/PodcastFeedView.h Wed Mar 03 22:24:42 2010 +0000 +++ b/application/inc/PodcastFeedView.h Wed Mar 03 23:56:05 2010 +0000 @@ -95,7 +95,7 @@ void DialogDismissedL(TInt aButtonId); // from MImageHandlerCallback - void ImageOperationCompleteL(TInt aError); + void ImageOperationCompleteL(TInt aError, TUint aHandle); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation); diff -r 8a5ead064c4f -r 26a3f2dfba08 application/inc/PodcastShowsView.h --- a/application/inc/PodcastShowsView.h Wed Mar 03 22:24:42 2010 +0000 +++ b/application/inc/PodcastShowsView.h Wed Mar 03 23:56:05 2010 +0000 @@ -109,7 +109,7 @@ * @param aError Error code given by the CImageHandler or 0 (zero) if the * image was loaded successfully. */ - virtual void ImageOperationCompleteL(TInt aError); + virtual void ImageOperationCompleteL(TInt aError, TUint aHandle); void HandleSetShowPlayed(TBool aPlayed); void HandleDeleteShow(); void UpdateViewTitleL(); diff -r 8a5ead064c4f -r 26a3f2dfba08 application/sis/podcatcher_udeb.sis Binary file application/sis/podcatcher_udeb.sis has changed diff -r 8a5ead064c4f -r 26a3f2dfba08 application/sis/podcatcher_udeb_signed.sis Binary file application/sis/podcatcher_udeb_signed.sis has changed diff -r 8a5ead064c4f -r 26a3f2dfba08 application/sis/podcatcher_urel.sis Binary file application/sis/podcatcher_urel.sis has changed diff -r 8a5ead064c4f -r 26a3f2dfba08 application/sis/podcatcher_urel_signed.sis Binary file application/sis/podcatcher_urel_signed.sis has changed diff -r 8a5ead064c4f -r 26a3f2dfba08 application/src/PodcastFeedView.cpp --- a/application/src/PodcastFeedView.cpp Wed Mar 03 22:24:42 2010 +0000 +++ b/application/src/PodcastFeedView.cpp Wed Mar 03 23:56:05 2010 +0000 @@ -371,6 +371,11 @@ aFeedInfo.LastUpdated().FormatL(updatedDate, KDateFormatShort()); } } + + if(aFeedInfo.LastError() != KErrNone) + { + GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); + } } CArrayPtr* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray(); @@ -395,16 +400,11 @@ if(BaflUtils::FileExists(iPodcastModel.FsSession(), aFeedInfo.ImageFileName())) { // If this fails, no reason to worry - TRAP_IGNORE(iPodcastModel.ImageHandler().LoadFileAndScaleL(aFeedInfo.FeedIcon(), aFeedInfo.ImageFileName(), TSize(64,56), *this)); + TRAP_IGNORE(iPodcastModel.ImageHandler().LoadFileAndScaleL(aFeedInfo.FeedIcon(), aFeedInfo.ImageFileName(), TSize(64,56), *this, aFeedInfo.Uid())); } } } - if(aFeedInfo.LastError() != KErrNone) - { - GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); - } - if (unplayedShows.Length() > 0) { unplayedShows.Insert(0,_L(", ")); } @@ -412,10 +412,10 @@ iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate, &unplayedShows); } -void CPodcastFeedView::ImageOperationCompleteL(TInt aError) +void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle) { if (aError == KErrNone) { - UpdateListboxItemsL(); + UpdateFeedInfoStatusL(aHandle, EFalse); } } diff -r 8a5ead064c4f -r 26a3f2dfba08 application/src/PodcastShowsView.cpp --- a/application/src/PodcastShowsView.cpp Wed Mar 03 22:24:42 2010 +0000 +++ b/application/src/PodcastShowsView.cpp Wed Mar 03 23:56:05 2010 +0000 @@ -619,7 +619,7 @@ } } -void CPodcastShowsView::ImageOperationCompleteL(TInt aError) +void CPodcastShowsView::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/) { iLastImageHandlerError = aError; if(iSetTitlebarImage) diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/inc/FeedEngine.h --- a/engine/inc/FeedEngine.h Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/inc/FeedEngine.h Wed Mar 03 23:56:05 2010 +0000 @@ -162,6 +162,7 @@ COpmlParser* iOpmlParser; RFeedInfoArray iSearchResults; TBool iAutoUpdatedInitiator; + TBool iCancelRequested; }; #endif /*FEEDENGINE_H_*/ diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/inc/FeedInfo.h --- a/engine/inc/FeedInfo.h Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/inc/FeedInfo.h Wed Mar 03 23:56:05 2010 +0000 @@ -76,7 +76,7 @@ private: CFeedInfo(); void ConstructL(); - void ImageOperationCompleteL(TInt aError); + void ImageOperationCompleteL(TInt aError, TUint aHandle); private: HBufC* iUrl; HBufC* iTitle; diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/inc/ImageHandler.h --- a/engine/inc/ImageHandler.h Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/inc/ImageHandler.h Wed Mar 03 23:56:05 2010 +0000 @@ -43,7 +43,7 @@ * @param aError Error code given by the CImageHandler or 0 (zero) if the * image was loaded successfully. */ - virtual void ImageOperationCompleteL(TInt aError) = 0; + virtual void ImageOperationCompleteL(TInt aError, TUint aHandle) = 0; }; // ============================================================================ @@ -54,6 +54,7 @@ TSize iScaledSize; MImageHandlerCallback* iCallBack; TFileName iFileName; + TUint iHandle; }; /** * CImageHandler @@ -104,6 +105,7 @@ const TFileName& aFileName, const TSize &aSize, MImageHandlerCallback& aCallback, + TUint aHandle, TInt aSelectedFrame = 0); /** @@ -176,7 +178,10 @@ /** target size for scaled image */ TSize iSize; - RArray iCallbackQue; + RArray iCallbackQue; + + /* Handle passed back to caller */ + TUint iHandle; }; #endif diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/inc/PodcastModel.h --- a/engine/inc/PodcastModel.h Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/inc/PodcastModel.h Wed Mar 03 23:56:05 2010 +0000 @@ -102,7 +102,7 @@ CPodcastModel(); void ConstructL(); // From ImageHandler - void ImageOperationCompleteL(TInt aError); + void ImageOperationCompleteL(TInt aError, TUint aHandle); private: CShowInfo* iPlayingPodcast; diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/src/FeedEngine.cpp --- a/engine/src/FeedEngine.cpp Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/src/FeedEngine.cpp Wed Mar 03 23:56:05 2010 +0000 @@ -158,6 +158,7 @@ { if(iClientState != EIdle) { + iCancelRequested = ETrue; iFeedsUpdating.Reset(); iFeedClient->Stop(); } @@ -199,12 +200,16 @@ DP("FeedEngine::UpdateFeedL BEGIN"); iActiveFeed = GetFeedInfoByUid(aFeedUid); iCatchupCounter = 0; + iCancelRequested = EFalse; if (iActiveFeed->LastUpdated() == 0) { iCatchupMode = ETrue; } - + + iActiveFeed->SetLastError(KErrNone); + DBUpdateFeed(*iActiveFeed); + iUpdatingFeedFileName.Copy (iPodcastModel.SettingsEngine().PrivatePath ()); _LIT(KFileNameFormat, "%lu.xml"); iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid); @@ -533,49 +538,52 @@ break; default: { - iActiveFeed->SetLastError(aError); - TTime time; - time.HomeTime(); - iActiveFeed->SetLastUpdated(time); - - if( aError == KErrNone) - { - TRAPD(parserErr, iParser->ParseFeedL(iUpdatingFeedFileName, iActiveFeed, iPodcastModel.SettingsEngine().MaxListItems())); - - if(parserErr) - { - // we do not need to any special action on this error. - iActiveFeed->SetLastError(parserErr); - DP1("CFeedEngine::Complete()\t Failed to parse feed. Leave with error code=%d", parserErr); - } - else - { - iPodcastModel.ShowEngine().DeleteOldShowsByFeed(iActiveFeed->Uid()); - } - - // delete the downloaded XML file as it is no longer needed - BaflUtils::DeleteFile(iPodcastModel.FsSession(),iUpdatingFeedFileName); - - // if the feed has specified a image url. download it if we dont already have it - if((iActiveFeed->ImageUrl().Length() > 0)) - { - if ( (iActiveFeed->ImageFileName().Length() == 0) || - (iActiveFeed->ImageFileName().Length() > 0 && - !BaflUtils::FileExists(iPodcastModel.FsSession(), - iActiveFeed->ImageFileName()) ) - ) + if (!iCancelRequested) { + iActiveFeed->SetLastError(aError); + TTime time; + time.HomeTime(); + iActiveFeed->SetLastUpdated(time); + + if( aError == KErrNone) + { + TRAPD(parserErr, iParser->ParseFeedL(iUpdatingFeedFileName, iActiveFeed, iPodcastModel.SettingsEngine().MaxListItems())); + + if(parserErr) + { + // we do not need to any special action on this error. + iActiveFeed->SetLastError(parserErr); + DP1("CFeedEngine::Complete()\t Failed to parse feed. Leave with error code=%d", parserErr); + } + else { - TRAPD(error, GetFeedImageL(iActiveFeed)); - if (error) + iPodcastModel.ShowEngine().DeleteOldShowsByFeed(iActiveFeed->Uid()); + } + + // delete the downloaded XML file as it is no longer needed + BaflUtils::DeleteFile(iPodcastModel.FsSession(),iUpdatingFeedFileName); + + // if the feed has specified a image url. download it if we dont already have it + if((iActiveFeed->ImageUrl().Length() > 0)) + { + if ( (iActiveFeed->ImageFileName().Length() == 0) || + (iActiveFeed->ImageFileName().Length() > 0 && + !BaflUtils::FileExists(iPodcastModel.FsSession(), + iActiveFeed->ImageFileName()) ) + ) { - // we have failed in a very early stage to fetch the image. - // continue with next Feed update - iActiveFeed->SetLastError(parserErr); - iClientState = EIdle; - } - } + TRAPD(error, GetFeedImageL(iActiveFeed)); + if (error) + { + // we have failed in a very early stage to fetch the image. + // continue with next Feed update + iActiveFeed->SetLastError(parserErr); + iClientState = EIdle; + } + } + } } } + iCancelRequested = EFalse; }break; } diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/src/FeedInfo.cpp --- a/engine/src/FeedInfo.cpp Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/src/FeedInfo.cpp Wed Mar 03 23:56:05 2010 +0000 @@ -229,7 +229,7 @@ iFeedIcon->Duplicate(aBitmapToClone->Handle()); } -void CFeedInfo::ImageOperationCompleteL(TInt /*aError*/) +void CFeedInfo::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/) { } diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/src/ImageHandler.cpp --- a/engine/src/ImageHandler.cpp Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/src/ImageHandler.cpp Wed Mar 03 23:56:05 2010 +0000 @@ -17,6 +17,7 @@ */ #include "ImageHandler.h" +#include "debug.h" // ============================================================================= // CImageHandler, a utility class for loading images. @@ -121,8 +122,11 @@ const TFileName& aFileName, const TSize &aSize, MImageHandlerCallback& aCallback, + TUint aHandle, TInt aSelectedFrame) - { + { + DP1("CImageHandler::LoadFileAndScaleL, iCallbackQueue.Count()=%d", iCallbackQue.Count()); + if(!IsActive()) { __ASSERT_ALWAYS(!IsActive(),User::Invariant()); @@ -130,16 +134,26 @@ iScaledBitmap = aScaledBitmap; iScaledBitmap->Reset(); iScaledBitmap->Create(aSize, EColor16M); - iCallback = &aCallback; + iCallback = &aCallback; + iHandle = aHandle; LoadFileL(aFileName, aSelectedFrame); } else { + for (int i=0;iImageOperationCompleteL(iStatus.Int()); + iCallback->ImageOperationCompleteL(iStatus.Int(), iHandle); if(iCallbackQue.Count()) { TInt loaderror = KErrNotFound; @@ -195,7 +210,7 @@ { TImageStruct imageStruct= iCallbackQue[0]; iCallbackQue.Remove(0); - TRAP(loaderror, LoadFileAndScaleL(imageStruct.iScaledImage, imageStruct.iFileName, imageStruct.iScaledSize, *imageStruct.iCallBack)); + TRAP(loaderror, LoadFileAndScaleL(imageStruct.iScaledImage, imageStruct.iFileName, imageStruct.iScaledSize, *imageStruct.iCallBack, imageStruct.iHandle)); } } } diff -r 8a5ead064c4f -r 26a3f2dfba08 engine/src/PodcastModel.cpp --- a/engine/src/PodcastModel.cpp Wed Mar 03 22:24:42 2010 +0000 +++ b/engine/src/PodcastModel.cpp Wed Mar 03 23:56:05 2010 +0000 @@ -435,7 +435,7 @@ } -void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/) +void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/) { }