From af07b24df2249c55c75d5455023992f280f3f947 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sun, 22 Sep 2013 13:15:16 +0100 Subject: [PATCH] api: make it possible to hide disabled services in the mux/service grids This can be done in 3 ways: none: don't hide anything all: hide all disabled elements (you can't re-enable in this state) default: hide those elements whose parents are disabled --- src/api.h | 2 +- src/api/api_idnode.c | 2 +- src/api/api_mpegts.c | 29 +++++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/api.h b/src/api.h index 97c85ded..b852cb8b 100644 --- a/src/api.h +++ b/src/api.h @@ -75,7 +75,7 @@ typedef struct api_idnode_grid_conf } api_idnode_grid_conf_t; typedef void (*api_idnode_grid_callback_t) - (idnode_set_t*, api_idnode_grid_conf_t*); + (idnode_set_t*, api_idnode_grid_conf_t*, htsmsg_t *args); typedef idnode_set_t *(*api_idnode_tree_callback_t) (void); diff --git a/src/api/api_idnode.c b/src/api/api_idnode.c index c075ab0c..26319e32 100644 --- a/src/api/api_idnode.c +++ b/src/api/api_idnode.c @@ -103,7 +103,7 @@ api_idnode_grid /* Create list */ pthread_mutex_lock(&global_lock); - cb(&ins, &conf); + cb(&ins, &conf, args); /* Sort */ if (conf.sort.key) diff --git a/src/api/api_mpegts.c b/src/api/api_mpegts.c index 3bb8227c..da13a017 100644 --- a/src/api/api_mpegts.c +++ b/src/api/api_mpegts.c @@ -79,7 +79,7 @@ exit: */ static void api_mpegts_network_grid - ( idnode_set_t *ins, api_idnode_grid_conf_t *conf ) + ( idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args ) { mpegts_network_t *mn; @@ -200,13 +200,23 @@ exit: */ static void api_mpegts_mux_grid - ( idnode_set_t *ins, api_idnode_grid_conf_t *conf ) + ( idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args ) { mpegts_network_t *mn; mpegts_mux_t *mm; + int hide = 1; + const char *s = htsmsg_get_str(args, "hidemode"); + if (s) { + if (!strcmp(s, "all")) + hide = 2; + else if (!strcmp(s, "none")) + hide = 0; + } LIST_FOREACH(mn, &mpegts_network_all, mn_global_link) { + //if (hide && !mn->mn_enabled) continue; LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link) { + if (hide == 2 && !mm->mm_is_enabled(mm)) continue; idnode_set_add(ins, (idnode_t*)mm, &conf->filter); } } @@ -217,15 +227,26 @@ api_mpegts_mux_grid */ static void api_mpegts_service_grid - ( idnode_set_t *ins, api_idnode_grid_conf_t *conf ) + ( idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args ) { mpegts_network_t *mn; mpegts_mux_t *mm; mpegts_service_t *ms; + int hide = 1; + const char *s = htsmsg_get_str(args, "hidemode"); + if (s) { + if (!strcmp(s, "all")) + hide = 2; + else if (!strcmp(s, "none")) + hide = 0; + } LIST_FOREACH(mn, &mpegts_network_all, mn_global_link) { + //if (hide && !mn->mn_enabled) continue; LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link) { + if (hide && !mm->mm_is_enabled(mm)) continue; LIST_FOREACH(ms, &mm->mm_services, s_dvb_mux_link) { + if (hide == 2 && !ms->s_is_enabled((service_t*)ms)) continue; idnode_set_add(ins, (idnode_t*)ms, &conf->filter); } } @@ -238,7 +259,7 @@ api_mpegts_service_grid #if ENABLE_LINUXDVB static void api_linuxdvb_satconf_grid - ( idnode_set_t *ins, api_idnode_grid_conf_t *conf ) + ( idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args ) { mpegts_input_t *mi; extern const idclass_t linuxdvb_satconf_class;