Rewrite dbus code using sdbus-c++

This commit is contained in:
Vibhav Pant
2023-08-15 20:52:51 +05:30
parent aea2e16937
commit c8af59666d
29 changed files with 1632 additions and 738 deletions
@@ -1,18 +1,26 @@
#ifndef PLATFORM_IMPL_LINUX_BLUETOOTH_ADAPTER_H_
#define PLATFORM_IMPL_LINUX_BLUETOOTH_ADAPTER_H_
#include <string>
#include <sdbus-c++/IConnection.h>
#include <sdbus-c++/ProxyInterfaces.h>
#include "absl/strings/string_view.h"
#include "internal/platform/implementation/bluetooth_adapter.h"
#include <systemd/sd-bus.h>
#include "internal/platform/implementation/linux/bluez.h"
#include "internal/platform/implementation/linux/bluez_adapter_client_glue.h"
namespace nearby {
namespace linux {
class BluetoothAdapter : public api::BluetoothAdapter {
class BluetoothAdapter
: public api::BluetoothAdapter,
public sdbus::ProxyInterfaces<org::bluez::Adapter1_proxy> {
public:
BluetoothAdapter(sd_bus *bus) { system_bus_ = bus; }
~BluetoothAdapter() override { sd_bus_unref(system_bus_); };
BluetoothAdapter(sdbus::IConnection &system_bus,
const sdbus::ObjectPath &adapter_object_path)
: ProxyInterfaces(system_bus, bluez::SERVICE_DEST, adapter_object_path) {
registerProxy();
}
~BluetoothAdapter() override { unregisterProxy(); }
bool SetStatus(Status status) override;
bool IsEnabled() const override;
@@ -25,9 +33,6 @@ public:
bool SetName(absl::string_view name) override;
bool SetName(absl::string_view name, bool persist) override;
std::string GetMacAddress() const override;
private:
sd_bus *system_bus_;
};
} // namespace linux
} // namespace nearby