application/src/PodcastFeedView.cpp
changeset 66 41d00e97e2f7
parent 63 a8538f50e2ba
child 69 04c6ccce8e7e
equal deleted inserted replaced
65:523e04129df6 66:41d00e97e2f7
   173 void CPodcastFeedView::DoActivateL(const TVwsViewId& aPrevViewId,
   173 void CPodcastFeedView::DoActivateL(const TVwsViewId& aPrevViewId,
   174 	                                  TUid aCustomMessageId,
   174 	                                  TUid aCustomMessageId,
   175 	                                  const TDesC8& aCustomMessage)
   175 	                                  const TDesC8& aCustomMessage)
   176 	{
   176 	{
   177 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   177 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   178 
   178 	
   179 	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
   179 	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
   180 		{
   180 		{
   181 		// back key from shows view
   181 		// back key from shows view
   182 		iViewingShows = EFalse;
   182 		iViewingShows = EFalse;
   183 		}
   183 		}
   184 	
   184 	
   185 	if (iViewingShows)
       
   186 		{
       
   187 		// go to shows view
       
   188 		AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID,  TUid::Uid(0), KNullDesC8());
       
   189 		} 
       
   190 	else 
       
   191 		{
       
   192 		UpdateListboxItemsL();		
   185 		UpdateListboxItemsL();		
   193 		UpdateToolbar();
   186 		UpdateToolbar();
   194 
   187 
   195 		if (iFirstActivateAfterLaunch)
   188 	if (iFirstActivateAfterLaunch)
   196 			{
   189 		{
   197 			iFirstActivateAfterLaunch = EFalse;
   190 		iFirstActivateAfterLaunch = EFalse;
   198 			}
       
   199 		}
   191 		}
   200 	}
   192 	}
   201 
   193 
   202 void CPodcastFeedView::DoDeactivate()
   194 void CPodcastFeedView::DoDeactivate()
   203 	{
   195 	{
   214 		{
   206 		{
   215 		case EEventPenDownOnItem:
   207 		case EEventPenDownOnItem:
   216 			DP("PEN DOWN");
   208 			DP("PEN DOWN");
   217 			break;
   209 			break;
   218 			
   210 			
   219 //#ifndef SYMBIAN1_UI
   211 #ifndef SYMBIAN1_UI
   220 	case EEventItemClicked:
   212 	case EEventItemClicked:
   221 		DP("SINGLE TAP");
   213 #endif
   222 		break;
       
   223 //#endif
       
   224 	case EEventEnterKeyPressed:
   214 	case EEventEnterKeyPressed:
   225 	case EEventItemDoubleClicked:
   215 	case EEventItemDoubleClicked:
   226 	case EEventItemActioned:
   216 	case EEventItemActioned:
   227 		DP("DOUBLE TAP");
   217 		DP("DOUBLE TAP");
   228 			{
   218 			{
   267 			{
   257 			{
   268 			if(aState == MFeedEngineObserver::EFeedManualUpdate)
   258 			if(aState == MFeedEngineObserver::EFeedManualUpdate)
   269 				{
   259 				{
   270 				TBuf<KMaxMessageLength> message;
   260 				TBuf<KMaxMessageLength> message;
   271 				iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   261 				iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   272 				ShowErrorMessage(message);
   262 				ShowErrorMessageL(message);
   273 				}
   263 				}
   274 			}
   264 			}
   275 			break;
   265 			break;
   276 		default: // Do nothing
   266 		default: // Do nothing
   277 			break;
   267 			break;
   543 			
   533 			
   544 			if (queueCount > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
   534 			if (queueCount > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
   545 				{
   535 				{
   546 				TBuf<KMaxMessageLength> message;
   536 				TBuf<KMaxMessageLength> message;
   547 				iEikonEnv->ReadResourceL(message, R_EXIT_SHOWS_DOWNLOADING);
   537 				iEikonEnv->ReadResourceL(message, R_EXIT_SHOWS_DOWNLOADING);
   548 				if(ShowQueryMessage(message))
   538 				if(ShowQueryMessageL(message))
   549 					{
   539 					{
   550 					// pass it on to AppUi, which will exit for us
   540 					// pass it on to AppUi, which will exit for us
   551 					CPodcastListView::HandleCommandL(aCommand);
   541 					CPodcastListView::HandleCommandL(aCommand);
   552 					}
   542 					}
   553 				} 
   543 				} 
   561 		default:
   551 		default:
   562 			CPodcastListView::HandleCommandL(aCommand);
   552 			CPodcastListView::HandleCommandL(aCommand);
   563 			break;
   553 			break;
   564 		}
   554 		}
   565 	
   555 	
   566 	iListContainer->SetLongTapDetected(EFalse); // in case we got here by long tapping
   556 	iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping
   567 	UpdateToolbar();
   557 	UpdateToolbar();
   568 	}
   558 	}
   569 
   559 
   570 void CPodcastFeedView::UpdateToolbar(TBool aVisible)
   560 void CPodcastFeedView::UpdateToolbar(TBool aVisible)
   571 {
   561 {
   622 				UpdateListboxItemsL();
   612 				UpdateListboxItemsL();
   623 				
   613 				
   624 				// ask if users wants to update it now
   614 				// ask if users wants to update it now
   625 				TBuf<KMaxMessageLength> message;
   615 				TBuf<KMaxMessageLength> message;
   626 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
   616 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
   627 				if(ShowQueryMessage(message))
   617 				if(ShowQueryMessageL(message))
   628 					{
   618 					{
   629 					CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid());
   619 					CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid());
   630 					
   620 					
   631 					iPodcastModel.ActiveShowList().Reset();
   621 					iPodcastModel.ActiveShowList().Reset();
   632 					iPodcastModel.SetActiveFeedInfo(info);			
   622 					iPodcastModel.SetActiveFeedInfo(info);			
   636 				}
   626 				}
   637 			else
   627 			else
   638 				{
   628 				{
   639 				TBuf<KMaxMessageLength> message;
   629 				TBuf<KMaxMessageLength> message;
   640 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
   630 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
   641 				ShowErrorMessage(message);
   631 				ShowErrorMessageL(message);
   642 				}		
   632 				}		
   643 			
   633 			
   644 			CleanupStack::PopAndDestroy(newFeedInfo);
   634 			CleanupStack::PopAndDestroy(newFeedInfo);
   645 			}
   635 			}
   646 		}
   636 		}
   667 				{
   657 				{
   668 				TBuf<KMaxMessageLength> dlgMessage;
   658 				TBuf<KMaxMessageLength> dlgMessage;
   669 				iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE);
   659 				iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE);
   670 
   660 
   671 				// Ask the user if it is OK to remove all shows
   661 				// Ask the user if it is OK to remove all shows
   672 				if ( ShowQueryMessage(dlgMessage))
   662 				if ( ShowQueryMessageL(dlgMessage))
   673 					{
   663 					{
   674 					PodcastUtils::FixProtocolsL(url);
   664 					PodcastUtils::FixProtocolsL(url);
   675 					
   665 					
   676 					//----- HACK ---- //
   666 					//----- HACK ---- //
   677 					CFeedInfo* temp = CFeedInfo::NewLC();
   667 					CFeedInfo* temp = CFeedInfo::NewLC();
   694 						UpdateListboxItemsL();
   684 						UpdateListboxItemsL();
   695 					} else {
   685 					} else {
   696 						// the feed existed. Object deleted in AddFeed.	
   686 						// the feed existed. Object deleted in AddFeed.	
   697 						TBuf<KMaxMessageLength> dlgMessage;
   687 						TBuf<KMaxMessageLength> dlgMessage;
   698 						iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS);
   688 						iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS);
   699 						ShowErrorMessage(dlgMessage);
   689 						ShowErrorMessageL(dlgMessage);
   700 					}
   690 					}
   701 					CleanupStack::PopAndDestroy(temp);
   691 					CleanupStack::PopAndDestroy(temp);
   702 				}
   692 				}
   703 			} else { // no url change, maybe title?
   693 			} else { // no url change, maybe title?
   704 				// Update the title
   694 				// Update the title
   705 				if (info->Title().Compare(title) != 0)
   695 				if (info->Title().Compare(title) != 0)
   706 				{
   696 				{
   707 					info->SetTitleL(title);
   697 					info->SetTitleL(title);
   708 					info->SetCustomTitle();	
   698 					info->SetCustomTitle();	
   709 					iPodcastModel.FeedEngine().UpdateFeed(info);
   699 					iPodcastModel.FeedEngine().UpdateFeedL(info);
   710 					UpdateListboxItemsL();
   700 					UpdateListboxItemsL();
   711 				}
   701 				}
   712 			}
   702 			}
   713 		}
   703 		}
   714 		}
   704 		}
   725 			CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]);
   715 			CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]);
   726 			TBuf<KMaxMessageLength> templ;
   716 			TBuf<KMaxMessageLength> templ;
   727 			TBuf<KMaxMessageLength> message;
   717 			TBuf<KMaxMessageLength> message;
   728 			iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT);
   718 			iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT);
   729 			message.Format(templ, &info->Title());					
   719 			message.Format(templ, &info->Title());					
   730 			if(ShowQueryMessage(message))
   720 			if(ShowQueryMessageL(message))
   731 				{
   721 				{
   732 				iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]);
   722 				iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]);
   733 				iItemArray->Delete(index);
   723 				iItemArray->Delete(index);
   734 				iItemIdArray.Remove(index);
   724 				iItemIdArray.Remove(index);
   735 				iListContainer->Listbox()->HandleItemRemovalL();
   725 				iListContainer->Listbox()->HandleItemRemovalL();
   789 				TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName));
   779 				TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName));
   790 									
   780 									
   791 				if (err != KErrNone) {
   781 				if (err != KErrNone) {
   792 					TBuf<KMaxMessageLength> message;
   782 					TBuf<KMaxMessageLength> message;
   793 					iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   783 					iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   794 					ShowErrorMessage(message);
   784 					ShowErrorMessageL(message);
   795 					}
   785 					}
   796 				}
   786 				}
   797 				
   787 				
   798 			}
   788 			}
   799 		CleanupStack::PopAndDestroy(dlg);
   789 		CleanupStack::PopAndDestroy(dlg);
   845 									
   835 									
   846 					TBuf<KMaxMessageLength> message;
   836 					TBuf<KMaxMessageLength> message;
   847 					TBuf<KMaxMessageLength> templ;
   837 					TBuf<KMaxMessageLength> templ;
   848 					iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   838 					iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   849 					message.Format(templ, numFeeds);
   839 					message.Format(templ, numFeeds);
   850 					ShowOkMessage(message);
   840 					ShowOkMessageL(message);
   851 					} 
   841 					} 
   852 				else 
   842 				else 
   853 					{
   843 					{
   854 					TBuf<KMaxMessageLength> message;
   844 					TBuf<KMaxMessageLength> message;
   855 					iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   845 					iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   856 					ShowErrorMessage(message);
   846 					ShowErrorMessageL(message);
   857 					}
   847 					}
   858 				}
   848 				}
   859 			CleanupStack::PopAndDestroy(fileDlg);
   849 			CleanupStack::PopAndDestroy(fileDlg);
   860 			}
   850 			}
   861 		CleanupStack::PopAndDestroy(dlg);
   851 		CleanupStack::PopAndDestroy(dlg);
   862 	}
   852 	}
   863 	CleanupStack::PopAndDestroy(memDlg);									
   853 	CleanupStack::PopAndDestroy(memDlg);									
   864 	}
   854 	}
   865 
   855 
   866 void CPodcastFeedView::CheckResumeDownload()
   856 void CPodcastFeedView::CheckResumeDownloadL()
   867 	{
   857 	{
   868 	// if there are shows queued for downloading, ask if we should resume now
   858 	// if there are shows queued for downloading, ask if we should resume now
   869 	RShowInfoArray showsDownloading;
   859 	RShowInfoArray showsDownloading;
   870 	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
   860 	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
   871 
   861 
   872 	if (showsDownloading.Count() > 0)
   862 	if (showsDownloading.Count() > 0)
   873 		{
   863 		{
   874 		TBuf<KMaxMessageLength> msg;
   864 		TBuf<KMaxMessageLength> msg;
   875 		iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT);
   865 		iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT);
   876 	
   866 	
   877 		if (ShowQueryMessage(msg))
   867 		if (ShowQueryMessageL(msg))
   878 			{
   868 			{
   879 			// need to suspend downloads before ResumeDownloadL will work :)
   869 			// need to suspend downloads before ResumeDownloadL will work :)
   880 			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
   870 			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
   881 			// resume downloading if user says yes
   871 			// resume downloading if user says yes
   882 			iPodcastModel.ShowEngine().ResumeDownloadsL();
   872 			iPodcastModel.ShowEngine().ResumeDownloadsL();
   900 		{
   890 		{
   901 		case KErrCouldNotConnect:
   891 		case KErrCouldNotConnect:
   902 			{
   892 			{
   903 			TBuf<KMaxMessageLength> message;
   893 			TBuf<KMaxMessageLength> message;
   904 			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   894 			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   905 			ShowErrorMessage(message);
   895 			ShowErrorMessageL(message);
   906 			}
   896 			}
   907 			break;
   897 			break;
   908 		case KErrNone: 
   898 		case KErrNone: 
   909 		default:			// we don't do more error handling here, just show 0 imported feeds
   899 		default:			// we don't do more error handling here, just show 0 imported feeds
   910 		switch (iOpmlState)
   900 		switch (iOpmlState)
   920 				TBuf<KMaxMessageLength> message;
   910 				TBuf<KMaxMessageLength> message;
   921 				TBuf<KMaxMessageLength> templ;
   911 				TBuf<KMaxMessageLength> templ;
   922 				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
   912 				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
   923 				message.Format(templ, aNumFeedsImported);
   913 				message.Format(templ, aNumFeedsImported);
   924 				
   914 				
   925 				if(ShowQueryMessage(message))
   915 				if(ShowQueryMessageL(message))
   926 					{
   916 					{
   927 					HandleCommandL(EPodcastUpdateAllFeeds);
   917 					HandleCommandL(EPodcastUpdateAllFeeds);
   928 					}
   918 					}
   929 				}
   919 				}
   930 				break;
   920 				break;
   931 			case EOpmlSearching:
   921 			case EOpmlSearching:
   932 				delete iWaitDialog;
   922 				delete iWaitDialog;
       
   923 				iWaitDialog = NULL;
   933 				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
   924 				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
   934 					{
   925 					{
   935 					TBuf<KMaxMessageLength> message;
   926 					TBuf<KMaxMessageLength> message;
   936 					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
   927 					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
   937 					ShowErrorMessage(message);
   928 					ShowErrorMessageL(message);
   938 					}
   929 					}
   939 				else
   930 				else
   940 					{
   931 					{
   941 					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
   932 					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
   942 					}
   933 					}
   966 
   957 
   967 	if (iUpdatingAllRunning) {
   958 	if (iUpdatingAllRunning) {
   968 		return; // we don't allow feed manipulation while update is running
   959 		return; // we don't allow feed manipulation while update is running
   969 	}
   960 	}
   970 
   961 
   971 	iListContainer->SetLongTapDetected(ETrue);
   962 	iListContainer->SetLongTapDetectedL(ETrue);
   972 
   963 
   973 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
   964 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
   974 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
   965 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
   975 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
   966 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
   976 
   967 
   979 		iStylusPopupMenu->ShowMenu();
   970 		iStylusPopupMenu->ShowMenu();
   980 		iStylusPopupMenu->SetPosition(aPenEventLocation);
   971 		iStylusPopupMenu->SetPosition(aPenEventLocation);
   981     }
   972     }
   982 	DP("CPodcastListView::HandleLongTapEventL END");
   973 	DP("CPodcastListView::HandleLongTapEventL END");
   983 }
   974 }
       
   975 
       
   976 TBool CPodcastFeedView::ViewingShows()
       
   977 	{
       
   978 	return iViewingShows;
       
   979 	}