Skip to content

Commit

Permalink
Control access to recordings and timers
Browse files Browse the repository at this point in the history
Provide options to access Live TV only (no recording or timer access) or to disable timers only.
  • Loading branch information
emveepee committed Apr 26, 2024
1 parent c66afa5 commit 48e1b09
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 48 deletions.
2 changes: 1 addition & 1 deletion pvr.nextpvr/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.nextpvr"
version="21.0.3"
version="21.1.0"
name="NextPVR PVR Client"
provider-name="Graeme Blackley">
<requires>@ADDON_DEPENDS@
Expand Down
3 changes: 3 additions & 0 deletions pvr.nextpvr/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
67 changes: 41 additions & 26 deletions pvr.nextpvr/resources/instance-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
<default>2</default>
<constraints>
<options>
<option label="Real Time">2</option>
<option label="Timeshift">4</option>
<option label="Transcoded">3</option>
<option label="30210">2</option>
<option label="30211">4</option>
<option label="30212">3</option>
</options>
</constraints>
<control format="string" type="spinner"/>
Expand Down Expand Up @@ -203,6 +203,13 @@
<default>false</default>
<control type="toggle"/>
</setting>
<setting help="30694" id="genrestring" label="30194" type="boolean">
<level>1</level>
<default>false</default>
<control type="toggle"/>
</setting>
</group>
<group id="13">
<setting help="30680" id="flattenrecording" label="30180" type="boolean">
<level>2</level>
<default>false</default>
Expand All @@ -228,23 +235,16 @@
<default>Default</default>
<constraints>
<options>
<option>No</option>
<option>Default</option>
<option>Span</option>
<option label="106">No</option>
<option label="571">Default</option>
<option label="30213">Span</option>
</options>
<allowempty>false</allowempty>
</constraints>
<control type="list" format="string">
<heading>30198</heading>
</control>
</setting>
<setting help="30694" id="genrestring" label="30194" type="boolean">
<level>1</level>
<default>false</default>
<control type="toggle"/>
</setting>
</group>
<group id="13">
<setting help="30699" id="ignorepadding" label="30199" type="boolean">
<level>2</level>
<default>true</default>
Expand Down Expand Up @@ -279,6 +279,21 @@
<default>false</default>
<control type="toggle"/>
</setting>
<setting id="accesscontrol" type="integer" label="30209" help="30709">
<level>3</level>
<default>3</default>
<constraints>
<options>
<option label="30214">3</option>
<option label="30215">2</option>
<option label="30216">1</option>
<option label="30217">0</option>
</options>
</constraints>
<control type="list" format="string">
<heading>30709</heading>
</control>
</setting>
<setting help="30688" id="showradio" label="30188" type="boolean">
<level>0</level>
<default>true</default>
Expand All @@ -292,19 +307,19 @@
</group>
<group id="15">
<setting id="heartbeat" type="integer" label="30207" help="30707">
<level>2</level>
<default>0</default>
<constraints>
<options>
<option label="13278">0</option>
<option label="30208">1</option>
<option label="33036">2</option>
<option label="1223">3</option>
</options>
</constraints>
<control type="list" format="string">
<heading>32009</heading>
</control>
<level>2</level>
<default>0</default>
<constraints>
<options>
<option label="13278">0</option>
<option label="30208">1</option>
<option label="33036">2</option>
<option label="1223">3</option>
</options>
</constraints>
<control type="list" format="string">
<heading>32009</heading>
</control>
</setting>
</group>
</category>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,46 @@ 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 ""
8 changes: 7 additions & 1 deletion src/InstanceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -134,6 +136,8 @@ void InstanceSettings::ReadFromAddon()
else if (m_heartbeat == eHeartbeat::None)
m_heartbeatInterval = std::numeric_limits<time_t>::max();

if (m_accessLevel == 3)
m_heartbeatInterval = std::numeric_limits<time_t>::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());
Expand Down Expand Up @@ -295,6 +299,8 @@ ADDON_STATUS InstanceSettings::SetValue(const std::string& settingName, const ko
return SetStringSetting<ADDON_STATUS>(settingName, settingValue, m_PIN, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "remoteaccess")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_remoteAccess, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "accesscontrol")
return SetSetting<int, ADDON_STATUS>(settingName, settingValue, m_accessLevel, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "showradio")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_showRadio, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "backendresume")
Expand Down
1 change: 1 addition & 0 deletions src/InstanceSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 27 additions & 19 deletions src/pvrclient-nextpvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 48e1b09

Please sign in to comment.