lib/avahi/Service: add field visible
Now individual services can be hidden or shown at any time.
This commit is contained in:
parent
8d02986b0e
commit
aef2c5dc14
@ -55,22 +55,25 @@ Publisher::~Publisher() noexcept
|
|||||||
client.RemoveListener(*this);
|
client.RemoveListener(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Publisher::UpdateServices() noexcept
|
||||||
|
{
|
||||||
|
if (visible && client.IsConnected())
|
||||||
|
defer_register_services.Schedule();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Publisher::AddService(Service &service) noexcept
|
Publisher::AddService(Service &service) noexcept
|
||||||
{
|
{
|
||||||
services.push_back(service);
|
services.push_back(service);
|
||||||
|
UpdateServices();
|
||||||
if (visible && client.IsConnected())
|
|
||||||
defer_register_services.Schedule();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Publisher::RemoveService(Service &service) noexcept
|
Publisher::RemoveService(Service &service) noexcept
|
||||||
{
|
{
|
||||||
services.erase(services.iterator_to(service));
|
services.erase(services.iterator_to(service));
|
||||||
|
UpdateServices();
|
||||||
if (visible && client.IsConnected())
|
|
||||||
defer_register_services.Schedule();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
@ -141,7 +144,8 @@ AddServices(AvahiEntryGroup &group,
|
|||||||
const IntrusiveList<Service> &services, const char *name)
|
const IntrusiveList<Service> &services, const char *name)
|
||||||
{
|
{
|
||||||
for (const auto &i : services)
|
for (const auto &i : services)
|
||||||
AddService(group, i, name);
|
if (i.visible)
|
||||||
|
AddService(group, i, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -59,6 +59,12 @@ public:
|
|||||||
Publisher(const Publisher &) = delete;
|
Publisher(const Publisher &) = delete;
|
||||||
Publisher &operator=(const Publisher &) = delete;
|
Publisher &operator=(const Publisher &) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this after a #Service field was modified to publish
|
||||||
|
* the changes.
|
||||||
|
*/
|
||||||
|
void UpdateServices() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish another service.
|
* Publish another service.
|
||||||
*
|
*
|
||||||
|
@ -22,6 +22,13 @@ struct Service : IntrusiveListHook<> {
|
|||||||
std::string type;
|
std::string type;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this is false, then the service is not published. You
|
||||||
|
* can change this field at any time and then call
|
||||||
|
* Publisher::UpdateServices() to publish the change.
|
||||||
|
*/
|
||||||
|
bool visible = true;
|
||||||
|
|
||||||
Service(AvahiIfIndex _interface, AvahiProtocol _protocol,
|
Service(AvahiIfIndex _interface, AvahiProtocol _protocol,
|
||||||
const char *_type, uint16_t _port) noexcept
|
const char *_type, uint16_t _port) noexcept
|
||||||
:interface(_interface), protocol(_protocol),
|
:interface(_interface), protocol(_protocol),
|
||||||
|
Loading…
Reference in New Issue
Block a user