]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
htsp: filter out the profiles and dvr configs without granted access
authorJaroslav Kysela <perex@perex.cz>
Sun, 19 Oct 2014 19:46:23 +0000 (21:46 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sun, 19 Oct 2014 19:46:23 +0000 (21:46 +0200)
src/htsp_server.c
src/profile.c
src/profile.h

index 8726157bb37810db81a89864eccc9508443ec7f6..8c6159006d500cf4eba462f47860c7f3a3304a4c 100644 (file)
@@ -1299,16 +1299,29 @@ static htsmsg_t *
 htsp_method_getDvrConfigs(htsp_connection_t *htsp, htsmsg_t *in)
 {
   htsmsg_t *out, *l, *c;
+  htsmsg_field_t *f;
   dvr_config_t *cfg;
+  const char *uuid, *s;
 
   l = htsmsg_create_list();
 
   LIST_FOREACH(cfg, &dvrconfigs, config_link)
     if (cfg->dvr_enabled) {
+      uuid = idnode_uuid_as_str(&cfg->dvr_id);
+      if (htsp->htsp_granted_access->aa_dvrcfgs) {
+        HTSMSG_FOREACH(f, htsp->htsp_granted_access->aa_dvrcfgs) {
+          if (!(s = htsmsg_field_get_str(f)))
+            continue;
+          if (strcmp(s, uuid) == 0)
+            break;
+        }
+        if (f == NULL)
+          continue;
+      }
       c = htsmsg_create_map();
       htsmsg_add_str(c, "uuid", idnode_uuid_as_str(&cfg->dvr_id));
-      htsmsg_add_str(c, "name", cfg->dvr_config_name);
-      htsmsg_add_str(c, "comment", cfg->dvr_comment);
+      htsmsg_add_str(c, "name", cfg->dvr_config_name ?: "");
+      htsmsg_add_str(c, "comment", cfg->dvr_comment ?: "");
       htsmsg_add_msg(l, NULL, c);
     }
 
@@ -2163,7 +2176,7 @@ htsp_method_getProfiles(htsp_connection_t *htsp, htsmsg_t *in)
   htsmsg_t *out, *l;
 
   l = htsmsg_create_list();
-  profile_get_htsp_list(l);
+  profile_get_htsp_list(l, htsp->htsp_granted_access->aa_profiles);
 
   out = htsmsg_create_map();
 
index 7d396569734209769eafaf6d70045268abafe178..12a820c28b8c18bd5f9e15f37f82894445dee4bf 100644 (file)
@@ -395,15 +395,28 @@ profile_class_get_list(void *o)
  *
  */
 void
-profile_get_htsp_list(htsmsg_t *array)
+profile_get_htsp_list(htsmsg_t *array, htsmsg_t *filter)
 {
   profile_t *pro;
   htsmsg_t *m;
+  htsmsg_field_t *f;
+  const char *uuid, *s;
 
   TAILQ_FOREACH(pro, &profiles, pro_link) {
     if (pro->pro_work) {
+      uuid = idnode_uuid_as_str(&pro->pro_id);
+      if (filter) {
+        HTSMSG_FOREACH(f, filter) {
+          if (!(s = htsmsg_field_get_str(f)))
+            continue;
+          if (strcmp(s, uuid) == 0)
+            break;
+        }
+        if (f == NULL)
+          continue;
+      }
       m = htsmsg_create_map();
-      htsmsg_add_str(m, "uuid", idnode_uuid_as_str(&pro->pro_id));
+      htsmsg_add_str(m, "uuid", uuid);
       htsmsg_add_str(m, "name", pro->pro_name ?: "");
       htsmsg_add_str(m, "comment", pro->pro_comment ?: "");
       htsmsg_add_msg(array, NULL, m);
index a0e71043f98745b8e5f2d95ad8092ac8e564afec..c8d05583e95768ec5f68f8dfae309d421f742a69 100644 (file)
@@ -116,7 +116,7 @@ const char *profile_get_name(profile_t *pro);
 static inline muxer_container_type_t profile_get_mc(profile_t *pro)
   { return pro->pro_get_mc(pro); }
 
-void profile_get_htsp_list(htsmsg_t *array);
+void profile_get_htsp_list(htsmsg_t *array, htsmsg_t *filter);
 
 void profile_init(void);
 void profile_done(void);