From a71d319a95523d9fbc57ecd483dbf634350cc0e3 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Tue, 26 Jan 2016 17:14:55 +0100 Subject: [PVR] Timer window: Show error box if 'Add timer' is selected and PVR backend does not support timers (fixes trac#16539) --- xbmc/pvr/windows/GUIWindowPVRTimers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp index bd5ea749a3..8c7093e1a2 100644 --- a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp @@ -377,6 +377,12 @@ bool CGUIWindowPVRTimers::ActionDeleteTimer(CFileItem *item) bool CGUIWindowPVRTimers::ActionShowTimer(CFileItem *item) { + if (!g_PVRClients->SupportsTimers()) + { + CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19215}); // "Information", "The PVR backend does not support timers." + return false; + } + bool bReturn = false; /* Check if "Add timer..." entry is pressed by OK, if yes -- cgit v1.2.3 From e15ed4cf55e9715a761166902034d87f44badaee Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Tue, 26 Jan 2016 15:26:29 +0100 Subject: [PVR] Guide/Search/channel window: Do not add 'Record' if backend does not support timers. --- xbmc/pvr/addons/PVRClients.cpp | 14 ++++++++++++++ xbmc/pvr/addons/PVRClients.h | 6 ++++++ xbmc/pvr/windows/GUIWindowPVRChannels.cpp | 2 +- xbmc/pvr/windows/GUIWindowPVRGuide.cpp | 2 +- xbmc/pvr/windows/GUIWindowPVRSearch.cpp | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index 17e5e2c290..da39071205 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -1439,6 +1439,20 @@ bool CPVRClients::GetClient(const std::string &strId, AddonPtr &addon) const return false; } +bool CPVRClients::SupportsTimers() const +{ + PVR_CLIENTMAP clients; + GetConnectedClients(clients); + + for (const auto &entry : clients) + { + if (entry.second->SupportsTimers()) + return true; + } + + return false; +} + bool CPVRClients::SupportsChannelGroups(int iClientId) const { PVR_CLIENT client; diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h index 03f5da1b44..7bd9b3a4af 100644 --- a/xbmc/pvr/addons/PVRClients.h +++ b/xbmc/pvr/addons/PVRClients.h @@ -322,6 +322,12 @@ namespace PVR /*! @name Timer methods */ //@{ + /*! + * @brief Check whether there is at least one connected client supporting timers. + * @return True if at least one connected client supports timers, false otherwise. + */ + bool SupportsTimers() const; + /*! * @brief Check whether a client supports timers. * @param iClientId The id of the client to check. diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp index 5d89d1e4c1..29fdf29908 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp @@ -85,7 +85,7 @@ void CGUIWindowPVRChannels::GetContextButtons(int itemNumber, CContextButtons &b if (channel->IsRecording()) buttons.Add(CONTEXT_BUTTON_STOP_RECORD, 19059); /* Stop recording */ - else + else if (g_PVRClients->SupportsTimers(channel->ClientID())) buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* Record */ if (ActiveAE::CActiveAEDSP::GetInstance().IsProcessing()) diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index ad6e04b31d..baa75af4ca 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -101,7 +101,7 @@ void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_DELETE_TIMER, 19060); /* Delete timer */ } } - else if (epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) + else if (g_PVRClients->SupportsTimers() && epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) { buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* Record */ buttons.Add(CONTEXT_BUTTON_ADD_TIMER, 19061); /* Add timer */ diff --git a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp index d782025773..f0786f7b4a 100644 --- a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp @@ -67,7 +67,7 @@ void CGUIWindowPVRSearch::GetContextButtons(int itemNumber, CContextButtons &but buttons.Add(CONTEXT_BUTTON_DELETE_TIMER, 19060); /* Delete timer */ } } - else if (epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) + else if (g_PVRClients->SupportsTimers() && epg->EndAsLocalTime() > CDateTime::GetCurrentDateTime()) { buttons.Add(CONTEXT_BUTTON_START_RECORD, 264); /* Record */ buttons.Add(CONTEXT_BUTTON_ADD_TIMER, 19061); /* Add timer */ -- cgit v1.2.3