]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
wizard: implement mapping / add channels dialogs
authorJaroslav Kysela <perex@perex.cz>
Wed, 20 Jan 2016 12:27:20 +0000 (13:27 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 20 Jan 2016 12:27:20 +0000 (13:27 +0100)
src/api/api_wizard.c
src/service_mapper.c
src/service_mapper.h
src/webui/static/app/mpegts.js
src/webui/static/app/wizard.js
src/wizard.c
src/wizard.h

index 9cc1e87808f1a3e47d2f99c72e86d72d29f1ee27..d7128e961fc6905dce73f14fbf92a8dd20e170b3 100644 (file)
@@ -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 },
index 40bdf5289f7cfbd510652de44a1e1c9004f87ace..e2e237310f8b9e889f962a6c1a6434f6302cb814 100644 (file)
@@ -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;
index c3f3c3d173671ba92d83778dceb8dca5bebb107b..979a0ebc14749d27b260332e7f1c801e6c56a5a3 100644 (file)
@@ -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 );
 
index 7aab2805926d7a0c63b74d6333238a508e4980a4..5af7bbbf11fb62ee74ff516f4a6b8dc4a8794edd 100644 (file)
@@ -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'),
index 84d5d6cb936c2387f5dae2ef20d5d33a6a4763ac..e11a0c7eaac192c0369b5e26e68e9943dc301cf0 100644 (file)
@@ -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',
index b45f975b47ff5b93d817999bbe4783f7c549627b..795e53e0e7dd80efcabc75cdce9a68d0cf3cbdbc 100644 (file)
@@ -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;
index 04096a3f13a3c9356f487431bcac15ca58602fec..4d25ffccc48bd3020d155e5c32b1e4b0b0ec6a1a 100644 (file)
@@ -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__ */