2007-01-11 21:41:17 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2007-04-05 05:22:33 +02:00
|
|
|
* Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
|
2007-01-11 21:41:17 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2009-01-08 21:37:02 +01:00
|
|
|
#include "config.h"
|
2007-01-11 21:41:17 +01:00
|
|
|
|
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)
|
|
|
|
{
|
2007-06-03 21:30:37 +02:00
|
|
|
const char *serviceName = SERVICE_NAME;
|
2009-01-17 20:23:27 +01:00
|
|
|
struct config_param *param;
|
2007-06-03 20:08:51 +02:00
|
|
|
|
2007-09-06 01:59:33 +02:00
|
|
|
zeroconfEnabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED, 1);
|
|
|
|
if (zeroconfEnabled == CONF_BOOL_UNSET)
|
2007-06-03 21:25:25 +02:00
|
|
|
zeroconfEnabled = DEFAULT_ZEROCONF_ENABLED;
|
|
|
|
|
|
|
|
if (!zeroconfEnabled)
|
2007-06-03 20:08:51 +02:00
|
|
|
return;
|
2007-01-14 03:08:09 +01:00
|
|
|
|
2009-01-17 20:23:27 +01:00
|
|
|
param = config_get_param(CONF_ZEROCONF_NAME);
|
2007-01-14 03:08:09 +01:00
|
|
|
|
2008-12-30 16:45:43 +01:00
|
|
|
if (param && *param->value != 0)
|
2007-01-14 03:08:09 +01:00
|
|
|
serviceName = param->value;
|
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
|
|
|
}
|