]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Added channel list function to epggrab, however as yet not sure how best to integrate...
authorAdam Sutton <dev@adamsutton.me.uk>
Fri, 8 Jun 2012 12:28:39 +0000 (13:28 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 30 Jul 2012 14:47:53 +0000 (15:47 +0100)
src/epggrab.c
src/epggrab/pyepg.c
src/epggrab/xmltv.c
src/webui/extjs.c
src/webui/static/app/xmltv.js [deleted file]

index b5a315bb9290a5c95695ec43e81b2a2b6085711a..8e91b1218bfb9d23690f521aad20dbe78414a631 100644 (file)
@@ -617,6 +617,30 @@ void epggrab_channel_updated ( epggrab_channel_t *ec )
   epggrab_module_channel_save(ec->mod, ec);
 }
 
+// TODO: currently lists ALL channels from ALL active modules
+// TODO: won't work if channels are handled internally within module!
+htsmsg_t *epggrab_channel_list ( void )
+{
+  char name[100];
+  epggrab_module_t *mod;
+  epggrab_channel_t *ec;
+  htsmsg_t *e, *m;
+  m = htsmsg_create_list();
+  LIST_FOREACH(mod, &epggrab_modules, link) {
+    if (mod->enabled && mod->channels) {
+      RB_FOREACH(ec, mod->channels, link) {
+        e = htsmsg_create_map();
+        htsmsg_add_str(e, "module", mod->id);
+        htsmsg_add_str(e, "id",     ec->id);
+        sprintf(name, "%s: %s", mod->name, ec->name);
+        htsmsg_add_str(e, "name", name);
+        htsmsg_add_msg(m, NULL, e);
+      }
+    }
+  }
+  return m;
+}
+
 /* **************************************************************************
  * Configuration
  * *************************************************************************/
@@ -695,12 +719,14 @@ int epggrab_set_module ( epggrab_module_t *mod )
 {
   int save = 0;
   if ( epggrab_module != mod ) {
+    if (epggrab_module) epggrab_enable_module(epggrab_module, 0);
     if (mod) {
       assert(mod->grab);
       assert(mod->trans);
       assert(mod->parse);
     }
     epggrab_module = mod;
+    if (epggrab_module) epggrab_enable_module(epggrab_module, 1);
     save           = 1;
   }
   return save;
index d58ac3e78d617d6d9646d8095734039234e03469..c89d78f945fe1ffd9ad176ac5db1b1ed363fc3a4 100644 (file)
@@ -429,6 +429,7 @@ void pyepg_init ( epggrab_module_list_t *list )
   mod->id                  = strdup("pyepg_ext");
   mod->path                = epggrab_module_socket_path("pyepg");
   mod->name                = strdup("PyEPG");
+  mod->channels            = &_pyepg_channels;
   mod->enable              = epggrab_module_enable_socket;
   mod->trans               = epggrab_module_trans_xml;
   mod->parse               = _pyepg_parse;
index fed77492568ab3711104f766d7434f4d720d0b67..4823a2a02baded37063c00add4596428c0ccce99 100644 (file)
@@ -414,6 +414,7 @@ static void _xmltv_load_grabbers ( epggrab_module_list_t *list )
       mod                      = calloc(1, sizeof(epggrab_module_t));
       mod->id = mod->path      = strdup(&outbuf[p]);
       mod->name                = malloc(200);
+      mod->channels            = &_xmltv_channels;
       sprintf((char*)mod->name, "XMLTV: %s", &outbuf[n]);
       *((uint8_t*)&mod->flags) = EPGGRAB_MODULE_SIMPLE;
       mod->grab                = epggrab_module_grab;
index 996ffa5348dc31e479760486b32643ddefc5af8d..f6c73a754c6928588948c6f517a48970a74b3fd9 100644 (file)
@@ -42,7 +42,6 @@
 #include "epggrab.h"
 #include "epg.h"
 #include "iptv_input.h"
-#include "epggrab/xmltv.h"
 
 static void
 extjs_load(htsbuf_queue_t *hq, const char *script)
@@ -507,6 +506,14 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
     pthread_mutex_unlock(&epggrab_mutex);
     htsmsg_add_msg(out, "entries", array);
 
+  /* Channel list */
+  } else if (!strcmp(op, "channelList")) {
+    out = htsmsg_create_map();
+    pthread_mutex_lock(&global_lock);
+    array = epggrab_channel_list();
+    pthread_mutex_unlock(&global_lock);
+    htsmsg_add_msg(out, "entries", array);
+
   /* Save settings */
   } else if (!strcmp(op, "saveSettings") ) {
     int save = 0;
@@ -538,6 +545,7 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
     return HTTP_STATUS_BAD_REQUEST;
   }
 
+  htsmsg_print(out);
   htsmsg_json_serialize(out, hq, 0);
   htsmsg_destroy(out);
   http_output_content(hc, "text/x-json; charset=UTF-8");
diff --git a/src/webui/static/app/xmltv.js b/src/webui/static/app/xmltv.js
deleted file mode 100644 (file)
index 51bed3d..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-tvheadend.grabberStore = new Ext.data.JsonStore({
-    root:'entries',
-    fields: ['identifier','name','version','apiconfig'],
-    url:'xmltv',
-    baseParams: {
-       op: 'listGrabbers'
-    }
-});
-
-tvheadend.xmltv = function() {
-
-    var confreader = new Ext.data.JsonReader({
-       root: 'xmltvSettings'
-    }, ['grabber','grabinterval','grabenable']);
-
-    var grabberSelect = new Ext.form.ComboBox({
-       loadingText: 'Loading, please wait...',
-       fieldLabel: 'XML-TV Source',
-       name: 'grabber',
-       width: 350,
-       displayField:'name',
-       valueField:'identifier',
-       store: tvheadend.grabberStore,
-       forceSelection: true,
-       editable: false,
-       triggerAction: 'all',
-       mode: 'remote',
-       emptyText: 'Select grabber'
-    });
-
-    var confpanel = new Ext.FormPanel({
-       title:'XML TV',
-       iconCls: 'xml',
-       border:false,
-       bodyStyle:'padding:15px',
-       labelAlign: 'right',
-       labelWidth: 200,
-       waitMsgTarget: true,
-       reader: confreader,
-       layout: 'form',
-       defaultType: 'textfield',
-       items: [
-           grabberSelect,
-           new Ext.form.NumberField({
-               allowNegative: false,
-               allowDecimals: false,
-               minValue: 1,
-               maxValue: 100,
-               fieldLabel: 'Grab interval (hours)',
-               name: 'grabinterval'
-           }), new Ext.form.Checkbox({
-               fieldLabel: 'Enable grabbing',
-               name: 'grabenable'
-           })
-       ],
-       tbar: [{
-           tooltip: 'Save changes made to configuration below',
-           iconCls:'save',
-           text: "Save configuration",
-           handler: saveChanges
-       }, '->', {
-           text: 'Help',
-           handler: function() {
-               new tvheadend.help('XMLTV configuration', 
-                                  'config_xmltv.html');
-           }
-       }]
-       
-    });
-
-    confpanel.on('render', function() {
-       confpanel.getForm().load({
-           url:'xmltv', 
-           params:{'op':'loadSettings'},
-           success:function(form, action) {
-               confpanel.enable();
-           }
-       });
-    });
-
-
-    grabberSelect.on('select', function(c,r,i) {
-
-           Ext.MessageBox.alert('XMLTV',
-                                'Make sure that the grabber is properly ' +
-                                'configured before saving configuration.<br>'+
-                                '<br>' +
-                                'To configure manually execute the ' +
-                                'following command in a shell on the ' +
-                                'server:<br>' +
-                                '$ ' + r.data.identifier + 
-                                ' --configure<br>' +
-                                '<br>' +
-                                'Note: It is important to configure the ' +
-                                'grabber using the same userid as tvheadend '+
-                                'since most grabbers save their '+
-                                'configuration in the users home directory.'+
-                                '<br>' +
-                                '<br>' +
-                                'Grabber version: ' + r.data.version
-                               );
-
-/*
-       if(r.data.apiconfig) {
-
-           Ext.MessageBox.confirm('XMLTV',
-                                  'Configure grabber? ' +
-                                  'If you know that the grabber is already '+
-                                  'set up or if you want to configure it '+
-                                  'manually you may skip this step',
-                                  function(button) {
-                                      Ext.MessageBox.alert('XMLTV',
-                                                           'oops, embedded '+
-                                                           'config not '+
-                                                           'implemeted yet');
-                                  }
-                                 );
-
-       } else {
-           Ext.MessageBox.alert('XMLTV',
-                                'This grabber does not support being ' +
-                                'configured from external application ' +
-                                '(such as Tvheadend).<br>' +
-                                'Make sure that the grabber is properly ' +
-                                'configured before saving configuration.<br>'+
-                                '<br>' +
-                                'To configure manually execute the ' +
-                                'following command in a shell on the ' +
-                                'server:<br>' +
-                                '$ ' + r.data.identifier + 
-                                ' --configure<br>' +
-                                '<br>' +
-                                'Note: It is important to configure the ' +
-                                'grabber using the same userid as tvheadend '+
-                                'since most grabbers save their '+
-                                'configuration in the users home directory.'+
-                                '<br>' +
-                                '<br>' +
-                                'Grabber version: ' + r.data.version
-                               );
-       }
-*/
-    });
-
-    function saveChanges() {
-       confpanel.getForm().submit({
-           url:'xmltv', 
-           params:{'op':'saveSettings'},
-           waitMsg:'Saving Data...',
-           failure: function(form, action) {
-               Ext.Msg.alert('Save failed', action.result.errormsg);
-           }
-       });
-    }
-
-    return confpanel;
-}
-