Skip to content

Commit

Permalink
custom props v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Sep 4, 2024
1 parent d0122da commit 4e3e874
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,11 @@ msgctxt "#30457"
msgid "DVR configuration"
msgstr ""

#empty strings from id 30458 to 30499
msgctxt "#30458"
msgid "Comment"
msgstr ""

#empty strings from id 30459 to 30499

msgctxt "#30500"
msgid "Streaming profile"
Expand Down
64 changes: 34 additions & 30 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CTvheadend::CTvheadend(const kodi::addon::IInstanceInfo& instance)
: kodi::addon::CInstancePVRClient(instance),
m_settings(new InstanceSettings(*this)),
m_conn(new HTSPConnection(m_settings, *this)),
m_customTimerProps({CUSTOM_PROP_ID_DVR_CONFIGURATION}, *m_conn, m_dvrConfigs),
m_customTimerProps({CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_DVR_COMMENT}, *m_conn, m_dvrConfigs),
m_streamchange(false),
m_vfs(new HTSPVFS(m_settings, *m_conn)),
m_queue(static_cast<size_t>(-1)),
Expand Down Expand Up @@ -892,7 +892,7 @@ struct TimerType : kodi::addon::PVRTimerType
unsigned int id,
unsigned int attributes,
const std::string& description,
const std::vector<kodi::addon::PVRIntSettingDefinition>& customIntSettingDefs,
const std::vector<kodi::addon::PVRSettingDefinition>& customSettingDefs,
const std::vector<kodi::addon::PVRTypeIntValue>& priorityValues,
const std::vector<kodi::addon::PVRTypeIntValue>& lifetimeValues,
const std::vector<kodi::addon::PVRTypeIntValue>& dupEpisodesValues =
Expand All @@ -901,7 +901,7 @@ struct TimerType : kodi::addon::PVRTimerType
SetId(id);
SetAttributes(attributes);
SetDescription(description);
SetCustomIntSettingDefinitions(customIntSettingDefs);
SetCustomSettingDefinitions(customSettingDefs);
SetPriorities(priorityValues, settings->GetDvrPriority());
SetLifetimes(lifetimeValues, LifetimeMapper::TvhToKodi(settings->GetDvrLifetime()));
SetPreventDuplicateEpisodes(dupEpisodesValues, settings->GetDvrDupdetect());
Expand Down Expand Up @@ -1004,8 +1004,8 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type

/* Timer types definition. */

/* Custom integer setting definitions */
const std::vector<kodi::addon::PVRIntSettingDefinition> customIntSettingDefs{
/* Custom setting definitions */
const std::vector<kodi::addon::PVRSettingDefinition> customSettingDefs{
m_customTimerProps.GetSettingDefinitions()};

/* One-shot manual (time and channel based) */
Expand All @@ -1018,8 +1018,8 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
TIMER_ONCE_MANUAL_ATTRIBS,
/* Let Kodi generate the description. */
"",
/* Custom int settings definitions. */
customIntSettingDefs,
/* Custom settings definitions. */
customSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
Expand All @@ -1035,8 +1035,8 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
TIMER_ONCE_EPG_ATTRIBS,
/* Let Kodi generate the description. */
"",
/* Custom int settings definitions. */
customIntSettingDefs,
/* Custom settings definitions. */
customSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
Expand All @@ -1052,8 +1052,8 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
TIMER_ONCE_MANUAL_ATTRIBS | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES,
/* Description. */
kodi::addon::GetLocalizedString(30350), // "One Time (Scheduled by timer rule)"
/* Custom int settings definitions. */
customIntSettingDefs,
/* Custom settings definitions. */
customSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
Expand All @@ -1069,16 +1069,16 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
TIMER_ONCE_EPG_ATTRIBS | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES,
/* Description. */
kodi::addon::GetLocalizedString(30350), // "One Time (Scheduled by timer rule)"
/* Custom int settings definitions. */
customIntSettingDefs,
/* Custom settings definitions. */
customSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
lifetimeValues));

/* Custom Timerec integer setting definitions */
const std::vector<kodi::addon::PVRIntSettingDefinition> customTimeRecIntSettingDefs{
m_timeRecordings.GetCustomIntSettingDefinitions()};
/* Custom Timerec setting definitions */
const std::vector<kodi::addon::PVRSettingDefinition> customTimeRecSettingDefs{
m_timeRecordings.GetCustomSettingDefinitions()};

/* Repeating manual (time and channel based) - timerec */
types.emplace_back(TimerType(
Expand All @@ -1094,16 +1094,16 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS,
/* Let Kodi generate the description. */
"",
/* Custom int settings definitions. */
customTimeRecIntSettingDefs,
/* Custom settings definitions. */
customTimeRecSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
lifetimeValues));

/* Custom Autorec integer setting definitions */
const std::vector<kodi::addon::PVRIntSettingDefinition> customAutoRecIntSettingDefs{
m_autoRecordings.GetCustomIntSettingDefinitions()};
const std::vector<kodi::addon::PVRSettingDefinition> customAutoRecSettingDefs{
m_autoRecordings.GetCustomSettingDefinitions()};

if (m_conn->GetProtocol() >= 29)
{
Expand Down Expand Up @@ -1132,8 +1132,8 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
TIMER_REPEATING_SERIESLINK_ATTRIBS,
/* Description. */
kodi::addon::GetLocalizedString(30369), // "Timer rule (series link)"
/* Custom int settings definitions. */
customAutoRecIntSettingDefs,
/* Custom settings definitions. */
customAutoRecSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
Expand Down Expand Up @@ -1166,8 +1166,8 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
TIMER_REPEATING_EPG_ATTRIBS,
/* Let Kodi generate the description. */
"",
/* Custom int settings definitions. */
customAutoRecIntSettingDefs,
/* Custom settings definitions. */
customAutoRecSettingDefs,
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
Expand Down Expand Up @@ -1228,8 +1228,8 @@ bool CTvheadend::CreateTimer(const Recording& tvhTmr, kodi::addon::PVRTimer& tmr
? m_autoRecordings.GetTimerIntIdFromStringId(tvhTmr.GetAutorecId())
: 0);

/* Custom integer props */
tmr.SetCustomIntProperties(m_customTimerProps.GetProperties(tvhTmr));
/* Custom props */
tmr.SetCustomProperties(m_customTimerProps.GetProperties(tvhTmr));

return true;
}
Expand Down Expand Up @@ -1314,8 +1314,8 @@ PVR_ERROR CTvheadend::AddTimer(const kodi::addon::PVRTimer& timer)
LifetimeMapper::KodiToTvh(timer.GetLifetime())); // remove from disk
htsmsg_add_u32(m, "priority", timer.GetPriority());

/* Custom integer props. */
m_customTimerProps.AppendPropertiesToHTSPMessage(timer.GetCustomIntProperties(), m);
/* Custom props. */
m_customTimerProps.AppendPropertiesToHTSPMessage(timer.GetCustomProperties(), m);

/* Send and Wait */
{
Expand Down Expand Up @@ -1450,8 +1450,8 @@ PVR_ERROR CTvheadend::UpdateTimer(const kodi::addon::PVRTimer& timer)
LifetimeMapper::KodiToTvh(timer.GetLifetime())); // remove from disk
htsmsg_add_u32(m, "priority", timer.GetPriority());

/* Custom integer props. */
m_customTimerProps.AppendPropertiesToHTSPMessage(timer.GetCustomIntProperties(), m);
/* Custom props. */
m_customTimerProps.AppendPropertiesToHTSPMessage(timer.GetCustomProperties(), m);

return SendDvrUpdate(m);
}
Expand Down Expand Up @@ -2777,6 +2777,10 @@ void CTvheadend::ParseRecordingAddOrUpdate(htsmsg_t* msg, bool bAdd)
if (str)
rec.SetConfigUuid(str);

str = htsmsg_get_str(msg, "comment");
if (str)
rec.SetComment(str);

if (m_conn->GetProtocol() >= 32)
{
if (rec.GetDescription().empty() && !rec.GetSubtitle().empty())
Expand Down
22 changes: 14 additions & 8 deletions src/tvheadend/AutoRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ AutoRecordings::AutoRecordings(const std::shared_ptr<InstanceSettings>& settings
Profiles& dvrConfigs)
: m_settings(settings),
m_conn(conn),
m_customTimerProps(
{CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE}, conn, dvrConfigs)
m_customTimerProps({CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE,
CUSTOM_PROP_ID_DVR_COMMENT},
conn,
dvrConfigs)
{
}

Expand Down Expand Up @@ -110,8 +112,8 @@ void AutoRecordings::GetAutorecTimers(std::vector<kodi::addon::PVRTimer>& timers
tmr.SetFullTextEpgSearch(rec.second.GetFulltext());
tmr.SetParentClientIndex(0);

/* Custom integer props. */
tmr.SetCustomIntProperties(m_customTimerProps.GetProperties(rec.second));
/* Custom props. */
tmr.SetCustomProperties(m_customTimerProps.GetProperties(rec.second));

timers.emplace_back(std::move(tmr));
}
Expand Down Expand Up @@ -141,8 +143,8 @@ const std::string AutoRecordings::GetTimerStringIdFromIntId(unsigned int intId)
return "";
}

const std::vector<kodi::addon::PVRIntSettingDefinition> AutoRecordings::
GetCustomIntSettingDefinitions() const
const std::vector<kodi::addon::PVRSettingDefinition> AutoRecordings::GetCustomSettingDefinitions()
const
{
return m_customTimerProps.GetSettingDefinitions();
}
Expand Down Expand Up @@ -273,8 +275,8 @@ PVR_ERROR AutoRecordings::SendAutorecAddOrUpdate(const kodi::addon::PVRTimer& ti
if (timer.GetTimerType() == TIMER_REPEATING_SERIESLINK)
htsmsg_add_str(m, "serieslinkUri", timer.GetSeriesLink().c_str());

/* Custom integer props. */
m_customTimerProps.AppendPropertiesToHTSPMessage(timer.GetCustomIntProperties(), m);
/* Custom props. */
m_customTimerProps.AppendPropertiesToHTSPMessage(timer.GetCustomProperties(), m);

/* Send and Wait */
{
Expand Down Expand Up @@ -478,6 +480,10 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t* msg, bool bAdd)
if (str)
rec.SetConfigUuid(str);

str = htsmsg_get_str(msg, "comment");
if (str)
rec.SetComment(str);

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tvheadend/AutoRecordings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AutoRecordings
int GetAutorecTimerCount() const;
void GetAutorecTimers(std::vector<kodi::addon::PVRTimer>& timers);
const unsigned int GetTimerIntIdFromStringId(const std::string& strId) const;
const std::vector<kodi::addon::PVRIntSettingDefinition> GetCustomIntSettingDefinitions() const;
const std::vector<kodi::addon::PVRSettingDefinition> GetCustomSettingDefinitions() const;

/* client to server messages */
PVR_ERROR SendAutorecAdd(const kodi::addon::PVRTimer& timer);
Expand Down
Loading

0 comments on commit 4e3e874

Please sign in to comment.