]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
webui: add some processing of capabilities for dynamic tab inclusion.
authorAdam Sutton <dev@adamsutton.me.uk>
Wed, 19 Dec 2012 22:17:18 +0000 (22:17 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Wed, 19 Dec 2012 22:30:16 +0000 (22:30 +0000)
src/webui/extjs.c
src/webui/static/app/tvheadend.js

index efb79c80f7ab02b8e3e1e9559e5bd613a76fa101..059417c0b2f63bcf6e87bd0bdd61aae5cc1bbfd8 100644 (file)
@@ -1941,6 +1941,26 @@ extjs_config(http_connection_t *hc, const char *remain, void *opaque)
   return 0;
 }
 
+/**
+ * Capability check
+ */
+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_json_serialize(l, hq, 0);
+  htsmsg_destroy(l);
+  http_output_content(hc, "text/x-json; charset=UTF-8");
+  return 0;
+}
+
 /**
  * WEB user interface
  */
@@ -1949,6 +1969,7 @@ extjs_start(void)
 {
   http_path_add("/about.html",       NULL, page_about,             ACCESS_WEB_INTERFACE);
   http_path_add("/extjs.html",       NULL, extjs_root,             ACCESS_WEB_INTERFACE);
+  http_path_add("/capabilities",     NULL, extjs_capabilities,     ACCESS_WEB_INTERFACE);
   http_path_add("/tablemgr",         NULL, extjs_tablemgr,         ACCESS_WEB_INTERFACE);
   http_path_add("/channels",         NULL, extjs_channels,         ACCESS_WEB_INTERFACE);
   http_path_add("/epggrab",          NULL, extjs_epggrab,          ACCESS_WEB_INTERFACE);
index 3b44f6cadc417cff1a9ecb5f8cc7936c26b7b42b..2a1af2b7e313439af5e99bb98f8bba9fd11f783c 100644 (file)
@@ -1,3 +1,6 @@
+tvheadend.accessupdate = null;
+tvheadend.capabilties  = null;
+
 /**
  * Displays a help popup window
  */
@@ -27,6 +30,21 @@ tvheadend.help = function(title, pagename) {
        });
 }
 
+/*
+ * General capabilities
+ */
+Ext.Ajax.request({
+  url: '/capabilities',
+  success: function(d)
+  {
+    if (d && d.responseText)
+      tvheadend.capabilities = Ext.util.JSON.decode(d.responseText);
+    if (tvheadend.capabilities && tvheadend.accessupdate)
+      accessUpdate(tvheadend.accessUpdate);
+    
+  }
+});
+
 /**
  * Displays a mediaplayer using VLC plugin
  */
@@ -223,6 +241,7 @@ tvheadend.VLC = function(url) {
  * Obviosuly, access is verified in the server too.
  */
 function accessUpdate(o) {
+  tvheadend.accessUpdate = o;
 
        if (o.dvr == true && tvheadend.dvrpanel == null) {
                tvheadend.dvrpanel = new tvheadend.dvr;
@@ -237,12 +256,22 @@ function accessUpdate(o) {
                        iconCls : 'wrench',
                        items : [ new tvheadend.miscconf, new tvheadend.chconf,
                                new tvheadend.epggrab, new tvheadend.cteditor,
-                               new tvheadend.dvrsettings, new tvheadend.tvadapters,
-                               new tvheadend.iptv, new tvheadend.acleditor,
-                               new tvheadend.cwceditor, new tvheadend.capmteditor ]
+                               new tvheadend.dvrsettings, 
+                               new tvheadend.iptv, new tvheadend.acleditor ]
                });
                tvheadend.rootTabPanel.add(tvheadend.confpanel);
        }
+  if (tvheadend.capabilities && tvheadend.confpanel) {
+    if (tvheadend.capabilities.indexOf('linuxdvb') != -1 ||
+        tvheadend.capabilities.indexOf('v4l')      != -1) {
+      tvheadend.confpanel.add(new tvheadend.tvadapters);
+    }
+    if (tvheadend.capabilities.indexOf('cwc')      != -1) {
+      tvheadend.confpanel.add(new tvheadend.cwceditor);
+      tvheadend.confpanel.add(new tvheadend.capmteditor);
+    }
+    tvheadend.confpanel.doLayout();
+  }
 
        if (o.admin == true && tvheadend.statuspanel == null) {
                tvheadend.statuspanel = new tvheadend.status;