Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
htsp server: allow to update the DVR config for DVR/auto/time entries…
…, fixes #3497
  • Loading branch information
perexg committed Feb 9, 2016
1 parent b1e89e6 commit 0f2dbb4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/dvr/dvr.h
Expand Up @@ -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,
Expand Down
24 changes: 17 additions & 7 deletions src/dvr/dvr_db.c
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1664,14 +1672,16 @@ static dvr_entry_t *_dvr_entry_update
*/
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);
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++;
}
Expand All @@ -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;
}
Expand Down
14 changes: 11 additions & 3 deletions src/htsp_server.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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();
}
Expand Down

0 comments on commit 0f2dbb4

Please sign in to comment.