From: Jaroslav Kysela Date: Wed, 11 May 2016 07:42:12 +0000 (+0200) Subject: epggrab: add possibility to re-run internal EPG grabbers X-Git-Tag: v4.2.1~542 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=14b81bb0c7b30d8316654a15ec5ee19387f0ed88;p=thirdparty%2Ftvheadend.git epggrab: add possibility to re-run internal EPG grabbers --- diff --git a/src/api/api_epggrab.c b/src/api/api_epggrab.c index fc35bfa75..f53f6f00e 100644 --- a/src/api/api_epggrab.c +++ b/src/api/api_epggrab.c @@ -68,6 +68,21 @@ api_epggrab_ota_trigger return 0; } +static int +api_epggrab_rerun_internal + ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) +{ + int32_t s32; + if (htsmsg_get_s32(args, "rerun", &s32)) + return EINVAL; + if (s32 > 0) { + pthread_mutex_lock(&global_lock); + epggrab_rerun_internal(); + pthread_mutex_unlock(&global_lock); + } + return 0; +} + void api_epggrab_init ( void ) { static api_hook_t ah[] = { @@ -79,6 +94,7 @@ void api_epggrab_init ( void ) { "epggrab/config/load", ACCESS_ADMIN, api_idnode_load_simple, &epggrab_conf.idnode }, { "epggrab/config/save", ACCESS_ADMIN, api_idnode_save_simple, &epggrab_conf.idnode }, { "epggrab/ota/trigger", ACCESS_ADMIN, api_epggrab_ota_trigger, NULL }, + { "epggrab/internal/rerun", ACCESS_ADMIN, api_epggrab_rerun_internal, NULL }, { NULL }, }; diff --git a/src/epggrab.c b/src/epggrab.c index dc7acbd6d..0809a7e4e 100644 --- a/src/epggrab.c +++ b/src/epggrab.c @@ -136,6 +136,13 @@ static void* _epggrab_internal_thread ( void* p ) return NULL; } +void +epggrab_rerun_internal(void) +{ + epggrab_confver++; + pthread_cond_signal(&epggrab_cond); +} + /* ************************************************************************** * Configuration * *************************************************************************/ @@ -193,8 +200,7 @@ static void epggrab_class_changed(idnode_t *self) { /* Register */ - epggrab_confver++; - pthread_cond_signal(&epggrab_cond); + epggrab_rerun_internal(); } static htsmsg_t * diff --git a/src/epggrab.h b/src/epggrab.h index 20e101eff..6b5cbd9f6 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -306,6 +306,7 @@ extern int epggrab_ota_running; int epggrab_activate_module ( epggrab_module_t *mod, int activate ); void epggrab_ota_set_cron ( void ); void epggrab_ota_trigger ( int secs ); +void epggrab_rerun_internal ( void ); /* * Load/Save diff --git a/src/webui/static/app/epggrab.js b/src/webui/static/app/epggrab.js index 990250f27..f2eafa976 100644 --- a/src/webui/static/app/epggrab.js +++ b/src/webui/static/app/epggrab.js @@ -1,3 +1,22 @@ +tvheadend.epggrab_rerun_button = function() { + return { + name: 'trigger', + builder: function() { + return new Ext.Toolbar.Button({ + text: _("Re-run Internal EPG Grabbers"), + tooltip: _('Re-run all internal EPG grabbers to import EPG data now'), + iconCls: 'find', + }); + }, + callback: function(conf) { + tvheadend.Ajax({ + url: 'api/epggrab/internal/rerun', + params: { rerun: 1 }, + }); + } + }; +} + tvheadend.epggrab_base = function(panel, index) { var triggerButton = { @@ -25,7 +44,7 @@ tvheadend.epggrab_base = function(panel, index) { tabIndex: index, width: 550, labelWidth: 200, - tbar: [triggerButton] + tbar: [triggerButton, tvheadend.epggrab_rerun_button()] }); } @@ -73,7 +92,8 @@ tvheadend.epggrab_mod = function(panel, index) { fields: ['uuid', 'title', 'status'], list: { url: 'api/epggrab/module/list', params: { } }, lcol: [actions], - plugins: [actions] + plugins: [actions], + tbar: [tvheadend.epggrab_rerun_button()] }); };