diff --git a/src/epggrab.c b/src/epggrab.c
index b5a315bb..8e91b121 100644
--- a/src/epggrab.c
+++ b/src/epggrab.c
@@ -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;
diff --git a/src/epggrab/pyepg.c b/src/epggrab/pyepg.c
index d58ac3e7..c89d78f9 100644
--- a/src/epggrab/pyepg.c
+++ b/src/epggrab/pyepg.c
@@ -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;
diff --git a/src/epggrab/xmltv.c b/src/epggrab/xmltv.c
index fed77492..4823a2a0 100644
--- a/src/epggrab/xmltv.c
+++ b/src/epggrab/xmltv.c
@@ -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;
diff --git a/src/webui/extjs.c b/src/webui/extjs.c
index 996ffa53..f6c73a75 100644
--- a/src/webui/extjs.c
+++ b/src/webui/extjs.c
@@ -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
index 51bed3d5..00000000
--- a/src/webui/static/app/xmltv.js
+++ /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.
'+
- '
' +
- 'To configure manually execute the ' +
- 'following command in a shell on the ' +
- 'server:
' +
- '$ ' + r.data.identifier +
- ' --configure
' +
- '
' +
- '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.'+
- '
' +
- '
' +
- '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).
' +
- 'Make sure that the grabber is properly ' +
- 'configured before saving configuration.
'+
- '
' +
- 'To configure manually execute the ' +
- 'following command in a shell on the ' +
- 'server:
' +
- '$ ' + r.data.identifier +
- ' --configure
' +
- '
' +
- '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.'+
- '
' +
- '
' +
- '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;
-}
-