application/src/PodcastFeedView.cpp
branchsymbian1
changeset 41 56821195bd44
parent 36 e010fc411ddc
child 37 1644b7cd063e
child 45 56d4e0784e5d
equal deleted inserted replaced
40:bf37b9711f0a 41:56821195bd44
   267 			{
   267 			{
   268 			if(aState == MFeedEngineObserver::EFeedManualUpdate)
   268 			if(aState == MFeedEngineObserver::EFeedManualUpdate)
   269 				{
   269 				{
   270 				TBuf<KMaxMessageLength> message;
   270 				TBuf<KMaxMessageLength> message;
   271 				iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   271 				iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   272 				ShowErrorMessage(message);
   272 				ShowErrorMessageL(message);
   273 				}
   273 				}
   274 			}
   274 			}
   275 			break;
   275 			break;
   276 		default: // Do nothing
   276 		default: // Do nothing
   277 			break;
   277 			break;
   550 			
   550 			
   551 			if (queueCount > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
   551 			if (queueCount > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
   552 				{
   552 				{
   553 				TBuf<KMaxMessageLength> message;
   553 				TBuf<KMaxMessageLength> message;
   554 				iEikonEnv->ReadResourceL(message, R_EXIT_SHOWS_DOWNLOADING);
   554 				iEikonEnv->ReadResourceL(message, R_EXIT_SHOWS_DOWNLOADING);
   555 				if(ShowQueryMessage(message))
   555 				if(ShowQueryMessageL(message))
   556 					{
   556 					{
   557 					// pass it on to AppUi, which will exit for us
   557 					// pass it on to AppUi, which will exit for us
   558 					CPodcastListView::HandleCommandL(aCommand);
   558 					CPodcastListView::HandleCommandL(aCommand);
   559 					}
   559 					}
   560 				} 
   560 				} 
   568 		default:
   568 		default:
   569 			CPodcastListView::HandleCommandL(aCommand);
   569 			CPodcastListView::HandleCommandL(aCommand);
   570 			break;
   570 			break;
   571 		}
   571 		}
   572 	
   572 	
   573 	iListContainer->SetLongTapDetected(EFalse); // in case we got here by long tapping
   573 	iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping
   574 	UpdateToolbar();
   574 	UpdateToolbar();
   575 	}
   575 	}
   576 
   576 
   577 void CPodcastFeedView::UpdateToolbar(TBool aVisible)
   577 void CPodcastFeedView::UpdateToolbar(TBool aVisible)
   578 {
   578 {
   629 				UpdateListboxItemsL();
   629 				UpdateListboxItemsL();
   630 				
   630 				
   631 				// ask if users wants to update it now
   631 				// ask if users wants to update it now
   632 				TBuf<KMaxMessageLength> message;
   632 				TBuf<KMaxMessageLength> message;
   633 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
   633 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
   634 				if(ShowQueryMessage(message))
   634 				if(ShowQueryMessageL(message))
   635 					{
   635 					{
   636 					CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid());
   636 					CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid());
   637 					
   637 					
   638 					iPodcastModel.ActiveShowList().Reset();
   638 					iPodcastModel.ActiveShowList().Reset();
   639 					iPodcastModel.SetActiveFeedInfo(info);			
   639 					iPodcastModel.SetActiveFeedInfo(info);			
   643 				}
   643 				}
   644 			else
   644 			else
   645 				{
   645 				{
   646 				TBuf<KMaxMessageLength> message;
   646 				TBuf<KMaxMessageLength> message;
   647 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
   647 				iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
   648 				ShowErrorMessage(message);
   648 				ShowErrorMessageL(message);
   649 				}		
   649 				}		
   650 			
   650 			
   651 			CleanupStack::PopAndDestroy(newFeedInfo);
   651 			CleanupStack::PopAndDestroy(newFeedInfo);
   652 			}
   652 			}
   653 		}
   653 		}
   674 				{
   674 				{
   675 				TBuf<KMaxMessageLength> dlgMessage;
   675 				TBuf<KMaxMessageLength> dlgMessage;
   676 				iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE);
   676 				iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE);
   677 
   677 
   678 				// Ask the user if it is OK to remove all shows
   678 				// Ask the user if it is OK to remove all shows
   679 				if ( ShowQueryMessage(dlgMessage))
   679 				if ( ShowQueryMessageL(dlgMessage))
   680 					{
   680 					{
   681 					PodcastUtils::FixProtocolsL(url);
   681 					PodcastUtils::FixProtocolsL(url);
   682 					
   682 					
   683 					//----- HACK ---- //
   683 					//----- HACK ---- //
   684 					CFeedInfo* temp = CFeedInfo::NewLC();
   684 					CFeedInfo* temp = CFeedInfo::NewLC();
   701 						UpdateListboxItemsL();
   701 						UpdateListboxItemsL();
   702 					} else {
   702 					} else {
   703 						// the feed existed. Object deleted in AddFeed.	
   703 						// the feed existed. Object deleted in AddFeed.	
   704 						TBuf<KMaxMessageLength> dlgMessage;
   704 						TBuf<KMaxMessageLength> dlgMessage;
   705 						iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS);
   705 						iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS);
   706 						ShowErrorMessage(dlgMessage);
   706 						ShowErrorMessageL(dlgMessage);
   707 					}
   707 					}
   708 					CleanupStack::PopAndDestroy(temp);
   708 					CleanupStack::PopAndDestroy(temp);
   709 				}
   709 				}
   710 			} else { // no url change, maybe title?
   710 			} else { // no url change, maybe title?
   711 				// Update the title
   711 				// Update the title
   712 				if (info->Title().Compare(title) != 0)
   712 				if (info->Title().Compare(title) != 0)
   713 				{
   713 				{
   714 					info->SetTitleL(title);
   714 					info->SetTitleL(title);
   715 					info->SetCustomTitle();	
   715 					info->SetCustomTitle();	
   716 					iPodcastModel.FeedEngine().UpdateFeed(info);
   716 					iPodcastModel.FeedEngine().UpdateFeedL(info);
   717 					UpdateListboxItemsL();
   717 					UpdateListboxItemsL();
   718 				}
   718 				}
   719 			}
   719 			}
   720 		}
   720 		}
   721 		}
   721 		}
   732 			CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]);
   732 			CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]);
   733 			TBuf<KMaxMessageLength> templ;
   733 			TBuf<KMaxMessageLength> templ;
   734 			TBuf<KMaxMessageLength> message;
   734 			TBuf<KMaxMessageLength> message;
   735 			iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT);
   735 			iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT);
   736 			message.Format(templ, &info->Title());					
   736 			message.Format(templ, &info->Title());					
   737 			if(ShowQueryMessage(message))
   737 			if(ShowQueryMessageL(message))
   738 				{
   738 				{
   739 				iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]);
   739 				iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]);
   740 				iItemArray->Delete(index);
   740 				iItemArray->Delete(index);
   741 				iItemIdArray.Remove(index);
   741 				iItemIdArray.Remove(index);
   742 				iListContainer->Listbox()->HandleItemRemovalL();
   742 				iListContainer->Listbox()->HandleItemRemovalL();
   796 				TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName));
   796 				TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName));
   797 									
   797 									
   798 				if (err != KErrNone) {
   798 				if (err != KErrNone) {
   799 					TBuf<KMaxMessageLength> message;
   799 					TBuf<KMaxMessageLength> message;
   800 					iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   800 					iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   801 					ShowErrorMessage(message);
   801 					ShowErrorMessageL(message);
   802 					}
   802 					}
   803 				}
   803 				}
   804 				
   804 				
   805 			}
   805 			}
   806 		CleanupStack::PopAndDestroy(dlg);
   806 		CleanupStack::PopAndDestroy(dlg);
   852 									
   852 									
   853 					TBuf<KMaxMessageLength> message;
   853 					TBuf<KMaxMessageLength> message;
   854 					TBuf<KMaxMessageLength> templ;
   854 					TBuf<KMaxMessageLength> templ;
   855 					iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   855 					iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   856 					message.Format(templ, numFeeds);
   856 					message.Format(templ, numFeeds);
   857 					ShowOkMessage(message);
   857 					ShowOkMessageL(message);
   858 					} 
   858 					} 
   859 				else 
   859 				else 
   860 					{
   860 					{
   861 					TBuf<KMaxMessageLength> message;
   861 					TBuf<KMaxMessageLength> message;
   862 					iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   862 					iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   863 					ShowErrorMessage(message);
   863 					ShowErrorMessageL(message);
   864 					}
   864 					}
   865 				}
   865 				}
   866 			CleanupStack::PopAndDestroy(fileDlg);
   866 			CleanupStack::PopAndDestroy(fileDlg);
   867 			}
   867 			}
   868 		CleanupStack::PopAndDestroy(dlg);
   868 		CleanupStack::PopAndDestroy(dlg);
   869 	}
   869 	}
   870 	CleanupStack::PopAndDestroy(memDlg);									
   870 	CleanupStack::PopAndDestroy(memDlg);									
   871 	}
   871 	}
   872 
   872 
   873 void CPodcastFeedView::CheckResumeDownload()
   873 void CPodcastFeedView::CheckResumeDownloadL()
   874 	{
   874 	{
   875 	// if there are shows queued for downloading, ask if we should resume now
   875 	// if there are shows queued for downloading, ask if we should resume now
   876 	RShowInfoArray showsDownloading;
   876 	RShowInfoArray showsDownloading;
   877 	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
   877 	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
   878 
   878 
   879 	if (showsDownloading.Count() > 0)
   879 	if (showsDownloading.Count() > 0)
   880 		{
   880 		{
   881 		TBuf<KMaxMessageLength> msg;
   881 		TBuf<KMaxMessageLength> msg;
   882 		iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT);
   882 		iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT);
   883 	
   883 	
   884 		if (ShowQueryMessage(msg))
   884 		if (ShowQueryMessageL(msg))
   885 			{
   885 			{
   886 			// need to suspend downloads before ResumeDownloadL will work :)
   886 			// need to suspend downloads before ResumeDownloadL will work :)
   887 			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
   887 			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
   888 			// resume downloading if user says yes
   888 			// resume downloading if user says yes
   889 			iPodcastModel.ShowEngine().ResumeDownloadsL();
   889 			iPodcastModel.ShowEngine().ResumeDownloadsL();
   907 		{
   907 		{
   908 		case KErrCouldNotConnect:
   908 		case KErrCouldNotConnect:
   909 			{
   909 			{
   910 			TBuf<KMaxMessageLength> message;
   910 			TBuf<KMaxMessageLength> message;
   911 			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   911 			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
   912 			ShowErrorMessage(message);
   912 			ShowErrorMessageL(message);
   913 			}
   913 			}
   914 			break;
   914 			break;
   915 		case KErrNone: 
   915 		case KErrNone: 
   916 		default:			// we don't do more error handling here, just show 0 imported feeds
   916 		default:			// we don't do more error handling here, just show 0 imported feeds
   917 		switch (iOpmlState)
   917 		switch (iOpmlState)
   927 				TBuf<KMaxMessageLength> message;
   927 				TBuf<KMaxMessageLength> message;
   928 				TBuf<KMaxMessageLength> templ;
   928 				TBuf<KMaxMessageLength> templ;
   929 				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
   929 				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
   930 				message.Format(templ, aNumFeedsImported);
   930 				message.Format(templ, aNumFeedsImported);
   931 				
   931 				
   932 				if(ShowQueryMessage(message))
   932 				if(ShowQueryMessageL(message))
   933 					{
   933 					{
   934 					HandleCommandL(EPodcastUpdateAllFeeds);
   934 					HandleCommandL(EPodcastUpdateAllFeeds);
   935 					}
   935 					}
   936 				}
   936 				}
   937 				break;
   937 				break;
   938 			case EOpmlSearching:
   938 			case EOpmlSearching:
   939 				delete iWaitDialog;
   939 				delete iWaitDialog;
       
   940 				iWaitDialog = NULL;
   940 				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
   941 				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
   941 					{
   942 					{
   942 					TBuf<KMaxMessageLength> message;
   943 					TBuf<KMaxMessageLength> message;
   943 					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
   944 					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
   944 					ShowErrorMessage(message);
   945 					ShowErrorMessageL(message);
   945 					}
   946 					}
   946 				else
   947 				else
   947 					{
   948 					{
   948 					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
   949 					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
   949 					}
   950 					}
   973 
   974 
   974 	if (iUpdatingAllRunning) {
   975 	if (iUpdatingAllRunning) {
   975 		return; // we don't allow feed manipulation while update is running
   976 		return; // we don't allow feed manipulation while update is running
   976 	}
   977 	}
   977 
   978 
   978 	iListContainer->SetLongTapDetected(ETrue);
   979 	iListContainer->SetLongTapDetectedL(ETrue);
   979 
   980 
   980 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
   981 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
   981 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
   982 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
   982 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
   983 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
   983 
   984