From: Jaroslav Kysela Date: Tue, 9 Feb 2016 10:15:51 +0000 (+0100) Subject: htsp server: allow to update the DVR config for DVR/auto/time entries, fixes #3497 X-Git-Tag: v4.2.1~1052 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f2dbb4f5f8a3957116dbf683ff1918dbf1c36dc;p=thirdparty%2Ftvheadend.git htsp server: allow to update the DVR config for DVR/auto/time entries, fixes #3497 --- diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h index 47e9ce2c3..e8caa1a54 100644 --- a/src/dvr/dvr.h +++ b/src/dvr/dvr.h @@ -532,7 +532,8 @@ dvr_entry_create_htsp( int enabled, const char *dvr_config_uuid, const char *comment ); dvr_entry_t * -dvr_entry_update( dvr_entry_t *de, int enabled, channel_t *ch, +dvr_entry_update( dvr_entry_t *de, int enabled, + const char *dvr_config_uuid, channel_t *ch, const char *title, const char *subtitle, const char *desc, const char *lang, time_t start, time_t stop, diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index b2860d186..95c437b6e 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -1481,10 +1481,11 @@ dvr_timer_remove_files(void *aux) #define DVR_UPDATED_EID (1<<14) #define DVR_UPDATED_BROADCAST (1<<15) #define DVR_UPDATED_EPISODE (1<<16) +#define DVR_UPDATED_CONFIG (1<<17) static char *dvr_updated_str(char *buf, size_t buflen, int flags) { - static const char *x = "ecoOsStumdpgrviBE"; + static const char *x = "ecoOsStumdpgrviBEC"; const char *p = x; char *w = buf, *end = buf + buflen; @@ -1502,7 +1503,8 @@ static char *dvr_updated_str(char *buf, size_t buflen, int flags) * */ static dvr_entry_t *_dvr_entry_update - ( dvr_entry_t *de, int enabled, epg_broadcast_t *e, channel_t *ch, + ( dvr_entry_t *de, int enabled, const char *dvr_config_uuid, + epg_broadcast_t *e, channel_t *ch, const char *title, const char *subtitle, const char *desc, const char *lang, time_t start, time_t stop, time_t start_extra, time_t stop_extra, @@ -1537,6 +1539,12 @@ static dvr_entry_t *_dvr_entry_update goto dosave; } + /* Configuration */ + if (dvr_config_uuid) { + de->de_config = dvr_config_find_by_name_default(dvr_config_uuid); + save |= DVR_UPDATED_CONFIG; + } + /* Channel */ if (ch && (ch != de->de_channel)) { de->de_channel = ch; @@ -1664,14 +1672,16 @@ dosave: */ dvr_entry_t * dvr_entry_update - ( dvr_entry_t *de, int enabled, channel_t *ch, + ( dvr_entry_t *de, int enabled, + const char *dvr_config_uuid, channel_t *ch, const char *title, const char *subtitle, const char *desc, const char *lang, time_t start, time_t stop, time_t start_extra, time_t stop_extra, dvr_prio_t pri, int retention, int removal ) { - return _dvr_entry_update(de, enabled, NULL, ch, title, subtitle, desc, lang, + return _dvr_entry_update(de, enabled, dvr_config_uuid, + NULL, ch, title, subtitle, desc, lang, start, stop, start_extra, stop_extra, pri, retention, removal); } @@ -1730,7 +1740,7 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e) epg_broadcast_get_title(e2, NULL), channel_get_name(ch), e2->start, e2->stop); - _dvr_entry_update(de, -1, e2, NULL, NULL, NULL, NULL, NULL, + _dvr_entry_update(de, -1, NULL, e2, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0, 0); return; } @@ -1773,7 +1783,7 @@ void dvr_event_updated(epg_broadcast_t *e) LIST_FOREACH(de, &e->channel->ch_dvrs, de_channel_link) { if (de->de_bcast != e) continue; - _dvr_entry_update(de, -1, e, NULL, NULL, NULL, NULL, + _dvr_entry_update(de, -1, NULL, e, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0, 0); found++; } @@ -1790,7 +1800,7 @@ void dvr_event_updated(epg_broadcast_t *e) epg_broadcast_get_title(e, NULL), channel_get_name(e->channel), e->start, e->stop); - _dvr_entry_update(de, -1, e, NULL, NULL, NULL, NULL, + _dvr_entry_update(de, -1, NULL, e, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0, 0); break; } diff --git a/src/htsp_server.c b/src/htsp_server.c index ebb90ce7d..731f9d144 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -641,6 +641,12 @@ serierec_convert(htsp_connection_t *htsp, htsmsg_t *in, channel_t *ch, int autor htsmsg_add_str(conf, "config_name", str ?: ""); htsmsg_add_str(conf, "owner", htsp->htsp_granted_access->aa_username ?: ""); htsmsg_add_str(conf, "creator", htsp->htsp_granted_access->aa_representative ?: ""); + } else { + str = htsmsg_get_str(in, "configName"); + if (str) { + str = htsp_dvr_config_name(htsp, str); + htsmsg_add_str(conf, "config_name", str ?: ""); + } } /* Weekdays only if present */ @@ -1881,7 +1887,7 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in) uint32_t u32; dvr_entry_t *de; time_t start, stop, start_extra, stop_extra, priority, retention, removal; - const char *title, *subtitle, *desc, *lang; + const char *dvr_config_name, *title, *subtitle, *desc, *lang; channel_t *channel = NULL; int enabled; @@ -1899,6 +1905,7 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in) return htsp_error("User does not have access to channel"); enabled = htsmsg_get_s64_or_default(in, "enabled", -1); + dvr_config_name = htsp_dvr_config_name(htsp, htsmsg_get_str(in, "configName")); start = htsmsg_get_s64_or_default(in, "start", 0); stop = htsmsg_get_s64_or_default(in, "stop", 0); start_extra = htsmsg_get_s64_or_default(in, "startExtra", 0); @@ -1911,8 +1918,9 @@ htsp_method_updateDvrEntry(htsp_connection_t *htsp, htsmsg_t *in) desc = htsmsg_get_str(in, "description"); lang = htsmsg_get_str(in, "language") ?: htsp->htsp_language; - de = dvr_entry_update(de, enabled, channel, title, subtitle, desc, lang, start, stop, - start_extra, stop_extra, priority, retention, removal); + de = dvr_entry_update(de, enabled, dvr_config_name, channel, title, subtitle, + desc, lang, start, stop, start_extra, stop_extra, + priority, retention, removal); return htsp_success(); }