zeroconf/avahi/Helper: embed the Avahi::Publisher without std::unique_ptr
This commit is contained in:
parent
74125c0922
commit
b20b773189
@ -4,7 +4,6 @@
|
|||||||
#include "Helper.hxx"
|
#include "Helper.hxx"
|
||||||
#include "lib/avahi/Client.hxx"
|
#include "lib/avahi/Client.hxx"
|
||||||
#include "lib/avahi/ErrorHandler.hxx"
|
#include "lib/avahi/ErrorHandler.hxx"
|
||||||
#include "lib/avahi/Publisher.hxx"
|
|
||||||
#include "lib/avahi/Service.hxx"
|
#include "lib/avahi/Service.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
@ -29,9 +28,11 @@ static std::weak_ptr<SharedAvahiClient> shared_avahi_client;
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
AvahiHelper::AvahiHelper(std::shared_ptr<SharedAvahiClient> _client,
|
AvahiHelper::AvahiHelper(std::shared_ptr<SharedAvahiClient> _client,
|
||||||
std::unique_ptr<Avahi::Publisher> _publisher)
|
const char *service_name,
|
||||||
|
std::forward_list<Avahi::Service> &&services)
|
||||||
:client(std::move(_client)),
|
:client(std::move(_client)),
|
||||||
publisher(std::move(_publisher)) {}
|
publisher(client->client, service_name,
|
||||||
|
std::move(services), *client) {}
|
||||||
|
|
||||||
AvahiHelper::~AvahiHelper() noexcept = default;
|
AvahiHelper::~AvahiHelper() noexcept = default;
|
||||||
|
|
||||||
@ -53,11 +54,6 @@ AvahiInit(EventLoop &event_loop, const char *service_name,
|
|||||||
AVAHI_PROTO_UNSPEC,
|
AVAHI_PROTO_UNSPEC,
|
||||||
service_type, port);
|
service_type, port);
|
||||||
|
|
||||||
auto publisher = std::make_unique<Avahi::Publisher>(client->client,
|
return std::make_unique<AvahiHelper>(std::move(client), service_name,
|
||||||
service_name,
|
std::move(services));
|
||||||
std::move(services),
|
|
||||||
*client);
|
|
||||||
|
|
||||||
return std::make_unique<AvahiHelper>(std::move(client),
|
|
||||||
std::move(publisher));
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// Copyright The Music Player Daemon Project
|
// Copyright The Music Player Daemon Project
|
||||||
|
|
||||||
#ifndef MPD_ZEROCONF_AVAHI_HELPER_HXX
|
#pragma once
|
||||||
#define MPD_ZEROCONF_AVAHI_HELPER_HXX
|
|
||||||
|
#include "lib/avahi/Publisher.hxx"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -13,16 +14,15 @@ class SharedAvahiClient;
|
|||||||
|
|
||||||
class AvahiHelper final {
|
class AvahiHelper final {
|
||||||
std::shared_ptr<SharedAvahiClient> client;
|
std::shared_ptr<SharedAvahiClient> client;
|
||||||
std::unique_ptr<Avahi::Publisher> publisher;
|
Avahi::Publisher publisher;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AvahiHelper(std::shared_ptr<SharedAvahiClient> _client,
|
AvahiHelper(std::shared_ptr<SharedAvahiClient> _client,
|
||||||
std::unique_ptr<Avahi::Publisher> _publisher);
|
const char *service_name,
|
||||||
|
std::forward_list<Avahi::Service> &&services);
|
||||||
~AvahiHelper() noexcept;
|
~AvahiHelper() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<AvahiHelper>
|
std::unique_ptr<AvahiHelper>
|
||||||
AvahiInit(EventLoop &event_loop, const char *service_name,
|
AvahiInit(EventLoop &event_loop, const char *service_name,
|
||||||
const char *service_type, unsigned port);
|
const char *service_type, unsigned port);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user