]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Minor addition to the way the server capabilities are checked.
authorAdam Sutton <dev@adamsutton.me.uk>
Sat, 5 Jan 2013 15:27:39 +0000 (15:27 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Sat, 5 Jan 2013 15:36:33 +0000 (15:36 +0000)
src/htsp_server.c
src/main.c
src/tvheadend.h
src/webui/extjs.c

index dece14a5914f3be6a03618433a665dba9e4cee7e..4b6ab6a303e38b233908c2ce2b1cf5910b7e40b9 100644 (file)
@@ -695,10 +695,9 @@ htsp_build_event
 static htsmsg_t *
 htsp_method_hello(htsp_connection_t *htsp, htsmsg_t *in)
 {
-  htsmsg_t *l, *r = htsmsg_create_map();
+  htsmsg_t *r;
   uint32_t v;
   const char *name;
-  int i = 0;
 
   if(htsmsg_get_u32(in, "htspversion", &v))
     return htsp_error("Missing argument 'htspversion'");
@@ -706,6 +705,8 @@ htsp_method_hello(htsp_connection_t *htsp, htsmsg_t *in)
   if((name = htsmsg_get_str(in, "clientname")) == NULL)
     return htsp_error("Missing argument 'clientname'");
 
+  r = htsmsg_create_map();
+
   tvh_str_update(&htsp->htsp_clientname, htsmsg_get_str(in, "clientname"));
 
   tvhlog(LOG_INFO, "htsp", "%s: Welcomed client software: %s (HTSPv%d)",
@@ -717,12 +718,7 @@ htsp_method_hello(htsp_connection_t *htsp, htsmsg_t *in)
   htsmsg_add_bin(r, "challenge", htsp->htsp_challenge, 32);
 
   /* Capabilities */
-  l = htsmsg_create_list();
-  while (tvheadend_capabilities[i]) {
-    htsmsg_add_str(l, NULL, tvheadend_capabilities[i]);
-    i++;
-  }
-  htsmsg_add_msg(r, "servercapability", l);
+  htsmsg_add_msg(r, "servercapability", tvheadend_capabilities_list(1));
 
   /* Set version to lowest num */
   htsp->htsp_version = MIN(HTSP_PROTO_VERSION, v);
index d56c63cb8448f93b3f76f152c933477b9d2ac3e7..704f6e4b400b8518ba93fc33f18c121a5b286a9c 100644 (file)
@@ -79,21 +79,20 @@ int htsp_port;
 int htsp_port_extra;
 const char *tvheadend_cwd;
 const char *tvheadend_webroot;
-
-const char *tvheadend_capabilities[] = {
+const tvh_caps_t tvheadend_capabilities[] = {
 #if ENABLE_CWC
-  "cwc",
+  { "cwc", NULL },
 #endif
 #if ENABLE_V4L
-  "v4l",
+  { "v4l", NULL },
 #endif
 #if ENABLE_LINUXDVB
-  "linuxdvb",
+  { "linuxdvb", NULL },
 #endif
 #if ENABLE_IMAGECACHE
-  "imagecache",
+  { "imagecache", &imagecache_enabled },
 #endif
-  NULL
+  { NULL, NULL }
 };
 
 static void
index 9bdaf1f243578b0ea79c7743764e5f1d85459dc1..b5d54c47e052df509b978edc6b9493ceea229015 100644 (file)
 #include "queue.h"
 #include "avg.h"
 #include "hts_strtab.h"
+#include "htsmsg.h"
 
 #include "redblack.h"
 
-extern const char *tvheadend_version;
-extern const char *tvheadend_cwd;
-extern const char *tvheadend_capabilities[];
-extern const char *tvheadend_webroot;
+typedef struct {
+  const char     *name;
+  const uint32_t *enabled;
+} tvh_caps_t;
+extern const char      *tvheadend_version;
+extern const char      *tvheadend_cwd;
+extern const char      *tvheadend_webroot;
+extern const tvh_caps_t tvheadend_capabilities[];
+
+static inline htsmsg_t *tvheadend_capabilities_list(int check)
+{
+  int i = 0;
+  htsmsg_t *r = htsmsg_create_list();
+  while (tvheadend_capabilities[i].name) {
+    if (!check ||
+        !tvheadend_capabilities[i].enabled ||
+        *tvheadend_capabilities[i].enabled)
+      htsmsg_add_str(r, NULL, tvheadend_capabilities[i].name);
+    i++;
+  }
+  return r;
+}
 
 #define PTS_UNSET INT64_C(0x8000000000000000)
 
@@ -369,6 +388,7 @@ static inline unsigned int tvh_strhash(const char *s, unsigned int mod)
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 
 void tvh_str_set(char **strp, const char *src);
 int tvh_str_update(char **strp, const char *src);
index 1fc3a8bfd050b51cb79d723b662300ef75bcf765..deca304b4e165d98e1c5c89a85ffa26d0951c753 100644 (file)
@@ -1986,13 +1986,7 @@ static int
 extjs_capabilities(http_connection_t *hc, const char *remain, void *opaque)
 {
   htsbuf_queue_t *hq = &hc->hc_reply;
-  htsmsg_t *l;
-  int i = 0;
-  l = htsmsg_create_list();
-  while (tvheadend_capabilities[i]) {
-    htsmsg_add_str(l, NULL, tvheadend_capabilities[i]);
-    i++;
-  }
+  htsmsg_t *l = tvheadend_capabilities_list(0);
   htsmsg_json_serialize(l, hq, 0);
   htsmsg_destroy(l);
   http_output_content(hc, "text/x-json; charset=UTF-8");