From: Jaroslav Kysela Date: Wed, 20 May 2015 17:14:09 +0000 (+0200) Subject: ACL: Add possibility to not show the failed recordings, fixes #2569 X-Git-Tag: v4.2.1~2513 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec3ba938d141bd7ccd140577e6aa1c54b138412c;p=thirdparty%2Ftvheadend.git ACL: Add possibility to not show the failed recordings, fixes #2569 --- diff --git a/docs/html/config_access.html b/docs/html/config_access.html index 1f16125ef..fbe9e9dba 100644 --- a/docs/html/config_access.html +++ b/docs/html/config_access.html @@ -104,6 +104,10 @@ The columns have the following functions: Enable to access to DVR entries created by other users with the ability to remove the DVR entries. +
Failed DVR +
+ Enable to access to DVR entries which were not succesfuly recorded. +
DVR Config Profile
If set, the user will only be able to use the DVR config profile diff --git a/src/access.c b/src/access.c index c4c65999e..2f931d35e 100644 --- a/src/access.c +++ b/src/access.c @@ -836,18 +836,20 @@ access_entry_update_rights(access_entry_t *ae) r |= ACCESS_ADVANCED_STREAMING; if (ae->ae_htsp_streaming) r |= ACCESS_HTSP_STREAMING; + if (ae->ae_webui) + r |= ACCESS_WEB_INTERFACE; if (ae->ae_dvr) r |= ACCESS_RECORDER; if (ae->ae_htsp_dvr) r |= ACCESS_HTSP_RECORDER; if (ae->ae_all_dvr) r |= ACCESS_ALL_RECORDER; - if (ae->ae_webui) - r |= ACCESS_WEB_INTERFACE; - if (ae->ae_admin) - r |= ACCESS_ADMIN; if (ae->ae_all_rw_dvr) r |= ACCESS_ALL_RW_RECORDER; + if (ae->ae_failed_dvr) + r |= ACCESS_FAILED_RECORDER; + if (ae->ae_admin) + r |= ACCESS_ADMIN; ae->ae_rights = r; } @@ -882,6 +884,7 @@ access_entry_create(const char *uuid, htsmsg_t *conf) ae->ae_htsp_streaming = 1; ae->ae_htsp_dvr = 1; ae->ae_all_dvr = 1; + ae->ae_failed_dvr = 1; idnode_load(&ae->ae_id, conf); /* note password has PO_NOSAVE, thus it must be set manually */ if ((s = htsmsg_get_str(conf, "password")) != NULL) @@ -1343,6 +1346,13 @@ const idclass_t access_entry_class = { .name = "All DVR (rw)", .off = offsetof(access_entry_t, ae_all_rw_dvr), }, + { + .type = PT_BOOL, + .id = "failed_dvr", + .name = "Failed DVR", + .off = offsetof(access_entry_t, ae_failed_dvr), + .opts = PO_ADVANCED | PO_HIDDEN, + }, { .type = PT_STR, .id = "dvr_config", @@ -1449,11 +1459,12 @@ access_init(int createdefault, int noacl) ae->ae_streaming = 1; ae->ae_adv_streaming = 1; ae->ae_htsp_streaming = 1; + ae->ae_webui = 1; ae->ae_dvr = 1; ae->ae_htsp_dvr = 1; ae->ae_all_dvr = 1; ae->ae_all_rw_dvr = 1; - ae->ae_webui = 1; + ae->ae_failed_dvr = 1; ae->ae_admin = 1; access_entry_update_rights(ae); diff --git a/src/access.h b/src/access.h index 964fe5c32..68afdce83 100644 --- a/src/access.h +++ b/src/access.h @@ -68,6 +68,7 @@ typedef struct access_entry { int ae_htsp_dvr; int ae_all_dvr; int ae_all_rw_dvr; + int ae_failed_dvr; struct dvr_config *ae_dvr_config; LIST_ENTRY(access_entry) ae_dvr_config_link; @@ -122,15 +123,17 @@ typedef struct access_ticket { #define ACCESS_RECORDER (1<<4) #define ACCESS_HTSP_RECORDER (1<<5) #define ACCESS_ALL_RECORDER (1<<6) -#define ACCESS_ADMIN (1<<7) -#define ACCESS_ALL_RW_RECORDER (1<<8) +#define ACCESS_ALL_RW_RECORDER (1<<7) +#define ACCESS_FAILED_RECORDER (1<<8) +#define ACCESS_ADMIN (1<<9) #define ACCESS_OR (1<<30) #define ACCESS_FULL \ (ACCESS_STREAMING | ACCESS_ADVANCED_STREAMING | \ ACCESS_HTSP_STREAMING | ACCESS_WEB_INTERFACE | \ ACCESS_RECORDER | ACCESS_HTSP_RECORDER | \ - ACCESS_ALL_RECORDER | ACCESS_ADMIN | ACCESS_ALL_RW_RECORDER) + ACCESS_ALL_RECORDER | ACCESS_ALL_RW_RECORDER | \ + ACCESS_FAILED_RECORDER | ACCESS_ADMIN) /** * Create a new ticket for the requested resource and generate a id for it diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h index 35279b9e0..1959dfc41 100644 --- a/src/dvr/dvr.h +++ b/src/dvr/dvr.h @@ -503,18 +503,7 @@ htsmsg_t *dvr_entry_class_pri_list(void *o); htsmsg_t *dvr_entry_class_config_name_list(void *o); htsmsg_t *dvr_entry_class_duration_list(void *o, const char *not_set, int max, int step); -static inline int dvr_entry_verify(dvr_entry_t *de, access_t *a, int readonly) -{ - if (readonly && !access_verify2(a, ACCESS_ALL_RECORDER)) - return 0; - - if (!access_verify2(a, ACCESS_ALL_RW_RECORDER)) - return 0; - - if (strcmp(de->de_owner ?: "", a->aa_username ?: "")) - return -1; - return 0; -} +int dvr_entry_verify(dvr_entry_t *de, access_t *a, int readonly); /** * diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index 39c931f2a..ccca1a932 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -47,6 +47,28 @@ static void dvr_timer_stop_recording(void *aux); static int dvr_entry_class_disp_title_set(void *o, const void *v); static int dvr_entry_class_disp_subtitle_set(void *o, const void *v); +/* + * + */ +int +dvr_entry_verify(dvr_entry_t *de, access_t *a, int readonly) +{ + if (access_verify2(a, ACCESS_FAILED_RECORDER) && + (de->de_sched_state == DVR_COMPLETED && + de->de_last_error != SM_CODE_OK)) + return -1; + + if (readonly && !access_verify2(a, ACCESS_ALL_RECORDER)) + return 0; + + if (!access_verify2(a, ACCESS_ALL_RW_RECORDER)) + return 0; + + if (strcmp(de->de_owner ?: "", a->aa_username ?: "")) + return -1; + return 0; +} + /* * */ diff --git a/src/htsp_server.c b/src/htsp_server.c index ee7f04b01..802c7cff8 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -1115,7 +1115,7 @@ htsp_method_async(htsp_connection_t *htsp, htsmsg_t *in) /* Send all DVR entries */ LIST_FOREACH(de, &dvrentries, de_global_link) if (!dvr_entry_verify(de, htsp->htsp_granted_access, 1) && - htsp_user_access_channel(htsp,de->de_channel)) + htsp_user_access_channel(htsp, de->de_channel)) htsp_send_message(htsp, htsp_build_dvrentry(de, "dvrEntryAdd"), NULL); /* Send EPG updates */ diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index d5e35a76a..0ec941d80 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -10,6 +10,13 @@ tvheadend.acleditor = function(panel, index) 'profile,conn_limit,dvr,htsp_dvr,all_dvr,all_rw_dvr,' + 'dvr_config,channel_min,channel_max,channel_tag,comment'; + var list2 = 'enabled,username,password,prefix,' + + 'webui,admin,' + + 'streaming,adv_streaming,htsp_streaming,' + + 'profile,conn_limit,dvr,htsp_dvr,all_dvr,all_rw_dvr,' + + 'failed_dvr,dvr_config,channel_min,channel_max,channel_tag,' + + 'comment'; + tvheadend.idnode_grid(panel, { url: 'api/access/entry', titleS: 'Access Entry', @@ -36,13 +43,13 @@ tvheadend.acleditor = function(panel, index) tabIndex: index, edit: { params: { - list: list + list: list2 } }, add: { url: 'api/access/entry', params: { - list: list + list: list2 }, create: { } },