Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
95c3f57b
Commit
95c3f57b
authored
Jan 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zeroconf: convert to C++
parent
068f191c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
49 deletions
+118
-49
Makefile.am
Makefile.am
+5
-4
Main.cxx
src/Main.cxx
+3
-3
ZeroconfAvahi.cxx
src/ZeroconfAvahi.cxx
+10
-6
ZeroconfAvahi.hxx
src/ZeroconfAvahi.hxx
+6
-14
ZeroconfBonjour.cxx
src/ZeroconfBonjour.cxx
+9
-6
ZeroconfBonjour.hxx
src/ZeroconfBonjour.hxx
+29
-0
ZeroconfGlue.cxx
src/ZeroconfGlue.cxx
+11
-8
ZeroconfGlue.hxx
src/ZeroconfGlue.hxx
+45
-0
ZeroconfInternal.hxx
src/ZeroconfInternal.hxx
+0
-8
No files found.
Makefile.am
View file @
95c3f57b
...
...
@@ -117,7 +117,6 @@ mpd_headers = \
src/uri.h
\
src/utils.h
\
src/string_util.h
\
src/zeroconf.h src/zeroconf-internal.h
\
src/timer.h
\
src/mpd_error.h
...
...
@@ -681,14 +680,16 @@ endif
if
HAVE_ZEROCONF
src_mpd_SOURCES
+=
src/zeroconf.c
src_mpd_SOURCES
+=
\
src/ZeroconfInternal.hxx
\
src/ZeroconfGlue.cxx src/ZeroconfGlue.hxx
if
HAVE_AVAHI
src_mpd_SOURCES
+=
src/
zeroconf-avahi.c
src_mpd_SOURCES
+=
src/
ZeroconfAvahi.cxx src/ZeroconfAvahi.hxx
endif
if
HAVE_BONJOUR
src_mpd_SOURCES
+=
src/
zeroconf-bonjour.c
src_mpd_SOURCES
+=
src/
ZeroconfBonjour.cxx src/ZeroconfBonjour.hxx
endif
endif
...
...
src/Main.cxx
View file @
95c3f57b
...
...
@@ -49,6 +49,7 @@
#include "IOThread.hxx"
#include "fs/Path.hxx"
#include "PlaylistRegistry.hxx"
#include "ZeroconfGlue.hxx"
extern
"C"
{
#include "daemon.h"
...
...
@@ -56,7 +57,6 @@ extern "C" {
#include "audio_config.h"
#include "pcm_resample.h"
#include "decoder_list.h"
#include "zeroconf.h"
}
#include "mpd_error.h"
...
...
@@ -490,7 +490,7 @@ int mpd_main(int argc, char *argv[])
return
EXIT_FAILURE
;
}
initZeroconf
();
ZeroconfInit
();
player_create
(
&
global_partition
->
pc
);
...
...
@@ -551,7 +551,7 @@ int mpd_main(int argc, char *argv[])
}
global_partition
->
pc
.
Kill
();
finishZeroconf
();
ZeroconfDeinit
();
listen_global_finish
();
delete
client_list
;
...
...
src/
zeroconf-avahi.c
→
src/
ZeroconfAvahi.cxx
View file @
95c3f57b
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,7 +18,8 @@
*/
#include "config.h"
#include "zeroconf-internal.h"
#include "ZeroconfAvahi.hxx"
#include "ZeroconfInternal.hxx"
#include "Listen.hxx"
#include "mpd_error.h"
...
...
@@ -116,7 +117,8 @@ static void avahiRegisterService(AvahiClient * c)
* if that's better. */
ret
=
avahi_entry_group_add_service
(
avahiGroup
,
AVAHI_IF_UNSPEC
,
AVAHI_PROTO_UNSPEC
,
0
,
avahiName
,
SERVICE_TYPE
,
NULL
,
AvahiPublishFlags
(
0
),
avahiName
,
SERVICE_TYPE
,
NULL
,
NULL
,
listen_port
,
NULL
);
if
(
ret
<
0
)
{
g_warning
(
"Failed to add service %s: %s"
,
SERVICE_TYPE
,
...
...
@@ -213,7 +215,8 @@ static void avahiClientCallback(AvahiClient * c, AvahiClientState state,
}
}
void
init_avahi
(
const
char
*
serviceName
)
void
AvahiInit
(
const
char
*
serviceName
)
{
int
error
;
g_debug
(
"Initializing interface"
);
...
...
@@ -234,11 +237,12 @@ void init_avahi(const char *serviceName)
if
(
!
avahiClient
)
{
g_warning
(
"Failed to create client: %s"
,
avahi_strerror
(
error
));
avahi_finish
();
AvahiDeinit
();
}
}
void
avahi_finish
(
void
)
void
AvahiDeinit
(
void
)
{
g_debug
(
"Shutting down interface"
);
...
...
src/
zeroconf.h
→
src/
ZeroconfAvahi.hxx
View file @
95c3f57b
...
...
@@ -17,21 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ZEROCONF_
H
#define MPD_ZEROCONF_
H
#ifndef MPD_ZEROCONF_
AVAHI_HXX
#define MPD_ZEROCONF_
AVAHI_HXX
#include "check.h"
void
AvahiInit
(
const
char
*
service_name
);
#ifdef HAVE_ZEROCONF
void
initZeroconf
(
void
);
void
finishZeroconf
(
void
);
#else
/* ! HAVE_ZEROCONF */
static
void
initZeroconf
(
void
)
{
}
static
void
finishZeroconf
(
void
)
{
}
#endif
/* ! HAVE_ZEROCONF */
void
AvahiDeinit
();
#endif
src/
zeroconf-bonjour.c
→
src/
ZeroconfBonjour.cxx
View file @
95c3f57b
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,7 +18,8 @@
*/
#include "config.h"
#include "zeroconf-internal.h"
#include "ZeroconfBonjour.hxx"
#include "ZeroconfInternal.hxx"
#include "Listen.hxx"
#include <glib.h>
...
...
@@ -42,7 +43,7 @@ dnsRegisterCallback(G_GNUC_UNUSED DNSServiceRef sdRef,
if
(
errorCode
!=
kDNSServiceErr_NoError
)
{
g_warning
(
"Failed to register zeroconf service."
);
bonjour_finish
();
BonjourDeinit
();
}
else
{
g_debug
(
"Registered zeroconf service with name '%s'"
,
name
);
}
...
...
@@ -58,10 +59,11 @@ bonjour_channel_event(G_GNUC_UNUSED GIOChannel *source,
return
dnsReference
!=
NULL
;
}
void
init_zeroconf_osx
(
const
char
*
serviceName
)
void
BonjourInit
(
const
char
*
service_name
)
{
DNSServiceErrorType
error
=
DNSServiceRegister
(
&
dnsReference
,
0
,
0
,
service
N
ame
,
0
,
0
,
service
_n
ame
,
SERVICE_TYPE
,
NULL
,
NULL
,
g_htons
(
listen_port
),
0
,
NULL
,
...
...
@@ -82,7 +84,8 @@ void init_zeroconf_osx(const char *serviceName)
g_io_add_watch
(
bonjour_channel
,
G_IO_IN
,
bonjour_channel_event
,
NULL
);
}
void
bonjour_finish
(
void
)
void
BonjourDeinit
()
{
if
(
bonjour_channel
!=
NULL
)
{
g_io_channel_unref
(
bonjour_channel
);
...
...
src/ZeroconfBonjour.hxx
0 → 100644
View file @
95c3f57b
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ZEROCONF_BONJOUR_HXX
#define MPD_ZEROCONF_BONJOUR_HXX
void
BonjourInit
(
const
char
*
service_name
);
void
BonjourDeinit
();
#endif
src/
zeroconf.c
→
src/
ZeroconfGlue.cxx
View file @
95c3f57b
...
...
@@ -18,8 +18,9 @@
*/
#include "config.h"
#include "zeroconf.h"
#include "zeroconf-internal.h"
#include "ZeroconfGlue.hxx"
#include "ZeroconfAvahi.hxx"
#include "ZeroconfBonjour.hxx"
#include "conf.h"
#include "Listen.hxx"
...
...
@@ -34,7 +35,8 @@
static
int
zeroconfEnabled
;
void
initZeroconf
(
void
)
void
ZeroconfInit
()
{
const
char
*
serviceName
;
...
...
@@ -52,24 +54,25 @@ void initZeroconf(void)
serviceName
=
config_get_string
(
CONF_ZEROCONF_NAME
,
SERVICE_NAME
);
#ifdef HAVE_AVAHI
init_avahi
(
serviceName
);
AvahiInit
(
serviceName
);
#endif
#ifdef HAVE_BONJOUR
init_zeroconf_osx
(
serviceName
);
BonjourInit
(
serviceName
);
#endif
}
void
finishZeroconf
(
void
)
void
ZeroconfDeinit
()
{
if
(
!
zeroconfEnabled
)
return
;
#ifdef HAVE_AVAHI
avahi_finish
();
AvahiDeinit
();
#endif
/* HAVE_AVAHI */
#ifdef HAVE_BONJOUR
bonjour_finish
();
BonjourDeinit
();
#endif
}
src/ZeroconfGlue.hxx
0 → 100644
View file @
95c3f57b
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ZEROCONF_GLUE_HXX
#define MPD_ZEROCONF_GLUE_HXX
#include "check.h"
#ifdef HAVE_ZEROCONF
void
ZeroconfInit
();
void
ZeroconfDeinit
();
#else
/* ! HAVE_ZEROCONF */
static
inline
void
ZeroconfInit
()
{}
static
inline
void
ZeroconfDeinit
()
{}
#endif
/* ! HAVE_ZEROCONF */
#endif
src/
zeroconf-internal.h
→
src/
ZeroconfInternal.hxx
View file @
95c3f57b
...
...
@@ -23,12 +23,4 @@
/* The dns-sd service type qualifier to publish */
#define SERVICE_TYPE "_mpd._tcp"
void
init_avahi
(
const
char
*
service_name
);
void
avahi_finish
(
void
);
void
init_zeroconf_osx
(
const
char
*
service_name
);
void
bonjour_finish
(
void
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment