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'");
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)",
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);
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
#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)
#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);
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");