Add support for creating manual DVR entries

This commit is contained in:
Andreas Öman 2009-12-15 20:09:38 +00:00
parent 91811247bc
commit f2cc5e306f
4 changed files with 157 additions and 18 deletions

View file

@ -133,6 +133,10 @@ typedef struct dvr_entry {
*/
dvr_entry_t *dvr_entry_create_by_event(event_t *e, const char *creator);
dvr_entry_t *dvr_entry_create(channel_t *ch, time_t start, time_t stop,
const char *title, const char *description,
const char *creator);
void dvr_init(void);
void dvr_autorec_init(void);

View file

@ -131,34 +131,31 @@ dvr_entry_link(dvr_entry_t *de)
}
/**
*
*/
dvr_entry_t *
dvr_entry_create_by_event(event_t *e, const char *creator)
dvr_entry_create(channel_t *ch, time_t start, time_t stop,
const char *title, const char *description,
const char *creator)
{
dvr_entry_t *de;
char tbuf[30];
struct tm tm;
time_t t;
channel_t *ch;
if(e->e_channel == NULL || e->e_title == NULL)
return NULL;
LIST_FOREACH(de, &e->e_channel->ch_dvrs, de_channel_link)
if(de->de_start == e->e_start && de->de_sched_state != DVR_COMPLETED)
LIST_FOREACH(de, &ch->ch_dvrs, de_channel_link)
if(de->de_start == start && de->de_sched_state != DVR_COMPLETED)
return NULL;
de = calloc(1, sizeof(dvr_entry_t));
de->de_id = ++de_tally;
ch = de->de_channel = e->e_channel;
ch = de->de_channel = ch;
LIST_INSERT_HEAD(&de->de_channel->ch_dvrs, de, de_channel_link);
de->de_start = e->e_start;
de->de_stop = e->e_stop;
de->de_start = start;
de->de_stop = stop;
if (ch->ch_dvr_extra_time_pre)
de->de_start_extra = ch->ch_dvr_extra_time_pre;
else
@ -168,8 +165,8 @@ dvr_entry_create_by_event(event_t *e, const char *creator)
else
de->de_stop_extra = dvr_extra_time_post;
de->de_creator = strdup(creator);
de->de_title = strdup(e->e_title);
de->de_desc = e->e_desc ? strdup(e->e_desc) : NULL;
de->de_title = strdup(title);
de->de_desc = description ? strdup(description) : NULL;
dvr_entry_link(de);
@ -187,6 +184,20 @@ dvr_entry_create_by_event(event_t *e, const char *creator)
}
/**
*
*/
dvr_entry_t *
dvr_entry_create_by_event(event_t *e, const char *creator)
{
if(e->e_channel == NULL || e->e_title == NULL)
return NULL;
return dvr_entry_create(e->e_channel, e->e_start, e->e_stop,
e->e_title, e->e_desc, creator);
}
/**
*
*/

View file

@ -765,6 +765,47 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
out = htsmsg_create_map();
htsmsg_add_u32(out, "success", 1);
} else if(!strcmp(op, "createEntry")) {
const char *title = http_arg_get(&hc->hc_req_args, "title");
const char *datestr = http_arg_get(&hc->hc_req_args, "date");
const char *startstr = http_arg_get(&hc->hc_req_args, "starttime");
const char *stopstr = http_arg_get(&hc->hc_req_args, "stoptime");
const char *channel = http_arg_get(&hc->hc_req_args, "channelid");
channel_t *ch = channel ? channel_find_by_identifier(atoi(channel)) : NULL;
if(ch == NULL || title == NULL ||
datestr == NULL || strlen(datestr) != 10 ||
startstr == NULL || strlen(startstr) != 5 ||
stopstr == NULL || strlen(stopstr) != 5) {
pthread_mutex_unlock(&global_lock);
return HTTP_STATUS_BAD_REQUEST;
}
struct tm t = {0};
t.tm_year = atoi(datestr + 6) - 1900;
t.tm_mon = atoi(datestr) - 1;
t.tm_mday = atoi(datestr + 3);
t.tm_hour = atoi(startstr);
t.tm_min = atoi(startstr + 3);
time_t start = timelocal(&t);
t.tm_hour = atoi(stopstr);
t.tm_min = atoi(stopstr + 3);
time_t stop = timelocal(&t);
if(stop < start)
stop += 86400;
dvr_entry_create(ch, start, stop, title, NULL, hc->hc_representative);
out = htsmsg_create_map();
htsmsg_add_u32(out, "success", 1);
} else if(!strcmp(op, "createAutoRec")) {
dvr_autorec_add(http_arg_get(&hc->hc_req_args, "title"),

View file

@ -74,7 +74,7 @@ tvheadend.dvrDetails = function(entry) {
/**
*
*/
tvheadend.dvrlog = function() {
tvheadend.dvrschedule = function() {
function renderDate(value){
var dt = new Date(value);
@ -141,26 +141,109 @@ tvheadend.dvrlog = function() {
}
]);
function addEntry() {
function createRecording() {
panel.getForm().submit({
params:{'op':'createEntry'},
url:'dvr/addentry',
waitMsg:'Creating entry...',
failure:function(response, options) {
Ext.MessageBox.alert('Server Error',
'Unable to create entry');
},
success: function() {
win.close();
}
});
}
var panel = new Ext.FormPanel({
frame:true,
border:true,
bodyStyle:'padding:5px',
labelAlign: 'right',
labelWidth: 110,
defaultType: 'textfield',
items: [
new Ext.form.ComboBox({
fieldLabel: 'Channel',
name: 'channel',
hiddenName: 'channelid',
editable: false,
allowBlank: false,
displayField: 'name',
valueField:'chid',
mode:'remote',
triggerAction: 'all',
store: tvheadend.channels
}),
new Ext.form.DateField({
allowBlank: false,
fieldLabel: 'Date',
name: 'date'
}),
new Ext.form.TimeField({
allowBlank: false,
fieldLabel: 'Start time',
name: 'starttime',
increment: 10,
format: 'H:i'
}),
new Ext.form.TimeField({
allowBlank: false,
fieldLabel: 'Stop time',
name: 'stoptime',
increment: 10,
format: 'H:i'
}),
{
allowBlank: false,
fieldLabel: 'Title',
name: 'title'
}
],
buttons: [{
text: 'Create',
handler: createRecording
}]
});
win = new Ext.Window({
title: 'Add single recording',
layout: 'fit',
width: 500,
height: 300,
plain: true,
items: panel
});
win.show();
};
var panel = new Ext.grid.GridPanel({
loadMask: true,
stripeRows: true,
disableSelection: true,
title: 'Recorder log',
title: 'Recorder schedule',
iconCls: 'clock',
store: tvheadend.dvrStore,
cm: dvrCm,
viewConfig: {forceFit:true},
tbar: [
'->',
{
tooltip: 'Schedule a new recording session on the server.',
iconCls:'add',
text: 'Add entry',
handler: addEntry
},'->',{
text: 'Help',
handler: function() {
new tvheadend.help('Digital Video Recorder',
'dvrlog.html');
}
}
],
bbar: new Ext.PagingToolbar({
store: tvheadend.dvrStore,
@ -316,7 +399,7 @@ tvheadend.dvr = function() {
autoScroll:true,
title: 'Digital Video Recorder',
iconCls: 'drive',
items: [new tvheadend.dvrlog,
items: [new tvheadend.dvrschedule,
new tvheadend.autoreceditor
]
});