From 3b3a8ce29d923d0af94aff18f3596510785d10bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Wed, 24 Sep 2008 20:10:49 +0000 Subject: [PATCH] Allow autorecording to be created directly as a result of an EPG search query. --- dvr/dvr.h | 8 +++++ dvr/dvr_autorec.c | 56 ++++++++++++++++++++++++++++++-- webui/extjs.c | 11 +++++++ webui/static/app/dvr.js | 30 ++++++++++++----- webui/static/app/epg.js | 47 +++++++++++++++++++++++++++ webui/static/app/ext.css | 7 ++++ webui/static/app/tableeditor.js | 21 ++++++------ webui/static/app/tvheadend.js | 5 +++ webui/static/icons/rec.png | Bin 0 -> 828 bytes 9 files changed, 165 insertions(+), 20 deletions(-) create mode 100644 webui/static/icons/rec.png diff --git a/dvr/dvr.h b/dvr/dvr.h index 9dc817e3..d218e258 100644 --- a/dvr/dvr.h +++ b/dvr/dvr.h @@ -159,4 +159,12 @@ void dvr_query(dvr_query_result_t *dqr); void dvr_query_free(dvr_query_result_t *dqr); void dvr_query_sort(dvr_query_result_t *dqr); +/** + * + */ +void dvr_autorec_add(const char *title, const char *channel, + const char *tag, const char *contentgrp, + const char *creator, const char *comment); + + #endif /* DVR_H */ diff --git a/dvr/dvr_autorec.c b/dvr/dvr_autorec.c index 475874e9..ca71ba01 100644 --- a/dvr/dvr_autorec.c +++ b/dvr/dvr_autorec.c @@ -26,9 +26,11 @@ #include #include #include +#include #include "tvhead.h" #include "dvr.h" +#include "notify.h" #include "dtable.h" #include "epg.h" @@ -240,7 +242,7 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values, if((dae = autorec_entry_find(id, maycreate)) == NULL) return NULL; - + tvh_str_set(&dae->dae_creator, htsmsg_get_str(values, "creator")); tvh_str_set(&dae->dae_comment, htsmsg_get_str(values, "comment")); @@ -249,7 +251,7 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values, LIST_REMOVE(dae, dae_channel_link); dae->dae_channel = NULL; } - if((ch = channel_find_by_name(s, 0)) != NULL) { + if((ch = channel_find_by_name(s, 0)) != NULL) { LIST_INSERT_HEAD(&ch->ch_autorecs, dae, dae_channel_link); dae->dae_channel = ch; } @@ -324,3 +326,53 @@ dvr_autorec_init(void) dt = dtable_create(&autorec_dtc, "autorec", NULL); dtable_load(dt); } + + +/** + * + */ +void +dvr_autorec_add(const char *title, const char *channel, + const char *tag, const char *cgrp, + const char *creator, const char *comment) +{ + dvr_autorec_entry_t *dae; + htsmsg_t *m; + channel_t *ch; + channel_tag_t *ct; + + if((dae = autorec_entry_find(NULL, 1)) == NULL) + return; + + tvh_str_set(&dae->dae_creator, creator); + tvh_str_set(&dae->dae_comment, comment); + + if(channel != NULL && (ch = channel_find_by_name(channel, 0)) != NULL) { + LIST_INSERT_HEAD(&ch->ch_autorecs, dae, dae_channel_link); + dae->dae_channel = ch; + } + + if(title != NULL && + !regcomp(&dae->dae_title_preg, title, + REG_ICASE | REG_EXTENDED | REG_NOSUB)) { + dae->dae_title = strdup(title); + } + + if(tag != NULL && (ct = channel_tag_find_by_name(tag)) != NULL) { + LIST_INSERT_HEAD(&ct->ct_autorecs, dae, dae_channel_tag_link); + dae->dae_channel_tag = ct; + } + + dae->dae_ecg = cgrp ? epg_content_group_find_by_name(cgrp) : NULL; + dae->dae_enabled = 1; + + m = autorec_record_build(dae); + hts_settings_save(m, "%s/%s", "autorec", dae->dae_id); + htsmsg_destroy(m); + + /* Notify web clients that we have messed with the tables */ + + m = htsmsg_create(); + htsmsg_add_u32(m, "asyncreload", 1); + notify_by_msg("autorec", m); +} diff --git a/webui/extjs.c b/webui/extjs.c index 96ebd0ad..9dcc6641 100644 --- a/webui/extjs.c +++ b/webui/extjs.c @@ -961,6 +961,17 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque) out = htsmsg_create(); htsmsg_add_u32(out, "success", 1); + } else if(!strcmp(op, "createAutoRec")) { + + dvr_autorec_add(http_arg_get(&hc->hc_req_args, "title"), + http_arg_get(&hc->hc_req_args, "channel"), + http_arg_get(&hc->hc_req_args, "tag"), + http_arg_get(&hc->hc_req_args, "contentgrp"), + hc->hc_representative, "Created from EPG query"); + + out = htsmsg_create(); + htsmsg_add_u32(out, "success", 1); + } else if(!strcmp(op, "loadSettings")) { r = htsmsg_create(); diff --git a/webui/static/app/dvr.js b/webui/static/app/dvr.js index fbe21c7f..4d2fbac6 100644 --- a/webui/static/app/dvr.js +++ b/webui/static/app/dvr.js @@ -185,6 +185,25 @@ tvheadend.dvrlog = function() { } return panel; } + +/** + * + */ +tvheadend.autorecRecord = Ext.data.Record.create([ + 'enabled','title','channel','tag','creator','contentgrp','comment' +]); + + +tvheadend.autorecStore = new Ext.data.JsonStore({ + root: 'entries', + fields: tvheadend.autorecRecord, + url: "tablemgr", + autoLoad: true, + id: 'id', + baseParams: {table: "autorec", op: "get"} +}); + + /** * */ @@ -239,7 +258,7 @@ tvheadend.autoreceditor = function() { }) },{ - header: "Creator", + header: "Created by", dataIndex: 'creator', editor: new fm.TextField({allowBlank: false}) },{ @@ -249,15 +268,10 @@ tvheadend.autoreceditor = function() { } ]); - var rec = Ext.data.Record.create([ - 'enabled','title','channel','tag','creator','contentgrp','comment' - ]); return new tvheadend.tableEditor('Automatic Recorder', - 'autorec', cm, rec, - [enabledColumn]); - - + 'autorec', cm, tvheadend.autorecRecord, + [enabledColumn], tvheadend.autorecStore); } /** * diff --git a/webui/static/app/epg.js b/webui/static/app/epg.js index df44953b..76081a53 100644 --- a/webui/static/app/epg.js +++ b/webui/static/app/epg.js @@ -266,6 +266,15 @@ tvheadend.epg = function() { { text: 'Reset', handler: epgQueryClear + }, + '->', + { + text: 'Create AutoRec', + iconCls: 'rec', + tooltip: 'Create an automatic recording entry that will ' + + 'record all future programmes that matches ' + + 'the current query.', + handler: createAutoRec } ], @@ -286,6 +295,44 @@ tvheadend.epg = function() { new tvheadend.epgDetails(grid.getStore().getAt(index).data); } + function createAutoRec() { + + var title = epgStore.baseParams.title ? + epgStore.baseParams.title : "Don't care"; + var channel = epgStore.baseParams.channel ? + epgStore.baseParams.channel : "Don't care"; + var tag = epgStore.baseParams.tag ? + epgStore.baseParams.tag : "Don't care"; + var contentgrp = epgStore.baseParams.contentgrp ? + epgStore.baseParams.contentgrp : "Don't care"; + + Ext.MessageBox.confirm('Auto Recorder', + 'This will create an automatic rule that ' + + 'continously scans the EPG for programmes ' + + 'to recrod that matches this query: ' + + '

' + + '
Title:
' + title + '
' + + '
Channel:
' + channel + '
' + + '
Tag:
' + tag + '
' + + '
Content Group:
' + contentgrp + '
' + + '
' + + 'Currently this will match (and record) ' + + epgStore.getTotalCount() + ' events. ' + + 'Are you sure?', + + function(button) { + if(button == 'no') + return; + createAutoRec2(epgStore.baseParams); + } + ); + } + + function createAutoRec2(params) { + /* Really do it */ + params.op = 'createAutoRec'; + Ext.Ajax.request({url: '/dvr', params: params}); + } return panel; } diff --git a/webui/static/app/ext.css b/webui/static/app/ext.css index ec34fb05..ebbec2f3 100644 --- a/webui/static/app/ext.css +++ b/webui/static/app/ext.css @@ -98,7 +98,14 @@ .save { background-image:url(../icons/save.gif) !important; } +.rec { + background-image:url(../icons/rec.png) !important; +} +.x-smallhdr { + float:left; + width: 100px; +} .x-epg-title { margin: 5px; diff --git a/webui/static/app/tableeditor.js b/webui/static/app/tableeditor.js index 24f9ded7..9ee27f3b 100644 --- a/webui/static/app/tableeditor.js +++ b/webui/static/app/tableeditor.js @@ -1,15 +1,16 @@ -tvheadend.tableEditor = function(title, dtable, cm, rec, plugins) { +tvheadend.tableEditor = function(title, dtable, cm, rec, plugins, store) { cm.defaultSortable = true; - var store = new Ext.data.JsonStore({ - root: 'entries', - fields: rec, - url: "tablemgr", - autoLoad: true, - id: 'id', - baseParams: {table: dtable, op: "get"} - }); - + if(store == null) { + store = new Ext.data.JsonStore({ + root: 'entries', + fields: rec, + url: "tablemgr", + autoLoad: true, + id: 'id', + baseParams: {table: dtable, op: "get"} + }); + } function addRecord() { Ext.Ajax.request({ diff --git a/webui/static/app/tvheadend.js b/webui/static/app/tvheadend.js index eb9806b3..c80e9dd3 100644 --- a/webui/static/app/tvheadend.js +++ b/webui/static/app/tvheadend.js @@ -19,6 +19,11 @@ tvheadend.comet_poller = function() { tvheadend.channelTags.reload(); break; + case 'autorec': + if(m.asyncreload != null) + tvheadend.autorecStore.reload(); + break; + case 'dvrdb': if(m.reload != null) tvheadend.dvrStore.reload(); diff --git a/webui/static/icons/rec.png b/webui/static/icons/rec.png new file mode 100644 index 0000000000000000000000000000000000000000..2386fac73e18a786919700b1b14d42c1ed288889 GIT binary patch literal 828 zcmV-C1H=4@P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iOT1 z5eFr+rJ^JN000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0007)Nkl+iIoJq_niB*S1hKKOmsDDaSc*aY7ZySqOGVI5 zu~8eVbm9esh-jlIf|tZ(&g_|e`EIYp%pX{=9-bv;MywD3Qh}y|t7IG=h3dc}s3!x7 zLZHEN#ygJ(FqdGnVf*o?7Qg+T3n}4i#GGK>;jBPZG#p}2JchpVqD;&4Bs^kfFjUI* zw=KW*8m(Rgy$7i>I^)1PYFXj(0XW0r05?9w-hWrJwmZPtdpArUUa;g6{Jmlz;af~~F zKYbcjBdQ4`Vyi!qFaBYf3^s|u5BMp=qCzQ@HRw~%Kt9|l%x_+k^2=?wH$wv=1;(CO zHq>**VVnrw5jO*j3H1x+H?B$c`xY_@VMgEi$n4gSury@TLui;vB;+M7L@MB}Jc(U@ zNrWRNVINZkb09f^7fP