zeroconf/Bonjour: return a std::unique_ptr<BonjourHelper>
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "Glue.hxx"
|
||||
#include "avahi/Init.hxx"
|
||||
#include "Bonjour.hxx"
|
||||
#include "config/Data.hxx"
|
||||
#include "config/Option.hxx"
|
||||
#include "Listen.hxx"
|
||||
@@ -27,6 +26,10 @@
|
||||
#include "Log.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#ifdef HAVE_BONJOUR
|
||||
#include "Bonjour.hxx"
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <string.h>
|
||||
@@ -49,6 +52,10 @@ static constexpr Domain zeroconf_domain("zeroconf");
|
||||
|
||||
static int zeroconfEnabled;
|
||||
|
||||
#ifdef HAVE_BONJOUR
|
||||
static std::unique_ptr<BonjourHelper> bonjour_helper;
|
||||
#endif
|
||||
|
||||
void
|
||||
ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop)
|
||||
{
|
||||
@@ -86,21 +93,21 @@ ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BONJOUR
|
||||
BonjourInit(loop, serviceName, listen_port);
|
||||
bonjour_helper = BonjourInit(loop, serviceName, listen_port);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ZeroconfDeinit() noexcept
|
||||
{
|
||||
#ifdef HAVE_BONJOUR
|
||||
bonjour_helper.reset();
|
||||
#endif
|
||||
|
||||
if (!zeroconfEnabled)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_AVAHI
|
||||
AvahiDeinit();
|
||||
#endif /* HAVE_AVAHI */
|
||||
|
||||
#ifdef HAVE_BONJOUR
|
||||
BonjourDeinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user