Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wizard: fix the network / tuner assignment and tuner enable
  • Loading branch information
perexg committed Jan 19, 2016
1 parent 3312f65 commit c6734e5
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/input/mpegts.h
Expand Up @@ -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 );


Expand Down
23 changes: 16 additions & 7 deletions src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_satconf.c
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions src/input/mpegts/mpegts_input.c
Expand Up @@ -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 )
{
Expand Down
8 changes: 8 additions & 0 deletions src/input/mpegts/mpegts_network.c
Expand Up @@ -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));
Expand Down
9 changes: 8 additions & 1 deletion src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c
Expand Up @@ -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);
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/wizard.c
Expand Up @@ -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]) {
Expand All @@ -347,6 +348,7 @@ static void login_save(idnode_t *in)
pw->pw_wizard = 1;
passwd_entry_save(pw);
}
htsmsg_destroy(conf);
}
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -954,7 +957,7 @@ wizard_page_t *wizard_status(const char *lang)
},
ICON(),
DESCRIPTION(status),
PREV_BUTTON(input),
PREV_BUTTON(muxes),
NEXT_BUTTON(mapping),
{}
};
Expand Down

0 comments on commit c6734e5

Please sign in to comment.