application/src/PodcastShowsView.cpp
branchsymbian1
changeset 356 697e27864f3a
parent 355 075b3a49cb55
child 358 d2ce95126703
equal deleted inserted replaced
346:a0eb6aaed052 356:697e27864f3a
    42 
    42 
    43 // these must correspond with TShowsIconIndex
    43 // these must correspond with TShowsIconIndex
    44 
    44 
    45 const TUint KShowIconArrayIds[] =
    45 const TUint KShowIconArrayIds[] =
    46 	{
    46 	{
    47 			EMbmPodcastAudio,
    47 	//	EShowIcon = 0,
    48 			EMbmPodcastAudio_mask,
    48 	EMbmPodcastAudio,
    49 			EMbmPodcastAudio_new,
    49 	EMbmPodcastAudio_mask,
    50 			EMbmPodcastAudio_new_mask,
    50 	//	EShowIconNew,
    51 			EMbmPodcastAudio_queued,
    51 	EMbmPodcastAudio_new,
    52 			EMbmPodcastAudio_queued_mask,
    52 	EMbmPodcastAudio_new_mask,
    53 			EMbmPodcastAudio_downloading,
    53 	//	EQuedShowIcon,
    54 			EMbmPodcastAudio_downloading_mask,
    54 	EMbmPodcastAudio_dl_queued,
    55 			EMbmPodcastAudio_downloaded,
    55 	EMbmPodcastAudio_dl_queued_mask,
    56 			EMbmPodcastAudio_downloaded_mask,
    56 	//	EQuedShowIconNew,
    57 			EMbmPodcastAudio_downloaded_new,
    57 	EMbmPodcastAudio_dl_queued_new,
    58 			EMbmPodcastAudio_downloaded_new_mask,
    58 	EMbmPodcastAudio_dl_queued_new_mask,
    59 			EMbmPodcastAudio_failed,
    59 	//	EDownloadingShowIcon,
    60 			EMbmPodcastAudio_failed_mask,
    60 	EMbmPodcastAudio_dl_active,
    61 			EMbmPodcastAudio_suspended,
    61 	EMbmPodcastAudio_dl_active_mask,
    62 			EMbmPodcastAudio_suspended_mask,
    62 	//	EDownloadingShowIconNew,
    63 			EMbmPodcastVideo,
    63 	EMbmPodcastAudio_dl_active_new,
    64 			EMbmPodcastVideo_mask,
    64 	EMbmPodcastAudio_dl_active_new_mask,
    65 			EMbmPodcastVideo_new,
    65 	//	EDownloadedShowIcon,
    66 			EMbmPodcastVideo_new_mask,
    66 	EMbmPodcastAudio_dl,
    67 			EMbmPodcastVideo_queued,
    67 	EMbmPodcastAudio_dl_mask,
    68 			EMbmPodcastVideo_queued_mask,
    68 	//	EDownloadedShowIconNew,
    69 			EMbmPodcastVideo_downloading,
    69 	EMbmPodcastAudio_dl_new,
    70 			EMbmPodcastVideo_downloading_mask,
    70 	EMbmPodcastAudio_dl_new_mask,
    71 			EMbmPodcastVideo_downloaded,
    71 	//	EFailedShowIcon,
    72 			EMbmPodcastVideo_downloaded_mask,
    72 	EMbmPodcastAudio_dl_failed,
    73 			EMbmPodcastVideo_downloaded_new,
    73 	EMbmPodcastAudio_dl_failed_mask,
    74 			EMbmPodcastVideo_downloaded_new_mask,
    74 	//	EFailedShowIconNew,
    75 			EMbmPodcastVideo_failed,
    75 	EMbmPodcastAudio_dl_failed_new,
    76 			EMbmPodcastVideo_failed_mask,
    76 	EMbmPodcastAudio_dl_failed_new_mask,
    77 			EMbmPodcastVideo_suspended,
    77 	//	ESuspendedShowIcon,
    78 			EMbmPodcastVideo_suspended_mask,
    78 	EMbmPodcastAudio_dl_suspended,
    79 			EMbmPodcastFeed,
    79 	EMbmPodcastAudio_dl_suspended_mask,
    80 			EMbmPodcastFeed_mask,
    80 	//	ESuspendedShowIconNew
    81 			0,
    81 	EMbmPodcastAudio_dl_suspended_new,
    82 			0
    82 	EMbmPodcastAudio_dl_suspended_new_mask,
       
    83 	//	EShowIcon = 0,
       
    84 	EMbmPodcastVideo,
       
    85 	EMbmPodcastVideo_mask,
       
    86 	//	EShowIconNew,
       
    87 	EMbmPodcastVideo_new,
       
    88 	EMbmPodcastVideo_new_mask,
       
    89 	//	EQuedShowIcon,
       
    90 	EMbmPodcastVideo_dl_queued,
       
    91 	EMbmPodcastVideo_dl_queued_mask,
       
    92 	//	EQuedShowIconNew,
       
    93 	EMbmPodcastVideo_dl_queued_new,
       
    94 	EMbmPodcastVideo_dl_queued_new_mask,
       
    95 	//	EDownloadingShowIcon,
       
    96 	EMbmPodcastVideo_dl_active,
       
    97 	EMbmPodcastVideo_dl_active_mask,
       
    98 	//	EDownloadingShowIconNew,
       
    99 	EMbmPodcastVideo_dl_active_new,
       
   100 	EMbmPodcastVideo_dl_active_new_mask,
       
   101 	//	EDownloadedShowIcon,
       
   102 	EMbmPodcastVideo_dl,
       
   103 	EMbmPodcastVideo_dl_mask,
       
   104 	//	EDownloadedShowIconNew,
       
   105 	EMbmPodcastVideo_dl_new,
       
   106 	EMbmPodcastVideo_dl_new_mask,
       
   107 	//	EFailedShowIcon,
       
   108 	EMbmPodcastVideo_dl_failed,
       
   109 	EMbmPodcastVideo_dl_failed_mask,
       
   110 	//	EFailedShowIconNew,
       
   111 	EMbmPodcastVideo_dl_failed_new,
       
   112 	EMbmPodcastVideo_dl_failed_new_mask,
       
   113 	//	ESuspendedShowIcon,
       
   114 	EMbmPodcastVideo_dl_suspended,
       
   115 	EMbmPodcastVideo_dl_suspended_mask,
       
   116 	//	ESuspendedShowIconNew
       
   117 	EMbmPodcastVideo_dl_suspended_new,
       
   118 	EMbmPodcastVideo_dl_suspended_new_mask,
       
   119 	EMbmPodcastFeed,
       
   120 	EMbmPodcastFeed_mask,
       
   121 	0,
       
   122 	0
    83 	};
   123 	};
    84 
   124 
    85 const TInt KVideoIconOffset = 8;
   125 const TInt KVideoIconOffset = 12;
    86 
   126 
    87 CPodcastShowsView* CPodcastShowsView::NewL(CPodcastModel& aPodcastModel)
   127 CPodcastShowsView* CPodcastShowsView::NewL(CPodcastModel& aPodcastModel)
    88 	{
   128 	{
    89 	CPodcastShowsView* self = CPodcastShowsView::NewLC(aPodcastModel);
   129 	CPodcastShowsView* self = CPodcastShowsView::NewLC(aPodcastModel);
    90 	CleanupStack::Pop(self);
   130 	CleanupStack::Pop(self);
   194 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
   234 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
   195 	}
   235 	}
   196 
   236 
   197 CPodcastShowsView::~CPodcastShowsView()
   237 CPodcastShowsView::~CPodcastShowsView()
   198 	{
   238 	{
       
   239 	DP("CPodcastShowsView::~CPodcastShowsView BEGIN");
   199 	iPodcastModel.ShowEngine().RemoveObserver(this);
   240 	iPodcastModel.ShowEngine().RemoveObserver(this);
   200 	iPodcastModel.FeedEngine().RemoveObserver(this);
   241 	iPodcastModel.FeedEngine().RemoveObserver(this);
   201 	
   242 	
   202     if(iStylusPopupMenu)
   243     if(iStylusPopupMenu)
   203         delete iStylusPopupMenu, iStylusPopupMenu = NULL;
   244         delete iStylusPopupMenu, iStylusPopupMenu = NULL;
       
   245 	
       
   246     DP("CPodcastShowsView::~CPodcastShowsView END");
   204 	}
   247 	}
   205 
   248 
   206 
   249 
   207 TUid CPodcastShowsView::Id() const
   250 TUid CPodcastShowsView::Id() const
   208 	{
   251 	{
   214 	{
   257 	{
   215 	DP("CPodcastShowsView::DoActivateL BEGIN");
   258 	DP("CPodcastShowsView::DoActivateL BEGIN");
   216 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   259 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   217 	
   260 	
   218 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
   261 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
       
   262 	
       
   263 	iShowNewShows = (aCustomMessageId.iUid == 1);
       
   264 	
       
   265 	if (iShowNewShows)
       
   266 		{
       
   267 		CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   268 		cba->SetCommandSetL(R_PODCAST_CBA);
       
   269 		cba->DrawDeferred();
       
   270 		}
       
   271 	else
       
   272 		{
       
   273 		CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   274 		cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_BACK);
       
   275 		cba->DrawDeferred();		
       
   276 		}
   219 	
   277 	
   220 	UpdateViewTitleL();
   278 	UpdateViewTitleL();
   221 	UpdateFeedUpdateStateL();
   279 	UpdateFeedUpdateStateL();
   222 	DP("CPodcastShowsView::DoActivateL END");
   280 	DP("CPodcastShowsView::DoActivateL END");
   223 	}
   281 	}
   357 	}
   415 	}
   358 
   416 
   359 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
   417 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
   360 	{
   418 	{
   361 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
   419 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
   362 
   420 	TBool isNew = aShowInfo->PlayState() == ENeverPlayed;
   363 	switch (aShowInfo->DownloadState())
   421 	switch (aShowInfo->DownloadState())
   364 		{
   422 		{
   365 		case EDownloaded:
   423 		case EDownloaded:
   366 			if (aShowInfo->PlayState() == ENeverPlayed) {
   424 			aIconIndex = isNew ? EDownloadedShowIconNew : EDownloadedShowIcon;
   367 				aIconIndex = EDownloadedNewShowIcon;
       
   368 			} else {
       
   369 				aIconIndex = EDownloadedShowIcon;
       
   370 			}
       
   371 			break;
   425 			break;
   372 		case ENotDownloaded:
   426 		case ENotDownloaded:
   373 			if (aShowInfo->PlayState() == ENeverPlayed) {
   427 			aIconIndex = isNew ? EShowIconNew : EShowIcon;
   374 				aIconIndex = ENewShowIcon;
       
   375 			} else {
       
   376 				aIconIndex = EShowIcon;
       
   377 			}
       
   378 			break;
   428 			break;
   379 		case EQueued:
   429 		case EQueued:
   380 			aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
   430 			aIconIndex = dlStop ? (isNew ? ESuspendedShowIconNew : ESuspendedShowIcon) : 
       
   431 								  (isNew ? EQuedShowIconNew : EQuedShowIcon);
   381 			break;
   432 			break;
   382 		case EDownloading:
   433 		case EDownloading:
   383 			aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
   434 			aIconIndex = dlStop ? (isNew ? ESuspendedShowIconNew : ESuspendedShowIcon) : 
       
   435 								  (isNew ? EDownloadingShowIconNew : EDownloadingShowIcon);	
   384 			break;
   436 			break;
   385 		case EFailedDownload:
   437 		case EFailedDownload:
   386 			aIconIndex = EFailedShowIcon;
   438 			aIconIndex = dlStop ? (isNew ? ESuspendedShowIconNew : ESuspendedShowIcon) : 
       
   439 								  (isNew ? EFailedShowIconNew : EFailedShowIconNew);
   387 			break;
   440 			break;
   388 		}
   441 		}
   389 	
   442 	
   390 	if (aShowInfo->ShowType() == EVideoPodcast)
   443 	if (aShowInfo->ShowType() == EVideoPodcast)
   391 		{
   444 		{
   392 		aIconIndex += KVideoIconOffset;
   445 		aIconIndex += KVideoIconOffset;
   393 		}
   446 		}
       
   447 	
       
   448 	//DP3("dlStop=%d, isNew=%d, aIconIndex=%d", dlStop, isNew, aIconIndex);
   394 	}
   449 	}
   395 	
   450 	
   396 
   451 
   397 void CPodcastShowsView::UpdateFeedUpdateStateL()
   452 void CPodcastShowsView::UpdateFeedUpdateStateL()
   398 	{
   453 	{
   421 	
   476 	
   422 	if(aSizeDownloaded > 0)
   477 	if(aSizeDownloaded > 0)
   423 		{
   478 		{
   424 		if (aShowInfo.ShowSize() > 0)
   479 		if (aShowInfo.ShowSize() > 0)
   425 			{
   480 			{
       
   481 				TInt showSize = aShowInfo.ShowSize() >= aSizeDownloaded ? aShowInfo.ShowSize() : aSizeDownloaded;
   426 				infoSize.Format(KSizeDownloadingOf(), ((float) aSizeDownloaded / (float) KSizeMb),
   482 				infoSize.Format(KSizeDownloadingOf(), ((float) aSizeDownloaded / (float) KSizeMb),
   427 						((float)aShowInfo.ShowSize() / (float)KSizeMb));
   483 						((float) showSize / (float)KSizeMb));
   428 			}
   484 			}
   429 		else
   485 		else
   430 			{
   486 			{
   431 			infoSize.Format(KShowsSizeFormatS60(), (float)aSizeDownloaded / (float)KSizeMb);
   487 			infoSize.Format(KShowsSizeFormatS60(), (float)aSizeDownloaded / (float)KSizeMb);
   432 			}
   488 			}
   507 	if (iListContainer->IsVisible())
   563 	if (iListContainer->IsVisible())
   508 		{
   564 		{
   509 		TListItemProperties itemProps;
   565 		TListItemProperties itemProps;
   510 		TInt len = 0;
   566 		TInt len = 0;
   511 
   567 
   512 		iPodcastModel.GetShowsByFeedL(iPodcastModel.ActiveFeedInfo()->Uid());
   568 		if (iShowNewShows)
   513 
   569 			{
       
   570 			iPodcastModel.GetNewShowsL();
       
   571 			}
       
   572 		else
       
   573 			{
       
   574 			iPodcastModel.GetShowsByFeedL(iPodcastModel.ActiveFeedInfo()->Uid());
       
   575 			}
       
   576 		
   514 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   577 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   515 		len = fItems.Count();
   578 		len = fItems.Count();
   516 
   579 
   517 		if (iListContainer->Listbox() != NULL)
   580 		if (iListContainer->Listbox() != NULL)
   518 			{
   581 			{
   597 			UpdateListboxItemsL();
   660 			UpdateListboxItemsL();
   598 			break;
   661 			break;
   599 		case EPodcastDeleteShow:
   662 		case EPodcastDeleteShow:
   600 			HandleDeleteShowL();
   663 			HandleDeleteShowL();
   601 			break;
   664 			break;
       
   665 		case EPodcastDownloadAll:
       
   666 			HandleDownloadAllL();
       
   667 			break;
   602 		case EPodcastDownloadShow:
   668 		case EPodcastDownloadShow:
   603 			{
   669 			{
   604 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
   670 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
   605 			
   671 			
   606 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
   672 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
   625 					CleanupStack::PopAndDestroy(str);
   691 					CleanupStack::PopAndDestroy(str);
   626 					}
   692 					}
   627 				}
   693 				}
   628 			}
   694 			}
   629 			break;
   695 			break;
       
   696 		case EPodcastUpdateAllFeeds:
       
   697 			{
       
   698 			iPodcastModel.FeedEngine().UpdateAllFeedsL();
       
   699 			UpdateToolbar();
       
   700 			}break;
   630 		case EPodcastCancelUpdateAllFeeds:
   701 		case EPodcastCancelUpdateAllFeeds:
   631 			iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
   702 			iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
   632 			break;
   703 			break;
   633 		case EPodcastShowInfo:
   704 		case EPodcastShowInfo:
   634 			{
   705 			{
   635 			DisplayShowInfoDialogL();
   706 			DisplayShowInfoDialogL();
   636 			}break;
   707 			}break;
   637 		case EPodcastFilterShowsAll:
       
   638 			iPodcastModel.ShowEngine().SetShowFilter(EAllShows);
       
   639 			UpdateListboxItemsL();
       
   640 			break;
       
   641 		case EPodcastFilterShowsDownloaded:
       
   642 			iPodcastModel.ShowEngine().SetShowFilter(EDownloadedShows);
       
   643 			UpdateListboxItemsL();
       
   644 			break;			
       
   645 		case EPodcastFilterShowsNew:
       
   646 			iPodcastModel.ShowEngine().SetShowFilter(ENewShows);
       
   647 			UpdateListboxItemsL();
       
   648 			break;
       
   649 		case EPodcastFilterShowsNewAndDownloaded:
       
   650 			iPodcastModel.ShowEngine().SetShowFilter(ENewAndDownloadedShows);
       
   651 			UpdateListboxItemsL();
       
   652 			break;	
       
   653 		default:
   708 		default:
   654 			CPodcastListView::HandleCommandL(aCommand);
   709 			CPodcastListView::HandleCommandL(aCommand);
   655 			break;
   710 			break;
   656 		}
   711 		}
   657 	iListContainer->SetLongTapDetectedL(EFalse);
   712 	iListContainer->SetLongTapDetectedL(EFalse);
   659 	UpdateToolbar();
   714 	UpdateToolbar();
   660 	}
   715 	}
   661 	
   716 	
   662 void CPodcastShowsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   717 void CPodcastShowsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   663 {
   718 {
   664 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   719 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU && !iShowNewShows)
   665 		{
   720 		{
   666 		TBool showMarkAllPlayed = EFalse;
   721 		TBool showMarkAllPlayed = EFalse;
   667 		for (int i=0;i<iPodcastModel.ActiveShowList().Count();i++)
   722 		for (int i=0;i<iPodcastModel.ActiveShowList().Count();i++)
   668 			{
   723 			{
   669 			CShowInfo* info = iPodcastModel.ActiveShowList()[i];
   724 			CShowInfo* info = iPodcastModel.ActiveShowList()[i];
   674 				}
   729 				}
   675 			
   730 			
   676 			}
   731 			}
   677 		
   732 		
   678 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
   733 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
   679 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, updatingState || !showMarkAllPlayed);
   734 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, updatingState || !showMarkAllPlayed);	
   680 
       
   681 			
       
   682 		}
   735 		}
   683 }
   736 }
   684 	
   737 	
   685 void CPodcastShowsView::DisplayShowInfoDialogL()
   738 void CPodcastShowsView::DisplayShowInfoDialogL()
   686 	{
   739 	{
   697 		note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack
   750 		note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack
   698 		note->RunLD();
   751 		note->RunLD();
   699 		}
   752 		}
   700 	}
   753 	}
   701 
   754 
       
   755 void CPodcastShowsView::HandleDownloadAllL()
       
   756 	{
       
   757 	
       
   758 	TBuf<KMaxMessageLength> msg;
       
   759 	iEikonEnv->ReadResourceL(msg, R_DOWNLOAD_ALL_QUERY);
       
   760 	if (!ShowQueryMessageL(msg))
       
   761 		{
       
   762 		return;
       
   763 		}
       
   764 		
       
   765 	for (int i=0;i<iPodcastModel.ActiveShowList().Count();i++)
       
   766 		{
       
   767 		CShowInfo* info = iPodcastModel.ActiveShowList()[i];
       
   768 
       
   769 		if (info->DownloadState() == ENotDownloaded)
       
   770 			{
       
   771 			TRAP_IGNORE(iPodcastModel.ShowEngine().AddDownloadL(*info));
       
   772 			}
       
   773 		}
       
   774 	}
       
   775 
   702 void CPodcastShowsView::UpdateToolbar(TBool aVisible)
   776 void CPodcastShowsView::UpdateToolbar(TBool aVisible)
   703 {
   777 {
   704 	CAknToolbar* toolbar = Toolbar();
   778 	CAknToolbar* toolbar = Toolbar();
   705 
   779 
   706 	if (toolbar) {
   780 	if (toolbar) {
   709 		}
   783 		}
   710 	
   784 	
   711 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() && 
   785 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() && 
   712 				iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
   786 				iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
   713 	
   787 	
   714 		toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); 
   788 		if (iShowNewShows)
       
   789 			{
       
   790 			updatingState = iPodcastModel.FeedEngine().ClientState();
       
   791 			toolbar->HideItem(EPodcastUpdateFeed, ETrue, ETrue ); 
       
   792 			toolbar->HideItem(EPodcastUpdateAllFeeds, updatingState, ETrue ); 
       
   793 			}
       
   794 		else
       
   795 			{
       
   796 			toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); 
       
   797 			toolbar->HideItem(EPodcastUpdateAllFeeds, ETrue, ETrue ); 
       
   798 			}
       
   799 
   715 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue );
   800 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue );
   716 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   801 		toolbar->HideItem(EPodcastDownloadAll, !iShowNewShows, ETrue);
   717 		TInt itemCnt = fItems.Count();
   802 		toolbar->HideItem(EPodcastMarkAllPlayed, !iShowNewShows, ETrue );
   718 	
   803 
   719 		TBool hideDownloadShowCmd = EFalse;
   804 		if (iShowNewShows) 
   720 		TBool dimDownloadShowCmd = EFalse;
   805 			{
   721 		TBool hideSetPlayed = EFalse;
   806 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
   722 	
   807 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
   723 		if(iListContainer->Listbox() != NULL)
   808 			toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue);
   724 		{
   809 			toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue );
   725 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
   810 			toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue );
   726 			
   811 			
   727 			if(index>= 0 && index < itemCnt)
   812 			TBool showDownloadAll = EFalse;
   728 			{
   813 			TInt count = iPodcastModel.ActiveShowList().Count();
   729 				switch(fItems[index]->DownloadState())
   814 			for (int i=0;i<count;i++)
       
   815 				{
       
   816 				CShowInfo* info = iPodcastModel.ActiveShowList()[i];
       
   817 				if (info->DownloadState() == ENotDownloaded)
   730 					{
   818 					{
   731 					case ENotDownloaded:
   819 					showDownloadAll = ETrue;
   732 					case EFailedDownload:
       
   733 						hideDownloadShowCmd = EFalse;
       
   734 						dimDownloadShowCmd = EFalse;
       
   735 						break;
       
   736 					case EQueued:
       
   737 					case EDownloading:
       
   738 						hideDownloadShowCmd = EFalse;
       
   739 						dimDownloadShowCmd = ETrue;
       
   740 						break;
       
   741 					case EDownloaded:
       
   742 						hideDownloadShowCmd = ETrue;
       
   743 						break;
       
   744 					}
   820 					}
       
   821 				}
       
   822 	
       
   823 			toolbar->SetItemDimmed(EPodcastMarkAllPlayed, !count, ETrue);
       
   824 			toolbar->SetItemDimmed(EPodcastDownloadAll, !showDownloadAll, ETrue);
       
   825 			}
       
   826 		else
       
   827 			{
       
   828 			RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
       
   829 			TInt itemCnt = fItems.Count();
       
   830 		
       
   831 			TBool hideDownloadShowCmd = EFalse;
       
   832 			TBool dimDownloadShowCmd = EFalse;
       
   833 			TBool hideSetPlayed = EFalse;
       
   834 		
       
   835 				if(iListContainer->Listbox() != NULL)
       
   836 				{
       
   837 					TInt index = iListContainer->Listbox()->CurrentItemIndex();
   745 					
   838 					
   746 				if(fItems[index]->PlayState() == EPlayed) {
   839 					if(index>= 0 && index < itemCnt)
   747 					hideSetPlayed = ETrue;
   840 					{
   748 				}
   841 						switch(fItems[index]->DownloadState())
   749 			}
   842 							{
   750 		}
   843 							case ENotDownloaded:
   751 		
   844 							case EFailedDownload:
   752 		if (hideDownloadShowCmd) {
   845 								hideDownloadShowCmd = EFalse;
   753 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
   846 								dimDownloadShowCmd = EFalse;
   754 			toolbar->HideItem(EPodcastDeleteShow, EFalse, ETrue);
   847 								break;
   755 			toolbar->SetItemDimmed(EPodcastDeleteShow, updatingState, ETrue);
   848 							case EQueued:
   756 		} else {
   849 							case EDownloading:
   757 			toolbar->HideItem(EPodcastDownloadShow, EFalse, ETrue );
   850 								hideDownloadShowCmd = EFalse;
   758 			toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue);
   851 								dimDownloadShowCmd = ETrue;
   759 			toolbar->SetItemDimmed(EPodcastDownloadShow, updatingState || dimDownloadShowCmd, ETrue);	
   852 								break;
   760 		}
   853 							case EDownloaded:
   761 		
   854 								hideDownloadShowCmd = ETrue;
   762 		if (hideSetPlayed) {
   855 								break;
   763 			toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue );
   856 							}
   764 			toolbar->HideItem(EPodcastMarkAsUnplayed, EFalse, ETrue );
   857 							
   765 			toolbar->SetItemDimmed(EPodcastMarkAsUnplayed, updatingState, ETrue);
   858 						if(fItems[index]->PlayState() == EPlayed) {
   766 		} else {
   859 							hideSetPlayed = ETrue;
   767 			toolbar->HideItem(EPodcastMarkAsPlayed, EFalse, ETrue );
   860 						}
   768 			toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue );
   861 					}
   769 			toolbar->SetItemDimmed(EPodcastMarkAsPlayed, updatingState, ETrue);
   862 				}		
   770 		}
   863 			
       
   864 			if (hideDownloadShowCmd) {
       
   865 				toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
       
   866 				toolbar->HideItem(EPodcastDeleteShow, EFalse, ETrue);
       
   867 				toolbar->SetItemDimmed(EPodcastDeleteShow, updatingState , ETrue);
       
   868 			} else {
       
   869 				toolbar->HideItem(EPodcastDownloadShow, EFalse, ETrue );
       
   870 				toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue);
       
   871 				toolbar->SetItemDimmed(EPodcastDownloadShow, updatingState || dimDownloadShowCmd || !itemCnt, ETrue);	
       
   872 			}
       
   873 			
       
   874 			if (hideSetPlayed) {
       
   875 				toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue );
       
   876 				toolbar->HideItem(EPodcastMarkAsUnplayed, EFalse, ETrue );
       
   877 				toolbar->SetItemDimmed(EPodcastMarkAsUnplayed, updatingState, ETrue);
       
   878 			} else {
       
   879 				toolbar->HideItem(EPodcastMarkAsPlayed, EFalse, ETrue );
       
   880 				toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue );
       
   881 				toolbar->SetItemDimmed(EPodcastMarkAsPlayed, updatingState|| !itemCnt, ETrue);
       
   882 			}
       
   883 		}		
   771 	}
   884 	}
   772 }
   885 }
   773 
   886 
   774 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
   887 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
   775 {
   888 {
   789 			CShowInfo *info = iPodcastModel.ActiveShowList()[index];
   902 			CShowInfo *info = iPodcastModel.ActiveShowList()[index];
   790 			TBool hideDownloadShowCmd = info->DownloadState() != ENotDownloaded;
   903 			TBool hideDownloadShowCmd = info->DownloadState() != ENotDownloaded;
   791 			TBool hideDeleteShowCmd = info->DownloadState() != EDownloaded;
   904 			TBool hideDeleteShowCmd = info->DownloadState() != EDownloaded;
   792 			TBool hideMarkOld = info->PlayState() == EPlayed;
   905 			TBool hideMarkOld = info->PlayState() == EPlayed;
   793 			
   906 			
   794 			iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsPlayed, hideMarkOld);
   907 			iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsPlayed, hideMarkOld || !iShowNewShows);
   795 			iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsUnplayed, !hideMarkOld);
   908 			iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsUnplayed, !hideMarkOld || !iShowNewShows);
   796 						
   909 						
   797 			iStylusPopupMenu->SetItemDimmed(EPodcastDownloadShow, hideDownloadShowCmd);
   910 			iStylusPopupMenu->SetItemDimmed(EPodcastDownloadShow, hideDownloadShowCmd);
   798 			iStylusPopupMenu->SetItemDimmed(EPodcastDeleteShow, hideDeleteShowCmd);
   911 			iStylusPopupMenu->SetItemDimmed(EPodcastDeleteShow, hideDeleteShowCmd);
   799 			}
   912 			}
   800 
   913 
   811 				
   924 				
   812 	if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
   925 	if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
   813 		{
   926 		{
   814 		CShowInfo *info = iPodcastModel.ActiveShowList()[index];
   927 		CShowInfo *info = iPodcastModel.ActiveShowList()[index];
   815 		info->SetPlayState(aPlayed ? EPlayed : ENeverPlayed);
   928 		info->SetPlayState(aPlayed ? EPlayed : ENeverPlayed);
   816 		iPodcastModel.ShowEngine().UpdateShowL(*info);
   929 		if (aPlayed)
   817 		UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0);
   930 			{
   818 		iListContainer->Listbox()->DrawItem(index);					
   931 			// PostPlayHandling calls UpdateShow, which is slow, so we don't need to do it again
       
   932 			iPodcastModel.ShowEngine().PostPlayHandling(info);
       
   933 			}
       
   934 		else
       
   935 			{
       
   936 			iPodcastModel.ShowEngine().UpdateShowL(*info);
       
   937 			}
       
   938 		
       
   939 		if (iShowNewShows)
       
   940 			{
       
   941 			UpdateListboxItemsL();
       
   942 
       
   943 			if (index > 0)
       
   944 				{
       
   945 				iListContainer->Listbox()->SetCurrentItemIndex(index - 1);
       
   946 				}
       
   947 			}
       
   948 		else
       
   949 			{
       
   950 			UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0);
       
   951 			iListContainer->Listbox()->DrawItem(index);	
       
   952 			}
   819 		}
   953 		}
   820 	}
   954 	}
   821 
   955 
   822 void CPodcastShowsView::HandleDeleteShowL()
   956 void CPodcastShowsView::HandleDeleteShowL()
   823 	{
   957 	{
   862 	{
   996 	{
   863 	DP("CPodcastShowsView::UpdateViewTitleL BEGIN");
   997 	DP("CPodcastShowsView::UpdateViewTitleL BEGIN");
   864 	 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
   998 	 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
   865 		      ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
   999 		      ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
   866 		 
  1000 		 
   867 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && 
  1001 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() &&
   868 				iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
  1002 				iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
   869 
  1003 
   870 		if (updatingState) {
  1004 		if (updatingState) {
   871 			SetEmptyTextL(R_PODCAST_EMPTY_LIST_UPDATING);		
  1005 			SetEmptyTextL(R_PODCAST_EMPTY_LIST_UPDATING);		
   872 		} else {
  1006 		} else {
   873 			SetEmptyTextL(R_PODCAST_EMPTY_LIST);
  1007 			SetEmptyTextL(R_PODCAST_EMPTY_LIST);
   874 		}
  1008 		}
   875 		
  1009 		
   876 		if(iPodcastModel.ActiveFeedInfo())
  1010 		if(iShowNewShows)
       
  1011 			{
       
  1012 			HBufC *title = iEikonEnv->AllocReadResourceLC(R_NEW_SHOWS);
       
  1013 			titlePane->SetTextL(*title);
       
  1014 			CleanupStack::PopAndDestroy(title);
       
  1015 			}
       
  1016 		else if(iPodcastModel.ActiveFeedInfo())
   877 			{
  1017 			{
   878 			if (iPodcastModel.ActiveFeedInfo()->Title() != KNullDesC)
  1018 			if (iPodcastModel.ActiveFeedInfo()->Title() != KNullDesC)
   879 				{
  1019 				{
   880 				titlePane->SetTextL( iPodcastModel.ActiveFeedInfo()->Title(), ETrue );
  1020 				titlePane->SetTextL( iPodcastModel.ActiveFeedInfo()->Title(), ETrue );
   881 				}
  1021 				}