Commit 07865d07 authored by Max Kellermann's avatar Max Kellermann

zeroconf/avahi/Poll: move to namespace Avahi

parent 1ac16516
......@@ -36,7 +36,7 @@
static constexpr Domain avahi_domain("avahi");
static char *avahi_name;
static MyAvahiPoll *avahi_poll;
static Avahi::Poll *avahi_poll;
static AvahiClient *avahi_client;
static AvahiEntryGroup *avahi_group;
......@@ -241,7 +241,7 @@ AvahiInit(EventLoop &loop, const char *serviceName)
avahi_name = avahi_strdup(serviceName);
avahi_poll = new MyAvahiPoll(loop);
avahi_poll = new Avahi::Poll(loop);
int error;
avahi_client = avahi_client_new(avahi_poll, AVAHI_CLIENT_NO_FAIL,
......
......@@ -39,6 +39,7 @@ ToAvahiWatchEvent(unsigned e) noexcept
}
struct AvahiWatch final {
private:
SocketEvent event;
const AvahiWatchCallback callback;
......@@ -109,7 +110,9 @@ private:
}
};
MyAvahiPoll::MyAvahiPoll(EventLoop &_loop) noexcept
namespace Avahi {
Poll::Poll(EventLoop &_loop) noexcept
:event_loop(_loop)
{
watch_new = WatchNew;
......@@ -122,20 +125,22 @@ MyAvahiPoll::MyAvahiPoll(EventLoop &_loop) noexcept
}
AvahiWatch *
MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event,
AvahiWatchCallback callback, void *userdata) noexcept
Poll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event,
AvahiWatchCallback callback, void *userdata) noexcept
{
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
const Poll &poll = *(const Poll *)api;
return new AvahiWatch(poll.event_loop, SocketDescriptor(fd), event,
callback, userdata);
}
AvahiTimeout *
MyAvahiPoll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv,
AvahiTimeoutCallback callback, void *userdata) noexcept
Poll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv,
AvahiTimeoutCallback callback, void *userdata) noexcept
{
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
const Poll &poll = *(const Poll *)api;
return new AvahiTimeout(poll.event_loop, tv, callback, userdata);
}
} // namespace Avahi
......@@ -24,14 +24,16 @@
class EventLoop;
class MyAvahiPoll final : public AvahiPoll {
namespace Avahi {
class Poll final : public AvahiPoll {
EventLoop &event_loop;
public:
explicit MyAvahiPoll(EventLoop &_loop) noexcept;
explicit Poll(EventLoop &_loop) noexcept;
MyAvahiPoll(const MyAvahiPoll &) = delete;
MyAvahiPoll &operator=(const MyAvahiPoll &) = delete;
Poll(const Poll &) = delete;
Poll &operator=(const Poll &) = delete;
EventLoop &GetEventLoop() const noexcept {
return event_loop;
......@@ -49,4 +51,6 @@ private:
void *userdata) noexcept;
};
} // namespace Avahi
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment