Updated to include support for mux configuration setting in UI, I have added a general config section (though currently it only contains this one value).
This commit is contained in:
parent
621441760d
commit
c7e08d26c0
10 changed files with 272 additions and 17 deletions
1
Makefile
1
Makefile
|
@ -76,6 +76,7 @@ SRCS = src/main.c \
|
|||
src/huffman.c \
|
||||
src/filebundle.c \
|
||||
src/muxes.c \
|
||||
src/config2.c \
|
||||
|
||||
SRCS += src/epggrab/module.c\
|
||||
src/epggrab/channel.c\
|
||||
|
|
15
docs/html/config_misc.html
Normal file
15
docs/html/config_misc.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<div class="hts-doc-text">
|
||||
|
||||
<p>
|
||||
This tabs allow configuration of several general parameters that affect the
|
||||
core TVH functionality.
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>DVB scan files path:
|
||||
<dd>Select the path to use for DVB scan configuration files. Typically</dt>
|
||||
dvb-apps stores these in /usr/share/dvb/. Leave blank to use TVH's internal
|
||||
file set (probably stored at /usr/share/tvheadend/data/dvb-scan/)</dd>
|
||||
</dl>
|
||||
|
||||
</div>
|
60
src/config2.c
Normal file
60
src/config2.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* TV headend - General configuration settings
|
||||
* Copyright (C) 2012 Adam Sutton
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tvheadend.h"
|
||||
#include "settings.h"
|
||||
#include "config2.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static htsmsg_t *config;
|
||||
|
||||
void config_init ( void )
|
||||
{
|
||||
config = hts_settings_load("config");
|
||||
if (!config) {
|
||||
tvhlog(LOG_WARNING, "config", "no configuration, loading defaults");
|
||||
config = htsmsg_create_map();
|
||||
}
|
||||
}
|
||||
|
||||
void config_save ( void )
|
||||
{
|
||||
hts_settings_save(config, "config");
|
||||
}
|
||||
|
||||
htsmsg_t *config_get_all ( void )
|
||||
{
|
||||
return htsmsg_copy(config);
|
||||
}
|
||||
|
||||
const char *config_get_muxconfpath ( void )
|
||||
{
|
||||
return htsmsg_get_str(config, "muxconfpath");
|
||||
}
|
||||
|
||||
int config_set_muxconfpath ( const char *path )
|
||||
{
|
||||
const char *c = config_get_muxconfpath();
|
||||
if (!c || strcmp(c, path)) {
|
||||
if (c) htsmsg_delete_field(config, "muxconfpath");
|
||||
htsmsg_add_str(config, "muxconfpath", path);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
35
src/config2.h
Normal file
35
src/config2.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* TV headend - General configuration settings
|
||||
* Copyright (C) 2012 Adam Sutton
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: expand this, possibly integrate command line
|
||||
|
||||
#ifndef __TVH_CONFIG__H__
|
||||
#define __TVH_CONFIG__H__
|
||||
|
||||
#include "htsmsg.h"
|
||||
|
||||
void config_init ( void );
|
||||
void config_save ( void );
|
||||
|
||||
htsmsg_t *config_get_all ( void );
|
||||
|
||||
const char *config_get_muxconfpath ( void );
|
||||
int config_set_muxconfpath ( const char *str )
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
#endif /* __TVH_CONFIG__H__ */
|
11
src/main.c
11
src/main.c
|
@ -58,6 +58,7 @@
|
|||
#include "settings.h"
|
||||
#include "ffdecsa/FFdecsa.h"
|
||||
#include "muxes.h"
|
||||
#include "config2.h"
|
||||
|
||||
int running;
|
||||
time_t dispatch_clock;
|
||||
|
@ -259,12 +260,11 @@ main(int argc, char **argv)
|
|||
char *p, *endp;
|
||||
uint32_t adapter_mask = 0xffffffff;
|
||||
int crash = 0;
|
||||
const char *muxpath = NULL;
|
||||
|
||||
// make sure the timezone is set
|
||||
tzset();
|
||||
|
||||
while((c = getopt(argc, argv, "Aa:fp:u:g:c:m:Chdr:j:s")) != -1) {
|
||||
while((c = getopt(argc, argv, "Aa:fp:u:g:c:Chdr:j:s")) != -1) {
|
||||
switch(c) {
|
||||
case 'a':
|
||||
adapter_mask = 0x0;
|
||||
|
@ -304,9 +304,6 @@ main(int argc, char **argv)
|
|||
case 'c':
|
||||
confpath = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
muxpath = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
log_debug_to_console = 1;
|
||||
break;
|
||||
|
@ -386,7 +383,9 @@ main(int argc, char **argv)
|
|||
* Initialize subsystems
|
||||
*/
|
||||
|
||||
muxes_init(muxpath);
|
||||
config_init();
|
||||
|
||||
muxes_init();
|
||||
|
||||
service_init();
|
||||
|
||||
|
|
14
src/muxes.c
14
src/muxes.c
|
@ -32,6 +32,7 @@
|
|||
#include "dvb/dvb.h"
|
||||
#include "muxes.h"
|
||||
#include "filebundle.h"
|
||||
#include "config2.h"
|
||||
|
||||
region_list_t regions_DVBC;
|
||||
region_list_t regions_DVBT;
|
||||
|
@ -95,7 +96,6 @@ tldcode2longname(const char *tld)
|
|||
for(i = 0; i < sizeof(tldlist) / sizeof(tldlist[0]); i++)
|
||||
if(!strcmp(tld, tldlist[i].code))
|
||||
return tldlist[i].name;
|
||||
tvhlog(LOG_WARNING, "muxes", "unknown tld code %s", tld);
|
||||
return tld;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,6 @@ static int _reg_cmp ( void *a, void *b )
|
|||
static region_t *_muxes_region_create
|
||||
( const char *type, const char *id, const char *desc )
|
||||
{
|
||||
printf("_muxes_region_create(%s, %s, %s)\n", type, id, desc);
|
||||
region_t *reg;
|
||||
region_list_t *list = NULL;
|
||||
if (!strcmp(type, "dvb-s")) list = ®ions_DVBS;
|
||||
|
@ -344,7 +343,7 @@ static void _muxes_load_dir ( const char *path, const char *type )
|
|||
if (de->type == FB_DIR) {
|
||||
snprintf(p, sizeof(p), "%s/%s", path, de->name);
|
||||
_muxes_load_dir(p, de->name);
|
||||
} else {
|
||||
} else if (type) {
|
||||
_muxes_load_file(type, dir, de->name);
|
||||
}
|
||||
}
|
||||
|
@ -355,12 +354,9 @@ static void _muxes_load_dir ( const char *path, const char *type )
|
|||
/*
|
||||
* Initialise the mux list
|
||||
*/
|
||||
void muxes_init ( const char *path )
|
||||
void muxes_init ( void )
|
||||
{
|
||||
/* Default */
|
||||
if (!path)
|
||||
path = "data/dvb-scan";
|
||||
|
||||
/* Process */
|
||||
const char *path = config_get_muxconfpath();
|
||||
if (!path || !*path) path = "data/dvb-scan";
|
||||
_muxes_load_dir(path, NULL);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,6 @@ extern region_list_t regions_DVBT;
|
|||
extern region_list_t regions_DVBS;
|
||||
extern region_list_t regions_ATSC;
|
||||
|
||||
void muxes_init ( const char *path );
|
||||
void muxes_init ( void );
|
||||
|
||||
#endif /* __TVH_MUXES_H__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "epg.h"
|
||||
#include "iptv_input.h"
|
||||
|
||||
#include "config2.h"
|
||||
|
||||
static void
|
||||
extjs_load(htsbuf_queue_t *hq, const char *script)
|
||||
{
|
||||
|
@ -131,6 +133,7 @@ extjs_root(http_connection_t *hc, const char *remain, void *opaque)
|
|||
extjs_load(hq, "static/app/epg.js");
|
||||
extjs_load(hq, "static/app/dvr.js");
|
||||
extjs_load(hq, "static/app/epggrab.js");
|
||||
extjs_load(hq, "static/app/config.js");
|
||||
|
||||
/**
|
||||
* Finally, the app itself
|
||||
|
@ -1697,6 +1700,58 @@ extjs_tvadapter(http_connection_t *hc, const char *remain, void *opaque)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static int
|
||||
extjs_config(http_connection_t *hc, const char *remain, void *opaque)
|
||||
{
|
||||
htsbuf_queue_t *hq = &hc->hc_reply;
|
||||
const char *op = http_arg_get(&hc->hc_req_args, "op");
|
||||
htsmsg_t *out, *m;
|
||||
const char *str;
|
||||
|
||||
if(op == NULL)
|
||||
return 400;
|
||||
|
||||
pthread_mutex_lock(&global_lock);
|
||||
|
||||
if(http_access_verify(hc, ACCESS_ADMIN)) {
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
return HTTP_STATUS_UNAUTHORIZED;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
|
||||
/* Basic settings (not the advanced schedule) */
|
||||
if(!strcmp(op, "loadSettings")) {
|
||||
pthread_mutex_lock(&global_lock);
|
||||
out = htsmsg_create_map();
|
||||
if ((m = config_get_all()))
|
||||
htsmsg_add_msg(out, "config", m);
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
|
||||
/* Save settings */
|
||||
} else if (!strcmp(op, "saveSettings") ) {
|
||||
int save = 0;
|
||||
pthread_mutex_lock(&global_lock);
|
||||
if ((str = http_arg_get(&hc->hc_req_args, "muxconfpath")))
|
||||
save |= config_set_muxconfpath(str);
|
||||
if (save) config_save();
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
out = htsmsg_create_map();
|
||||
htsmsg_add_u32(out, "success", 1);
|
||||
|
||||
} else {
|
||||
return HTTP_STATUS_BAD_REQUEST;
|
||||
}
|
||||
|
||||
htsmsg_json_serialize(out, hq, 0);
|
||||
htsmsg_destroy(out);
|
||||
http_output_content(hc, "text/x-json; charset=UTF-8");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* WEB user interface
|
||||
|
@ -1717,6 +1772,7 @@ extjs_start(void)
|
|||
http_path_add("/dvr", NULL, extjs_dvr, ACCESS_WEB_INTERFACE);
|
||||
http_path_add("/dvrlist", NULL, extjs_dvrlist, ACCESS_WEB_INTERFACE);
|
||||
http_path_add("/ecglist", NULL, extjs_ecglist, ACCESS_WEB_INTERFACE);
|
||||
http_path_add("/config", NULL, extjs_config, ACCESS_WEB_INTERFACE);
|
||||
|
||||
http_path_add("/mergechannel",
|
||||
NULL, extjs_mergechannel, ACCESS_ADMIN);
|
||||
|
|
91
src/webui/static/app/config.js
Normal file
91
src/webui/static/app/config.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
tvheadend.miscconf = function() {
|
||||
|
||||
/*
|
||||
* Basic Config
|
||||
*/
|
||||
|
||||
var confreader = new Ext.data.JsonReader(
|
||||
{ root: 'config' },
|
||||
[
|
||||
'muxconfpath',
|
||||
]
|
||||
);
|
||||
|
||||
/* ****************************************************************
|
||||
* Form Fields
|
||||
* ***************************************************************/
|
||||
|
||||
var dvbscanPath = new Ext.form.TextField({
|
||||
fieldLabel : 'DVB scan files path',
|
||||
name : 'muxconfpath',
|
||||
allowBlank : true,
|
||||
});
|
||||
|
||||
/* ****************************************************************
|
||||
* Form
|
||||
* ***************************************************************/
|
||||
|
||||
var saveButton = new Ext.Button({
|
||||
text : "Save configuration",
|
||||
tooltip : 'Save changes made to configuration below',
|
||||
iconCls :'save',
|
||||
handler : saveChanges,
|
||||
});
|
||||
|
||||
var helpButton = new Ext.Button({
|
||||
text : 'Help',
|
||||
handler : function() {
|
||||
new tvheadend.help('General Configuration',
|
||||
'config_misc.html');
|
||||
}
|
||||
});
|
||||
|
||||
var confpanel = new Ext.FormPanel({
|
||||
title : 'General',
|
||||
iconCls : 'wrench',
|
||||
border : false,
|
||||
bodyStyle : 'padding:15px',
|
||||
labelAlign : 'left',
|
||||
labelWidth : 150,
|
||||
waitMsgTarget : true,
|
||||
reader : confreader,
|
||||
layout : 'form',
|
||||
defaultType : 'textfield',
|
||||
autoHeight : true,
|
||||
items : [
|
||||
dvbscanPath
|
||||
],
|
||||
tbar: [
|
||||
saveButton,
|
||||
'->',
|
||||
helpButton
|
||||
]
|
||||
});
|
||||
|
||||
/* ****************************************************************
|
||||
* Load/Save
|
||||
* ***************************************************************/
|
||||
|
||||
confpanel.on('render', function() {
|
||||
confpanel.getForm().load({
|
||||
url : 'config',
|
||||
params : { op : 'loadSettings' },
|
||||
success : function ( form, action ) {
|
||||
confpanel.enable();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function saveChanges() {
|
||||
confpanel.getForm().submit({
|
||||
url : 'config',
|
||||
params : { op : 'saveSettings' },
|
||||
waitMsg : 'Saving Data...',
|
||||
failure : function (form, action) {
|
||||
Ext.Msg.alert('Save failed', action.result.errormsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return confpanel;
|
||||
}
|
|
@ -233,7 +233,9 @@ function accessUpdate(o) {
|
|||
autoScroll:true,
|
||||
title: 'Configuration',
|
||||
iconCls: 'wrench',
|
||||
items: [new tvheadend.chconf,
|
||||
items: [
|
||||
new tvheadend.miscconf,
|
||||
new tvheadend.chconf,
|
||||
new tvheadend.epggrab,
|
||||
new tvheadend.cteditor,
|
||||
new tvheadend.dvrsettings,
|
||||
|
|
Loading…
Add table
Reference in a new issue