mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Rewrite dbus code using sdbus-c++
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user