Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make timerec and autorec updateable
  • Loading branch information
Glenn-1990 authored and perexg committed Nov 5, 2015
1 parent 374ab83 commit c05eda1
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 219 deletions.
18 changes: 6 additions & 12 deletions src/dvr/dvr.h
Expand Up @@ -567,13 +567,9 @@ dvr_entry_create_(int enabled, const char *config_uuid, epg_broadcast_t *e,
dvr_prio_t pri, int retention, int removal, const char *comment);

dvr_autorec_entry_t *
dvr_autorec_create_htsp(const char *dvr_config_name, const char *title, int fulltext,
channel_t *ch, uint32_t enabled, int32_t start,
int32_t start_window, uint32_t days, time_t start_extra,
time_t stop_extra, dvr_prio_t pri, int retention, int removal,
int min_duration, int max_duration, dvr_autorec_dedup_t dup_detect,
const char *owner, const char *creator,
const char *comment, const char *name, const char *directory);
dvr_autorec_create_htsp(htsmsg_t *conf);

void dvr_autorec_update_htsp(dvr_autorec_entry_t *dae, htsmsg_t *conf);

dvr_autorec_entry_t *
dvr_autorec_add_series_link(const char *dvr_config_name,
Expand Down Expand Up @@ -644,11 +640,9 @@ dvr_timerec_entry_t *
dvr_timerec_create(const char *uuid, htsmsg_t *conf);

dvr_timerec_entry_t*
dvr_timerec_create_htsp(const char *dvr_config_name, const char *title,
channel_t *ch, uint32_t enabled, uint32_t start, uint32_t stop,
uint32_t weekdays, dvr_prio_t pri, int retention, int removal,
const char *owner, const char *creator, const char *comment,
const char *name, const char *directory);
dvr_timerec_create_htsp(htsmsg_t *conf);

void dvr_timerec_update_htsp(dvr_timerec_entry_t *dte, htsmsg_t *conf);

static inline dvr_timerec_entry_t *
dvr_timerec_find_by_uuid(const char *uuid)
Expand Down
54 changes: 11 additions & 43 deletions src/dvr/dvr_autorec.c
Expand Up @@ -273,51 +273,9 @@ dvr_autorec_create(const char *uuid, htsmsg_t *conf)


dvr_autorec_entry_t*
dvr_autorec_create_htsp(const char *dvr_config_name, const char *title, int fulltext,
channel_t *ch, uint32_t enabled, int32_t start, int32_t start_window,
uint32_t weekdays, time_t start_extra, time_t stop_extra,
dvr_prio_t pri, int retention, int removal,
int min_duration, int max_duration, dvr_autorec_dedup_t dup_detect,
const char *owner, const char *creator, const char *comment,
const char *name, const char *directory)
dvr_autorec_create_htsp(htsmsg_t *conf)
{
dvr_autorec_entry_t *dae;
htsmsg_t *conf, *days;

conf = htsmsg_create_map();
days = htsmsg_create_list();

htsmsg_add_u32(conf, "enabled", enabled > 0 ? 1 : 0);
htsmsg_add_u32(conf, "retention", retention);
htsmsg_add_u32(conf, "removal", removal);
htsmsg_add_u32(conf, "pri", pri);
htsmsg_add_u32(conf, "minduration", min_duration);
htsmsg_add_u32(conf, "maxduration", max_duration);
htsmsg_add_s64(conf, "start_extra", start_extra);
htsmsg_add_s64(conf, "stop_extra", stop_extra);
htsmsg_add_str(conf, "title", title);
htsmsg_add_u32(conf, "fulltext", fulltext);
htsmsg_add_u32(conf, "record", dup_detect);
htsmsg_add_str(conf, "config_name", dvr_config_name ?: "");
htsmsg_add_str(conf, "owner", owner ?: "");
htsmsg_add_str(conf, "creator", creator ?: "");
htsmsg_add_str(conf, "comment", comment ?: "");
htsmsg_add_str(conf, "name", name ?: "");
htsmsg_add_str(conf, "directory", directory ?: "");

if (start >= 0)
htsmsg_add_s32(conf, "start", start);
if (start_window >= 0)
htsmsg_add_s32(conf, "start_window", start_window);
if (ch)
htsmsg_add_str(conf, "channel", idnode_uuid_as_sstr(&ch->ch_id));

int i;
for (i = 0; i < 7; i++)
if (weekdays & (1 << i))
htsmsg_add_u32(days, NULL, i + 1);

htsmsg_add_msg(conf, "weekdays", days);

dae = dvr_autorec_create(NULL, conf);
htsmsg_destroy(conf);
Expand All @@ -330,6 +288,16 @@ dvr_autorec_create_htsp(const char *dvr_config_name, const char *title, int full
return dae;
}

void
dvr_autorec_update_htsp(dvr_autorec_entry_t *dae, htsmsg_t *conf)
{
idnode_update(&dae->dae_id, conf);
dvr_autorec_save(dae);
dvr_autorec_changed(dae, 1);
tvhlog(LOG_INFO, "autorec", "\"%s\" on \"%s\": Updated", dae->dae_title ? dae->dae_title : "",
(dae->dae_channel && dae->dae_channel->ch_name) ? dae->dae_channel->ch_name : "any channel");
}

/**
*
*/
Expand Down
48 changes: 13 additions & 35 deletions src/dvr/dvr_timerec.c
Expand Up @@ -202,54 +202,32 @@ dvr_timerec_create(const char *uuid, htsmsg_t *conf)
}

dvr_timerec_entry_t*
dvr_timerec_create_htsp(const char *dvr_config_name, const char *title,
channel_t *ch, uint32_t enabled, uint32_t start, uint32_t stop,
uint32_t weekdays, dvr_prio_t pri, int retention, int removal,
const char *owner, const char *creator, const char *comment,
const char *name, const char *directory)
dvr_timerec_create_htsp(htsmsg_t *conf)
{
dvr_timerec_entry_t *dte;
htsmsg_t *conf, *days;

conf = htsmsg_create_map();
days = htsmsg_create_list();

htsmsg_add_u32(conf, "enabled", enabled > 0 ? 1 : 0);
htsmsg_add_u32(conf, "retention", retention);
htsmsg_add_u32(conf, "removal", removal);
htsmsg_add_u32(conf, "pri", pri);
htsmsg_add_str(conf, "title", title);
htsmsg_add_str(conf, "config_name", dvr_config_name ?: "");
htsmsg_add_str(conf, "owner", owner ?: "");
htsmsg_add_str(conf, "creator", creator ?: "");
htsmsg_add_str(conf, "comment", comment ?: "");
htsmsg_add_str(conf, "name", name ?: "");
htsmsg_add_str(conf, "directory", directory ?: "");
htsmsg_add_u32(conf, "start", start);
htsmsg_add_u32(conf, "stop", stop);

if (ch)
htsmsg_add_str(conf, "channel", idnode_uuid_as_sstr(&ch->ch_id));

int i;
for (i = 0; i < 7; i++)
if (weekdays & (1 << i))
htsmsg_add_u32(days, NULL, i + 1);

htsmsg_add_msg(conf, "weekdays", days);

dte = dvr_timerec_create(NULL, conf);
htsmsg_destroy(conf);

if (dte)
{
if (dte) {
dvr_timerec_save(dte);
dvr_timerec_check(dte);
}

return dte;
}

void
dvr_timerec_update_htsp (dvr_timerec_entry_t *dte, htsmsg_t *conf)
{
idnode_update(&dte->dte_id, conf);
dvr_timerec_save(dte);
dvr_timerec_check(dte);
htsp_timerec_entry_update(dte);
tvhlog(LOG_INFO, "timerec", "\"%s\" on \"%s\": Updated", dte->dte_title ? dte->dte_title : "",
(dte->dte_channel && dte->dte_channel->ch_name) ? dte->dte_channel->ch_name : "any channel");
}

/**
*
*/
Expand Down

0 comments on commit c05eda1

Please sign in to comment.