diff --git a/src/zeroconf/Glue.cxx b/src/zeroconf/Glue.cxx index 06af7a041..34c9612f3 100644 --- a/src/zeroconf/Glue.cxx +++ b/src/zeroconf/Glue.cxx @@ -84,13 +84,5 @@ ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop) } } -#ifdef HAVE_AVAHI - return std::make_unique(AvahiInit(loop, serviceName, - listen_port)); -#endif - -#ifdef HAVE_BONJOUR - return std::make_unique(BonjourInit(loop, serviceName, - listen_port)); -#endif + return std::make_unique(loop, serviceName, listen_port); } diff --git a/src/zeroconf/Helper.cxx b/src/zeroconf/Helper.cxx index c44f47193..b996823b1 100644 --- a/src/zeroconf/Helper.cxx +++ b/src/zeroconf/Helper.cxx @@ -21,10 +21,16 @@ #ifdef HAVE_AVAHI #include "avahi/Helper.hxx" +#define CreateHelper AvahiInit #endif #ifdef HAVE_BONJOUR #include "Bonjour.hxx" +#define CreateHelper BonjourInit #endif +ZeroconfHelper::ZeroconfHelper(EventLoop &event_loop, const char *name, + unsigned port) + :helper(CreateHelper(event_loop, name, port)) {} + ZeroconfHelper::~ZeroconfHelper() noexcept = default; diff --git a/src/zeroconf/Helper.hxx b/src/zeroconf/Helper.hxx index 7c7a22215..1b39bf440 100644 --- a/src/zeroconf/Helper.hxx +++ b/src/zeroconf/Helper.hxx @@ -24,6 +24,7 @@ #include +class EventLoop; class AvahiHelper; class BonjourHelper; @@ -37,9 +38,8 @@ class ZeroconfHelper final { #endif public: - template - ZeroconfHelper(T &&_helper) noexcept - :helper(std::forward(_helper)) {} + ZeroconfHelper(EventLoop &event_loop, const char *name, + unsigned port); ~ZeroconfHelper() noexcept; };