Fix for download icons not updating correctly
authorteknolog
Thu, 04 Mar 2010 22:06:39 +0000
changeset 34 a6046405f1aa
parent 33 64ed1227e68d
child 36 e010fc411ddc
child 38 c11e52c5acd2
Fix for download icons not updating correctly
application/sis/podcatcher_udeb.sis
application/sis/podcatcher_udeb_signed.sis
application/sis/podcatcher_urel.sis
application/sis/podcatcher_urel_signed.sis
application/src/PodcastQueueView.cpp
application/src/PodcastShowsView.cpp
engine/src/ShowEngine.cpp
Binary file application/sis/podcatcher_udeb.sis has changed
Binary file application/sis/podcatcher_udeb_signed.sis has changed
Binary file application/sis/podcatcher_urel.sis has changed
Binary file application/sis/podcatcher_urel_signed.sis has changed
--- a/application/src/PodcastQueueView.cpp	Thu Mar 04 19:46:25 2010 +0000
+++ b/application/src/PodcastQueueView.cpp	Thu Mar 04 22:06:39 2010 +0000
@@ -305,29 +305,32 @@
 void CPodcastQueueView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
 	{
 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
-	TUint showDownloadingUid = iPodcastModel.ShowEngine().ShowDownloading() ? iPodcastModel.ShowEngine().ShowDownloading()->Uid() : 0;
-	
-	if (showDownloadingUid == aShowInfo->Uid())
-		{
-		aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
-		}
-	else
+
+	switch (aShowInfo->DownloadState())
 		{
-		switch (aShowInfo->DownloadState())
-			{
-			case EQueued:
-				aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
-				break;
-			case EDownloading:
-				aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
-				break;
-			case EFailedDownload:
-				aIconIndex = EFailedShowIcon;
-				break;
-			default:
-				DP("Wrong download state for queue view!");
-				break;
+		case EDownloaded:
+			if (aShowInfo->PlayState() == ENeverPlayed) {
+				aIconIndex = EDownloadedNewShowIcon;
+			} else {
+				aIconIndex = EDownloadedShowIcon;
 			}
+			break;
+		case ENotDownloaded:
+			if (aShowInfo->PlayState() == ENeverPlayed) {
+				aIconIndex = ENewShowIcon;
+			} else {
+				aIconIndex = EShowIcon;
+			}
+			break;
+		case EQueued:
+			aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
+			break;
+		case EDownloading:
+			aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
+			break;
+		case EFailedDownload:
+			aIconIndex = EFailedShowIcon;
+			break;
 		}
 	}
 
--- a/application/src/PodcastShowsView.cpp	Thu Mar 04 19:46:25 2010 +0000
+++ b/application/src/PodcastShowsView.cpp	Thu Mar 04 22:06:39 2010 +0000
@@ -245,9 +245,23 @@
 		}		
 	}
 
-void CPodcastShowsView::ShowDownloadFinishedL(TUint /*aShowUid*/, TInt aError)
+void CPodcastShowsView::ShowDownloadFinishedL(TUint aShowUid, TInt aError)
 	{
 	iProgressAdded = EFalse;
+	CShowInfo *info = NULL;
+	RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
+	
+	for (TInt i=0;i<fItems.Count();i++)
+		{
+		if (fItems[i]->Uid() == aShowUid)
+			{
+			info = fItems[i];
+			}
+		}
+	
+	if (info == NULL) {
+		return;
+	}
 	
 	switch(aError)
 		{
@@ -336,40 +350,32 @@
 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
 	{
 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
-	TUint showDownloadingUid = iPodcastModel.ShowEngine().ShowDownloading() ? iPodcastModel.ShowEngine().ShowDownloading()->Uid() : 0;
-	
-	if (showDownloadingUid == aShowInfo->Uid())
-		{
-		aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
-		}
-	else
+
+	switch (aShowInfo->DownloadState())
 		{
-		switch (aShowInfo->DownloadState())
-			{
-			case EDownloaded:
-				if (aShowInfo->PlayState() == ENeverPlayed) {
-					aIconIndex = EDownloadedNewShowIcon;
-				} else {
-					aIconIndex = EDownloadedShowIcon;
-				}
-				break;
-			case ENotDownloaded:
-				if (aShowInfo->PlayState() == ENeverPlayed) {
-					aIconIndex = ENewShowIcon;
-				} else {
-					aIconIndex = EShowIcon;
-				}
-				break;
-			case EQueued:
-				aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
-				break;
-			case EDownloading:
-				aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
-				break;
-			case EFailedDownload:
-				aIconIndex = EFailedShowIcon;
-				break;
+		case EDownloaded:
+			if (aShowInfo->PlayState() == ENeverPlayed) {
+				aIconIndex = EDownloadedNewShowIcon;
+			} else {
+				aIconIndex = EDownloadedShowIcon;
 			}
+			break;
+		case ENotDownloaded:
+			if (aShowInfo->PlayState() == ENeverPlayed) {
+				aIconIndex = ENewShowIcon;
+			} else {
+				aIconIndex = EShowIcon;
+			}
+			break;
+		case EQueued:
+			aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
+			break;
+		case EDownloading:
+			aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
+			break;
+		case EFailedDownload:
+			aIconIndex = EFailedShowIcon;
+			break;
 		}
 	}
 	
@@ -509,7 +515,7 @@
 			if (allUidsMatch && len > 0)
 				{
 				for (TInt loop = 0; loop< len; loop++)
-					{					
+					{
 					UpdateShowItemDataL(fItems[loop], loop);
 					}
 				iListContainer->Listbox()->DrawNow();
@@ -814,6 +820,7 @@
 void CPodcastShowsView::DownloadQueueUpdatedL(TInt aDownloadingShows, TInt aQueuedShows)
 	{
 	((CPodcastAppUi*)AppUi())->UpdateQueueTab(aDownloadingShows+aQueuedShows);
+	UpdateListboxItemsL();
 	}
 
 void CPodcastShowsView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
--- a/engine/src/ShowEngine.cpp	Thu Mar 04 19:46:25 2010 +0000
+++ b/engine/src/ShowEngine.cpp	Thu Mar 04 22:06:39 2010 +0000
@@ -1171,19 +1171,20 @@
 	const TInt count = DBGetDownloadsCount();
 	DP("CShowEngine::DownloadNextShow\tTrying to start new download");DP1("CShowEngine::DownloadNextShow\tShows in download queue %d", count);
 
-	// Inform the observers
-	NotifyDownloadQueueUpdatedL();
-
 	if (count > 0)
 		{
 		if (iPodcastModel.SettingsEngine().DownloadSuspended())
 			{
 			DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING");
+			// Inform the observers
+			NotifyDownloadQueueUpdatedL();
 			return;
 			}
 		else if (iShowClient->IsActive())
 			{
 			DP("CShowEngine::DownloadNextShow\tDownload process is already active.");
+			// Inform the observers
+			NotifyDownloadQueueUpdatedL();
 			return;
 			}
 		else
@@ -1201,6 +1202,10 @@
 				info->SetLastError(KErrNone);
 				DBUpdateShow(*info);
 				iShowDownloading = info;
+				// Inform the observers
+				// important to do this after we change download state
+				NotifyDownloadQueueUpdatedL();
+
 				TRAPD(error,getOk = GetShowL(info));
 				if (error != KErrNone || !getOk)
 					{
@@ -1224,6 +1229,8 @@
 		}
 	else
 		{
+		// Inform the observers
+		NotifyDownloadQueueUpdatedL();
 		iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download");
 		}
 	DP("CShowEngine::DownloadNextShowL END");