lib/avahi/Publisher: allow RegisterServices() to throw
This commit is contained in:
parent
09d1ab7abe
commit
1b241fc97a
|
@ -49,7 +49,11 @@ Publisher::Publisher(Client &_client, const char *_name,
|
||||||
client.AddListener(*this);
|
client.AddListener(*this);
|
||||||
|
|
||||||
if (client.IsConnected())
|
if (client.IsConnected())
|
||||||
|
try {
|
||||||
RegisterServices(client.GetClient());
|
RegisterServices(client.GetClient());
|
||||||
|
} catch (...) {
|
||||||
|
error_handler.OnAvahiError(std::current_exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Publisher::~Publisher() noexcept
|
Publisher::~Publisher() noexcept
|
||||||
|
@ -126,11 +130,10 @@ AddServices(AvahiEntryGroup &group,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Publisher::RegisterServices(AvahiClient *c) noexcept
|
Publisher::RegisterServices(AvahiClient *c)
|
||||||
{
|
{
|
||||||
assert(visible);
|
assert(visible);
|
||||||
|
|
||||||
try {
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
group.reset(avahi_entry_group_new(c, GroupCallback, this));
|
group.reset(avahi_entry_group_new(c, GroupCallback, this));
|
||||||
if (!group)
|
if (!group)
|
||||||
|
@ -142,9 +145,6 @@ Publisher::RegisterServices(AvahiClient *c) noexcept
|
||||||
if (int error = avahi_entry_group_commit(group.get());
|
if (int error = avahi_entry_group_commit(group.get());
|
||||||
error != AVAHI_OK)
|
error != AVAHI_OK)
|
||||||
throw MakeError(error, "Failed to commit Avahi service group");
|
throw MakeError(error, "Failed to commit Avahi service group");
|
||||||
} catch (...) {
|
|
||||||
error_handler.OnAvahiError(std::current_exception());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -168,14 +168,22 @@ Publisher::ShowServices() noexcept
|
||||||
visible = true;
|
visible = true;
|
||||||
|
|
||||||
if (client.IsConnected())
|
if (client.IsConnected())
|
||||||
|
try {
|
||||||
RegisterServices(client.GetClient());
|
RegisterServices(client.GetClient());
|
||||||
|
} catch (...) {
|
||||||
|
error_handler.OnAvahiError(std::current_exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Publisher::OnAvahiConnect(AvahiClient *c) noexcept
|
Publisher::OnAvahiConnect(AvahiClient *c) noexcept
|
||||||
{
|
{
|
||||||
if (visible)
|
if (visible)
|
||||||
|
try {
|
||||||
RegisterServices(c);
|
RegisterServices(c);
|
||||||
|
} catch (...) {
|
||||||
|
error_handler.OnAvahiError(std::current_exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
AvahiEntryGroupState state,
|
AvahiEntryGroupState state,
|
||||||
void *userdata) noexcept;
|
void *userdata) noexcept;
|
||||||
|
|
||||||
void RegisterServices(AvahiClient *c) noexcept;
|
void RegisterServices(AvahiClient *c);
|
||||||
|
|
||||||
/* virtual methods from class AvahiConnectionListener */
|
/* virtual methods from class AvahiConnectionListener */
|
||||||
void OnAvahiConnect(AvahiClient *client) noexcept override;
|
void OnAvahiConnect(AvahiClient *client) noexcept override;
|
||||||
|
|
Loading…
Reference in New Issue