application/src/PodcastShowsView.cpp
branchnewlist
changeset 350 9c4fd008e20f
parent 348 bd7f3de17443
child 352 31f9864a37ac
equal deleted inserted replaced
349:4538abb763e4 350:9c4fd008e20f
    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);
   372 	}
   412 	}
   373 
   413 
   374 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
   414 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
   375 	{
   415 	{
   376 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
   416 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
   377 
   417 	TBool isNew = aShowInfo->PlayState() == ENeverPlayed;
       
   418 	DP1("downloadstate=%d", aShowInfo->DownloadState());
   378 	switch (aShowInfo->DownloadState())
   419 	switch (aShowInfo->DownloadState())
   379 		{
   420 		{
   380 		case EDownloaded:
   421 		case EDownloaded:
   381 			if (aShowInfo->PlayState() == ENeverPlayed) {
   422 			aIconIndex = isNew ? EDownloadedShowIconNew : EDownloadedShowIcon;
   382 				aIconIndex = EDownloadedNewShowIcon;
       
   383 			} else {
       
   384 				aIconIndex = EDownloadedShowIcon;
       
   385 			}
       
   386 			break;
   423 			break;
   387 		case ENotDownloaded:
   424 		case ENotDownloaded:
   388 			if (aShowInfo->PlayState() == ENeverPlayed) {
   425 			aIconIndex = isNew ? EShowIconNew : EShowIcon;
   389 				aIconIndex = ENewShowIcon;
       
   390 			} else {
       
   391 				aIconIndex = EShowIcon;
       
   392 			}
       
   393 			break;
   426 			break;
   394 		case EQueued:
   427 		case EQueued:
   395 			aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
   428 			aIconIndex = dlStop ? (isNew ? ESuspendedShowIconNew : ESuspendedShowIcon) : 
       
   429 								  (isNew ? EQuedShowIconNew : EQuedShowIcon);
   396 			break;
   430 			break;
   397 		case EDownloading:
   431 		case EDownloading:
   398 			aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
   432 			aIconIndex = dlStop ? (isNew ? ESuspendedShowIconNew : ESuspendedShowIcon) : 
       
   433 								  (isNew ? EDownloadingShowIconNew : EDownloadingShowIcon);	
   399 			break;
   434 			break;
   400 		case EFailedDownload:
   435 		case EFailedDownload:
   401 			aIconIndex = EFailedShowIcon;
   436 			aIconIndex = dlStop ? (isNew ? ESuspendedShowIconNew : ESuspendedShowIcon) : 
       
   437 								  (isNew ? EFailedShowIconNew : EFailedShowIconNew);
   402 			break;
   438 			break;
   403 		}
   439 		}
   404 	
   440 	
   405 	if (aShowInfo->ShowType() == EVideoPodcast)
   441 	if (aShowInfo->ShowType() == EVideoPodcast)
   406 		{
   442 		{
   407 		aIconIndex += KVideoIconOffset;
   443 		aIconIndex += KVideoIconOffset;
   408 		}
   444 		}
       
   445 	
       
   446 	DP3("dlStop=%d, isNew=%d, aIconIndex=%d", dlStop, isNew, aIconIndex);
   409 	}
   447 	}
   410 	
   448 	
   411 
   449 
   412 void CPodcastShowsView::UpdateFeedUpdateStateL()
   450 void CPodcastShowsView::UpdateFeedUpdateStateL()
   413 	{
   451 	{
   621 			UpdateListboxItemsL();
   659 			UpdateListboxItemsL();
   622 			break;
   660 			break;
   623 		case EPodcastDeleteShow:
   661 		case EPodcastDeleteShow:
   624 			HandleDeleteShowL();
   662 			HandleDeleteShowL();
   625 			break;
   663 			break;
       
   664 		case EPodcastDownloadAll:
       
   665 			HandleDownloadAllL();
       
   666 			break;
   626 		case EPodcastDownloadShow:
   667 		case EPodcastDownloadShow:
   627 			{
   668 			{
   628 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
   669 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
   629 			
   670 			
   630 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
   671 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
   710 		note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack
   751 		note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack
   711 		note->RunLD();
   752 		note->RunLD();
   712 		}
   753 		}
   713 	}
   754 	}
   714 
   755 
       
   756 void CPodcastShowsView::HandleDownloadAllL()
       
   757 	{
       
   758 	
       
   759 	TBuf<KMaxMessageLength> msg;
       
   760 	iEikonEnv->ReadResourceL(msg, R_DOWNLOAD_ALL_QUERY);
       
   761 	if (!ShowQueryMessageL(msg))
       
   762 		{
       
   763 		return;
       
   764 		}
       
   765 		
       
   766 	for (int i=0;i<iPodcastModel.ActiveShowList().Count();i++)
       
   767 		{
       
   768 		CShowInfo* info = iPodcastModel.ActiveShowList()[i];
       
   769 
       
   770 		if (info->DownloadState() == ENotDownloaded)
       
   771 			{
       
   772 			TRAP_IGNORE(iPodcastModel.ShowEngine().AddDownloadL(*info));
       
   773 			}
       
   774 		}
       
   775 	}
       
   776 
   715 void CPodcastShowsView::UpdateToolbar(TBool aVisible)
   777 void CPodcastShowsView::UpdateToolbar(TBool aVisible)
   716 {
   778 {
   717 	CAknToolbar* toolbar = Toolbar();
   779 	CAknToolbar* toolbar = Toolbar();
   718 
   780 
   719 	if (toolbar) {
   781 	if (toolbar) {
   735 			toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); 
   797 			toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); 
   736 			toolbar->HideItem(EPodcastUpdateAllFeeds, ETrue, ETrue ); 
   798 			toolbar->HideItem(EPodcastUpdateAllFeeds, ETrue, ETrue ); 
   737 			}
   799 			}
   738 
   800 
   739 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue );
   801 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue );
   740 
   802 		toolbar->HideItem(EPodcastDownloadAll, !iShowNewShows, ETrue);
       
   803 
       
   804 		if (iShowNewShows) 
       
   805 			{
       
   806 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
       
   807 			
       
   808 			TBool showDownloadAll = EFalse;
       
   809 			for (int i=0;i<iPodcastModel.ActiveShowList().Count();i++)
       
   810 				{
       
   811 				CShowInfo* info = iPodcastModel.ActiveShowList()[i];
       
   812 				if (info->DownloadState() == ENotDownloaded)
       
   813 					{
       
   814 					showDownloadAll = ETrue;
       
   815 					}
       
   816 				}
       
   817 	
       
   818 			toolbar->SetItemDimmed(EPodcastDownloadAll, !showDownloadAll, ETrue);
       
   819 			}
       
   820 		
   741 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   821 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   742 		TInt itemCnt = fItems.Count();
   822 		TInt itemCnt = fItems.Count();
   743 	
   823 	
   744 		TBool hideDownloadShowCmd = EFalse;
   824 		TBool hideDownloadShowCmd = EFalse;
   745 		TBool dimDownloadShowCmd = EFalse;
   825 		TBool dimDownloadShowCmd = EFalse;
   746 		TBool hideSetPlayed = EFalse;
   826 		TBool hideSetPlayed = EFalse;
   747 	
   827 	
   748 		if(iListContainer->Listbox() != NULL)
   828 			if(iListContainer->Listbox() != NULL)
   749 		{
   829 			{
   750 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
   830 				TInt index = iListContainer->Listbox()->CurrentItemIndex();
   751 			
   831 				
   752 			if(index>= 0 && index < itemCnt)
   832 				if(index>= 0 && index < itemCnt)
   753 			{
   833 				{
   754 				switch(fItems[index]->DownloadState())
   834 					switch(fItems[index]->DownloadState())
   755 					{
   835 						{
   756 					case ENotDownloaded:
   836 						case ENotDownloaded:
   757 					case EFailedDownload:
   837 						case EFailedDownload:
   758 						hideDownloadShowCmd = EFalse;
   838 							hideDownloadShowCmd = EFalse;
   759 						dimDownloadShowCmd = EFalse;
   839 							dimDownloadShowCmd = EFalse;
   760 						break;
   840 							break;
   761 					case EQueued:
   841 						case EQueued:
   762 					case EDownloading:
   842 						case EDownloading:
   763 						hideDownloadShowCmd = EFalse;
   843 							hideDownloadShowCmd = EFalse;
   764 						dimDownloadShowCmd = ETrue;
   844 							dimDownloadShowCmd = ETrue;
   765 						break;
   845 							break;
   766 					case EDownloaded:
   846 						case EDownloaded:
   767 						hideDownloadShowCmd = ETrue;
   847 							hideDownloadShowCmd = ETrue;
   768 						break;
   848 							break;
       
   849 						}
       
   850 						
       
   851 					if(fItems[index]->PlayState() == EPlayed) {
       
   852 						hideSetPlayed = ETrue;
   769 					}
   853 					}
   770 					
       
   771 				if(fItems[index]->PlayState() == EPlayed) {
       
   772 					hideSetPlayed = ETrue;
       
   773 				}
   854 				}
   774 			}
   855 			}		
   775 		}
       
   776 		
   856 		
   777 		if (hideDownloadShowCmd) {
   857 		if (hideDownloadShowCmd) {
   778 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
   858 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
   779 			toolbar->HideItem(EPodcastDeleteShow, EFalse, ETrue);
   859 			toolbar->HideItem(EPodcastDeleteShow, EFalse, ETrue);
   780 			toolbar->SetItemDimmed(EPodcastDeleteShow, updatingState, ETrue);
   860 			toolbar->SetItemDimmed(EPodcastDeleteShow, updatingState , ETrue);
   781 		} else {
   861 		} else {
   782 			toolbar->HideItem(EPodcastDownloadShow, EFalse, ETrue );
   862 			toolbar->HideItem(EPodcastDownloadShow, EFalse, ETrue );
   783 			toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue);
   863 			toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue);
   784 			toolbar->SetItemDimmed(EPodcastDownloadShow, updatingState || dimDownloadShowCmd, ETrue);	
   864 			toolbar->SetItemDimmed(EPodcastDownloadShow, updatingState || dimDownloadShowCmd || !itemCnt, ETrue);	
   785 		}
   865 		}
   786 		
   866 		
   787 		if (hideSetPlayed) {
   867 		if (hideSetPlayed) {
   788 			toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue );
   868 			toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue );
   789 			toolbar->HideItem(EPodcastMarkAsUnplayed, EFalse, ETrue );
   869 			toolbar->HideItem(EPodcastMarkAsUnplayed, EFalse, ETrue );
   790 			toolbar->SetItemDimmed(EPodcastMarkAsUnplayed, updatingState, ETrue);
   870 			toolbar->SetItemDimmed(EPodcastMarkAsUnplayed, updatingState, ETrue);
   791 		} else {
   871 		} else {
   792 			toolbar->HideItem(EPodcastMarkAsPlayed, EFalse, ETrue );
   872 			toolbar->HideItem(EPodcastMarkAsPlayed, EFalse, ETrue );
   793 			toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue );
   873 			toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue );
   794 			toolbar->SetItemDimmed(EPodcastMarkAsPlayed, updatingState, ETrue);
   874 			toolbar->SetItemDimmed(EPodcastMarkAsPlayed, updatingState|| !itemCnt, ETrue);
   795 		}
   875 		}
   796 	}
   876 	}
   797 }
   877 }
   798 
   878 
   799 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
   879 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)