diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 5d235778..6134839d 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -298,6 +298,7 @@ extjs_channels_delete(htsmsg_t *in) channel_delete(ch); } +#include "epggrab/private.h" /** * @@ -336,6 +337,42 @@ extjs_channels_update(htsmsg_t *in) if((s = htsmsg_get_str(c, "number")) != NULL) channel_set_number(ch, atoi(s)); + + if((s = htsmsg_get_str(c, "epggrabsrc")) != NULL) { + char *sptr; + char *modecid = strtok_r((char*)s, ",", &sptr); + char *modid, *ecid; + epggrab_module_t *mod; + epggrab_channel_t *ec; + + /* Clear existing */ + LIST_FOREACH(mod, &epggrab_modules, link) { + if (mod->type != EPGGRAB_OTA && mod->channels) { + RB_FOREACH(ec, mod->channels, link) { + if (ec->channel == ch) { + ec->channel = NULL; + mod->ch_save(mod, ec); + } + } + } + } + + /* Add new */ + while (modecid) { + modid = strtok(modecid, "|"); + ecid = strtok(NULL, "|"); + modecid = strtok_r(NULL, ",", &sptr); + + if (!(mod = epggrab_module_find_by_id(modid))) + continue; + if (!mod->channels) + continue; + if (!(ec = epggrab_channel_find(mod->channels, ecid, 0, NULL, mod))) + continue; + + epggrab_channel_link(ec, ch); + } + } } } @@ -352,6 +389,9 @@ extjs_channels(http_connection_t *hc, const char *remain, void *opaque) channel_tag_mapping_t *ctm; const char *op = http_arg_get(&hc->hc_req_args, "op"); const char *entries = http_arg_get(&hc->hc_req_args, "entries"); + char *epggrabsrc; + epggrab_module_t *mod; + epggrab_channel_t *ec; if(op == NULL) return 400; @@ -386,6 +426,27 @@ extjs_channels(http_connection_t *hc, const char *remain, void *opaque) htsmsg_add_s32(c, "epg_post_end", ch->ch_dvr_extra_time_post); htsmsg_add_s32(c, "number", ch->ch_number); + epggrabsrc = NULL; + LIST_FOREACH(mod, &epggrab_modules, link) { + if (mod->type != EPGGRAB_OTA && mod->channels) { + RB_FOREACH(ec, mod->channels, link) { + if (ec->channel == ch) { + char id[100]; + sprintf(id, "%s|%s", mod->id, ec->id); + if (!epggrabsrc) { + epggrabsrc = strdup(id); + } else { + epggrabsrc = realloc(epggrabsrc, strlen(epggrabsrc) + 2 + strlen(id)); + strcat(epggrabsrc, ","); + strcat(epggrabsrc, id); + } + } + } + } + } + if (epggrabsrc) htsmsg_add_str(c, "epggrabsrc", epggrabsrc); + free(epggrabsrc); + htsmsg_add_msg(array, NULL, c); } diff --git a/src/webui/static/app/chconf.js b/src/webui/static/app/chconf.js index 18476ec7..0004a050 100644 --- a/src/webui/static/app/chconf.js +++ b/src/webui/static/app/chconf.js @@ -27,7 +27,7 @@ tvheadend.comet.on('channeltags', function(m) { tvheadend.channels = new Ext.data.JsonStore({ autoLoad: true, root:'entries', - fields: ['name', 'chid', 'xmltvsrc', 'tags', 'ch_icon', + fields: ['name', 'chid', 'epggrabsrc', 'tags', 'ch_icon', 'epg_pre_start', 'epg_post_end', 'number'], id: 'chid', sortInfo: { field: 'number', direction: "ASC" }, @@ -104,16 +104,6 @@ tvheadend.mergeChannel = function(chan) { */ tvheadend.chconf = function() { - var xmltvChannels = new Ext.data.JsonStore({ - root:'entries', - fields: ['xcTitle','xcIcon'], - url:'xmltv', - baseParams: { - op: 'listChannels' - } - }); - - var fm = Ext.form; var actions = new Ext.ux.grid.RowActions({ @@ -169,20 +159,20 @@ tvheadend.chconf = function() } }, { - header: "XMLTV source", - dataIndex: 'xmltvsrc', + header: "EPG Grab source", + dataIndex: 'epggrabsrc', width: 150, - editor: new fm.ComboBox({ + editor: new Ext.ux.form.LovCombo({ loadingText: 'Loading...', - store: xmltvChannels, + store: tvheadend.epggrabChannels, allowBlank: true, typeAhead: true, minChars: 2, lazyRender: true, triggerAction: 'all', mode: 'remote', - displayField:'xcTitle', - valueField:'xcTitle' + displayField:'mod-name', + valueField:'mod-id' }) }, {