From: Jaroslav Kysela Date: Tue, 19 Jan 2016 16:27:11 +0000 (+0100) Subject: wizard: fix the network / tuner assignment and tuner enable X-Git-Tag: v4.2.1~1153 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c6734e530cc6dffa4e151ef632c3509e602e1e2f;p=thirdparty%2Ftvheadend.git wizard: fix the network / tuner assignment and tuner enable --- diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 07e38ddd8..3926802d7 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -783,6 +783,8 @@ int mpegts_input_grace ( mpegts_input_t * mi, mpegts_mux_t * mm ); int mpegts_input_is_enabled ( mpegts_input_t * mi, mpegts_mux_t *mm, int flags ); +void mpegts_input_set_enabled ( mpegts_input_t *mi, int enabled ); + void mpegts_input_empty_status ( mpegts_input_t *mi, tvh_input_stream_t *st ); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index ef0f90e9b..f95b4073e 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -1753,24 +1753,33 @@ linuxdvb_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *lang const char *ntype = htsmsg_get_str(conf, "mpegts_network_type"); mpegts_network_t *mn; + if (LIST_FIRST(&lfe->mi_mux_active)) + return; mn = linuxdvb_frontend_wizard_network(lfe); if (ntype && (mn == NULL || mn->mn_wizard)) { htsmsg_t *nlist; mpegts_network_wizard_create(ntype, &nlist, lang); if (lfe->lfe_satconf) { htsmsg_t *conf = htsmsg_create_map(); - htsmsg_add_msg(conf, "networks", nlist); - linuxdvb_satconf_create(lfe, NULL, NULL, conf); - mn = linuxdvb_frontend_wizard_network(lfe); + htsmsg_t *elems = htsmsg_create_list(); + htsmsg_t *elem = htsmsg_create_map(); + htsmsg_add_str(conf, "type", "simple"); + htsmsg_add_bool(elem, "enable", 1); + htsmsg_add_msg(elem, "networks", nlist); + htsmsg_add_msg(elems, NULL, elem); + htsmsg_add_msg(conf, "elements", elems); + if (lfe->lfe_satconf) { + linuxdvb_satconf_delete(lfe->lfe_satconf, 0); + lfe->lfe_satconf = NULL; + } + lfe->lfe_satconf = linuxdvb_satconf_create(lfe, NULL, NULL, conf); htsmsg_destroy(conf); } else { mpegts_input_set_networks((mpegts_input_t *)lfe, nlist); htsmsg_destroy(nlist); } - if (mn) { - mn->mn_wizard = 1; - mn->mn_config_save(mn); - } + if (linuxdvb_frontend_wizard_network(lfe)) + mpegts_input_set_enabled((mpegts_input_t *)lfe, 1); } } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 00b815a9e..e99dc8fa8 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -987,7 +987,7 @@ linuxdvb_satconf_create if (conf) { /* Load elements */ - // Note: we do things this way else hte orbital_pos field in advanced + // Note: we do things this way else the orbital_pos field in advanced // will result in extra elements if ((l = htsmsg_get_list(conf, "elements"))) { HTSMSG_FOREACH(f, l) { diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 343ad4d18..078849c2b 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -332,6 +332,18 @@ mpegts_input_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm, int flags ) return mi->mi_enabled; } +void +mpegts_input_set_enabled ( mpegts_input_t *mi, int enabled ) +{ + enabled = !!enabled; + if (mi->mi_enabled != enabled) { + htsmsg_t *conf = htsmsg_create_map(); + htsmsg_add_bool(conf, "enabled", enabled); + idnode_update(&mi->ti_id, conf); + htsmsg_destroy(conf); + } +} + static void mpegts_input_display_name ( mpegts_input_t *mi, char *buf, size_t len ) { diff --git a/src/input/mpegts/mpegts_network.c b/src/input/mpegts/mpegts_network.c index 6d22087e2..0f10cbf69 100644 --- a/src/input/mpegts/mpegts_network.c +++ b/src/input/mpegts/mpegts_network.c @@ -507,15 +507,23 @@ mpegts_network_wizard_create if (nlist) *nlist = NULL; + mnb = mpegts_network_builder_find(clazz); if (mnb == NULL) return; + /* only one network per type */ + LIST_FOREACH(mn, &mpegts_network_all, mn_global_link) + if (mn->mn_id.in_class == mnb->idc) + goto found; + conf = htsmsg_create_map(); htsmsg_add_str(conf, "networkname", idclass_get_caption(mnb->idc, lang)); htsmsg_add_bool(conf, "wizard", 1); mn = mnb->build(mnb->idc, conf); htsmsg_destroy(conf); + +found: if (mn && nlist) { *nlist = htsmsg_create_list(); htsmsg_add_str(*nlist, NULL, idnode_uuid_as_str(&mn->mn_id, buf)); diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index fd7b86eb1..f0612e154 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -1797,11 +1797,18 @@ satip_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *lang ) mn = satip_frontend_wizard_network(lfe); if (ntype && lfe->sf_master == 0 && (mn == NULL || mn->mn_wizard)) { htsmsg_t *conf = htsmsg_create_map(); + htsmsg_t *list = htsmsg_create_list(); + htsmsg_t *pos = htsmsg_create_map(); htsmsg_t *nlist; mpegts_network_wizard_create(ntype, &nlist, lang); - htsmsg_add_msg(conf, "networks", nlist); + htsmsg_add_bool(pos, "enabled", 1); + htsmsg_add_msg(pos, "networks", nlist); + htsmsg_add_msg(list, NULL, pos); + htsmsg_add_msg(conf, "satconf", list); satip_satconf_create(lfe, conf, satip_frontend_default_positions(lfe)); htsmsg_destroy(conf); + if (satip_frontend_wizard_network(lfe)) + mpegts_input_set_enabled((mpegts_input_t *)lfe, 1); } } diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c index 3b5d10755..31515339f 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c @@ -626,6 +626,8 @@ tvhdhomerun_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *la htsmsg_add_str(nlist, NULL, ntype); mpegts_input_set_networks((mpegts_input_t *)hfe, nlist); htsmsg_destroy(nlist); + if (tvhdhomerun_frontend_wizard_network(hfe)) + mpegts_input_set_enabled((mpegts_input_t *)hfe, 1); } } diff --git a/src/wizard.c b/src/wizard.c index 89ce8b458..2767aef97 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -322,6 +322,7 @@ static void login_save(idnode_t *in) pw->pw_wizard = 1; passwd_entry_save(pw); } + htsmsg_destroy(conf); } if (w->username[0]) { @@ -347,6 +348,7 @@ static void login_save(idnode_t *in) pw->pw_wizard = 1; passwd_entry_save(pw); } + htsmsg_destroy(conf); } } } @@ -727,7 +729,7 @@ static void muxes_save(idnode_t *in) if (idnode_is_instance(&mn->mn_id, &dvb_network_class) && w->muxes[idx][0]) { dvb_network_scanfile_set((dvb_network_t *)mn, w->muxes[idx]); } else if (idnode_is_instance(&mn->mn_id, &iptv_auto_network_class) && - w->iptv_url[0]) { + w->iptv_url[idx]) { m = htsmsg_create_map(); htsmsg_add_str(m, "url", w->iptv_url[idx]); idnode_load(&mn->mn_id, m); @@ -851,7 +853,7 @@ MUXES_FCN(5) MUXES_FCN(6) DESCRIPTION_FCN(muxes, N_("\ -Assign predefined mxues to networks.\ +Assign predefined muxes to networks.\ ")) wizard_page_t *wizard_muxes(const char *lang) @@ -893,7 +895,7 @@ wizard_page_t *wizard_muxes(const char *lang) mpegts_network_t *mn; int idx, midx = 0; - page->aux = w = calloc(1, sizeof(wizard_network_t)); + page->aux = w = calloc(1, sizeof(wizard_muxes_t)); ic->ic_groups = groups; ic->ic_properties = w->props; ic->ic_save = muxes_save; @@ -912,6 +914,7 @@ wizard_page_t *wizard_muxes(const char *lang) w->props[idx++] = nprops[midx * 3 + 2]; midx++; } else if (idnode_is_instance(&mn->mn_id, &iptv_auto_network_class)) { + snprintf(w->iptv_url[midx], sizeof(w->iptv_url[midx]), "%s", ((iptv_network_t *)mn)->in_url ?: ""); w->props[idx++] = iptvprops[midx * 3 + 0]; w->props[idx++] = iptvprops[midx * 3 + 1]; w->props[idx++] = iptvprops[midx * 3 + 2]; @@ -954,7 +957,7 @@ wizard_page_t *wizard_status(const char *lang) }, ICON(), DESCRIPTION(status), - PREV_BUTTON(input), + PREV_BUTTON(muxes), NEXT_BUTTON(mapping), {} };