diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2017-02-11 21:39:08 +0100 |
---|---|---|
committer | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2017-02-16 22:19:22 +0100 |
commit | a23d810bc9bf3211678087d547d93eebd1b32449 (patch) | |
tree | 0b8ee73cb3b953f1bc5ebc9d1aa6ecb98eb49254 | |
parent | a2a844f46469a2a7c0ed878d0c73766524726519 (diff) |
[PVR] Move 'enter parental pin' from pvr manager and pvr timers to gui actions.
-rw-r--r-- | addons/resource.language.en_gb/resources/strings.po | 19 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/VideoPlayer.cpp | 3 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/PVROperations.cpp | 4 | ||||
-rw-r--r-- | xbmc/pvr/PVRActionListener.cpp | 4 | ||||
-rw-r--r-- | xbmc/pvr/PVRGUIActions.cpp | 73 | ||||
-rw-r--r-- | xbmc/pvr/PVRGUIActions.h | 19 | ||||
-rw-r--r-- | xbmc/pvr/PVRManager.cpp | 34 | ||||
-rw-r--r-- | xbmc/pvr/PVRManager.h | 13 | ||||
-rw-r--r-- | xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp | 3 | ||||
-rw-r--r-- | xbmc/pvr/timers/PVRTimers.cpp | 18 | ||||
-rw-r--r-- | xbmc/pvr/timers/PVRTimers.h | 10 | ||||
-rw-r--r-- | xbmc/settings/SettingConditions.cpp | 4 |
12 files changed, 107 insertions, 97 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index c9369f446a..9c962eee84 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -9120,7 +9120,6 @@ msgstr "" #: xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp #: xbmc/pvr/recordings/PVRRecording.cpp #: xbmc/pvr/timers/PVRTimerInfoTag.cpp -#: xbmc/pvr/timers/PVRTimers.cpp #: xbmc/pvr/windows/GUIWindowPVRTimersBase.cpp #: xbmc/pvr/PVRGUIActions.cpp #: xbmc/pvr/PVRManager.cpp @@ -9593,7 +9592,7 @@ msgstr "" #. message box text stating that a timer could not be saved #: xbmc/pvr/timers/PVRTimerInfoTag.cpp -#: xbmc/pvr/timers/PVRTimers.cpp +#: xbmc/pvr/PVRGUIActions.cpp msgctxt "#19109" msgid "Couldn't save timer. Check the log for more information about this message." msgstr "" @@ -10211,7 +10210,7 @@ msgid "Enter a valid URL for the new channel" msgstr "" #. message box text stating that a pvr backend does not support timers -#: xbmc/pvr/timers/PVRTimers.cpp +#: xbmc/pvr/timers/PVRGUIActions.cpp #: xbmc/pvr/windows/GUIWindowsPVRTimersBase.cpp msgctxt "#19215" msgid "The PVR backend does not support timers." @@ -10485,27 +10484,21 @@ msgid "Change PIN" msgstr "" #. generic 'parental control enter pin' label -#: xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp -#: xbmc/pvr/PVRManager.cpp -#: xbmc/settings/SettingConditions.cpp +#: xbmc/pvr/PVRGUIActions.cpp msgctxt "#19262" msgid "Parental control. Enter PIN:" msgstr "" -#. label for 'parental control pin' verification dialog -#: xbmc/pvr/PVRManager.cpp -msgctxt "#19263" -msgid "Locked channel. Enter PIN:" -msgstr "" +# empty string with id 19263 #. label for 'incorrect pin' error dialog header -#: xbmc/pvr/PVRManager.cpp +#: xbmc/pvr/PVRGUIActions.cpp msgctxt "#19264" msgid "Incorrect PIN" msgstr "" #. label for 'incorrect pin' error dialog text -#: xbmc/pvr/PVRManager.cpp +#: xbmc/pvr/PVRGUIActions.cpp msgctxt "#19265" msgid "The entered PIN was incorrect." msgstr "" diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index 131139a285..2e1c637486 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -5089,9 +5089,6 @@ bool CVideoPlayer::SwitchChannel(const CPVRChannelPtr &channel) if (g_PVRManager.IsPlayingChannel(channel)) return false; // desired channel already active, nothing to do. - if (!g_PVRManager.CheckParentalLock(channel)) - return false; - /* set GUI info */ if (!g_PVRManager.PerformChannelSwitch(channel, true)) return false; diff --git a/xbmc/interfaces/json-rpc/PVROperations.cpp b/xbmc/interfaces/json-rpc/PVROperations.cpp index 50b9e0551f..707d586655 100644 --- a/xbmc/interfaces/json-rpc/PVROperations.cpp +++ b/xbmc/interfaces/json-rpc/PVROperations.cpp @@ -344,7 +344,7 @@ JSONRPC_STATUS CPVROperations::AddTimer(const std::string &method, ITransportLay CPVRTimerInfoTagPtr newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag, parameterObject["timerrule"].asBoolean(false)); if (newTimer) { - if (g_PVRTimers->AddTimer(newTimer)) + if (CPVRGUIActions::GetInstance().AddTimer(newTimer)) return ACK; } return FailedToExecute; @@ -397,7 +397,7 @@ JSONRPC_STATUS CPVROperations::ToggleTimer(const std::string &method, ITransport if (!timer) return InvalidParams; - sentOkay = g_PVRTimers->AddTimer(timer); + sentOkay = CPVRGUIActions::GetInstance().AddTimer(timer); } if (sentOkay) diff --git a/xbmc/pvr/PVRActionListener.cpp b/xbmc/pvr/PVRActionListener.cpp index f8663b078f..002d1175a2 100644 --- a/xbmc/pvr/PVRActionListener.cpp +++ b/xbmc/pvr/PVRActionListener.cpp @@ -59,7 +59,7 @@ void CPVRActionListener::Init() void CPVRActionListener::Deinit() { CServiceBroker::GetSettings().UnregisterCallback(this); -} +} bool CPVRActionListener::OnAction(const CAction &action) { @@ -202,5 +202,5 @@ void CPVRActionListener::OnSettingAction(const CSetting *setting) g_PVRClients->SetEPGTimeFrame(static_cast<const CSettingInt*>(setting)->GetValue()); } } - + } // namespace PVR diff --git a/xbmc/pvr/PVRGUIActions.cpp b/xbmc/pvr/PVRGUIActions.cpp index 0ec9aa987b..230d32dda1 100644 --- a/xbmc/pvr/PVRGUIActions.cpp +++ b/xbmc/pvr/PVRGUIActions.cpp @@ -20,6 +20,7 @@ #include "Application.h" #include "dialogs/GUIDialogKaiToast.h" +#include "dialogs/GUIDialogNumeric.h" #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogProgress.h" #include "dialogs/GUIDialogSelect.h" @@ -75,7 +76,7 @@ namespace PVR bool CPVRGUIActions::ShowEPGInfo(const CFileItemPtr &item) const { const CPVRChannelPtr channel(CPVRItem(item).GetChannel()); - if (channel && !g_PVRManager.CheckParentalLock(channel)) + if (channel && !CheckParentalLock(channel)) return false; const CEpgInfoTagPtr epgTag(CPVRItem(item).GetEpgInfoTag()); @@ -158,7 +159,7 @@ namespace PVR if (ShowTimerSettings(newTimer)) { /* Add timer to backend */ - return g_PVRTimers->AddTimer(newTimer); + return AddTimer(newTimer); } return false; } @@ -182,7 +183,7 @@ namespace PVR return false; } - if (!g_PVRManager.CheckParentalLock(channel)) + if (!CheckParentalLock(channel)) return false; const CEpgInfoTagPtr epgTag(CPVRItem(item).GetEpgInfoTag()); @@ -216,7 +217,28 @@ namespace PVR return false; } - return g_PVRTimers->AddTimer(newTimer); + return AddTimer(newTimer); + } + + bool CPVRGUIActions::AddTimer(const CPVRTimerInfoTagPtr &item) const + { + if (!item->m_channel && item->GetTimerType() && !item->GetTimerType()->IsEpgBasedTimerRule()) + { + CLog::Log(LOGERROR, "CPVRGUIActions - %s - no channel given", __FUNCTION__); + CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19109}); // "Information", "Couldn't save timer. Check the log for more information about this message." + return false; + } + + if (!g_PVRClients->SupportsTimers(item->m_iClientId)) + { + CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19215}); // "Information", "The PVR backend does not support timers." + return false; + } + + if (!CheckParentalLock(item->m_channel)) + return false; + + return g_PVRTimers->AddTimer(item); } namespace @@ -335,7 +357,7 @@ namespace PVR if (!channel) return bReturn; - if (!g_PVRManager.CheckParentalLock(channel)) + if (!CheckParentalLock(channel)) return bReturn; if (g_PVRClients->HasTimerSupport(channel->ClientID())) @@ -516,11 +538,11 @@ namespace PVR // end up with one timer missing wrt to the rule defined by the new timer. if (g_PVRTimers->DeleteTimer(timer, timer->IsRecording(), false)) { - if (g_PVRTimers->AddTimer(newTimer)) + if (AddTimer(newTimer)) return true; // rollback. - return g_PVRTimers->AddTimer(timer); + return AddTimer(timer); } } } @@ -917,7 +939,7 @@ namespace PVR // switch to channel or if recording present, ask whether to switch or play recording... bool bSwitchSuccessful(false); - if (channel && g_PVRManager.CheckParentalLock(channel)) + if (channel && CheckParentalLock(channel)) { const CPVRRecordingPtr recording(channel->GetRecording()); if (recording) @@ -1306,7 +1328,7 @@ namespace PVR } else { - if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262)) || // "Parental control. Enter PIN:" + if (!CheckParentalPIN() || !CGUIDialogYesNo::ShowAndGetInput(CVariant{19098}, // "Warning!" CVariant{19186})) // "All your TV related data (channels, groups, guide) will be cleared. Are you sure?" return false; @@ -1396,6 +1418,39 @@ namespace PVR return true; } + bool CPVRGUIActions::CheckParentalLock(const CPVRChannelPtr &channel) const + { + bool bReturn = !g_PVRManager.IsParentalLocked(channel) || CheckParentalPIN(); + + if (!bReturn) + CLog::Log(LOGERROR, "CPVRGUIActions - %s - parental lock verification failed for channel '%s': wrong PIN entered.", __FUNCTION__, channel->ChannelName().c_str()); + + return bReturn; + } + + bool CPVRGUIActions::CheckParentalPIN() const + { + std::string pinCode = CServiceBroker::GetSettings().GetString(CSettings::SETTING_PVRPARENTAL_PIN); + + if (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPARENTAL_ENABLED) || pinCode.empty()) + return true; + + // Locked channel. Enter PIN: + bool bValidPIN = CGUIDialogNumeric::ShowAndVerifyInput(pinCode, g_localizeStrings.Get(19262), true); // "Parental control. Enter PIN:" + if (!bValidPIN) + { + // display message: The entered PIN number was incorrect + CGUIDialogOK::ShowAndGetInput(CVariant{19264}, CVariant{19265}); // "Incorrect PIN", "The entered PIN was incorrect." + } + else + { + // restart the parental timer + g_PVRManager.RestartParentalTimer(); + } + + return bValidPIN; + } + CPVRChannelNumberInputHandler &CPVRGUIActions::GetChannelNumberInputHandler() { // window/dialog specific input handler diff --git a/xbmc/pvr/PVRGUIActions.h b/xbmc/pvr/PVRGUIActions.h index 1f852136ae..43ff28eba0 100644 --- a/xbmc/pvr/PVRGUIActions.h +++ b/xbmc/pvr/PVRGUIActions.h @@ -98,6 +98,12 @@ namespace PVR bool AddTimer(const CFileItemPtr &item, bool bShowTimerSettings) const; /*! + * @brief Add a timer to the client. Doesn't add the timer to the container. The backend will do this. + * @return True if it was sent correctly, false if not. + */ + bool AddTimer(const CPVRTimerInfoTagPtr &item) const; + + /*! * @brief Create a new timer rule, either interactive or non-interactive. * @param item containing epg data to create a timer rule for. item must be an epg tag or a channel. * @param bShowTimerSettings is used to control whether a settings dialog will be opened prior creating the timer rule. @@ -287,6 +293,19 @@ namespace PVR bool ResetPVRDatabase(bool bResetEPGOnly); /*! + * @brief Check if channel is parental locked. Ask for PIN if necessary. + * @param channel The channel to do the check for. + * @return True if channel is unlocked (by default or PIN unlocked), false otherwise. + */ + bool CheckParentalLock(const CPVRChannelPtr &channel) const; + + /*! + * @brief Open Numeric dialog to check for parental PIN. + * @return True if entered PIN was correct, false otherwise. + */ + bool CheckParentalPIN() const; + + /*! * @brief Get the currently active channel number input handler. * @return the handler. */ diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 5f1bd195a9..7795c50f73 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -26,8 +26,6 @@ #include "Application.h" #include "dialogs/GUIDialogExtendedProgressBar.h" #include "dialogs/GUIDialogKaiToast.h" -#include "dialogs/GUIDialogNumeric.h" -#include "dialogs/GUIDialogOK.h" #include "epg/EpgContainer.h" #include "GUIInfoManager.h" #include "guilib/GUIWindowManager.h" @@ -760,15 +758,10 @@ void CPVRManager::StartRecordingOnPlayingChannel(bool bOnOff) CJobManager::GetInstance().AddJob(new CPVRSetRecordingOnChannelJob(m_addons->GetPlayingChannel(), bOnOff), NULL); } -bool CPVRManager::CheckParentalLock(const CPVRChannelPtr &channel) +void CPVRManager::RestartParentalTimer() { - bool bReturn = !IsParentalLocked(channel) || - CheckParentalPIN(); - - if (!bReturn) - CLog::Log(LOGERROR, "PVRManager - %s - parental lock verification failed for channel '%s': wrong PIN entered.", __FUNCTION__, channel->ChannelName().c_str()); - - return bReturn; + if (m_parentalTimer) + m_parentalTimer->StartZero(); } bool CPVRManager::IsParentalLocked(const CPVRChannelPtr &channel) @@ -794,27 +787,6 @@ bool CPVRManager::IsParentalLocked(const CPVRChannelPtr &channel) return bReturn; } -bool CPVRManager::CheckParentalPIN(const std::string& strTitle /* = "" */) -{ - std::string pinCode = CServiceBroker::GetSettings().GetString(CSettings::SETTING_PVRPARENTAL_PIN); - - if (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPARENTAL_ENABLED) || pinCode.empty()) - return true; - - // Locked channel. Enter PIN: - bool bValidPIN = CGUIDialogNumeric::ShowAndVerifyInput(pinCode, !strTitle.empty() ? strTitle : g_localizeStrings.Get(19263), true); - if (!bValidPIN) - // display message: The entered PIN number was incorrect - CGUIDialogOK::ShowAndGetInput(CVariant{19264}, CVariant{19265}); - else if (m_parentalTimer) - { - // reset the timer - m_parentalTimer->StartZero(); - } - - return bValidPIN; -} - void CPVRManager::SetPlayingGroup(const CPVRChannelGroupPtr &group) { if (m_channelGroups && group) diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index faf4f6cd80..b6f8461fa7 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -479,13 +479,6 @@ namespace PVR void SearchMissingChannelIcons(void); /*! - * @brief Check if channel is parental locked. Ask for PIN if necessary. - * @param channel The channel to open. - * @return True if channel is unlocked (by default or PIN unlocked), false otherwise. - */ - bool CheckParentalLock(const CPVRChannelPtr &channel); - - /*! * @brief Check if parental lock is overridden at the given moment. * @param channel The channel to open. * @return True if parental lock is overridden, false otherwise. @@ -493,11 +486,9 @@ namespace PVR bool IsParentalLocked(const CPVRChannelPtr &channel); /*! - * @brief Open Numeric dialog to check for parental PIN. - * @param strTitle Override the title of the dialog if set. - * @return True if entered PIN was correct, false otherwise. + * @brief Restart the parantal timer. */ - bool CheckParentalPIN(const std::string& strTitle = ""); + void RestartParentalTimer(); /*! * @brief Executes "pvrpowermanagement.setwakeupcmd" diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp index e8598956b3..ff0066926a 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp @@ -36,6 +36,7 @@ #include "utils/StringUtils.h" #include "utils/Variant.h" +#include "pvr/PVRGUIActions.h" #include "pvr/PVRManager.h" #include "pvr/addons/PVRClients.h" #include "pvr/channels/PVRChannelGroupsContainer.h" @@ -291,7 +292,7 @@ bool CGUIDialogPVRChannelManager::OnClickButtonRadioParentalLocked(CGUIMessage & bool selected(msg.GetParam1() == 1); // ask for PIN first - if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str())) + if (!CPVRGUIActions::GetInstance().CheckParentalPIN()) { // failed - reset to previous SET_CONTROL_SELECTED(GetID(), RADIOBUTTON_PARENTAL_LOCK, !selected); return false; diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 6b3cc4d9ac..d45039396f 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -26,7 +26,6 @@ #include "ServiceBroker.h" #include "dialogs/GUIDialogKaiToast.h" -#include "dialogs/GUIDialogOK.h" #include "epg/EpgContainer.h" #include "events/EventLog.h" #include "events/NotificationEvent.h" @@ -39,7 +38,6 @@ #include "utils/log.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" -#include "utils/Variant.h" using namespace PVR; using namespace EPG; @@ -677,22 +675,6 @@ bool CPVRTimers::DeleteTimersOnChannel(const CPVRChannelPtr &channel, bool bDele bool CPVRTimers::AddTimer(const CPVRTimerInfoTagPtr &item) { - if (!item->m_channel && item->GetTimerType() && !item->GetTimerType()->IsEpgBasedTimerRule()) - { - CLog::Log(LOGERROR, "PVRTimers - %s - no channel given", __FUNCTION__); - CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19109}); // Couldn't save timer - return false; - } - - if (!g_PVRClients->SupportsTimers(item->m_iClientId)) - { - CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19215}); - return false; - } - - if (!g_PVRManager.CheckParentalLock(item->m_channel)) - return false; - return item->AddToClient(); } diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h index 5519f6f541..0ffa7aa747 100644 --- a/xbmc/pvr/timers/PVRTimers.h +++ b/xbmc/pvr/timers/PVRTimers.h @@ -183,26 +183,26 @@ namespace PVR /*! * @brief Add a timer to the client. Doesn't add the timer to the container. The backend will do this. - * @return True if it was sent correctly, false if not. + * @return True if timer add request was sent correctly, false if not. */ - static bool AddTimer(const CPVRTimerInfoTagPtr &item); + static bool AddTimer(const CPVRTimerInfoTagPtr &item); /*! * @brief Delete a timer on the client. Doesn't delete the timer from the container. The backend will do this. * @param bDeleteRule Also delete the timer rule that scheduled the timer instead of single timer only. - * @return True if it was sent correctly, false if not. + * @return True if timer delete request was sent correctly, false if not. */ static bool DeleteTimer(const CPVRTimerInfoTagPtr &tag, bool bForce = false, bool bDeleteRule = false); /*! * @brief Rename a timer on the client. Doesn't update the timer in the container. The backend will do this. - * @return True if it was sent correctly, false if not. + * @return True if timer rename request was sent correctly, false if not. */ static bool RenameTimer(CFileItem &item, const std::string &strNewName); /*! * @brief Update the timer on the client. Doesn't update the timer in the container. The backend will do this. - * @return True if it was sent correctly, false if not. + * @return True if timer update request was sent correctly, false if not. */ static bool UpdateTimer(const CPVRTimerInfoTagPtr &item); diff --git a/xbmc/settings/SettingConditions.cpp b/xbmc/settings/SettingConditions.cpp index 6b1f2b6d75..4abfb5c43d 100644 --- a/xbmc/settings/SettingConditions.cpp +++ b/xbmc/settings/SettingConditions.cpp @@ -34,7 +34,7 @@ #include "peripherals/Peripherals.h" #include "peripherals/bus/virtual/PeripheralBusAddon.h" #include "profiles/ProfilesManager.h" -#include "pvr/PVRManager.h" +#include "pvr/PVRGUIActions.h" #include "settings/SettingAddon.h" #if defined(HAS_LIBAMCODEC) #include "utils/AMLUtils.h" @@ -72,7 +72,7 @@ bool CheckMasterLock(const std::string &condition, const std::string &value, con bool CheckPVRParentalPin(const std::string &condition, const std::string &value, const CSetting *setting, void *data) { - return PVR::g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()); + return PVR::CPVRGUIActions::GetInstance().CheckParentalPIN(); } bool HasPeripherals(const std::string &condition, const std::string &value, const CSetting *setting, void *data) |