#include "tvheadend.h"
#include "avahi.h"
+#include "config.h"
static AvahiEntryGroup *group = NULL;
static char *name = NULL;
static AvahiSimplePoll *avahi_asp = NULL;
static const AvahiPoll *avahi_poll = NULL;
+static int avahi_do_restart = 0;
static void create_services(AvahiClient *c);
AvahiClient *ac;
char *name2;
- name = name2 = avahi_strdup("Tvheadend");
+ do {
+ if (avahi_poll)
+ avahi_simple_poll_free((AvahiSimplePoll *)avahi_poll);
- ac = avahi_client_new(avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, NULL, NULL);
-
- while(avahi_simple_poll_iterate(avahi_asp, -1) == 0);
+ avahi_asp = avahi_simple_poll_new();
+ avahi_poll = avahi_simple_poll_get(avahi_asp);
- avahi_client_free(ac);
+ if(avahi_do_restart) {
+ tvhlog(LOG_INFO, "AVAHI", "Service restarted.");
+ avahi_do_restart = 0;
+ group = NULL;
+ }
- name = NULL;
- free(name2);
+ name = name2 = avahi_strdup(config_get_server_name());
- return NULL;
-
+ ac = avahi_client_new(avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, NULL, NULL);
+
+ while((avahi_do_restart == 0) &&
+ (avahi_simple_poll_iterate(avahi_asp, -1) == 0));
+
+ avahi_client_free(ac);
+
+ name = NULL;
+ free(name2);
+
+ } while (tvheadend_running && avahi_do_restart);
+ return NULL;
}
/**
void
avahi_init(void)
{
- avahi_asp = avahi_simple_poll_new();
- avahi_poll = avahi_simple_poll_get(avahi_asp);
tvhthread_create(&avahi_tid, NULL, avahi_thread, NULL);
}
pthread_join(avahi_tid, NULL);
avahi_simple_poll_free((AvahiSimplePoll *)avahi_poll);
}
+
+void
+avahi_restart(void)
+{
+ avahi_do_restart = 1;
+ avahi_simple_poll_quit(avahi_asp);
+}
#ifdef CONFIG_AVAHI
void avahi_init(void);
void avahi_done(void);
+void avahi_restart(void);
#else
static inline void avahi_init(void) { }
static inline void avahi_done(void) { }
+static inline void avahi_restart(void) {}
#endif
#include "spawn.h"
#include "lock.h"
#include "profile.h"
+#include "avahi.h"
/* *************************************************************************
* Global data
if (config_newcfg) {
htsmsg_set_u32(config, "version", ARRAY_SIZE(config_migrate_table));
htsmsg_set_str(config, "fullversion", tvheadend_version);
+ htsmsg_set_str(config, "server_name", "Tvheadend");
config_save();
/* Perform migrations */
return 0;
}
+const char *config_get_server_name ( void )
+{
+ const char *s = htsmsg_get_str(config, "server_name");
+ if (s == NULL || *s == '\0')
+ return "Tvheadend";
+ return s;
+}
+
+int config_set_server_name ( const char *name )
+{
+ int r = config_set_str("server_name", name);
+ avahi_restart();
+ return r;
+}
+
const char *config_get_language ( void )
{
const char *s = htsmsg_get_str(config, "language");
int config_get_int ( const char *fld, int dflt );
int config_set_int ( const char *fld, int val );
+const char *config_get_server_name ( void );
+int config_set_server_name ( const char *str )
+ __attribute__((warn_unused_result));
+
const char *config_get_muxconfpath ( void );
int config_set_muxconfpath ( const char *str )
__attribute__((warn_unused_result));
<specVersion><major>1</major><minor>1</minor></specVersion>\n\
<device>\n\
<deviceType>urn:ses-com:device:SatIPServer:1</deviceType>\n\
-<friendlyName>TVHeadend%s</friendlyName>\n\
+<friendlyName>%s%s</friendlyName>\n\
<manufacturer>TVHeadend Team</manufacturer>\n\
<manufacturerURL>http://tvheadend.org</manufacturerURL>\n\
<modelDescription>TVHeadend %s</modelDescription>\n\
snprintf(buf2, sizeof(buf2), " %s", satip_server_uuid + 26);
snprintf(buf, sizeof(buf), MSG,
+ config_get_server_name(),
buf2, tvheadend_version,
satip_server_uuid,
http_server_ip, http_server_port,
/* Misc settings */
pthread_mutex_lock(&global_lock);
+ if ((str = http_arg_get(&hc->hc_req_args, "server_name")))
+ save |= config_set_server_name(str);
if ((str = http_arg_get(&hc->hc_req_args, "muxconfpath")))
save |= config_set_muxconfpath(str);
if ((str = http_arg_get(&hc->hc_req_args, "language")))
root: 'config'
},
[
- 'muxconfpath', 'language',
+ 'server_name', 'muxconfpath', 'language',
'tvhtime_update_enabled', 'tvhtime_ntp_enabled',
'tvhtime_tolerance',
'prefer_picon', 'chiconpath', 'piconpath',
* DVB path
*/
+ var serverName = new Ext.form.TextField({
+ fieldLabel: 'Tvheadend server name',
+ name: 'server_name',
+ allowBlank: true,
+ width: 400
+ });
+
+ var serverWrap = new Ext.form.FieldSet({
+ title: 'Server',
+ width: 700,
+ autoHeight: true,
+ collapsible: true,
+ animCollapse: true,
+ items : [ serverName ]
+ });
+
var dvbscanPath = new Ext.form.TextField({
fieldLabel: 'DVB scan files path',
name: 'muxconfpath',
}
});
- var _items = [languageWrap, dvbscanWrap, tvhtimePanel, piconPanel];
+ var _items = [serverWrap, languageWrap, dvbscanWrap, tvhtimePanel, piconPanel];
if (satipPanel)
_items.push(satipPanel);