Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: add possibility to re-run internal EPG grabbers
  • Loading branch information
perexg committed May 11, 2016
1 parent bd6dcac commit 14b81bb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/api/api_epggrab.c
Expand Up @@ -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[] = {
Expand All @@ -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 },
};

Expand Down
10 changes: 8 additions & 2 deletions src/epggrab.c
Expand Up @@ -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
* *************************************************************************/
Expand Down Expand Up @@ -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 *
Expand Down
1 change: 1 addition & 0 deletions src/epggrab.h
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions 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 = {
Expand Down Expand Up @@ -25,7 +44,7 @@ tvheadend.epggrab_base = function(panel, index) {
tabIndex: index,
width: 550,
labelWidth: 200,
tbar: [triggerButton]
tbar: [triggerButton, tvheadend.epggrab_rerun_button()]
});

}
Expand Down Expand Up @@ -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()]
});

};

0 comments on commit 14b81bb

Please sign in to comment.