From: Jaroslav Kysela Date: Wed, 20 Jan 2016 12:27:20 +0000 (+0100) Subject: wizard: implement mapping / add channels dialogs X-Git-Tag: v4.2.1~1151 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98e106bb9d56bfb8f7dfff55b08312ec6ded2837;p=thirdparty%2Ftvheadend.git wizard: implement mapping / add channels dialogs --- diff --git a/src/api/api_wizard.c b/src/api/api_wizard.c index 9cc1e8780..d7128e961 100644 --- a/src/api/api_wizard.c +++ b/src/api/api_wizard.c @@ -120,6 +120,8 @@ api_wizard_init ( void ) { "wizard/status/progress", ACCESS_ADMIN, wizard_status_progress, NULL }, { "wizard/mapping/load", ACCESS_ADMIN, wizard_idnode_load_simple, wizard_mapping }, { "wizard/mapping/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_mapping }, + { "wizard/channels/load", ACCESS_ADMIN, wizard_idnode_load_simple, wizard_channels }, + { "wizard/channels/save", ACCESS_ADMIN, wizard_idnode_save_simple, wizard_channels }, { "wizard/start", ACCESS_ADMIN, wizard_start, NULL }, { "wizard/cancel", ACCESS_ADMIN, wizard_cancel, NULL }, { NULL }, diff --git a/src/service_mapper.c b/src/service_mapper.c index 40bdf5289..e2e237310 100644 --- a/src/service_mapper.c +++ b/src/service_mapper.c @@ -59,7 +59,7 @@ service_mapper_status ( void ) /* * Start a new mapping */ -static void +void service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids ) { int e, tr, qd = 0; diff --git a/src/service_mapper.h b/src/service_mapper.h index c3f3c3d17..979a0ebc1 100644 --- a/src/service_mapper.h +++ b/src/service_mapper.h @@ -51,6 +51,9 @@ extern service_mapper_t service_mapper_conf; void service_mapper_init ( void ); void service_mapper_done ( void ); +// Start service mapper +void service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids ); + // Stop pending services (remove from Q) void service_mapper_stop ( void ); diff --git a/src/webui/static/app/mpegts.js b/src/webui/static/app/mpegts.js index 7aab28059..5af7bbbf1 100644 --- a/src/webui/static/app/mpegts.js +++ b/src/webui/static/app/mpegts.js @@ -308,6 +308,7 @@ tvheadend.services = function(panel, index) conf.selected = null; } tvheadend.idnode_grid(panel, { + id: 'services', url: 'api/mpegts/service', titleS: _('Service'), titleP: _('Services'), diff --git a/src/webui/static/app/wizard.js b/src/webui/static/app/wizard.js index 84d5d6cb9..e11a0c7ea 100644 --- a/src/webui/static/app/wizard.js +++ b/src/webui/static/app/wizard.js @@ -12,7 +12,8 @@ tvheadend.wizard_start = function(page) { network: 'tvadapters', muxes: 'mpegts_network', status: 'status_streams', - mapping: 'channels', + mapping: 'services', + channels: 'channels' } function cancel(conf) { @@ -165,9 +166,9 @@ tvheadend.wizard_start = function(page) { tvheadend.wizard = page; - if (tvheadend.wizard_delayed_activation == null) { - tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask(activate_tab); - tvheadend.wizard_delayed_activation.delay(1000); + if (tvheadend.wizard_delayed_activation == null) + tvheadend.wizard_delayed_activation = new Ext.util.DelayedTask(); + tvheadend.wizard_delayed_activation.delay(1000, activate_tab); tvheadend.Ajax({ url: 'api/wizard/' + page + '/load', diff --git a/src/wizard.c b/src/wizard.c index b45f975b4..795e53e0e 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -22,6 +22,7 @@ #include "settings.h" #include "input.h" #include "input/mpegts/iptv/iptv_private.h" +#include "service_mapper.h" #include "wizard.h" /* @@ -103,21 +104,6 @@ static wizard_page_t *page_init return page; } -/* - * - */ - -static const void *hello_get_network(void *o) -{ - strcpy(prop_sbuf, "Test123"); - return &prop_sbuf_ptr; -} - -static int hello_set_network(void *o, const void *v) -{ - return 0; -} - /* * Hello */ @@ -994,8 +980,53 @@ wizard_page_t *wizard_status(const char *lang) * Service Mapping */ +typedef struct wizard_mapping { + int mapall; + int provtags; + int nettags; +} wizard_mapping_t; + +static void mapping_save(idnode_t *in) +{ + wizard_page_t *p = (wizard_page_t *)in; + wizard_mapping_t *w = p->aux; + service_mapper_conf_t conf; + + if (!w->mapall) + return; + memset(&conf, 0, sizeof(conf)); + conf.type_tags = 1; + conf.encrypted = 1; + conf.provider_tags = w->provtags; + conf.network_tags = w->nettags; + service_mapper_start(&conf, NULL); +} + +#define MAPPING_FCN(name) \ +static const void *mapping_get_##name(void *o) \ +{ \ + static int n; \ + wizard_page_t *p = o; \ + wizard_mapping_t *w = p->aux; \ + n = w->name; \ + return &n; \ +} \ +static int mapping_set_##name(void *o, const void *v) \ +{ \ + wizard_page_t *p = o; \ + wizard_mapping_t *w = p->aux; \ + w->name = *(int *)v; \ + return 1; \ +} + +MAPPING_FCN(mapall) +MAPPING_FCN(provtags) +MAPPING_FCN(nettags) + DESCRIPTION_FCN(mapping, N_("\ -Do the service mapping to channels.\ +Map all discovered services to channels.\n\ +Note: You may ommit this step (do not check the map all services) and\ +do the service to channel mapping manually.\n\ ")) @@ -1003,20 +1034,64 @@ wizard_page_t *wizard_mapping(const char *lang) { static const property_t props[] = { { - .type = PT_STR, - .id = "pnetwork", - .name = N_("Select network"), - .desc = N_("Select a Network."), - .get = hello_get_network, - .set = hello_set_network, + .type = PT_BOOL, + .id = "mapall", + .name = N_("Map all services"), + .get = mapping_get_mapall, + .set = mapping_set_mapall, + }, + { + .type = PT_BOOL, + .id = "provtags", + .name = N_("Create provider tags"), + .get = mapping_get_provtags, + .set = mapping_set_provtags, + }, + { + .type = PT_BOOL, + .id = "nettags", + .name = N_("Create network tags"), + .get = mapping_get_nettags, + .set = mapping_set_nettags, }, ICON(), DESCRIPTION(mapping), PREV_BUTTON(status), + NEXT_BUTTON(channels), + LAST_BUTTON(), + {} + }; + wizard_page_t *page = page_init("mapping", "wizard_mapping", N_("Service mapping")); + idclass_t *ic = (idclass_t *)page->idnode.in_class; + wizard_mapping_t *w; + ic->ic_properties = props; + ic->ic_save = mapping_save; + page->aux = w = calloc(1, sizeof(wizard_mapping_t)); + w->provtags = service_mapper_conf.d.provider_tags; + w->nettags = service_mapper_conf.d.network_tags; + return page; +} + +/* + * Discovered channels + */ + +DESCRIPTION_FCN(channels, N_("\ +You are finished now.\n\ +You may further customize your settings by editing channel numbers etc.\ +")) + + +wizard_page_t *wizard_channels(const char *lang) +{ + static const property_t props[] = { + ICON(), + DESCRIPTION(channels), + PREV_BUTTON(mapping), LAST_BUTTON(), {} }; - wizard_page_t *page = page_init("mapping", "wizard_service_map", N_("Service mapping")); + wizard_page_t *page = page_init("channels", "wizard_channels", N_("Service mapping")); idclass_t *ic = (idclass_t *)page->idnode.in_class; ic->ic_properties = props; return page; diff --git a/src/wizard.h b/src/wizard.h index 04096a3f1..4d25ffccc 100644 --- a/src/wizard.h +++ b/src/wizard.h @@ -37,5 +37,6 @@ wizard_page_t *wizard_network(const char *lang); wizard_page_t *wizard_muxes(const char *lang); wizard_page_t *wizard_status(const char *lang); wizard_page_t *wizard_mapping(const char *lang); +wizard_page_t *wizard_channels(const char *lang); #endif /* __TVH_WIZARD_H__ */