diff --git a/internal/platform/implementation/linux/avahi.cc b/internal/platform/implementation/linux/avahi.cc index c437699c..022610c3 100644 --- a/internal/platform/implementation/linux/avahi.cc +++ b/internal/platform/implementation/linux/avahi.cc @@ -58,7 +58,7 @@ void ServiceBrowser::onItemNew(const int32_t &interface, const std::string &type, const std::string &domain, const uint32_t &flags) { - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << ": Found new item through the ServiceBrowser: " << "interface: " << interface << ", protocol: " << protocol << ", name: '" << name << "', type: '" @@ -123,18 +123,18 @@ void ServiceBrowser::onItemRemove( } void ServiceBrowser::onFailure(const std::string &error) { - LOG(ERROR) << __func__ << ": " << getObjectPath() + LOG(ERROR) << __func__ << ": " << getProxy().getObjectPath() << ": ServiceBrowser reported a failure: " << error; } void ServiceBrowser::onAllForNow() { - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << ": notified via ServiceBrowser that all records have " "been added for now"; } void ServiceBrowser::onCacheExhausted() { - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << ": notified via ServiceBrowser of cache exhaustion"; } diff --git a/internal/platform/implementation/linux/avahi.h b/internal/platform/implementation/linux/avahi.h index 4c2578f3..7c8f87aa 100644 --- a/internal/platform/implementation/linux/avahi.h +++ b/internal/platform/implementation/linux/avahi.h @@ -44,7 +44,8 @@ class Server final public: Server(sdbus::IConnection &system_bus, api::WifiLanMedium::DiscoveredServiceCallback callback) - : ProxyInterfaces(system_bus, "org.freedesktop.Avahi", "/"), + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.freedesktop.Avahi"), + sdbus::ObjectPath("/")), discovery_cb_(std::move(callback)) { registerProxy(); @@ -74,13 +75,13 @@ class EntryGroup final public: EntryGroup(sdbus::IConnection &system_bus, const sdbus::ObjectPath &entry_group_object_path) - : ProxyInterfaces(system_bus, "org.freedesktop.Avahi", + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.freedesktop.Avahi"), entry_group_object_path) { registerProxy(); } ~EntryGroup() { LOG(INFO) << __func__ << ": Freeing entry group " - << getObjectPath(); + << getProxy().getObjectPath(); try { Free(); @@ -103,14 +104,14 @@ class ServiceBrowser final ServiceBrowser(sdbus::IConnection &system_bus, const sdbus::ObjectPath &service_browser_object_path, std::shared_ptr avahi_server) - : ProxyInterfaces(system_bus, "org.freedesktop.Avahi", + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.freedesktop.Avahi"), service_browser_object_path), server_(avahi_server) { registerProxy(); } ~ServiceBrowser() { LOG(INFO) << __func__ << ": Freeing service browser " - << getObjectPath(); + << getProxy().getObjectPath(); try { Free(); diff --git a/internal/platform/implementation/linux/ble_gatt_client.cc b/internal/platform/implementation/linux/ble_gatt_client.cc index fdb0dcbf..9dbd7ff5 100644 --- a/internal/platform/implementation/linux/ble_gatt_client.cc +++ b/internal/platform/implementation/linux/ble_gatt_client.cc @@ -399,7 +399,8 @@ try { void BluezGattDiscovery::onInterfacesAdded( const sdbus::ObjectPath &objectPath, - const std::map> + const std::map> &interfacesAndProperties) { if (interfacesAndProperties.count( org::bluez::GattCharacteristic1_proxy::INTERFACE_NAME) == 0) @@ -421,7 +422,7 @@ void BluezGattDiscovery::onInterfacesAdded( void BluezGattDiscovery::onInterfacesRemoved( const sdbus::ObjectPath &objectPath, - const std::vector &interfaces) { + const std::vector &interfaces) { auto begin = interfaces.cbegin(); auto end = interfaces.cend(); diff --git a/internal/platform/implementation/linux/ble_gatt_client.h b/internal/platform/implementation/linux/ble_gatt_client.h index 80394006..7ae7eb45 100644 --- a/internal/platform/implementation/linux/ble_gatt_client.h +++ b/internal/platform/implementation/linux/ble_gatt_client.h @@ -67,11 +67,12 @@ class BluezGattDiscovery final : public bluez::BluezObjectManager { protected: void onInterfacesAdded( const sdbus::ObjectPath &objectPath, - const std::map> + const std::map> &interfacesAndProperties) override ABSL_LOCKS_EXCLUDED(mutex_); void onInterfacesRemoved(const sdbus::ObjectPath &objectPath, - const std::vector &interfaces) override - ABSL_LOCKS_EXCLUDED(mutex_); + const std::vector &interfaces) + override ABSL_LOCKS_EXCLUDED(mutex_); private: std::optional> diff --git a/internal/platform/implementation/linux/ble_gatt_server.cc b/internal/platform/implementation/linux/ble_gatt_server.cc index 1a18cf07..24afa9ac 100644 --- a/internal/platform/implementation/linux/ble_gatt_server.cc +++ b/internal/platform/implementation/linux/ble_gatt_server.cc @@ -50,7 +50,7 @@ GattServer::CreateCharacteristic( LOG(ERROR) << __func__ << ": error emitting InterfacesAdded signal for object path " - << service->getObjectPath() << " with name '" << e.getName() + << service->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; return std::nullopt; } @@ -64,12 +64,12 @@ GattServer::CreateCharacteristic( LOG(INFO)<< __func__ << ": Registering service on gattmanager with characteristic_uuid: " << std::string(characteristic_uuid) << " and service_uuid: " << std::string(service_uuid); - gatt_manager_ -> RegisterApplication(gatt_service_root_object_manager -> getObjectPath(), {}); + gatt_manager_ -> RegisterApplication(gatt_service_root_object_manager -> getObject().getObjectPath(), {}); } catch (const sdbus::Error& e) { LOG(ERROR) << __func__ << ": error calling RegisterAplication for GattManager with object path " - << gatt_manager_->getObjectPath() << " with name '" << e.getName() + << gatt_manager_->getProxy().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; return std::nullopt; } @@ -142,7 +142,7 @@ void GattServer::Stop() { absl::MutexLock lock(&services_mutex_); for (auto& [uuid, service] : services_) { LOG(INFO) << __func__ << ": Unregistering service " - << service->getObjectPath(); + << service->getObject().getObjectPath(); try { manager.UnregisterApplication("/"); } catch (const sdbus::Error& e) { diff --git a/internal/platform/implementation/linux/ble_v2_medium.cc b/internal/platform/implementation/linux/ble_v2_medium.cc index 9d9c5ce6..d008bcea 100644 --- a/internal/platform/implementation/linux/ble_v2_medium.cc +++ b/internal/platform/implementation/linux/ble_v2_medium.cc @@ -88,9 +88,9 @@ BleV2Medium::BleV2Medium(BluetoothAdapter &adapter) LOG(INFO) << __func__ << ": Registering path /com/google/nearby/medium/ble/advertisement/monitor with AdvertisementMonitorManager at " - << adv_monitor_manager_->getObjectPath(); + << adv_monitor_manager_->getProxy().getObjectPath(); try { - adv_monitor_manager_->RegisterMonitor(root_object_manager_->getObjectPath()); + adv_monitor_manager_->RegisterMonitor(root_object_manager_->getObject().getObjectPath()); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(adv_monitor_manager_, "RegisterMonitor", e); } @@ -131,11 +131,11 @@ BleV2Medium::BleV2Medium(BluetoothAdapter &adapter) LOG(INFO) << __func__ << ": Registering advertisement, is_extended: " << advertising_data.is_extended_advertisement - << " " << (*it) -> getObjectPath() << " on bluetooth adapter " + << " " << (*it) -> getObject().getObjectPath() << " on bluetooth adapter " << adapter_.GetObjectPath(); try { - adv_manager_->RegisterAdvertisement((*it)->getObjectPath(), {}); + adv_manager_->RegisterAdvertisement((*it)->getObject().getObjectPath(), {}); } catch (const sdbus::Error &e) { advs_.erase(it); DBUS_LOG_METHOD_CALL_ERROR(adv_manager_, "RegisterAdvertisement", e); @@ -175,7 +175,7 @@ BleV2Medium::StartAdvertising( // Keep async API surface, but register using the same typed DBus path as the // working sync implementation to avoid signature mismatch (oa{sv} vs sa{sv}). try { - adv_manager_->RegisterAdvertisement((*adv_it)->getObjectPath(), {}); + adv_manager_->RegisterAdvertisement((*adv_it)->getObject().getObjectPath(), {}); shared_cb->start_advertising_result(absl::OkStatus()); } catch (const sdbus::Error &e) { advs_.erase(adv_it); @@ -199,10 +199,10 @@ BleV2Medium::StartAdvertising( absl::AnyInvocable stop_adv = [&, adv_it]() { LOG(INFO) << __func__ << ": Unregistering advertisement object " - << (*adv_it)->getObjectPath(); + << (*adv_it)->getObject().getObjectPath(); absl::MutexLock lock(&advs_mutex_); try { - adv_manager_->UnregisterAdvertisement((*adv_it)->getObjectPath()); + adv_manager_->UnregisterAdvertisement((*adv_it)->getObject().getObjectPath()); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(adv_manager_, "UnregisterAdvertisement", e); return absl::UnknownError(e.getMessage()); @@ -219,7 +219,7 @@ BleV2Medium::StartAdvertising( try { for (auto& adv: advs_) { - adv_manager_->UnregisterAdvertisement(adv->getObjectPath()); + adv_manager_->UnregisterAdvertisement(adv->getObject().getObjectPath()); } } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(adv_manager_, "UnregisterAdvertisement", e); @@ -270,13 +270,13 @@ bool BleV2Medium::StartScanning(const Uuid &service_uuid, monitor->emitInterfacesAddedSignal( {org::bluez::AdvertisementMonitor1_adaptor::INTERFACE_NAME}); - // adv_monitor_manager_ -> RegisterMonitor(monitor -> getObjectPath()); - LOG(INFO)<< __func__ << ": Registered advertisement monitor with path " << monitor -> getObjectPath(); + // adv_monitor_manager_ -> RegisterMonitor(monitor -> getObject().getObjectPath()); + LOG(INFO)<< __func__ << ": Registered advertisement monitor with path " << monitor -> getObject().getObjectPath(); } catch (const sdbus::Error &e) { LOG(ERROR) << __func__ << ": error emitting InterfacesAdded signal for object path " - << monitor->getObjectPath() << " with name '" << e.getName() + << monitor->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; return false; } @@ -294,7 +294,7 @@ bool BleV2Medium::StartScanning(const Uuid &service_uuid, LOG(ERROR) << __func__ << ": error emitting InterfacesRemoved signal for object path " - << monitor->getObjectPath() << " with name '" << e.getName() + << monitor->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; } return false; @@ -321,7 +321,7 @@ bool BleV2Medium::StopScanning() { auto &adapter = adapter_.GetBluezAdapterObject(); LOG(INFO) << __func__ << ": Stopping discovery for adapter " - << adapter.getObjectPath(); + << adapter.getProxy().getObjectPath(); try { adapter.StopDiscovery(); // this will stop bluetooth classic discovery as well. do we want this? } catch (const sdbus::Error &e) { @@ -336,7 +336,7 @@ bool BleV2Medium::StopScanning() { auto &[adv_monitor, _watcher] = session; LOG(INFO) << __func__ << ": Removing advertising monitor " - << adv_monitor->getObjectPath(); + << adv_monitor->getObject().getObjectPath(); adv_monitor->emitInterfacesRemovedSignal( {org::bluez::AdvertisementMonitor1_adaptor::INTERFACE_NAME}); } @@ -371,7 +371,7 @@ bool BleV2Medium::StopScanning() { LOG(ERROR) << __func__ << ": error emitting InterfacesAdded signal for object path " - << monitor->getObjectPath() << " with name '" << e.getName() + << monitor->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; return nullptr; } @@ -389,7 +389,7 @@ bool BleV2Medium::StopScanning() { LOG(ERROR) << __func__ << ": error emitting InterfacesRemoved signal for object path " - << monitor->getObjectPath() << " with name '" << e.getName() + << monitor->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; } return nullptr; @@ -417,7 +417,7 @@ bool BleV2Medium::StopScanning() { LOG(ERROR) << __func__ << ": error emitting InterfacesRemoved signal for object path " - << monitor->getObjectPath() << " with name '" << e.getName() + << monitor->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; } @@ -510,7 +510,7 @@ bool BleV2Medium::StartLEDiscovery() { try { LOG(INFO) << __func__ << ": Starting LE discovery on " - << adapter.getObjectPath(); + << adapter.getProxy().getObjectPath(); adapter.StartDiscovery(); } catch (const sdbus::Error &e) { if (e.getName() != "org.bluez.Error.InProgress") { diff --git a/internal/platform/implementation/linux/bluetooth_adapter.h b/internal/platform/implementation/linux/bluetooth_adapter.h index ccb76913..93d32399 100644 --- a/internal/platform/implementation/linux/bluetooth_adapter.h +++ b/internal/platform/implementation/linux/bluetooth_adapter.h @@ -29,7 +29,8 @@ class BluezAdapter : public sdbus::ProxyInterfaces { public: BluezAdapter(sdbus::IConnection &system_bus, const sdbus::ObjectPath &adapter_object_path) - : ProxyInterfaces(system_bus, bluez::SERVICE_DEST, adapter_object_path) { + : ProxyInterfaces(system_bus, sdbus::ServiceName(bluez::SERVICE_DEST), + adapter_object_path) { registerProxy(); } ~BluezAdapter() { unregisterProxy(); } @@ -68,7 +69,7 @@ class BluetoothAdapter : public api::BluetoothAdapter { } sdbus::ObjectPath GetObjectPath() const { - return bluez_adapter_->getObjectPath(); + return bluez_adapter_->getProxy().getObjectPath(); } BluezAdapter &GetBluezAdapterObject() { return *bluez_adapter_; } diff --git a/internal/platform/implementation/linux/bluetooth_bluez_profile.cc b/internal/platform/implementation/linux/bluetooth_bluez_profile.cc index 24cc91ad..18cdd266 100644 --- a/internal/platform/implementation/linux/bluetooth_bluez_profile.cc +++ b/internal/platform/implementation/linux/bluetooth_bluez_profile.cc @@ -47,7 +47,7 @@ bool ProfileManager::ProfileRegistered(absl::string_view service_uuid) { void Profile::Release() { released_ = true; - LOG(INFO) << __func__ << ": Profile object " << getObjectPath() + LOG(INFO) << __func__ << ": Profile object " << getObject().getObjectPath() << " has been released"; } @@ -57,7 +57,7 @@ void Profile::NewConnection( if (released_) { LOG(ERROR) << __func__ << ": NewConnection called on released object " - << getObjectPath(); + << getObject().getObjectPath(); throw sdbus::Error("org.bluez.Error.Rejected", "NewConnection called on released object"); } @@ -70,7 +70,7 @@ void Profile::NewConnection( auto alias = device->GetName(); auto mac_addr = device->GetAddress(); - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getObject().getObjectPath() << ": Connected to " << mac_addr.ToString(); FDProperties props(fd_props); @@ -79,7 +79,7 @@ void Profile::NewConnection( << " alias=" << alias; LOG(INFO) << "PUSH_ENTER profile=" << this << " mutex=" << &connections_lock_ - << " obj=" << getObjectPath() + << " obj=" << getObject().getObjectPath() << " path=" << device_object_path; { absl::MutexLock l(&connections_lock_); @@ -91,7 +91,7 @@ void Profile::RequestDisconnection( const sdbus::ObjectPath &device_object_path) { auto device = devices_.get_device_by_path(device_object_path); if (device == nullptr) { - LOG(ERROR) << __func__ << ": " << getObjectPath() + LOG(ERROR) << __func__ << ": " << getObject().getObjectPath() << ": RequestDisconnection called with a device object " "we don't know about: " << device_object_path; @@ -135,8 +135,8 @@ bool ProfileManager::Register(std::optional name, options["Channel"] = static_cast(0); options["PSM"] = static_cast(0); - RegisterProfile(profile->getObjectPath(), std::string(service_uuid), - options); + RegisterProfile(profile->getObject().getObjectPath(), + std::string(service_uuid), options); } catch (const sdbus::Error &e) { BLUEZ_LOG_METHOD_CALL_ERROR(&getProxy(), "RegisterProfile", e); return false; @@ -200,13 +200,13 @@ std::optional ProfileManager::GetServiceRecordFD( } ); - LOG(INFO) << __func__ << ": " << profile->getObjectPath() + LOG(INFO) << __func__ << ": " << profile->getObject().getObjectPath() << ": Attempting to get a FD for service " << service_uuid << " on device " << mac_addr.ToString(); LOG(INFO) << "WAIT profile=" << profile.get() << " mutex=" << &profile->connections_lock_ - << " obj=" << profile->getObjectPath() + << " obj=" << profile->getObject().getObjectPath() << " key=" << mac_addr.ToString(); auto cond = [mac_addr, profile, cancellation_flag]() { profile->connections_lock_.AssertHeld(); @@ -228,7 +228,7 @@ std::optional ProfileManager::GetServiceRecordFD( if (cancellation_flag != nullptr && cancellation_flag->Cancelled()) { LOG(INFO) - << __func__ << ": " << profile->getObjectPath() << ": " + << __func__ << ": " << profile->getObject().getObjectPath() << ": " << remote_device.GetMacAddress().ToString() << ": Cancelled waiting for a new connection on profile " << service_uuid; @@ -261,7 +261,7 @@ ProfileManager::GetServiceRecordFD(absl::string_view service_uuid, profile = registered_services_[std::string(service_uuid)]; } - LOG(INFO) << __func__ << ": " << profile->getObjectPath() + LOG(INFO) << __func__ << ": " << profile->getObject().getObjectPath() << ": Attempting to get a FD for service " << service_uuid; @@ -291,7 +291,7 @@ ProfileManager::GetServiceRecordFD(absl::string_view service_uuid, if (cancellation_flag != nullptr && cancellation_flag->Cancelled()) { LOG(INFO) << __func__ << ": Cancelled waiting for new connections on profile " - << profile->getObjectPath(); + << profile->getObject().getObjectPath(); profile->connections_lock_.Unlock(); return std::nullopt; } diff --git a/internal/platform/implementation/linux/bluetooth_bluez_profile.h b/internal/platform/implementation/linux/bluetooth_bluez_profile.h index 5ce50080..d0613eb8 100644 --- a/internal/platform/implementation/linux/bluetooth_bluez_profile.h +++ b/internal/platform/implementation/linux/bluetooth_bluez_profile.h @@ -61,7 +61,7 @@ class Profile final devices_(devices) { registerAdaptor(); LOG(INFO) << __func__ << ": Created a new BlueZ profile at :" - << getObjectPath(); + << getObject().getObjectPath(); } ~Profile() { unregisterAdaptor(); } @@ -110,7 +110,8 @@ class ProfileManager final ProfileManager &operator=(const ProfileManager &) = delete; ProfileManager &operator=(ProfileManager &&) = delete; ProfileManager(sdbus::IConnection &system_bus, BluetoothDevices &devices) - : ProxyInterfaces(system_bus, bluez::SERVICE_DEST, "/org/bluez"), + : ProxyInterfaces(system_bus, sdbus::ServiceName(bluez::SERVICE_DEST), + sdbus::ObjectPath("/org/bluez")), devices_(devices) { registerProxy(); } diff --git a/internal/platform/implementation/linux/bluetooth_classic_device.cc b/internal/platform/implementation/linux/bluetooth_classic_device.cc index b74dce6b..cfd7e8f5 100644 --- a/internal/platform/implementation/linux/bluetooth_classic_device.cc +++ b/internal/platform/implementation/linux/bluetooth_classic_device.cc @@ -152,7 +152,7 @@ bool BluetoothDevice::ConnectToProfile(absl::string_view service_uuid) { ObserverList &observers) : BluetoothDevice(device), ProxyInterfaces(*system_bus, bluez::SERVICE_DEST, - device->getObjectPath()), + device->getProxy().getObjectPath()), system_bus_(std::move(system_bus)), observers_(observers) { registerProxy(); @@ -170,7 +170,7 @@ void MonitoredBluetoothDevice::onPropertiesChanged( it++) { if (it->first == bluez::DEVICE_PROP_ADDRESS) { - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << ": Notifying observers about address change"; std::string address = it->second; for (const auto &observer : observers_.GetObservers()) { @@ -178,14 +178,14 @@ void MonitoredBluetoothDevice::onPropertiesChanged( } } else if (it->first == bluez::DEVICE_PROP_PAIRED) { - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << "Notifying observers about paired status change."; for (const auto &observer : observers_.GetObservers()) { observer->DevicePairedChanged(*this, it->second); } } else if (it->first == bluez::DEVICE_PROP_CONNECTED) { LOG(INFO) - << __func__ << ": " << getObjectPath() + << __func__ << ": " << getProxy().getObjectPath() << "Notifying observers about connected status change"; for (const auto &observer : observers_.GetObservers()) { observer->DeviceConnectedStateChanged(*this, it->second); diff --git a/internal/platform/implementation/linux/bluetooth_classic_device.h b/internal/platform/implementation/linux/bluetooth_classic_device.h index cd0aef92..99841b8a 100644 --- a/internal/platform/implementation/linux/bluetooth_classic_device.h +++ b/internal/platform/implementation/linux/bluetooth_classic_device.h @@ -118,7 +118,7 @@ class BluetoothDevice : public api::BluetoothDevice { void MarkLost() { lost_ = true; } void UnmarkLost() { lost_ = false; } bool Lost() const { return lost_; } - sdbus::ObjectPath GetObjectPath() {return device_->getObjectPath();} + sdbus::ObjectPath GetObjectPath() {return device_->getProxy().getObjectPath();} private: UniqueId unique_id_; diff --git a/internal/platform/implementation/linux/bluetooth_classic_medium.cc b/internal/platform/implementation/linux/bluetooth_classic_medium.cc index 941ae4e3..a205efc5 100644 --- a/internal/platform/implementation/linux/bluetooth_classic_medium.cc +++ b/internal/platform/implementation/linux/bluetooth_classic_medium.cc @@ -87,7 +87,7 @@ bool BluetoothClassicMedium::StartDiscovery( bool BluetoothClassicMedium::StopDiscovery() { auto &adapter = adapter_.GetBluezAdapterObject(); LOG(INFO) << __func__ << "Stopping discovery on " - << adapter.getObjectPath(); + << adapter.getProxy().getObjectPath(); auto ret = true; try { adapter.StopDiscovery(); diff --git a/internal/platform/implementation/linux/bluetooth_devices.cc b/internal/platform/implementation/linux/bluetooth_devices.cc index 353e478d..012abce5 100644 --- a/internal/platform/implementation/linux/bluetooth_devices.cc +++ b/internal/platform/implementation/linux/bluetooth_devices.cc @@ -143,17 +143,20 @@ std::shared_ptr BluetoothDevices::add_new_device( } void DeviceWatcher::onInterfacesAdded( - const sdbus::ObjectPath &object, - const std::map> - &interfaces) { + const sdbus::ObjectPath &objectPath, + const std::map> + &interfacesAndProperties) { auto path_prefix = absl::Substitute("$0/dev_", adapter_object_path_); - if (object.find(path_prefix) != 0) { + if (objectPath.find(path_prefix) != 0) { return; } - if (interfaces.count(org::bluez::Device1_proxy::INTERFACE_NAME) == 0) return; + if (interfacesAndProperties.count(org::bluez::Device1_proxy::INTERFACE_NAME) == + 0) + return; - auto device = devices_->add_new_device(object); + auto device = devices_->add_new_device(objectPath); device->SetDiscoveryCallback(discovery_cb_); if (discovery_cb_ != nullptr && discovery_cb_->device_discovered_cb != nullptr) { @@ -168,10 +171,10 @@ void DeviceWatcher::onInterfacesAdded( } void DeviceWatcher::onInterfacesRemoved( - const sdbus::ObjectPath &object, - const std::vector &interfaces) { + const sdbus::ObjectPath &objectPath, + const std::vector &interfaces) { auto path_prefix = absl::Substitute("$0/dev_", adapter_object_path_); - if (object.find(path_prefix) != 0) { + if (objectPath.find(path_prefix) != 0) { return; } diff --git a/internal/platform/implementation/linux/bluetooth_devices.h b/internal/platform/implementation/linux/bluetooth_devices.h index bcfb6e1c..3e471c7c 100644 --- a/internal/platform/implementation/linux/bluetooth_devices.h +++ b/internal/platform/implementation/linux/bluetooth_devices.h @@ -109,7 +109,8 @@ class DeviceWatcher final : sdbus::ProxyInterfaces { discovery_callback, std::shared_ptr> observers) - : ProxyInterfaces(system_bus, "org.bluez", "/"), + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.bluez"), + sdbus::ObjectPath("/")), adapter_object_path_(adapter_object_path), adapter_(adapter), devices_(std::move(devices)), @@ -127,11 +128,13 @@ class DeviceWatcher final : sdbus::ProxyInterfaces { ~DeviceWatcher() { unregisterProxy(); } void onInterfacesAdded( - const sdbus::ObjectPath &object, - const std::map> - &interfaces) override; - void onInterfacesRemoved(const sdbus::ObjectPath &object, - const std::vector &interfaces) override; + const sdbus::ObjectPath &objectPath, + const std::map> + &interfacesAndProperties) override; + void onInterfacesRemoved(const sdbus::ObjectPath &objectPath, + const std::vector &interfaces) + override; private: void notifyExistingDevices(); diff --git a/internal/platform/implementation/linux/bluez.h b/internal/platform/implementation/linux/bluez.h index cf3d9218..819950c0 100644 --- a/internal/platform/implementation/linux/bluez.h +++ b/internal/platform/implementation/linux/bluez.h @@ -29,7 +29,7 @@ LOG(ERROR) << __func__ << ": Got error '" << (err).getName() \ << "' with message '" << (err).getMessage() \ << "' while calling " << method << " on object " \ - << (proxy)->getObjectPath(); \ + << (proxy)->getProxy().getObjectPath(); \ } while (false) namespace nearby { @@ -67,7 +67,7 @@ class BluezObjectManager : public sdbus::ProxyInterfaces { public: explicit BluezObjectManager(sdbus::IConnection &system_bus) - : ProxyInterfaces(system_bus, "org.bluez", "/") { + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.bluez"), sdbus::ObjectPath("/")) { registerProxy(); } virtual ~BluezObjectManager() { unregisterProxy(); } @@ -75,11 +75,12 @@ class BluezObjectManager protected: void onInterfacesAdded( const sdbus::ObjectPath &objectPath, - const std::map> + const std::map> &interfacesAndProperties) override {} void onInterfacesRemoved( const sdbus::ObjectPath &objectPath, - const std::vector &interfaces) override {} + const std::vector &interfaces) override {} }; } // namespace bluez diff --git a/internal/platform/implementation/linux/bluez_advertisement_monitor.cc b/internal/platform/implementation/linux/bluez_advertisement_monitor.cc index bc3cd882..521061d5 100644 --- a/internal/platform/implementation/linux/bluez_advertisement_monitor.cc +++ b/internal/platform/implementation/linux/bluez_advertisement_monitor.cc @@ -52,7 +52,7 @@ void AdvertisementMonitor::DeviceFound(const sdbus::ObjectPath &device) { LOG(ERROR) << __func__ << ": Could not parse UUID string in ServiceData for peripheral " - << peripheral->getObjectPath(); + << peripheral->getProxy().getObjectPath(); continue; } diff --git a/internal/platform/implementation/linux/bluez_advertisement_monitor.h b/internal/platform/implementation/linux/bluez_advertisement_monitor.h index 6aadd517..9cbbe57b 100644 --- a/internal/platform/implementation/linux/bluez_advertisement_monitor.h +++ b/internal/platform/implementation/linux/bluez_advertisement_monitor.h @@ -53,7 +53,8 @@ class AdvertisementMonitor final // Methods void Release() override {} void Activate() override { - LOG(INFO) <<__func__ << ": bluez advertisement monitor activated at path: " << getObjectPath(); + LOG(INFO) <<__func__ << ": bluez advertisement monitor activated at path: " + << getObject().getObjectPath(); if (start_scanning_result_callback_ != nullptr) { start_scanning_result_callback_(absl::OkStatus()); } diff --git a/internal/platform/implementation/linux/bluez_advertisement_monitor_manager.h b/internal/platform/implementation/linux/bluez_advertisement_monitor_manager.h index 196b5e96..1cc55319 100644 --- a/internal/platform/implementation/linux/bluez_advertisement_monitor_manager.h +++ b/internal/platform/implementation/linux/bluez_advertisement_monitor_manager.h @@ -36,7 +36,8 @@ class AdvertisementMonitorManager final AdvertisementMonitorManager( sdbus::IConnection &system_bus, const ::nearby::linux::BluetoothAdapter &adapter) - : ProxyInterfaces(system_bus, "org.bluez", adapter.GetObjectPath()) { + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.bluez"), + adapter.GetObjectPath()) { registerProxy(); } diff --git a/internal/platform/implementation/linux/bluez_device.h b/internal/platform/implementation/linux/bluez_device.h index f419cbf0..215cf445 100644 --- a/internal/platform/implementation/linux/bluez_device.h +++ b/internal/platform/implementation/linux/bluez_device.h @@ -29,7 +29,7 @@ class Device : public sdbus::ProxyInterfaces { public: Device(std::shared_ptr system_bus, const sdbus::ObjectPath &device_path) - : ProxyInterfaces(*system_bus, "org.bluez", device_path), + : ProxyInterfaces(*system_bus, sdbus::ServiceName("org.bluez"), device_path), system_bus(std::move(system_bus)) { registerProxy(); } diff --git a/internal/platform/implementation/linux/bluez_gatt_characteristic_client.h b/internal/platform/implementation/linux/bluez_gatt_characteristic_client.h index 38b731cb..1da6a434 100644 --- a/internal/platform/implementation/linux/bluez_gatt_characteristic_client.h +++ b/internal/platform/implementation/linux/bluez_gatt_characteristic_client.h @@ -32,7 +32,8 @@ class GattCharacteristicClient public: GattCharacteristicClient(std::shared_ptr system_bus, sdbus::ObjectPath path) - : ProxyInterfaces(*system_bus, "org.bluez", std::move(path)), + : ProxyInterfaces(*system_bus, sdbus::ServiceName("org.bluez"), + std::move(path)), system_bus_(std::move(system_bus)) { registerProxy(); } diff --git a/internal/platform/implementation/linux/bluez_gatt_characteristic_server.cc b/internal/platform/implementation/linux/bluez_gatt_characteristic_server.cc index 979f1afc..dde5a09f 100644 --- a/internal/platform/implementation/linux/bluez_gatt_characteristic_server.cc +++ b/internal/platform/implementation/linux/bluez_gatt_characteristic_server.cc @@ -63,8 +63,9 @@ absl::Status GattCharacteristicServer::NotifyChanged( } catch (const sdbus::Error &e) { LOG(ERROR) << __func__ << ": Error emitting PropertiesChanged signal on " - << getObjectPath() << " with name '" << e.getName() - << "' and message '" << e.getMessage() << "'"; + << getObject().getObjectPath() << " with name '" + << e.getName() << "' and message '" << e.getMessage() + << "'"; return absl::UnknownError(e.getMessage()); } } diff --git a/internal/platform/implementation/linux/bluez_gatt_characteristic_server.h b/internal/platform/implementation/linux/bluez_gatt_characteristic_server.h index 9184cfb5..eb19c621 100644 --- a/internal/platform/implementation/linux/bluez_gatt_characteristic_server.h +++ b/internal/platform/implementation/linux/bluez_gatt_characteristic_server.h @@ -68,7 +68,7 @@ class GattCharacteristicServer final LOG(INFO) << __func__ << "Creating a " << org::bluez::GattCharacteristic1_adaptor::INTERFACE_NAME - << " object at " << getObjectPath(); + << " object at " << getObject().getObjectPath(); } ~GattCharacteristicServer() { unregisterAdaptor(); } diff --git a/internal/platform/implementation/linux/bluez_gatt_manager.h b/internal/platform/implementation/linux/bluez_gatt_manager.h index 0c6830ca..33116870 100644 --- a/internal/platform/implementation/linux/bluez_gatt_manager.h +++ b/internal/platform/implementation/linux/bluez_gatt_manager.h @@ -32,7 +32,7 @@ class GattManager GattManager(sdbus::IConnection &system_bus, sdbus::ObjectPath adapter_object_path) - : ProxyInterfaces(system_bus, "org.bluez", + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.bluez"), std::move(adapter_object_path)) { registerProxy(); } diff --git a/internal/platform/implementation/linux/bluez_gatt_service_client.h b/internal/platform/implementation/linux/bluez_gatt_service_client.h index ac1d99d4..7e3896a9 100644 --- a/internal/platform/implementation/linux/bluez_gatt_service_client.h +++ b/internal/platform/implementation/linux/bluez_gatt_service_client.h @@ -28,7 +28,7 @@ class GattServiceClient final public: GattServiceClient(std::shared_ptr system_bus, sdbus::ObjectPath service_object_path) - : ProxyInterfaces(*system_bus, "org.bluez", + : ProxyInterfaces(*system_bus, sdbus::ServiceName("org.bluez"), std::move(service_object_path)) { registerProxy(); } diff --git a/internal/platform/implementation/linux/bluez_gatt_service_server.cc b/internal/platform/implementation/linux/bluez_gatt_service_server.cc index 1d8f36b8..c6b43137 100644 --- a/internal/platform/implementation/linux/bluez_gatt_service_server.cc +++ b/internal/platform/implementation/linux/bluez_gatt_service_server.cc @@ -32,7 +32,7 @@ bool GattServiceServer::AddCharacteristic( auto count = characteristics_.size(); std::shared_ptr chr = std::make_shared( - getObject().getConnection(), getObjectPath(), count, characteristic, + getObject().getConnection(), getObject().getObjectPath(), count, characteristic, server_cb_, devices_); try { chr->emitInterfacesAddedSignal( @@ -41,7 +41,7 @@ bool GattServiceServer::AddCharacteristic( LOG(ERROR) << __func__ << ": error emitting InterfacesAdded signal for object path " - << chr->getObjectPath() << " with name '" << e.getName() + << chr->getObject().getObjectPath() << " with name '" << e.getName() << "' and message '" << e.getMessage() << "'"; return false; } diff --git a/internal/platform/implementation/linux/bluez_gatt_service_server.h b/internal/platform/implementation/linux/bluez_gatt_service_server.h index f105e0ba..dd197284 100644 --- a/internal/platform/implementation/linux/bluez_gatt_service_server.h +++ b/internal/platform/implementation/linux/bluez_gatt_service_server.h @@ -56,14 +56,14 @@ class GattServiceServer final registerAdaptor(); LOG(INFO) << __func__ << ": Created a " << org::bluez::GattService1_adaptor::INTERFACE_NAME - << " object at " << getObjectPath(); + << " object at " << getObject().getObjectPath(); } ~GattServiceServer() { absl::MutexLock lock(&characterstics_mutex_); for (auto &[_uuid, characteristic] : characteristics_) { LOG(INFO) << __func__ << ": Removing characteristic " - << characteristic->getObjectPath(); + << characteristic->getObject().getObjectPath(); try { characteristic->emitInterfacesRemovedSignal( {org::bluez::GattCharacteristic1_adaptor::INTERFACE_NAME}); @@ -71,8 +71,8 @@ class GattServiceServer final LOG(ERROR) << __func__ << ": error emitting InterfacesRemoved signal for object path " - << characteristic->getObjectPath() << " with name '" << e.getName() - << "' and message '" << e.getMessage() << "'"; + << characteristic->getObject().getObjectPath() << " with name '" + << e.getName() << "' and message '" << e.getMessage() << "'"; } } unregisterAdaptor(); diff --git a/internal/platform/implementation/linux/bluez_le_advertisement.cc b/internal/platform/implementation/linux/bluez_le_advertisement.cc index ef27025d..3de5727a 100644 --- a/internal/platform/implementation/linux/bluez_le_advertisement.cc +++ b/internal/platform/implementation/linux/bluez_le_advertisement.cc @@ -59,7 +59,7 @@ LEAdvertisement::LEAdvertisement( LOG(INFO) << __func__ << ": Created a org.bluez.LEAdvertisement1 instance at " - << getObjectPath(); + << getObject().getObjectPath(); } } // namespace bluez } // namespace linux diff --git a/internal/platform/implementation/linux/bluez_le_advertisement.h b/internal/platform/implementation/linux/bluez_le_advertisement.h index 432ba41b..8de0a8ce 100644 --- a/internal/platform/implementation/linux/bluez_le_advertisement.h +++ b/internal/platform/implementation/linux/bluez_le_advertisement.h @@ -59,7 +59,8 @@ class LEAdvertisement final // Methods void Release() override { LOG(INFO) << __func__ - << ": LE Advertisement released: " << getObjectPath(); + << ": LE Advertisement released: " + << getObject().getObjectPath(); } // Properties @@ -100,7 +101,8 @@ class LEAdvertisementManager final public: LEAdvertisementManager(sdbus::IConnection& system_bus, BluetoothAdapter& adapter) - : ProxyInterfaces(system_bus, "org.bluez", adapter.GetObjectPath()) { + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.bluez"), + adapter.GetObjectPath()) { registerProxy(); } ~LEAdvertisementManager() { unregisterProxy(); } diff --git a/internal/platform/implementation/linux/bluez_le_bearer_client.h b/internal/platform/implementation/linux/bluez_le_bearer_client.h index 571bcf6d..952be3de 100644 --- a/internal/platform/implementation/linux/bluez_le_bearer_client.h +++ b/internal/platform/implementation/linux/bluez_le_bearer_client.h @@ -35,7 +35,8 @@ class LEBearerClient public: LEBearerClient(std::shared_ptr system_bus, sdbus::ObjectPath bearer_path) - : ProxyInterfaces(*system_bus, "org.bluez", std::move(bearer_path)), + : ProxyInterfaces(*system_bus, sdbus::ServiceName("org.bluez"), + std::move(bearer_path)), system_bus_(std::move(system_bus)) { registerProxy(); } diff --git a/internal/platform/implementation/linux/dbus.h b/internal/platform/implementation/linux/dbus.h index ac48f5dd..8d498dd7 100644 --- a/internal/platform/implementation/linux/dbus.h +++ b/internal/platform/implementation/linux/dbus.h @@ -25,7 +25,7 @@ LOG(ERROR) << __func__ << ": Got error '" << (e).getName() \ << "' with message '" << (e).getMessage() \ << "' while calling " << (m) << " on object " \ - << (p)->getObjectPath(); \ + << (p)->getProxy().getObjectPath(); \ } while (false) #define DBUS_LOG_PROPERTY_GET_ERROR(p, prop, e) \ @@ -33,7 +33,7 @@ LOG(ERROR) << __func__ << ": Got error '" << (e).getName() \ << "' with message '" << (e).getMessage() \ << "' while getting property " << (prop) \ - << " on object " << (p)->getObjectPath(); \ + << " on object " << (p)->getProxy().getObjectPath(); \ } while (false) #define DBUS_LOG_PROPERTY_SET_ERROR(p, prop, e) \ @@ -41,7 +41,7 @@ LOG(ERROR) << __func__ << ": Got error '" << (e).getName() \ << "' with message '" << (e).getMessage() \ << "' while setting property " << (prop) \ - << " on object " << (p)->getObjectPath(); \ + << " on object " << (p)->getProxy().getObjectPath(); \ } while (false) namespace nearby { diff --git a/internal/platform/implementation/linux/device_info.h b/internal/platform/implementation/linux/device_info.h index a3e256f8..4bf9668b 100644 --- a/internal/platform/implementation/linux/device_info.h +++ b/internal/platform/implementation/linux/device_info.h @@ -43,8 +43,8 @@ class CurrentUserSession final CurrentUserSession &operator=(CurrentUserSession &&) = delete; ~CurrentUserSession() { unregisterProxy(); } explicit CurrentUserSession(sdbus::IConnection &system_bus) - : ProxyInterfaces(system_bus, "org.freedesktop.login1", - "/org/freedesktop/login1/session/auto") { + : ProxyInterfaces(system_bus, sdbus::ServiceName("org.freedesktop.login1"), + sdbus::ObjectPath("/org/freedesktop/login1/session/auto")) { registerProxy(); } @@ -79,8 +79,9 @@ class Hostnamed Hostnamed &operator=(const Hostnamed &) = delete; Hostnamed &operator=(Hostnamed &&) = delete; explicit Hostnamed(sdbus::IConnection &system_bus) - : ProxyInterfaces(system_bus, "org.freedesktop.hostname1", - "/org/freedesktop/hostname1") { + : ProxyInterfaces(system_bus, + sdbus::ServiceName("org.freedesktop.hostname1"), + sdbus::ObjectPath("/org/freedesktop/hostname1")) { registerProxy(); } ~Hostnamed() { unregisterProxy(); } @@ -94,8 +95,9 @@ class LoginManager final LoginManager &operator=(const LoginManager &) = delete; LoginManager &operator=(LoginManager &&) = delete; explicit LoginManager(sdbus::IConnection &system_bus) - : ProxyInterfaces(system_bus, "org.freedesktop.login1", - "/org/freedesktop/login1") { + : ProxyInterfaces(system_bus, + sdbus::ServiceName("org.freedesktop.login1"), + sdbus::ObjectPath("/org/freedesktop/login1")) { registerProxy(); } ~LoginManager() { unregisterProxy(); } diff --git a/internal/platform/implementation/linux/network_manager.h b/internal/platform/implementation/linux/network_manager.h index bad70919..b5afc829 100644 --- a/internal/platform/implementation/linux/network_manager.h +++ b/internal/platform/implementation/linux/network_manager.h @@ -36,8 +36,9 @@ class NetworkManager final NetworkManager &operator=(const NetworkManager &) = delete; NetworkManager &operator=(NetworkManager &&) = delete; explicit NetworkManager(std::shared_ptr system_bus) - : ProxyInterfaces(*system_bus, "org.freedesktop.NetworkManager", - "/org/freedesktop/NetworkManager"), + : ProxyInterfaces(*system_bus, + sdbus::ServiceName("org.freedesktop.NetworkManager"), + sdbus::ObjectPath("/org/freedesktop/NetworkManager")), system_bus_(std::move(system_bus)), state_(kNMStateUnknown) { registerProxy(); @@ -106,7 +107,8 @@ class IP4Config : public sdbus::ProxyInterfaces< IP4Config &operator=(IP4Config &&) = delete; IP4Config(std::shared_ptr system_bus, const sdbus::ObjectPath &config_object_path) - : ProxyInterfaces(*system_bus, "org.freedesktop.NetworkManager", + : ProxyInterfaces(*system_bus, + sdbus::ServiceName("org.freedesktop.NetworkManager"), config_object_path), system_bus_(std::move(system_bus)) { registerProxy(); @@ -125,8 +127,9 @@ class ObjectManager final ObjectManager &operator=(const ObjectManager &) = delete; ObjectManager &operator=(ObjectManager &&) = delete; explicit ObjectManager(std::shared_ptr system_bus) - : ProxyInterfaces(*system_bus, "org.freedesktop.NetworkManager", - "/org/freedesktop"), + : ProxyInterfaces(*system_bus, + sdbus::ServiceName("org.freedesktop.NetworkManager"), + sdbus::ObjectPath("/org/freedesktop")), system_bus_(std::move(system_bus)) { registerProxy(); } @@ -141,11 +144,12 @@ class ObjectManager final protected: void onInterfacesAdded( const sdbus::ObjectPath &objectPath, - const std::map> + const std::map> &interfacesAndProperties) override {} void onInterfacesRemoved( const sdbus::ObjectPath &objectPath, - const std::vector &interfaces) override {} + const std::vector &interfaces) override {} private: std::shared_ptr system_bus_; diff --git a/internal/platform/implementation/linux/network_manager_access_point.h b/internal/platform/implementation/linux/network_manager_access_point.h index 131e4f6f..92e0993c 100644 --- a/internal/platform/implementation/linux/network_manager_access_point.h +++ b/internal/platform/implementation/linux/network_manager_access_point.h @@ -31,7 +31,8 @@ class NetworkManagerAccessPoint NetworkManagerAccessPoint &operator=(NetworkManagerAccessPoint &&) = delete; NetworkManagerAccessPoint(sdbus::IConnection &system_bus, sdbus::ObjectPath access_point_object_path) - : ProxyInterfaces(system_bus, "org.freedesktop.NetworkManager", + : ProxyInterfaces(system_bus, + sdbus::ServiceName("org.freedesktop.NetworkManager"), std::move(access_point_object_path)) { registerProxy(); } diff --git a/internal/platform/implementation/linux/network_manager_active_connection.cc b/internal/platform/implementation/linux/network_manager_active_connection.cc index d8ee63d0..4f2fdfc5 100644 --- a/internal/platform/implementation/linux/network_manager_active_connection.cc +++ b/internal/platform/implementation/linux/network_manager_active_connection.cc @@ -105,7 +105,7 @@ std::vector ActiveConnection::GetIP4Addresses() { std::pair, bool> ActiveConnection::WaitForConnection(absl::Duration timeout) { LOG(INFO) << __func__ << ": Waiting for an update to " - << getObjectPath() << "'s state"; + << getProxy().getObjectPath() << "'s state"; auto state_changed = [this]() { this->state_mutex_.AssertReaderHeld(); diff --git a/internal/platform/implementation/linux/network_manager_active_connection.h b/internal/platform/implementation/linux/network_manager_active_connection.h index 7d1a3bc7..f93b8e4d 100644 --- a/internal/platform/implementation/linux/network_manager_active_connection.h +++ b/internal/platform/implementation/linux/network_manager_active_connection.h @@ -67,7 +67,8 @@ class ActiveConnection ActiveConnection &operator=(ActiveConnection &&) = delete; explicit ActiveConnection(std::shared_ptr system_bus, sdbus::ObjectPath active_connection_path) - : ProxyInterfaces(*system_bus, "org.freedesktop.NetworkManager", + : ProxyInterfaces(*system_bus, + sdbus::ServiceName("org.freedesktop.NetworkManager"), std::move(active_connection_path)), system_bus_(std::move(system_bus)), state_(kStateUnknown), diff --git a/internal/platform/implementation/linux/wifi_direct.cc b/internal/platform/implementation/linux/wifi_direct.cc index 7b15bcd2..cd576a24 100644 --- a/internal/platform/implementation/linux/wifi_direct.cc +++ b/internal/platform/implementation/linux/wifi_direct.cc @@ -50,7 +50,7 @@ NetworkManagerWifiDirectMedium::ListenForService(int port) { LOG(ERROR) << __func__ << "Could not find any IPv4 addresses for active connection " - << active_connection->getObjectPath(); + << active_connection->getProxy().getObjectPath(); return nullptr; } @@ -88,7 +88,7 @@ bool NetworkManagerWifiDirectMedium::DisconnectWifiDirect() { } try { - network_manager_->DeactivateConnection(active_connection->getObjectPath()); + network_manager_->DeactivateConnection(active_connection->getProxy().getObjectPath()); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(network_manager_, "DeactivateConnection", e); return false; @@ -112,7 +112,7 @@ bool NetworkManagerWifiDirectMedium::StartWifiDirect( // According to the comments in the windows implementation, the wifi direct // medium is currently just a regular wifi hotspot. auto wireless_device = std::make_unique( - network_manager_, wireless_device_->getObjectPath()); + network_manager_, wireless_device_->getProxy().getObjectPath()); auto hotspot = NetworkManagerWifiHotspotMedium(network_manager_, std::move(wireless_device)); @@ -127,7 +127,7 @@ bool NetworkManagerWifiDirectMedium::StartWifiDirect( bool NetworkManagerWifiDirectMedium::StopWifiDirect() { auto wireless_device = std::make_unique( - network_manager_, wireless_device_->getObjectPath()); + network_manager_, wireless_device_->getProxy().getObjectPath()); auto hotspot = NetworkManagerWifiHotspotMedium(network_manager_, std::move(wireless_device)); diff --git a/internal/platform/implementation/linux/wifi_direct_server_socket.cc b/internal/platform/implementation/linux/wifi_direct_server_socket.cc index 36c7ac46..a51fb529 100644 --- a/internal/platform/implementation/linux/wifi_direct_server_socket.cc +++ b/internal/platform/implementation/linux/wifi_direct_server_socket.cc @@ -27,7 +27,7 @@ std::string NetworkManagerWifiDirectServerSocket::GetIPAddress() const { LOG(ERROR) << __func__ << ": Could not find any IPv4 addresses for active connection " - << active_conn_->getObjectPath(); + << active_conn_->getProxy().getObjectPath(); return std::string(); } return ip4addresses[0]; diff --git a/internal/platform/implementation/linux/wifi_hotspot.cc b/internal/platform/implementation/linux/wifi_hotspot.cc index 67248750..2d47b97e 100644 --- a/internal/platform/implementation/linux/wifi_hotspot.cc +++ b/internal/platform/implementation/linux/wifi_hotspot.cc @@ -100,7 +100,7 @@ NetworkManagerWifiHotspotMedium::ListenForService(int port) { LOG(ERROR) << __func__ << "Could not find any IPv4 addresses for active connection " - << active_connection->getObjectPath(); + << active_connection->getProxy().getObjectPath(); return nullptr; } @@ -126,7 +126,7 @@ NetworkManagerWifiHotspotMedium::ListenForService(int port) { LOG(INFO) << __func__ << ": Listening for services on " << ip4addresses[0] << ":" << port << " on device " - << wireless_device_->getObjectPath(); + << wireless_device_->getProxy().getObjectPath(); ret = listen(sock, 0); if (ret < 0) { @@ -142,7 +142,7 @@ NetworkManagerWifiHotspotMedium::ListenForService(int port) { bool NetworkManagerWifiHotspotMedium::StartWifiHotspot( HotspotCredentials *hotspot_credentials) { if (WifiHotspotActive()) { - LOG(ERROR) << __func__ << ": " << wireless_device_->getObjectPath() + LOG(ERROR) << __func__ << ": " << wireless_device_->getProxy().getObjectPath() << ": cannot start WiFi hotspot, a hotspot is already " "active on this device"; return false; @@ -224,7 +224,7 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot( try { auto [path, active_path, result] = network_manager_->AddAndActivateConnection2( - connection_settings, wireless_device_->getObjectPath(), "/", + connection_settings, wireless_device_->getProxy().getObjectPath(), "/", {{"persist", "volatile"}, {"bind-activation", "dbus-client"}}); active_conn = std::make_unique( system_bus_, active_path); @@ -253,7 +253,7 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot( LOG(ERROR) << __func__ << ": " << ": timed out while waiting for connection " - << active_conn->getObjectPath() + << active_conn->getProxy().getObjectPath() << " to be activated, last NMActiveConnectionStateReason: " << reason->ToString(); DisconnectWifiHotspot(); @@ -279,15 +279,15 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot( } LOG(INFO) << __func__ << ": Started a WiFi hotspot on device " - << wireless_device_->getObjectPath() << " at " - << active_conn->getObjectPath(); + << wireless_device_->getProxy().getObjectPath() << " at " + << active_conn->getProxy().getObjectPath(); return true; } bool NetworkManagerWifiHotspotMedium::StopWifiHotspot() { if (!WifiHotspotActive()) { LOG(ERROR) - << __func__ << ": " << wireless_device_->getObjectPath() + << __func__ << ": " << wireless_device_->getProxy().getObjectPath() << ": Cannot stop WiFi hotspot as a WiFi hotspot is not active"; } @@ -298,7 +298,7 @@ bool NetworkManagerWifiHotspotMedium::StopWifiHotspot() { active_ap_path = wireless_device_->ActiveAccessPoint(); if (active_ap_path.empty()) { LOG(ERROR) << __func__ << ": No active access points on " - << wireless_device_->getObjectPath(); + << wireless_device_->getProxy().getObjectPath(); return false; } } catch (const sdbus::Error &e) { @@ -315,12 +315,12 @@ bool NetworkManagerWifiHotspotMedium::StopWifiHotspot() { return false; } - LOG(INFO) << __func__ << ": " << wireless_device_->getObjectPath() + LOG(INFO) << __func__ << ": " << wireless_device_->getProxy().getObjectPath() << ": Deactivating active connection " - << active_connection->getObjectPath(); + << active_connection->getProxy().getObjectPath(); try { - network_manager_->DeactivateConnection(active_connection->getObjectPath()); + network_manager_->DeactivateConnection(active_connection->getProxy().getObjectPath()); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(network_manager_, "DeactivateConnection", e); return false; @@ -352,7 +352,7 @@ bool NetworkManagerWifiHotspotMedium::DisconnectWifiHotspot() { } try { - network_manager_->DeactivateConnection(active_connection->getObjectPath()); + network_manager_->DeactivateConnection(active_connection->getProxy().getObjectPath()); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(network_manager_, "DeactivateConnection", e); return false; diff --git a/internal/platform/implementation/linux/wifi_hotspot_server_socket.cc b/internal/platform/implementation/linux/wifi_hotspot_server_socket.cc index 5a085dfc..6f246529 100644 --- a/internal/platform/implementation/linux/wifi_hotspot_server_socket.cc +++ b/internal/platform/implementation/linux/wifi_hotspot_server_socket.cc @@ -32,7 +32,7 @@ std::string NetworkManagerWifiHotspotServerSocket::GetIPAddress() const { LOG(ERROR) << __func__ << ": Could not find any IPv4 addresses for active connection " - << active_conn_->getObjectPath(); + << active_conn_->getProxy().getObjectPath(); return {}; } return ip4addresses[0]; @@ -122,7 +122,7 @@ void NetworkManagerWifiHotspotServerSocket::PopulateHotspotCredentials( if (ip4addresses.empty()) { LOG(ERROR) << __func__ << ": Could not find any IPv4 addresses for active connection " - << active_conn_->getObjectPath(); + << active_conn_->getProxy().getObjectPath(); return; } diff --git a/internal/platform/implementation/linux/wifi_lan.cc b/internal/platform/implementation/linux/wifi_lan.cc index 5004e660..87bec32b 100644 --- a/internal/platform/implementation/linux/wifi_lan.cc +++ b/internal/platform/implementation/linux/wifi_lan.cc @@ -192,7 +192,7 @@ bool WifiLanMedium::StartDiscovery( auto &object = service_browsers_[service_type]; LOG(ERROR) << __func__ << ": A service browser for service type " << service_type << " already exists at " - << object->getObjectPath(); + << object->getProxy().getObjectPath(); return false; } } @@ -225,7 +225,7 @@ bool WifiLanMedium::StartDiscovery( try { LOG(INFO) << __func__ << ": Starting service discovery for " - << browser->getObjectPath(); + << browser->getProxy().getObjectPath(); browser->Start(); } catch (const sdbus::Error &e) { DBUS_LOG_METHOD_CALL_ERROR(browser, "Start", e); diff --git a/internal/platform/implementation/linux/wifi_medium.cc b/internal/platform/implementation/linux/wifi_medium.cc index 79ed65ce..b6a9048d 100644 --- a/internal/platform/implementation/linux/wifi_medium.cc +++ b/internal/platform/implementation/linux/wifi_medium.cc @@ -79,14 +79,14 @@ api::WifiInformation &NetworkManagerWifiMedium::GetInformation() { api::WifiInformation{true, ssid, active_access_point->HwAddress(), to_signed(active_access_point->Frequency())}; networkmanager::ObjectManager manager(system_bus_); - auto ip4config = manager.GetIp4Config(active_access_point->getObjectPath()); + auto ip4config = manager.GetIp4Config(active_access_point->getProxy().getObjectPath()); } catch (const sdbus::Error &e) { LOG(ERROR) - << __func__ << ": " << getObjectPath() << ": Got error '" << e.getName() + << __func__ << ": " << getProxy().getObjectPath() << ": Got error '" << e.getName() << "' with message '" << e.getMessage() << "' while populating network information for access point " - << active_access_point->getObjectPath(); + << active_access_point->getProxy().getObjectPath(); } return information_; @@ -135,8 +135,8 @@ NetworkManagerWifiMedium::SearchBySSID(absl::string_view ssid, return ap; } - LOG(INFO) << __func__ << ": " << getObjectPath() << ": SSID " << ssid - << " not currently known by device " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << ": SSID " << ssid + << " not currently known by device " << getProxy().getObjectPath() << ", requesting a scan"; std::int64_t cur_last_scan; @@ -163,13 +163,13 @@ NetworkManagerWifiMedium::SearchBySSID(absl::string_view ssid, last_scan_lock_.ReaderUnlock(); if (!success) { - LOG(WARNING) << __func__ << ": " << getObjectPath() + LOG(WARNING) << __func__ << ": " << getProxy().getObjectPath() << ": timed out waiting for scan to finish"; } ap = SearchBySSIDNoScan(ssid_bytes); if (ap == nullptr) { - LOG(WARNING) << __func__ << ": " << getObjectPath() + LOG(WARNING) << __func__ << ": " << getProxy().getObjectPath() << ": Couldn't find SSID " << ssid; } @@ -194,7 +194,7 @@ NetworkManagerWifiMedium::WifiConnectionStatus NetworkManagerWifiMedium::Connect NetworkManagerWifiMedium::WifiAuthType auth_type) { auto ap = SearchBySSID(ssid); if (ap == nullptr) { - LOG(ERROR) << __func__ << ": " << getObjectPath() + LOG(ERROR) << __func__ << ": " << getProxy().getObjectPath() << ": Couldn't find SSID " << ssid; return NetworkManagerWifiMedium::WifiConnectionStatus::kConnectionFailure; } @@ -236,7 +236,7 @@ NetworkManagerWifiMedium::WifiConnectionStatus NetworkManagerWifiMedium::Connect sdbus::ObjectPath connection_path, active_conn_path; try { auto [cp, acp, _r] = network_manager_->AddAndActivateConnection2( - connection_settings, getObjectPath(), ap->getObjectPath(), + connection_settings, getProxy().getObjectPath(), ap->getProxy().getObjectPath(), {{"persist", "volatile"}, {"bind-activation", "dbus-client"}}); connection_path = std::move(cp); active_conn_path = std::move(acp); @@ -245,14 +245,14 @@ NetworkManagerWifiMedium::WifiConnectionStatus NetworkManagerWifiMedium::Connect return NetworkManagerWifiMedium::WifiConnectionStatus::kUnknown; } - LOG(INFO) << __func__ << ": " << getObjectPath() + LOG(INFO) << __func__ << ": " << getProxy().getObjectPath() << ": Added a new connection at " << connection_path; auto active_connection = networkmanager::ActiveConnection(system_bus_, active_conn_path); auto [reason, timeout] = active_connection.WaitForConnection(); if (timeout) { LOG(ERROR) - << __func__ << ": " << getObjectPath() + << __func__ << ": " << getProxy().getObjectPath() << ": timed out while waiting for connection " << active_conn_path << " to be activated, last NMActiveConnectionStateReason: " << reason->ToString(); @@ -260,7 +260,7 @@ NetworkManagerWifiMedium::WifiConnectionStatus NetworkManagerWifiMedium::Connect } if (reason.has_value()) { - LOG(ERROR) << __func__ << ": " << getObjectPath() << ": connection " + LOG(ERROR) << __func__ << ": " << getProxy().getObjectPath() << ": connection " << active_conn_path << " failed to activate, NMActiveConnectionStateReason:" << reason->ToString(); @@ -286,7 +286,7 @@ NetworkManagerWifiMedium::GetActiveConnection() { active_ap_path = ActiveAccessPoint(); if (active_ap_path.empty()) { LOG(ERROR) << __func__ << ": No active access points on " - << getObjectPath(); + << getProxy().getObjectPath(); return nullptr; } } catch (const sdbus::Error &e) { @@ -296,13 +296,13 @@ NetworkManagerWifiMedium::GetActiveConnection() { auto object_manager = networkmanager::ObjectManager(system_bus_); auto conn = object_manager.GetActiveConnectionForAccessPoint(active_ap_path, - getObjectPath()); + getProxy().getObjectPath()); if (conn == nullptr) { LOG(ERROR) << __func__ << ": Could not find an active connection using the access point " - << active_ap_path << " and device " << getObjectPath(); + << active_ap_path << " and device " << getProxy().getObjectPath(); } return conn; } diff --git a/internal/platform/implementation/linux/wifi_medium.h b/internal/platform/implementation/linux/wifi_medium.h index eaa354c6..e9248d04 100644 --- a/internal/platform/implementation/linux/wifi_medium.h +++ b/internal/platform/implementation/linux/wifi_medium.h @@ -74,7 +74,7 @@ class NetworkManagerWifiMedium std::shared_ptr network_manager, const sdbus::ObjectPath &wireless_device_object_path) : ProxyInterfaces(*network_manager->GetConnection(), - "org.freedesktop.NetworkManager", + sdbus::ServiceName("org.freedesktop.NetworkManager"), wireless_device_object_path), system_bus_(network_manager->GetConnection()), network_manager_(std::move(network_manager)),