]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
ACL: Add possibility to not show the failed recordings, fixes #2569
authorJaroslav Kysela <perex@perex.cz>
Wed, 20 May 2015 17:14:09 +0000 (19:14 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 20 May 2015 17:14:09 +0000 (19:14 +0200)
docs/html/config_access.html
src/access.c
src/access.h
src/dvr/dvr.h
src/dvr/dvr_db.c
src/htsp_server.c
src/webui/static/app/acleditor.js

index 1f16125ef2ed0d311d649bd78f0dab24e9252e3e..fbe9e9dbaa451cdc738f9c52fdb93e6924702d4d 100644 (file)
@@ -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.
 
+  <dt><b>Failed DVR</b>
+  <dd>
+  Enable to access to DVR entries which were not succesfuly recorded.
+
   <dt><b>DVR Config Profile</b>
   <dd>
   If set, the user will only be able to use the DVR config profile
index c4c65999e024873ffec584223fcb2dff8070b47d..2f931d35ec502e41ec5b59031ff8851f9e64f678 100644 (file)
@@ -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);
 
index 964fe5c329eccabeaad492c75d90c1b0a7ef1ab4..68afdce8323482c445e891972adeda75483dd1f1 100644 (file)
@@ -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
index 35279b9e0a94d990d77467fb40ec3e80215673cf..1959dfc41a0d0d9693d4d57451a34155c23f0305 100644 (file)
@@ -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);
 
 /**
  *
index 39c931f2a08a1a0b323afb18daffa96eeba0819b..ccca1a9322a480ac0a012beab0d77c71869d9c12 100644 (file)
@@ -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;
+}
+
 /*
  *
  */
index ee7f04b016e9bbd16199464d1da07be250012d51..802c7cff847969ed9b9ec080c56d4dbb7d18f3c1 100644 (file)
@@ -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 */
index d5e35a76a8a50527c0c2680b8221f86b2de5ca0a..0ec941d8053e3a0d4116335046c3ec37d19c9f76 100644 (file)
@@ -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: { }
         },