Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
BluetoothAdapter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceBluetooth/phosphorservicebluetooth_export.h>
7
8#include <QObject>
9#include <QString>
10#include <QVariantMap>
11
12#include <memory>
13
14class QDBusConnection;
15
17
30class PHOSPHORSERVICEBLUETOOTH_EXPORT BluetoothAdapter : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY(QString dbusPath READ dbusPath CONSTANT)
34 Q_PROPERTY(QString address READ address NOTIFY addressChanged)
35 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
36 Q_PROPERTY(QString alias READ alias NOTIFY aliasChanged)
37 Q_PROPERTY(bool powered READ powered NOTIFY poweredChanged)
38 Q_PROPERTY(bool discoverable READ discoverable NOTIFY discoverableChanged)
39 Q_PROPERTY(bool pairable READ pairable NOTIFY pairableChanged)
40 Q_PROPERTY(bool discovering READ discovering NOTIFY discoveringChanged)
41
42public:
43 BluetoothAdapter(QDBusConnection connection, const QString& dbusPath, const QVariantMap& initialProperties,
44 QObject* parent = nullptr);
46
47 [[nodiscard]] QString dbusPath() const;
48 [[nodiscard]] QString address() const;
49 [[nodiscard]] QString name() const;
50 [[nodiscard]] QString alias() const;
51 [[nodiscard]] bool powered() const;
52 [[nodiscard]] bool discoverable() const;
53 [[nodiscard]] bool pairable() const;
54 [[nodiscard]] bool discovering() const;
55
59 Q_INVOKABLE void setPowered(bool powered);
60
63 Q_INVOKABLE void setDiscoverable(bool discoverable);
64
68 Q_INVOKABLE void startDiscovery();
69 Q_INVOKABLE void stopDiscovery();
70
74 Q_INVOKABLE void removeDevice(const QString& devicePath);
75
76Q_SIGNALS:
78 void operationFinished(const QString& operation, const QString& errorName);
86
87private Q_SLOTS:
88 void _q_onPropertiesChanged(const QString& interfaceName, const QVariantMap& changed,
89 const QStringList& invalidated);
90
91private:
92 Q_DISABLE_COPY_MOVE(BluetoothAdapter)
93 class Private;
94 std::unique_ptr<Private> d;
95};
96
97} // namespace PhosphorServiceBluetooth
void startDiscovery()
Begin/end scanning for nearby devices (StartDiscovery / StopDiscovery).
void operationFinished(const QString &operation, const QString &errorName)
Completion of a write request; state follows BlueZ properties.
BluetoothAdapter(QDBusConnection connection, const QString &dbusPath, const QVariantMap &initialProperties, QObject *parent=nullptr)
void setPowered(bool powered)
Power the adapter on/off (org.bluez.Adapter1.Powered).
void setDiscoverable(bool discoverable)
Toggle inbound discoverability (org.bluez.Adapter1.Discoverable).
void removeDevice(const QString &devicePath)
Forget a device under this adapter (org.bluez.Adapter1.RemoveDevice), dropping its pairing/cache.
Definition BluetoothAdapter.h:16