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
29b49dd6
Commit
29b49dd6
authored
Feb 24, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zeroconf/{bonjour,avahi}: pass service_type as parameter
parent
9d6bf7e7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
24 additions
and
42 deletions
+24
-42
Bonjour.cxx
src/zeroconf/Bonjour.cxx
+6
-5
Bonjour.hxx
src/zeroconf/Bonjour.hxx
+4
-2
Glue.cxx
src/zeroconf/Glue.cxx
+5
-1
Helper.cxx
src/zeroconf/Helper.cxx
+2
-2
Helper.hxx
src/zeroconf/Helper.hxx
+1
-1
Internal.hxx
src/zeroconf/Internal.hxx
+0
-26
Helper.cxx
src/zeroconf/avahi/Helper.cxx
+3
-3
Helper.hxx
src/zeroconf/avahi/Helper.hxx
+2
-1
RunZeroconf.cxx
test/RunZeroconf.cxx
+1
-1
No files found.
src/zeroconf/Bonjour.cxx
View file @
29b49dd6
...
...
@@ -18,7 +18,6 @@
*/
#include "Bonjour.hxx"
#include "Internal.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include "util/Compiler.h"
...
...
@@ -53,8 +52,9 @@ RegisterBonjour(const char *name, const char *type, unsigned port,
return
ref
;
}
BonjourHelper
::
BonjourHelper
(
EventLoop
&
_loop
,
const
char
*
name
,
unsigned
port
)
:
service_ref
(
RegisterBonjour
(
name
,
SERVICE_TYPE
,
port
,
BonjourHelper
::
BonjourHelper
(
EventLoop
&
_loop
,
const
char
*
name
,
const
char
*
service_type
,
unsigned
port
)
:
service_ref
(
RegisterBonjour
(
name
,
service_type
,
port
,
Callback
,
this
)),
socket_event
(
_loop
,
BIND_THIS_METHOD
(
OnSocketReady
),
...
...
@@ -86,7 +86,8 @@ BonjourHelper::Callback([[maybe_unused]] DNSServiceRef sdRef,
}
std
::
unique_ptr
<
BonjourHelper
>
BonjourInit
(
EventLoop
&
loop
,
const
char
*
service_name
,
unsigned
port
)
BonjourInit
(
EventLoop
&
loop
,
const
char
*
name
,
const
char
*
service_type
,
unsigned
port
)
{
return
std
::
make_unique
<
BonjourHelper
>
(
loop
,
service_nam
e
,
port
);
return
std
::
make_unique
<
BonjourHelper
>
(
loop
,
name
,
service_typ
e
,
port
);
}
src/zeroconf/Bonjour.hxx
View file @
29b49dd6
...
...
@@ -34,7 +34,8 @@ class BonjourHelper final {
SocketEvent
socket_event
;
public
:
BonjourHelper
(
EventLoop
&
_loop
,
const
char
*
name
,
unsigned
port
);
BonjourHelper
(
EventLoop
&
_loop
,
const
char
*
name
,
const
char
*
service_name
,
unsigned
port
);
~
BonjourHelper
()
noexcept
{
DNSServiceRefDeallocate
(
service_ref
);
...
...
@@ -64,6 +65,7 @@ private:
* Throws on error.
*/
std
::
unique_ptr
<
BonjourHelper
>
BonjourInit
(
EventLoop
&
loop
,
const
char
*
service_name
,
unsigned
port
);
BonjourInit
(
EventLoop
&
loop
,
const
char
*
name
,
const
char
*
service_type
,
unsigned
port
);
#endif
src/zeroconf/Glue.cxx
View file @
29b49dd6
...
...
@@ -52,6 +52,9 @@ static constexpr Domain zeroconf_domain("zeroconf");
*/
#define SERVICE_NAME "Music Player @ %h"
/* The dns-sd service type qualifier to publish */
#define SERVICE_TYPE "_mpd._tcp"
#define DEFAULT_ZEROCONF_ENABLED 1
std
::
unique_ptr
<
ZeroconfHelper
>
...
...
@@ -84,5 +87,6 @@ ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop)
}
}
return
std
::
make_unique
<
ZeroconfHelper
>
(
loop
,
serviceName
,
listen_port
);
return
std
::
make_unique
<
ZeroconfHelper
>
(
loop
,
serviceName
,
SERVICE_TYPE
,
listen_port
);
}
src/zeroconf/Helper.cxx
View file @
29b49dd6
...
...
@@ -30,7 +30,7 @@
#endif
ZeroconfHelper
::
ZeroconfHelper
(
EventLoop
&
event_loop
,
const
char
*
name
,
unsigned
port
)
:
helper
(
CreateHelper
(
event_loop
,
name
,
port
))
{}
const
char
*
service_type
,
unsigned
port
)
:
helper
(
CreateHelper
(
event_loop
,
name
,
service_type
,
port
))
{}
ZeroconfHelper
::~
ZeroconfHelper
()
noexcept
=
default
;
src/zeroconf/Helper.hxx
View file @
29b49dd6
...
...
@@ -39,7 +39,7 @@ class ZeroconfHelper final {
public
:
ZeroconfHelper
(
EventLoop
&
event_loop
,
const
char
*
name
,
unsigned
port
);
const
char
*
service_type
,
unsigned
port
);
~
ZeroconfHelper
()
noexcept
;
};
...
...
src/zeroconf/Internal.hxx
deleted
100644 → 0
View file @
9d6bf7e7
/*
* Copyright 2003-2021 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 ZEROCONF_INTERNAL_HXX
#define ZEROCONF_INTERNAL_HXX
/* The dns-sd service type qualifier to publish */
#define SERVICE_TYPE "_mpd._tcp"
#endif
src/zeroconf/avahi/Helper.cxx
View file @
29b49dd6
...
...
@@ -22,7 +22,6 @@
#include "ErrorHandler.hxx"
#include "Publisher.hxx"
#include "Service.hxx"
#include "../Internal.hxx"
#include "util/RuntimeError.hxx"
#include "Log.hxx"
...
...
@@ -53,7 +52,8 @@ AvahiHelper::AvahiHelper(std::shared_ptr<SharedAvahiClient> _client,
AvahiHelper
::~
AvahiHelper
()
noexcept
=
default
;
std
::
unique_ptr
<
AvahiHelper
>
AvahiInit
(
EventLoop
&
event_loop
,
const
char
*
service_name
,
unsigned
port
)
AvahiInit
(
EventLoop
&
event_loop
,
const
char
*
service_name
,
const
char
*
service_type
,
unsigned
port
)
{
if
(
!
avahi_is_valid_service_name
(
service_name
))
throw
FormatRuntimeError
(
"Invalid zeroconf_name
\"
%s
\"
"
,
...
...
@@ -67,7 +67,7 @@ AvahiInit(EventLoop &event_loop, const char *service_name, unsigned port)
std
::
forward_list
<
Avahi
::
Service
>
services
;
services
.
emplace_front
(
AVAHI_IF_UNSPEC
,
AVAHI_PROTO_UNSPEC
,
SERVICE_TYPE
,
port
);
service_type
,
port
);
auto
publisher
=
std
::
make_unique
<
Avahi
::
Publisher
>
(
client
->
client
,
service_name
,
...
...
src/zeroconf/avahi/Helper.hxx
View file @
29b49dd6
...
...
@@ -38,6 +38,7 @@ public:
};
std
::
unique_ptr
<
AvahiHelper
>
AvahiInit
(
EventLoop
&
event_loop
,
const
char
*
service_name
,
unsigned
port
);
AvahiInit
(
EventLoop
&
event_loop
,
const
char
*
service_name
,
const
char
*
service_type
,
unsigned
port
);
#endif
test/RunZeroconf.cxx
View file @
29b49dd6
...
...
@@ -29,7 +29,7 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
EventLoop
event_loop
;
const
ShutdownHandler
shutdown_handler
(
event_loop
);
const
ZeroconfHelper
helper
(
event_loop
,
"test"
,
1234
);
const
ZeroconfHelper
helper
(
event_loop
,
"test"
,
"_mpd._tcp"
,
1234
);
event_loop
.
Run
();
...
...
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