src/huffman.c \
src/filebundle.c \
src/muxes.c \
+ src/config2.c \
SRCS += src/epggrab/module.c\
src/epggrab/channel.c\
--- /dev/null
+<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>
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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__ */
#include "settings.h"
#include "ffdecsa/FFdecsa.h"
#include "muxes.h"
+#include "config2.h"
int running;
time_t dispatch_clock;
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;
case 'c':
confpath = optarg;
break;
- case 'm':
- muxpath = optarg;
- break;
case 'd':
log_debug_to_console = 1;
break;
* Initialize subsystems
*/
- muxes_init(muxpath);
+ config_init();
+
+ muxes_init();
service_init();
#include "dvb/dvb.h"
#include "muxes.h"
#include "filebundle.h"
+#include "config2.h"
region_list_t regions_DVBC;
region_list_t regions_DVBT;
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;
}
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;
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);
}
}
/*
* 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);
}
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__ */
#include "epg.h"
#include "iptv_input.h"
+#include "config2.h"
+
static void
extjs_load(htsbuf_queue_t *hq, const char *script)
{
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
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
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);
--- /dev/null
+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;
+}
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,