]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Removed the EIT enabled flag and using proper OTA config system.
authorAdam Sutton <dev@adamsutton.me.uk>
Mon, 18 Jun 2012 12:33:02 +0000 (13:33 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 30 Jul 2012 14:49:49 +0000 (15:49 +0100)
src/epggrab.c
src/epggrab.h
src/epggrab/eit.c
src/epggrab/pyepg.c
src/epggrab/xmltv.c
src/webui/extjs.c
src/webui/static/app/epggrab.js

index 8302d3e2f15af1a9c8a4eeb7dff345f94cb9b7dc..c36b7bbb832c1bfd907635a98b6a3d663bcdefb2 100644 (file)
@@ -29,7 +29,6 @@ pthread_mutex_t       epggrab_mutex;
 pthread_cond_t        epggrab_cond;
 
 /* Config */
-uint32_t              epggrab_eitenabled;
 uint32_t              epggrab_interval;
 epggrab_module_t*     epggrab_module;
 epggrab_module_list_t epggrab_modules;
@@ -664,7 +663,6 @@ static void _epggrab_load ( void )
 
   /* Process */
   if (m) {
-    htsmsg_get_u32(m, "eit",      &epggrab_eitenabled);
     if (!htsmsg_get_u32(m, old ? "grab-interval" : "interval", &epggrab_interval))
       if (old) epggrab_interval *= 3600;
     htsmsg_get_u32(m, "grab-enabled", &enabled);
@@ -727,7 +725,6 @@ void epggrab_save ( void )
 
   /* Save */
   m = htsmsg_create_map();
-  htsmsg_add_u32(m, "eitenabled", epggrab_eitenabled);
   htsmsg_add_u32(m, "interval",   epggrab_interval);
   if ( epggrab_module )
     htsmsg_add_str(m, "module", epggrab_module->id);
@@ -743,17 +740,6 @@ void epggrab_save ( void )
   htsmsg_destroy(m);
 }
 
-int epggrab_set_eitenabled ( uint32_t eitenabled )
-{
-  // TODO: could use module variable
-  int save = 0;
-  if ( epggrab_eitenabled != eitenabled ) {
-    save = 1;
-    epggrab_eitenabled = eitenabled;
-  }
-  return save;
-}
-
 int epggrab_set_interval ( uint32_t interval )
 {
   int save = 0;
@@ -813,7 +799,6 @@ int epggrab_enable_module_by_id ( const char *id, uint8_t e )
 void epggrab_init ( void )
 {
   /* Defaults */
-  epggrab_eitenabled = 1;         // on air grab enabled
   epggrab_interval   = 12 * 3600; // hours
   epggrab_module     = NULL;      // disabled
 
index 36e5d87a6c8a48b97c6d3cc5ad2603e4e9093685..88e3bb15bcbebef1e4c328ff92337c7d649ccf9e 100644 (file)
@@ -86,9 +86,9 @@ void epggrab_channel_link ( epggrab_channel_t *ch );
 /*
  * Grabber flags
  */
-#define EPGGRAB_MODULE_SIMPLE   0x01
-#define EPGGRAB_MODULE_EXTERNAL 0x02
-#define EPGGRAB_MODULE_SPECIAL  0x04
+#define EPGGRAB_MODULE_INTERNAL 0x01 ///< IP based internally run
+#define EPGGRAB_MODULE_EXTERNAL 0x02 ///< IP based externally run
+#define EPGGRAB_MODULE_OTA      0x04 ///< DVB OTA EPGs
 
 /*
  * Grabber base class
@@ -163,14 +163,12 @@ htsmsg_t*         epggrab_module_list       ( void );
  * Configuration
  */
 extern pthread_mutex_t      epggrab_mutex;
-extern uint32_t             epggrab_eitenabled;
 extern uint32_t             epggrab_interval;
 extern epggrab_module_t*    epggrab_module;
 
 /*
  * Update
  */
-int  epggrab_set_eitenabled      ( uint32_t eitenabled );
 int  epggrab_set_interval        ( uint32_t interval );
 int  epggrab_set_module          ( epggrab_module_t *module );
 int  epggrab_set_module_by_id    ( const char *id );
index 3670eacda6d56eb41b0eef58c84daea48b94c7f6..8ba807ec1aeac3afe86495fd110a235f1c822e9a 100644 (file)
 #include "epg.h"
 #include "epggrab/eit.h"
 
+static epggrab_module_t _eit_mod;
+
 /* ************************************************************************
- * Module Setup
+ * Processing
  * ***********************************************************************/
 
 static const char *
@@ -47,13 +49,13 @@ void eit_callback ( channel_t *ch, int id, time_t start, time_t stop,
   const char *description = NULL;
   char *uri;
 
+  /* Disabled? */
+  if (!_eit_mod.enabled) return;
+
   /* Ignore */
   if (!ch || !ch->ch_name || !ch->ch_name[0]) return;
   if (!title) return;
 
-  /* Disabled? */
-  if (!epggrab_eitenabled) return;
-
   /* Find broadcast */
   ebc  = epg_broadcast_find_by_time(ch, start, stop, 1, &save);
   if (!ebc) return;
@@ -97,13 +99,11 @@ void eit_callback ( channel_t *ch, int id, time_t start, time_t stop,
  * Module Setup
  * ***********************************************************************/
 
-static epggrab_module_t _eit_mod;
-
 void eit_init ( epggrab_module_list_t *list )
 {
   _eit_mod.id     = strdup("eit");
   _eit_mod.name   = strdup("EIT: On-Air Grabber");
-  *((uint8_t*)&_eit_mod.flags) = EPGGRAB_MODULE_SPECIAL;
+  *((uint8_t*)&_eit_mod.flags) = EPGGRAB_MODULE_OTA;
   LIST_INSERT_HEAD(list, &_eit_mod, link);
   // Note: this is mostly ignored anyway as EIT is treated as a special case!
 }
index 827ac7982ac88b893b9276e95ebf991ea4735a2e..7276083895eb1b6254100f27e7643c6e66850b7e 100644 (file)
@@ -427,7 +427,7 @@ void pyepg_init ( epggrab_module_list_t *list )
   mod->ch_add              = epggrab_module_channel_add;
   mod->ch_rem              = epggrab_module_channel_rem;
   mod->ch_mod              = epggrab_module_channel_mod;
-  *((uint8_t*)&mod->flags) = EPGGRAB_MODULE_SIMPLE;
+  *((uint8_t*)&mod->flags) = EPGGRAB_MODULE_INTERNAL;
   LIST_INSERT_HEAD(list, mod, link);
   _pyepg_module = mod;
 
index 0b9592981e1ddb59552a66b6b1ae17d05d470d4f..3cabdc9e2ba4ab58ca382859430e67939688485c 100644 (file)
@@ -389,7 +389,7 @@ static void _xmltv_load_grabbers ( epggrab_module_list_t *list )
       mod->name                = malloc(200);
       mod->channels            = &_xmltv_channels;
       sprintf((char*)mod->name, "XMLTV: %s", &outbuf[n]);
-      *((uint8_t*)&mod->flags) = EPGGRAB_MODULE_SIMPLE;
+      *((uint8_t*)&mod->flags) = EPGGRAB_MODULE_INTERNAL;
       mod->grab                = epggrab_module_grab;
       mod->trans               = epggrab_module_trans_xml;
       mod->parse               = _xmltv_parse;
index ee86d89ca2441ff56f0eb0bff668af333c1b2dbd..d0dcdfbe5ebbc9d421ba09e1001a778a9679651b 100644 (file)
@@ -486,7 +486,6 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
 
     pthread_mutex_lock(&epggrab_mutex);
     r = htsmsg_create_map();
-    htsmsg_add_u32(r, "eitenabled", epggrab_eitenabled);
     if (epggrab_module)
       htsmsg_add_str(r, "module", epggrab_module->id);
     htsmsg_add_u32(r, "interval", epggrab_interval);
@@ -514,8 +513,6 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
   } else if (!strcmp(op, "saveSettings") ) {
     int save = 0;
     pthread_mutex_lock(&epggrab_mutex);
-    u32 = http_arg_get(&hc->hc_req_args, "eitenabled") ? 1 : 0;
-    save |= epggrab_set_eitenabled(u32);
     if ( (str = http_arg_get(&hc->hc_req_args, "interval")) )
       save |= epggrab_set_interval(atoi(str));
     if ( (str = http_arg_get(&hc->hc_req_args, "module")) )
index f889b476afbeeec24511cc13bbad581569903d62..30c30b7189c34f790093f148b556ca0f340a4b53 100644 (file)
@@ -7,8 +7,9 @@ tvheadend.epggrab = function() {
   /*
    * Module lists (I'm sure there is a better way!)
    */
-  var EPGGRAB_MODULE_SIMPLE   = 0x01;
+  var EPGGRAB_MODULE_INTERNAL = 0x01;
   var EPGGRAB_MODULE_EXTERNAL = 0x02;
+  var EPGGRAB_MODULE_OTA      = 0x04;
 
   var moduleStore = new Ext.data.JsonStore({
     root       : 'entries',
@@ -17,20 +18,23 @@ tvheadend.epggrab = function() {
     autoLoad   : true,
     fields     : [ 'id', 'name', 'path', 'flags', 'enabled' ]
   });
-  var simpleModuleStore = new Ext.data.Store({
+  var internalModuleStore = new Ext.data.Store({
     recordType: moduleStore.recordType
   });
   var externalModuleStore = new Ext.data.Store({
     recordType: moduleStore.recordType
   });
+  var otaModuleStore = new Ext.data.Store({
+    recordType: moduleStore.recordType
+  });
   moduleStore.on('load', function() {
     moduleStore.filterBy(function(r) {
-      return r.get('flags') & EPGGRAB_MODULE_SIMPLE;
+      return r.get('flags') & EPGGRAB_MODULE_INTERNAL;
     });
-    r = new simpleModuleStore.recordType({ id: '', name : 'Disabled'});
-    simpleModuleStore.add(r);
+    r = new internalModuleStore.recordType({ id: '', name : 'Disabled'});
+    internalModuleStore.add(r);
     moduleStore.each(function(r) {
-      simpleModuleStore.add(r.copy());
+      internalModuleStore.add(r.copy());
     });
     moduleStore.filterBy(function(r) {
       return r.get('flags') & EPGGRAB_MODULE_EXTERNAL;
@@ -38,6 +42,12 @@ tvheadend.epggrab = function() {
     moduleStore.each(function(r) {
       externalModuleStore.add(r.copy());
     });
+    moduleStore.filterBy(function(r) {
+      return r.get('flags') & EPGGRAB_MODULE_OTA;
+    });
+    moduleStore.each(function(r) {
+      otaModuleStore.add(r.copy());
+    });
   });
 
   /*
@@ -46,7 +56,7 @@ tvheadend.epggrab = function() {
 
   var confreader = new Ext.data.JsonReader(
     { root: 'epggrabSettings' },
-    [ 'module', 'eitenabled', 'advanced', 'interval' ]
+    [ 'module', 'interval' ]
   );
 
   /* ****************************************************************
@@ -56,7 +66,7 @@ tvheadend.epggrab = function() {
   /*
    * Module selector
    */
-  var simpleModule = new Ext.form.ComboBox({
+  var internalModule = new Ext.form.ComboBox({
     fieldLabel     : 'Module',
     hiddenName     : 'module',
     width          : 300,
@@ -66,7 +76,7 @@ tvheadend.epggrab = function() {
     editable       : false,
     mode           : 'local',
     triggerAction  : 'all',
-    store          : simpleModuleStore
+    store          : internalModuleStore
   });
 
   /*
@@ -182,9 +192,38 @@ tvheadend.epggrab = function() {
     },
     iconCls        : 'icon-grid',
   });
-  var advancedPanel = externalGrid;
+
+  /*
+   * OTA modules
+   */
+
+  var otaSelectionModel = new Ext.grid.CheckboxSelectionModel({
+    singleSelect : false,
+    listeners : {
+      'rowselect' : function (s, ri, r) {
+        r.set('enabled', 1);
+      },
+      'rowdeselect' : function (s, ri, r) {
+        r.set('enabled', 0);
+      }
+    }
+  });
+
+  var otaGrid = new Ext.grid.EditorGridPanel({
+    store          : otaModuleStore,
+    cm             : externalColumnModel,
+    sm             : otaSelectionModel,
+    width          : 600,
+    height         : 150,
+    frame          : false,
+    viewConfig     : {
+      forceFit  : true,
+    },
+    iconCls        : 'icon-grid',
+  });
+
+  /* HACK: get display working */
   externalGrid.on('render', function(){
-    // TODO: bit of hack to get selection working
     delay = new Ext.util.DelayedTask(function(){
     rows = [];
     externalModuleStore.each(function(r){
@@ -194,16 +233,21 @@ tvheadend.epggrab = function() {
     });
     delay.delay(100);
   });
+  otaGrid.on('render', function(){
+    delay = new Ext.util.DelayedTask(function(){
+    rows = [];
+    otaModuleStore.each(function(r){
+      if (r.get('enabled')) rows.push(r);
+    });
+    otaSelectionModel.selectRecords(rows);
+    });
+    delay.delay(100);
+  });
 
   /* ****************************************************************
    * Form
    * ***************************************************************/
 
-  var eitCheck = new Ext.form.Checkbox({
-    fieldLabel    : 'EIT Enabled',
-    name          : 'eitenabled'
-  });
-
   var saveButton = new Ext.Button({
     text     : "Save configuration",
     tooltip  : 'Save changes made to configuration below',
@@ -231,12 +275,13 @@ tvheadend.epggrab = function() {
     defaultType   : 'textfield',
     items         : [
       interval,
-      eitCheck,
-      simpleModule,
+      internalModule,
       intervalValue,
       intervalUnit,
       new Ext.form.Label({text: 'External Interfaces'}),
-      advancedPanel
+      externalGrid,
+      new Ext.form.Label({text: 'OTA Modules'}),
+      otaGrid,
     ],
     tbar: [
       saveButton,
@@ -264,6 +309,9 @@ tvheadend.epggrab = function() {
     externalModuleStore.each(function(r) {
       mods.push({id: r.get('id'), enabled: r.get('enabled') ? 1 : 0});
     });  
+    otaModuleStore.each(function(r) {
+      mods.push({id: r.get('id'), enabled: r.get('enabled') ? 1 : 0});
+    });  
     mods = Ext.util.JSON.encode(mods);
     confpanel.getForm().submit({
       url     : 'epggrab', 
@@ -280,4 +328,3 @@ tvheadend.epggrab = function() {
 
   return confpanel;
 }
-