Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: ota - add trigger button to webui
  • Loading branch information
perexg committed Jan 21, 2015
1 parent 1377fad commit 3077ffa
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/epggrab.h
Expand Up @@ -292,6 +292,7 @@ int epggrab_enable_module_by_id ( const char *id, uint8_t e );
int epggrab_ota_set_cron ( const char *cron, int lock );
int epggrab_ota_set_timeout ( uint32_t e );
int epggrab_ota_set_initial ( uint32_t e );
void epggrab_ota_trigger ( int secs );

/*
* Load/Save
Expand Down
15 changes: 11 additions & 4 deletions src/epggrab/otamux.c
Expand Up @@ -812,17 +812,24 @@ epggrab_ota_init ( void )
}
}

void
epggrab_ota_trigger ( int secs )
{
/* notify another system layers, that we will do EPG OTA */
secs = MIN(1, MAX(secs, 7*24*3600));
dbus_emit_signal_s64("/epggrab/ota", "next", time(NULL) + secs);
epggrab_ota_pending_flag = 1;
epggrab_ota_kick(secs);
}

void
epggrab_ota_post ( void )
{
time_t t = (time_t)-1;

/* Init timer (call after full init - wait for network tuners) */
if (epggrab_ota_initial) {
/* notify another system layers, that we will do EPG OTA */
dbus_emit_signal_s64("/epggrab/ota", "next", time(NULL) + 15);
epggrab_ota_pending_flag = 1;
epggrab_ota_kick(15);
epggrab_ota_trigger(15);
t = time(NULL);
}

Expand Down
13 changes: 13 additions & 0 deletions src/webui/extjs.c
Expand Up @@ -381,6 +381,19 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
out = htsmsg_create_map();
htsmsg_add_u32(out, "success", 1);

/* OTA EPG trigger */
} else if (!strcmp(op, "otaepgTrigger") ) {

str = http_arg_get(&hc->hc_req_args, "after");
if (!str)
return HTTP_STATUS_BAD_REQUEST;

pthread_mutex_lock(&global_lock);
epggrab_ota_trigger(atoi(str));
pthread_mutex_unlock(&global_lock);
out = htsmsg_create_map();
htsmsg_add_u32(out, "success", 1);

} else {
return HTTP_STATUS_BAD_REQUEST;
}
Expand Down
2 changes: 1 addition & 1 deletion src/webui/static/app/config.js
Expand Up @@ -236,7 +236,7 @@ tvheadend.miscconf = function(panel, index) {

var helpButton = new Ext.Button({
text: 'Help',
iconCls: 'help',
iconCls: 'help',
handler: function() {
new tvheadend.help('General Configuration', 'config_misc.html');
}
Expand Down
26 changes: 23 additions & 3 deletions src/webui/static/app/epggrab.js
Expand Up @@ -4,8 +4,7 @@ tvheadend.epggrabChannels = new Ext.data.JsonStore({
baseParams: {
op: 'channelList'
},
fields: ['id', 'mod', 'name', 'icon', 'number', 'channel', 'mod-id',
'mod-name']
fields: ['id', 'mod', 'name', 'icon', 'number', 'channel', 'mod-id', 'mod-name']
});

tvheadend.epggrab = function(panel, index) {
Expand Down Expand Up @@ -296,6 +295,13 @@ tvheadend.epggrab = function(panel, index) {
handler: saveChanges
});

var otaepgButton = new Ext.Button({
text: "Trigger OTA EPG Grabber",
tooltip: 'Tune over-the-air EPG muxes to grab new events now',
iconCls: 'find',
handler: otaepgTrigger
});

var helpButton = new Ext.Button({
text: 'Help',
iconCls: 'help',
Expand All @@ -317,7 +323,7 @@ tvheadend.epggrab = function(panel, index) {
defaultType: 'textfield',
autoHeight: true,
items: [simplePanel, internalPanel, otaPanel, externalPanel],
tbar: [saveButton, '->', helpButton]
tbar: [saveButton, otaepgButton, '->', helpButton]
});

/* ****************************************************************
Expand Down Expand Up @@ -395,5 +401,19 @@ tvheadend.epggrab = function(panel, index) {
});
}

function otaepgTrigger() {
Ext.Ajax.request({
url: 'epggrab',
params: {
op: 'otaepgTrigger',
after: 1,
},
waitMsg: 'Triggering...',
failure: function(response, options) {
Ext.Msg.alert('Trigger failed', response.statusText);
}
});
}

tvheadend.paneladd(panel, confpanel, index);
};

0 comments on commit 3077ffa

Please sign in to comment.