From 3b6d91df046dfa503ee0154ed2a5b9308e445b79 Mon Sep 17 00:00:00 2001 From: Martin Vallevand Date: Thu, 25 Apr 2024 13:03:43 -0400 Subject: [PATCH] Control access to recordings and timers Provide options to access Live TV only (no recording or timer access) or to disable timers only. --- pvr.nextpvr/addon.xml.in | 2 +- pvr.nextpvr/changelog.txt | 3 + pvr.nextpvr/resources/instance-settings.xml | 67 ++++++++++++------- .../resource.language.en_gb/strings.po | 45 ++++++++++++- src/InstanceSettings.cpp | 8 ++- src/InstanceSettings.h | 1 + src/pvrclient-nextpvr.cpp | 46 +++++++------ 7 files changed, 124 insertions(+), 48 deletions(-) diff --git a/pvr.nextpvr/addon.xml.in b/pvr.nextpvr/addon.xml.in index 74eab79c..e2325f69 100644 --- a/pvr.nextpvr/addon.xml.in +++ b/pvr.nextpvr/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.nextpvr/changelog.txt b/pvr.nextpvr/changelog.txt index 056fbc10..1d596095 100644 --- a/pvr.nextpvr/changelog.txt +++ b/pvr.nextpvr/changelog.txt @@ -1,3 +1,6 @@ +v21.0.4 +- Allow control of recording and timers access + v21.0.3 - Translations updates from Weblate - de_de, es_es, fi_fi, it_it, ru_ru diff --git a/pvr.nextpvr/resources/instance-settings.xml b/pvr.nextpvr/resources/instance-settings.xml index d6607a73..5814e3f2 100644 --- a/pvr.nextpvr/resources/instance-settings.xml +++ b/pvr.nextpvr/resources/instance-settings.xml @@ -82,9 +82,9 @@ 2 - - - + + + @@ -203,6 +203,13 @@ false + + 1 + false + + + + 2 false @@ -228,9 +235,9 @@ Default - - - + + + false @@ -238,13 +245,6 @@ 30198 - - 1 - false - - - - 2 true @@ -279,6 +279,21 @@ false + + 3 + 3 + + + + + + + + + + 30709 + + 0 true @@ -292,19 +307,19 @@ - 2 - 0 - - - - - - - - - - 32009 - + 2 + 0 + + + + + + + + + + 32009 + diff --git a/pvr.nextpvr/resources/language/resource.language.en_gb/strings.po b/pvr.nextpvr/resources/language/resource.language.en_gb/strings.po index 00f543e8..02049f21 100644 --- a/pvr.nextpvr/resources/language/resource.language.en_gb/strings.po +++ b/pvr.nextpvr/resources/language/resource.language.en_gb/strings.po @@ -394,7 +394,50 @@ msgctxt "#30707" msgid "Interval to check for backend changes made outside this Kodi client" msgstr "" - msgctxt "#30208" msgid "Every 5 minutes" msgstr "" + +msgctxt "#30209" +msgid "Recording and timer control" +msgstr "" + +msgctxt "#30709" +msgid "Manage user rights for recordings and timers" +msgstr "" + +msgctxt "#30210" +msgid "Real Time" +msgstr "" + +msgctxt "#30211" +msgid "Timeshift" +msgstr "" + +msgctxt "#30212" +msgid "Transcoded" +msgstr "" + +msgctxt "#30213" +msgid "Spann" +msgstr "" + +msgctxt "#30214" +msgid "Full access to recordings and timers" +msgstr "" + +msgctxt "#30215" +msgid "Play and delete recordings with no timers" +msgstr "" + +msgctxt "#30216" +msgid "Play recordings with no timers" +msgstr "" + +msgctxt "#30217" +msgid "Live TV only" +msgstr "" + +msgctxt "#30218" +msgid "Repeating (all episodes)" +msgstr "" diff --git a/src/InstanceSettings.cpp b/src/InstanceSettings.cpp index 7e36ddf1..377db6d3 100644 --- a/src/InstanceSettings.cpp +++ b/src/InstanceSettings.cpp @@ -79,7 +79,9 @@ void InstanceSettings::ReadFromAddon() m_ignorePadding = ReadBoolSetting("ignorepadding", true); - m_resolution = ReadStringSetting("resolution", "720"); + m_resolution = ReadStringSetting("resolution", "720"); + + m_accessLevel = ReadIntSetting("accesscontrol", 3); m_showRadio = ReadBoolSetting("showradio", true); @@ -134,6 +136,8 @@ void InstanceSettings::ReadFromAddon() else if (m_heartbeat == eHeartbeat::None) m_heartbeatInterval = std::numeric_limits::max(); + if (m_accessLevel == 3) + m_heartbeatInterval = std::numeric_limits::max(); /* Log the current settings for debugging purposes */ kodi::Log(ADDON_LOG_DEBUG, "settings: host='%s', port=%i, instance=%d, mac=%4.4s...", m_hostname.c_str(), m_port, m_instanceNumber, m_hostMACAddress.c_str()); @@ -295,6 +299,8 @@ ADDON_STATUS InstanceSettings::SetValue(const std::string& settingName, const ko return SetStringSetting(settingName, settingValue, m_PIN, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK); else if (settingName == "remoteaccess") return SetSetting(settingName, settingValue, m_remoteAccess, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK); + else if (settingName == "accesscontrol") + return SetSetting(settingName, settingValue, m_accessLevel, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK); else if (settingName == "showradio") return SetSetting(settingName, settingValue, m_showRadio, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK); else if (settingName == "backendresume") diff --git a/src/InstanceSettings.h b/src/InstanceSettings.h index 035c535e..3c97c52e 100644 --- a/src/InstanceSettings.h +++ b/src/InstanceSettings.h @@ -84,6 +84,7 @@ namespace NextPVR enum eHeartbeat m_heartbeat; time_t m_heartbeatInterval; bool m_instancePriority = true; + int m_accessLevel = 3; //Channel bool m_showRadio = true; diff --git a/src/pvrclient-nextpvr.cpp b/src/pvrclient-nextpvr.cpp index 6165a9e0..054b4b07 100644 --- a/src/pvrclient-nextpvr.cpp +++ b/src/pvrclient-nextpvr.cpp @@ -337,7 +337,7 @@ bool cPVRClientNextPVR::IsUp() // trigger EPG updates for all channels with a guide source kodi::Log(ADDON_LOG_DEBUG, "Trigger EPG update start"); int channels = 0; - for (const auto &updateChannel : m_channels.m_channelDetails) + for (const auto& updateChannel : m_channels.m_channelDetails) { if (updateChannel.second.first == false) { @@ -352,27 +352,35 @@ bool cPVRClientNextPVR::IsUp() return m_bConnected; } } - if (update_time <= m_timers.m_lastTimerUpdateTime + 1) + if (m_settings->m_accessLevel > 0) { - // we already updated this one in Kodi - m_lastRecordingUpdateTime = time(nullptr); - return m_bConnected; - } - if (m_request.GetLastUpdate("recording.lastupdated&ignore_resume=true", lastUpdate) == tinyxml2::XML_SUCCESS) - { - if (lastUpdate <= m_timers.m_lastTimerUpdateTime) + if (update_time <= m_timers.m_lastTimerUpdateTime + 1) { - if (m_settings->m_backendResume) + // we already updated this one in Kodi + m_lastRecordingUpdateTime = time(nullptr); + return m_bConnected; + } + if (m_request.GetLastUpdate("recording.lastupdated&ignore_resume=true", lastUpdate) == tinyxml2::XML_SUCCESS) + { + if (lastUpdate <= m_timers.m_lastTimerUpdateTime) { - // only resume position changed - m_recordings.GetRecordingsLastPlayedPosition(); - m_lastRecordingUpdateTime = update_time; + if (m_settings->m_backendResume) + { + // only resume position changed + m_recordings.GetRecordingsLastPlayedPosition(); + m_lastRecordingUpdateTime = update_time; + } + return m_bConnected; } - return m_bConnected; } + TriggerRecordingUpdate(); + if (m_settings->m_accessLevel == 3) + TriggerTimerUpdate(); + } + else + { + m_lastRecordingUpdateTime = time(nullptr); } - TriggerRecordingUpdate(); - TriggerTimerUpdate(); } else { @@ -1020,11 +1028,11 @@ PVR_ERROR cPVRClientNextPVR::GetCapabilities(kodi::addon::PVRCapabilities& capab kodi::Log(ADDON_LOG_DEBUG, "->GetCapabilities()"); capabilities.SetSupportsEPG(true); - capabilities.SetSupportsRecordings(true); - capabilities.SetSupportsRecordingsDelete(true); + capabilities.SetSupportsRecordings(m_settings->m_accessLevel > 0); + capabilities.SetSupportsRecordingsDelete(m_settings->m_accessLevel > 1); capabilities.SetSupportsRecordingsUndelete(false); capabilities.SetSupportsRecordingSize(m_settings->m_showRecordingSize); - capabilities.SetSupportsTimers(true); + capabilities.SetSupportsTimers(m_settings->m_accessLevel == 3); capabilities.SetSupportsTV(true); capabilities.SetSupportsRadio(m_settings->m_showRadio); capabilities.SetSupportsChannelGroups(true);