Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: Add owner (user) field
  • Loading branch information
perexg committed Dec 16, 2014
1 parent 932ade3 commit 066b273
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 22 deletions.
12 changes: 10 additions & 2 deletions src/api/api_dvr.c
Expand Up @@ -209,7 +209,9 @@ api_dvr_entry_create_by_event
dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
if (cfg) {
de = dvr_entry_create_by_event(idnode_uuid_as_str(&cfg->dvr_id),
e, 0, 0, perm->aa_representative,
e, 0, 0,
perm->aa_username,
perm->aa_representative,
NULL, DVR_PRIO_NORMAL, 0, comment);
if (de)
dvr_entry_save(de);
Expand Down Expand Up @@ -257,6 +259,8 @@ api_dvr_autorec_create
if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;

if (perm->aa_username)
htsmsg_set_str(conf, "owner", perm->aa_username);
if (perm->aa_representative)
htsmsg_set_str(conf, "creator", perm->aa_representative);

Expand Down Expand Up @@ -301,7 +305,9 @@ api_dvr_autorec_create_by_series
dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid);
if (cfg) {
dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id),
e, perm->aa_representative,
e,
perm->aa_username,
perm->aa_representative,
"Created from EPG query");
if (dae) {
dvr_autorec_save(dae);
Expand Down Expand Up @@ -338,6 +344,8 @@ api_dvr_timerec_create
if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;

if (perm->aa_username)
htsmsg_set_str(conf, "owner", perm->aa_username);
if (perm->aa_representative)
htsmsg_set_str(conf, "creator", perm->aa_representative);

Expand Down
18 changes: 12 additions & 6 deletions src/dvr/dvr.h
Expand Up @@ -154,6 +154,7 @@ typedef struct dvr_entry {
time_t de_start_extra;
time_t de_stop_extra;

char *de_owner;
char *de_creator;
char *de_comment;
char *de_filename; /* Initially null if no filename has been
Expand Down Expand Up @@ -243,6 +244,7 @@ typedef struct dvr_autorec_entry {
LIST_ENTRY(dvr_autorec_entry) dae_config_link;

int dae_enabled;
char *dae_owner;
char *dae_creator;
char *dae_comment;

Expand Down Expand Up @@ -296,6 +298,7 @@ typedef struct dvr_timerec_entry {
LIST_ENTRY(dvr_timerec_entry) dte_config_link;

int dte_enabled;
char *dte_owner;
char *dte_creator;
char *dte_comment;

Expand Down Expand Up @@ -404,7 +407,7 @@ dvr_entry_t *
dvr_entry_create_by_event( const char *dvr_config_uuid,
epg_broadcast_t *e,
time_t start_extra, time_t stop_extra,
const char *creator,
const char *owner, const char *creator,
dvr_autorec_entry_t *dae,
dvr_prio_t pri, int retention,
const char *comment );
Expand All @@ -415,7 +418,8 @@ dvr_entry_create_htsp( const char *dvr_config_uuid,
time_t start_extra, time_t stop_extra,
const char *title, const char *description,
const char *lang, epg_genre_t *content_type,
const char *creator, dvr_autorec_entry_t *dae,
const char *owner, const char *creator,
dvr_autorec_entry_t *dae,
dvr_prio_t pri, int retention,
const char *comment );

Expand Down Expand Up @@ -475,8 +479,8 @@ dvr_entry_create_(const char *config_uuid, epg_broadcast_t *e,
time_t start_extra, time_t stop_extra,
const char *title, const char *description,
const char *lang, epg_genre_t *content_type,
const char *creator, dvr_autorec_entry_t *dae,
dvr_timerec_entry_t *tae,
const char *owner, const char *creator,
dvr_autorec_entry_t *dae, dvr_timerec_entry_t *tae,
dvr_prio_t pri, int retention, const char *comment);

dvr_autorec_entry_t *
Expand All @@ -485,12 +489,14 @@ dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
uint32_t days, time_t start_extra, time_t stop_extra,
dvr_prio_t pri, int retention,
int min_duration, int max_duration,
const char *creator, const char *comment);
const char *owner, const char *creator,
const char *comment);

dvr_autorec_entry_t *
dvr_autorec_add_series_link(const char *dvr_config_name,
epg_broadcast_t *event,
const char *creator, const char *comment);
const char *owner, const char *creator,
const char *comment);

void dvr_autorec_save(dvr_autorec_entry_t *dae);

Expand Down
15 changes: 13 additions & 2 deletions src/dvr/dvr_autorec.c
Expand Up @@ -197,7 +197,7 @@ dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
uint32_t weekdays, time_t start_extra, time_t stop_extra,
dvr_prio_t pri, int retention,
int min_duration, int max_duration,
const char *creator, const char *comment)
const char *owner, const char *creator, const char *comment)
{
dvr_autorec_entry_t *dae;
htsmsg_t *conf, *days;
Expand All @@ -214,6 +214,7 @@ dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
htsmsg_add_s64(conf, "stop_extra", stop_extra);
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 ?: "");

Expand Down Expand Up @@ -248,7 +249,8 @@ dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
dvr_autorec_entry_t *
dvr_autorec_add_series_link(const char *dvr_config_name,
epg_broadcast_t *event,
const char *creator, const char *comment)
const char *owner, const char *creator,
const char *comment)
{
dvr_autorec_entry_t *dae;
htsmsg_t *conf;
Expand All @@ -264,6 +266,7 @@ dvr_autorec_add_series_link(const char *dvr_config_name,
htsmsg_add_str(conf, "channel", channel_get_name(event->channel));
if (event->serieslink)
htsmsg_add_str(conf, "serieslink", event->serieslink->uri);
htsmsg_add_str(conf, "owner", owner ?: "");
htsmsg_add_str(conf, "creator", creator ?: "");
htsmsg_add_str(conf, "comment", comment ?: "");
dae = dvr_autorec_create(NULL, conf);
Expand Down Expand Up @@ -291,6 +294,7 @@ autorec_entry_destroy(dvr_autorec_entry_t *dae, int delconf)
LIST_REMOVE(dae, dae_config_link);

free(dae->dae_name);
free(dae->dae_owner);
free(dae->dae_creator);
free(dae->dae_comment);

Expand Down Expand Up @@ -959,6 +963,13 @@ const idclass_t dvr_autorec_entry_class = {
.get = dvr_autorec_entry_class_series_link_get,
.opts = PO_RDONLY,
},
{
.type = PT_STR,
.id = "owner",
.name = "Owner",
.off = offsetof(dvr_autorec_entry_t, dae_owner),
.opts = PO_RDONLY,
},
{
.type = PT_STR,
.id = "creator",
Expand Down
18 changes: 15 additions & 3 deletions src/dvr/dvr_db.c
Expand Up @@ -458,6 +458,7 @@ dvr_entry_create_(const char *config_uuid, epg_broadcast_t *e,
time_t start_extra, time_t stop_extra,
const char *title, const char *description,
const char *lang, epg_genre_t *content_type,
const char *owner,
const char *creator, dvr_autorec_entry_t *dae,
dvr_timerec_entry_t *dte,
dvr_prio_t pri, int retention,
Expand All @@ -479,6 +480,7 @@ dvr_entry_create_(const char *config_uuid, epg_broadcast_t *e,
htsmsg_add_str(conf, "config_name", config_uuid ?: "");
htsmsg_add_s64(conf, "start_extra", start_extra);
htsmsg_add_s64(conf, "stop_extra", stop_extra);
htsmsg_add_str(conf, "owner", owner ?: "");
htsmsg_add_str(conf, "creator", creator ?: "");
htsmsg_add_str(conf, "comment", comment ?: "");
if (e) {
Expand Down Expand Up @@ -547,6 +549,7 @@ dvr_entry_create_htsp(const char *config_uuid,
const char *title,
const char *description, const char *lang,
epg_genre_t *content_type,
const char *owner,
const char *creator, dvr_autorec_entry_t *dae,
dvr_prio_t pri, int retention,
const char *comment)
Expand All @@ -558,7 +561,7 @@ dvr_entry_create_htsp(const char *config_uuid,
NULL,
ch, start, stop, start_extra, stop_extra,
title, description, lang, content_type,
creator, dae, NULL, pri, retention,
owner, creator, dae, NULL, pri, retention,
comment);
}

Expand All @@ -569,6 +572,7 @@ dvr_entry_t *
dvr_entry_create_by_event(const char *config_uuid,
epg_broadcast_t *e,
time_t start_extra, time_t stop_extra,
const char *owner,
const char *creator, dvr_autorec_entry_t *dae,
dvr_prio_t pri, int retention,
const char *comment)
Expand All @@ -581,7 +585,7 @@ dvr_entry_create_by_event(const char *config_uuid,
start_extra, stop_extra,
NULL, NULL, NULL,
LIST_FIRST(&e->episode->genre),
creator, dae, NULL, pri, retention,
owner, creator, dae, NULL, pri, retention,
comment);
}

Expand Down Expand Up @@ -639,7 +643,7 @@ dvr_entry_create_by_autorec(epg_broadcast_t *e, dvr_autorec_entry_t *dae)

dvr_entry_create_by_event(idnode_uuid_as_str(&dae->dae_config->dvr_id), e,
dae->dae_start_extra, dae->dae_stop_extra,
buf, dae, dae->dae_pri, dae->dae_retention,
dae->dae_owner, buf, dae, dae->dae_pri, dae->dae_retention,
dae->dae_comment);
}

Expand Down Expand Up @@ -670,6 +674,7 @@ dvr_entry_dec_ref(dvr_entry_t *de)
LIST_REMOVE(de, de_config_link);

free(de->de_filename);
free(de->de_owner);
free(de->de_creator);
free(de->de_comment);
if (de->de_title) lang_str_destroy(de->de_title);
Expand Down Expand Up @@ -1819,6 +1824,13 @@ const idclass_t dvr_entry_class = {
.rend = dvr_entry_class_config_name_rend,
.get_opts = dvr_entry_class_start_opts,
},
{
.type = PT_STR,
.id = "owner",
.name = "Owner",
.off = offsetof(dvr_entry_t, de_owner),
.opts = PO_RDONLY,
},
{
.type = PT_STR,
.id = "creator",
Expand Down
10 changes: 9 additions & 1 deletion src/dvr/dvr_timerec.c
Expand Up @@ -155,7 +155,7 @@ dvr_timerec_check(dvr_timerec_entry_t *dte)
de = dvr_entry_create_(idnode_uuid_as_str(&dte->dte_config->dvr_id),
NULL, dte->dte_channel,
start, stop, 0, 0, title,
NULL, NULL, NULL, buf,
NULL, NULL, NULL, dte->dte_owner, buf,
NULL, dte, dte->dte_pri, dte->dte_retention,
dte->dte_comment);

Expand Down Expand Up @@ -216,6 +216,7 @@ timerec_entry_destroy(dvr_timerec_entry_t *dte, int delconf)

free(dte->dte_name);
free(dte->dte_title);
free(dte->dte_owner);
free(dte->dte_creator);
free(dte->dte_comment);

Expand Down Expand Up @@ -553,6 +554,13 @@ const idclass_t dvr_timerec_entry_class = {
.rend = dvr_timerec_entry_class_config_name_rend,
.list = dvr_entry_class_config_name_list,
},
{
.type = PT_STR,
.id = "owner",
.name = "Owner",
.off = offsetof(dvr_timerec_entry_t, dte_creator),
.opts = PO_RDONLY,
},
{
.type = PT_STR,
.id = "creator",
Expand Down
8 changes: 6 additions & 2 deletions src/htsp_server.c
Expand Up @@ -1384,13 +1384,16 @@ htsp_method_addDvrEntry(htsp_connection_t *htsp, htsmsg_t *in)
// create the dvr entry
de = dvr_entry_create_htsp(dvr_config_name, ch, start, stop,
start_extra, stop_extra,
title, desc, lang, 0, creator, NULL,
title, desc, lang, 0,
htsp->htsp_granted_access->aa_username,
creator, NULL,
priority, retention, comment);

/* Event timer */
} else {
de = dvr_entry_create_by_event(dvr_config_name, e,
start_extra, stop_extra,
htsp->htsp_granted_access->aa_username,
creator, NULL,
priority, retention, comment);
}
Expand Down Expand Up @@ -1574,7 +1577,8 @@ htsp_method_addAutorecEntry(htsp_connection_t *htsp, htsmsg_t *in)
return htsp_error("User does not have access");

dae = dvr_autorec_create_htsp(dvr_config_name, title, ch, start, start_window, days_of_week,
start_extra, stop_extra, priority, retention, min_duration, max_duration, creator, comment);
start_extra, stop_extra, priority, retention, min_duration, max_duration,
htsp->htsp_granted_access->aa_username, creator, comment);

/* create response */
out = htsmsg_create_map();
Expand Down
3 changes: 2 additions & 1 deletion src/webui/simpleui.c
Expand Up @@ -315,7 +315,8 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque)
de = dvr_entry_find_by_event(e);

if((http_arg_get(&hc->hc_req_args, "rec")) != NULL) {
de = dvr_entry_create_by_event(NULL, e, 0, 0, hc->hc_username ?: NULL, NULL,
de = dvr_entry_create_by_event(NULL, e, 0, 0, hc->hc_username ?: NULL,
hc->hc_representative ?: NULL, NULL,
DVR_PRIO_NORMAL, 0, "simpleui");
} else if(de != NULL && (http_arg_get(&hc->hc_req_args, "cancel")) != NULL) {
de = dvr_entry_cancel(de);
Expand Down
12 changes: 7 additions & 5 deletions src/webui/static/app/dvr.js
Expand Up @@ -207,7 +207,7 @@ tvheadend.dvr_upcoming = function(panel, index) {
},
del: true,
list: 'disp_title,episode,pri,start_real,stop_real,' +
'duration,channelname,creator,config_name,' +
'duration,channelname,owner,creator,config_name,' +
'sched_status,comment',
sort: {
field: 'start_real',
Expand Down Expand Up @@ -270,7 +270,7 @@ tvheadend.dvr_finished = function(panel, index) {
delquestion: 'Do you really want to delete the selected recordings?<br/><br/>' +
'The associated file will be removed from the storage.',
list: 'disp_title,episode,start_real,stop_real,' +
'duration,filesize,channelname,creator,' +
'duration,filesize,channelname,owner,creator,' +
'sched_status,url,comment',
columns: {
filesize: {
Expand Down Expand Up @@ -350,7 +350,7 @@ tvheadend.dvr_failed = function(panel, index) {
delquestion: 'Do you really want to delete the selected recordings?<br/><br/>' +
'The associated file will be removed from the storage.',
list: 'disp_title,episode,start_real,stop_real,' +
'duration,filesize,channelname,creator,' +
'duration,filesize,channelname,owner,creator,' +
'status,sched_status,url,comment',
columns: {
filesize: {
Expand Down Expand Up @@ -437,6 +437,7 @@ tvheadend.autorec_editor = function(panel, index) {
start_window: { width: 100 },
pri: { width: 80 },
config_name: { width: 120 },
owner: { width: 100 },
creator: { width: 200 },
comment: { width: 200 }
},
Expand All @@ -450,7 +451,7 @@ tvheadend.autorec_editor = function(panel, index) {
},
del: true,
list: 'enabled,name,title,channel,tag,content_type,minduration,' +
'maxduration,weekdays,start,start_window,pri,config_name,creator,comment',
'maxduration,weekdays,start,start_window,pri,config_name,owner,creator,comment',
columns: {
weekdays: {
renderer: function(st) { return tvheadend.weekdaysRenderer(st); }
Expand Down Expand Up @@ -490,6 +491,7 @@ tvheadend.timerec_editor = function(panel, index) {
stop: { width: 100 },
pri: { width: 80 },
config_name: { width: 120 },
owner: { width: 100 },
creator: { width: 200 },
comment: { width: 200 }
},
Expand All @@ -501,7 +503,7 @@ tvheadend.timerec_editor = function(panel, index) {
create: { }
},
del: true,
list: 'enabled,name,title,channel,weekdays,start,stop,pri,config_name,comment',
list: 'enabled,name,title,channel,weekdays,start,stop,pri,config_name,owner,creator,comment',
columns: {
weekdays: {
renderer: function(st) { return tvheadend.weekdaysRenderer(st); }
Expand Down

0 comments on commit 066b273

Please sign in to comment.