2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2010-01-01 05:55:13 +01:00
|
|
|
* Copyright (C) 2003-2010 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2007-01-11 21:41:17 +01:00
|
|
|
*
|
|
|
|
* 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 2 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-01-11 21:41:17 +01:00
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2007-01-11 21:41:17 +01:00
|
|
|
#include "zeroconf.h"
|
2008-12-30 16:43:58 +01:00
|
|
|
#include "zeroconf-internal.h"
|
2007-01-11 21:41:17 +01:00
|
|
|
#include "conf.h"
|
|
|
|
|
2008-11-24 14:40:40 +01:00
|
|
|
#include <glib.h>
|
|
|
|
|
2008-01-03 11:03:28 +01:00
|
|
|
/* The default service name to publish
|
2007-01-11 21:41:17 +01:00
|
|
|
* (overridden by 'zeroconf_name' config parameter)
|
|
|
|
*/
|
|
|
|
#define SERVICE_NAME "Music Player"
|
|
|
|
|
2007-06-03 21:25:25 +02:00
|
|
|
#define DEFAULT_ZEROCONF_ENABLED 1
|
|
|
|
|
2007-06-03 21:30:37 +02:00
|
|
|
static int zeroconfEnabled;
|
2007-06-02 19:06:08 +02:00
|
|
|
|
2007-01-14 03:08:09 +01:00
|
|
|
void initZeroconf(void)
|
|
|
|
{
|
2009-01-27 20:17:44 +01:00
|
|
|
const char *serviceName;
|
2007-06-03 20:08:51 +02:00
|
|
|
|
2009-01-17 20:23:33 +01:00
|
|
|
zeroconfEnabled = config_get_bool(CONF_ZEROCONF_ENABLED,
|
|
|
|
DEFAULT_ZEROCONF_ENABLED);
|
2007-06-03 21:25:25 +02:00
|
|
|
if (!zeroconfEnabled)
|
2007-06-03 20:08:51 +02:00
|
|
|
return;
|
2007-01-14 03:08:09 +01:00
|
|
|
|
2009-01-27 20:17:44 +01:00
|
|
|
serviceName = config_get_string(CONF_ZEROCONF_NAME, SERVICE_NAME);
|
2007-06-02 19:06:08 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_AVAHI
|
2007-01-14 03:08:09 +01:00
|
|
|
init_avahi(serviceName);
|
2007-06-02 19:06:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_BONJOUR
|
|
|
|
init_zeroconf_osx(serviceName);
|
|
|
|
#endif
|
2007-01-11 21:41:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void finishZeroconf(void)
|
|
|
|
{
|
2007-06-03 21:25:25 +02:00
|
|
|
if (!zeroconfEnabled)
|
2007-06-03 20:08:51 +02:00
|
|
|
return;
|
|
|
|
|
2007-01-14 05:25:27 +01:00
|
|
|
#ifdef HAVE_AVAHI
|
2008-12-30 16:43:58 +01:00
|
|
|
avahi_finish();
|
2007-05-16 01:23:09 +02:00
|
|
|
#endif /* HAVE_AVAHI */
|
2007-06-02 19:06:08 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_BONJOUR
|
2008-12-30 16:43:58 +01:00
|
|
|
bonjour_finish();
|
2007-06-02 19:06:08 +02:00
|
|
|
#endif
|
2007-01-11 21:41:17 +01:00
|
|
|
}
|