Removed the EIT enabled flag and using proper OTA config system.

This commit is contained in:
Adam Sutton 2012-06-18 13:33:02 +01:00
parent 44d4536584
commit aa74afec72
7 changed files with 79 additions and 52 deletions

View 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

View 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 );

View file

@ -22,8 +22,10 @@
#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!
}

View 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;

View 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;

View 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")) )

View 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;
}