Provide Avahi Server object to ServiceBrowser objects.

This commit is contained in:
Vibhav Pant
2023-08-29 16:14:33 +05:30
parent adb1e1d235
commit 6b4c8446bc
3 changed files with 6 additions and 5 deletions
@@ -60,10 +60,11 @@ class ServiceBrowser : public sdbus::ProxyInterfaces<
public:
ServiceBrowser(sdbus::IConnection &system_bus,
const sdbus::ObjectPath &service_browser_object_path,
api::WifiLanMedium::DiscoveredServiceCallback callback)
api::WifiLanMedium::DiscoveredServiceCallback callback,
std::shared_ptr<Server> avahi_server)
: ProxyInterfaces(system_bus, "org.freedesktop.Avahi",
service_browser_object_path),
discovery_cb_(std::move(callback)) {
discovery_cb_(std::move(callback)), server_(avahi_server) {
registerProxy();
}
~ServiceBrowser() {
@@ -26,7 +26,7 @@ namespace linux {
WifiLanMedium::WifiLanMedium(sdbus::IConnection &system_bus)
: system_bus_(system_bus),
network_manager_(std::make_shared<linux::NetworkManager>(system_bus)),
avahi_(std::make_unique<avahi::Server>(system_bus)) {}
avahi_(std::make_shared<avahi::Server>(system_bus)) {}
bool WifiLanMedium::IsNetworkConnected() const {
auto state = network_manager_->getState();
@@ -151,7 +151,7 @@ bool WifiLanMedium::StartDiscovery(
service_browsers_.emplace(
service_type,
std::make_unique<avahi::ServiceBrowser>(
system_bus_, browser_object_path, std::move(callback)));
system_bus_, browser_object_path, std::move(callback), avahi_));
} catch (const sdbus::Error &e) {
DBUS_LOG_METHOD_CALL_ERROR(avahi_, "ServiceBrowserPrepare", e);
return false;
@@ -50,7 +50,7 @@ private:
std::shared_ptr<NetworkManager> network_manager_;
std::unique_ptr<avahi::Server> avahi_;
std::shared_ptr<avahi::Server> avahi_;
absl::Mutex entry_groups_mutex_;
absl::flat_hash_map<std::pair<std::string, std::string>,