From: Jaroslav Kysela Date: Wed, 1 Jun 2016 12:42:26 +0000 (+0200) Subject: bouquet: move 'rescan' trigger from table to toolbar button X-Git-Tag: v4.2.1~441 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e637f9f903f6d820f701a1461b144e67665c6fa;p=thirdparty%2Ftvheadend.git bouquet: move 'rescan' trigger from table to toolbar button --- diff --git a/src/api/api_bouquet.c b/src/api/api_bouquet.c index 6ed798f68..21ab504d4 100644 --- a/src/api/api_bouquet.c +++ b/src/api/api_bouquet.c @@ -81,6 +81,41 @@ api_bouquet_create return 0; } +static int +api_bouquet_scan + ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) +{ + htsmsg_field_t *f; + htsmsg_t *uuids; + bouquet_t *bq; + const char *uuid; + + if (!(f = htsmsg_field_find(args, "uuid"))) + return -EINVAL; + if ((uuids = htsmsg_field_get_list(f))) { + HTSMSG_FOREACH(f, uuids) { + if (!(uuid = htsmsg_field_get_str(f))) continue; + pthread_mutex_lock(&global_lock); + bq = bouquet_find_by_uuid(uuid); + if (bq) + bouquet_scan(bq); + pthread_mutex_unlock(&global_lock); + } + } else if ((uuid = htsmsg_field_get_str(f))) { + pthread_mutex_lock(&global_lock); + bq = bouquet_find_by_uuid(uuid); + if (bq) + bouquet_scan(bq); + pthread_mutex_unlock(&global_lock); + if (!bq) + return -ENOENT; + } else { + return -EINVAL; + } + + return 0; +} + void api_bouquet_init ( void ) { static api_hook_t ah[] = { @@ -88,6 +123,7 @@ void api_bouquet_init ( void ) { "bouquet/class", ACCESS_ADMIN, api_idnode_class, (void*)&bouquet_class }, { "bouquet/grid", ACCESS_ADMIN, api_idnode_grid, api_bouquet_grid }, { "bouquet/create", ACCESS_ADMIN, api_bouquet_create, NULL }, + { "bouquet/scan", ACCESS_ADMIN, api_bouquet_scan, NULL }, { NULL }, }; diff --git a/src/api/api_mpegts.c b/src/api/api_mpegts.c index 348e3e433..cfd684fb3 100644 --- a/src/api/api_mpegts.c +++ b/src/api/api_mpegts.c @@ -151,21 +151,19 @@ api_mpegts_network_scan if ((uuids = htsmsg_field_get_list(f))) { HTSMSG_FOREACH(f, uuids) { if (!(uuid = htsmsg_field_get_str(f))) continue; + pthread_mutex_lock(&global_lock); mn = mpegts_network_find(uuid); - if (mn) { - pthread_mutex_lock(&global_lock); + if (mn) mpegts_network_scan(mn); - pthread_mutex_unlock(&global_lock); - } + pthread_mutex_unlock(&global_lock); } } else if ((uuid = htsmsg_field_get_str(f))) { + pthread_mutex_lock(&global_lock); mn = mpegts_network_find(uuid); - if (mn) { - pthread_mutex_lock(&global_lock); + if (mn) mpegts_network_scan(mn); - pthread_mutex_unlock(&global_lock); - } - else + pthread_mutex_unlock(&global_lock); + if (!mn) return -ENOENT; } else { return -EINVAL; diff --git a/src/bouquet.c b/src/bouquet.c index 20a355fc7..aa9379409 100644 --- a/src/bouquet.c +++ b/src/bouquet.c @@ -609,6 +609,24 @@ bouquet_change_comment ( bouquet_t *bq, const char *comment, int replace ) bq->bq_saveflag = 1; } +/* + * + */ +void +bouquet_scan ( bouquet_t *bq ) +{ + void mpegts_mux_bouquet_rescan ( const char *src, const char *extra ); + void iptv_bouquet_trigger_by_uuid( const char *uuid ); +#if ENABLE_IPTV + if (bq->bq_src && strncmp(bq->bq_src, "iptv-network://", 15) == 0) + return iptv_bouquet_trigger_by_uuid(bq->bq_src + 15); +#endif + if (bq->bq_src && strncmp(bq->bq_src, "exturl://", 9) == 0) + return bouquet_download_trigger(bq); + mpegts_mux_bouquet_rescan(bq->bq_src, bq->bq_comment); + bq->bq_rescan = 0; +} + /* ************************************************************************** * Class definition * **************************************************************************/ @@ -654,37 +672,13 @@ bouquet_class_get_list(void *o, const char *lang) return m; } -static void -bouquet_class_rescan_notify0 ( bouquet_t *bq, const char *lang ) -{ - void mpegts_mux_bouquet_rescan ( const char *src, const char *extra ); - void iptv_bouquet_trigger_by_uuid( const char *uuid ); -#if ENABLE_IPTV - if (bq->bq_src && strncmp(bq->bq_src, "iptv-network://", 15) == 0) - return iptv_bouquet_trigger_by_uuid(bq->bq_src + 15); -#endif - if (bq->bq_src && strncmp(bq->bq_src, "exturl://", 9) == 0) - return bouquet_download_trigger(bq); - mpegts_mux_bouquet_rescan(bq->bq_src, bq->bq_comment); - bq->bq_rescan = 0; -} - -static void -bouquet_class_rescan_notify ( void *obj, const char *lang ) -{ - bouquet_t *bq = obj; - - if (bq->bq_rescan) - bouquet_class_rescan_notify0(bq, lang); -} - static void bouquet_class_enabled_notify ( void *obj, const char *lang ) { bouquet_t *bq = obj; if (bq->bq_enabled) - bouquet_class_rescan_notify0(bq, lang); + bouquet_scan(bq); bouquet_map_to_channels(bq); } @@ -976,15 +970,6 @@ const idclass_t bouquet_class = { .off = offsetof(bouquet_t, bq_enabled), .notify = bouquet_class_enabled_notify, }, - { - .type = PT_BOOL, - .id = "rescan", - .name = N_("Rescan"), - .desc = N_("Rescan the mux for changes to the bouquet."), - .off = offsetof(bouquet_t, bq_rescan), - .notify = bouquet_class_rescan_notify, - .opts = PO_NOSAVE, - }, { .type = PT_BOOL, .id = "maptoch", diff --git a/src/bouquet.h b/src/bouquet.h index cf4cdb3de..900637e0b 100644 --- a/src/bouquet.h +++ b/src/bouquet.h @@ -102,6 +102,7 @@ void bouquet_notify_channels(bouquet_t *bq); void bouquet_add_service(bouquet_t *bq, service_t *s, uint64_t lcn, const char *tag); void bouquet_completed(bouquet_t *bq, uint32_t seen); void bouquet_change_comment(bouquet_t *bq, const char *comment, int replace); +void bouquet_scan(bouquet_t *bq); uint64_t bouquet_get_channel_number(bouquet_t *bq, service_t *t); diff --git a/src/webui/static/app/cteditor.js b/src/webui/static/app/cteditor.js index d33f4a7c8..f90dcbebe 100644 --- a/src/webui/static/app/cteditor.js +++ b/src/webui/static/app/cteditor.js @@ -35,12 +35,46 @@ tvheadend.bouquet = function(panel, index) var elist = 'enabled,rescan,ext_url,' + list0; var alist = 'enabled,ext_url,' + list0; + var scanButton = { + name: 'scan', + builder: function() { + return new Ext.Toolbar.Button({ + tooltip: _('Rescan the mux for changes to the bouquet.'), + iconCls: 'find', + text: _('Force Scan'), + disabled: true + }); + }, + callback: function(conf, e, store, select) { + var r = select.getSelections(); + if (r && r.length > 0) { + var uuids = []; + for (var i = 0; i < r.length; i++) + uuids.push(r[i].id); + tvheadend.Ajax({ + url: 'api/bouquet/scan', + params: { + uuid: Ext.encode(uuids) + }, + success: function(d) { + store.reload(); + } + }); + } + } + }; + + function selected(s, abuttons) { + abuttons.scan.setDisabled(!s || s.length <= 0); + } + tvheadend.idnode_grid(panel, { url: 'api/bouquet', titleS: _('Bouquet'), titleP: _('Bouquets'), iconCls: 'bouquets', tabIndex: index, + tbar: [scanButton], columns: { enabled: { width: 50 }, rescan: { width: 50 }, @@ -61,6 +95,7 @@ tvheadend.bouquet = function(panel, index) }, del: true, edit: { params: { list: elist } }, + selected: selected, sort: { field: 'name', direction: 'ASC'