File indexing completed on 2025-01-19 12:42:13
0001 /* 0002 * BluezQt - Asynchronous Bluez wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef DECLARATIVEADAPTER_H 0010 #define DECLARATIVEADAPTER_H 0011 0012 #include <QQmlListProperty> 0013 0014 #include "adapter.h" 0015 0016 class DeclarativeDevice; 0017 0018 class DeclarativeAdapter : public QObject 0019 { 0020 Q_OBJECT 0021 0022 Q_PROPERTY(QString ubi READ ubi CONSTANT) 0023 Q_PROPERTY(QString address READ address CONSTANT) 0024 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 0025 Q_PROPERTY(QString systemName READ systemName NOTIFY systemNameChanged) 0026 Q_PROPERTY(quint32 adapterClass READ adapterClass NOTIFY adapterClassChanged) 0027 Q_PROPERTY(bool powered READ isPowered WRITE setPowered NOTIFY poweredChanged) 0028 Q_PROPERTY(bool discoverable READ isDiscoverable WRITE setDiscoverable NOTIFY discoverableChanged) 0029 Q_PROPERTY(quint32 discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged) 0030 Q_PROPERTY(bool pairable READ isPairable WRITE setPairable NOTIFY pairableChanged) 0031 Q_PROPERTY(quint32 pairableTimeout READ pairableTimeout WRITE setPairableTimeout NOTIFY pairableTimeoutChanged) 0032 Q_PROPERTY(bool discovering READ isDiscovering NOTIFY discoveringChanged) 0033 Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged) 0034 Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged) 0035 Q_PROPERTY(QQmlListProperty<DeclarativeDevice> devices READ devices NOTIFY devicesChanged) 0036 0037 public: 0038 explicit DeclarativeAdapter(BluezQt::AdapterPtr adapter, QObject *parent = nullptr); 0039 0040 QString ubi() const; 0041 0042 QString address() const; 0043 0044 QString name() const; 0045 void setName(const QString &name); 0046 0047 QString systemName() const; 0048 0049 quint32 adapterClass() const; 0050 0051 bool isPowered() const; 0052 void setPowered(bool powered); 0053 0054 bool isDiscoverable() const; 0055 void setDiscoverable(bool discoverable); 0056 0057 quint32 discoverableTimeout() const; 0058 void setDiscoverableTimeout(quint32 timeout); 0059 0060 bool isPairable() const; 0061 void setPairable(bool pairable); 0062 0063 quint32 pairableTimeout() const; 0064 void setPairableTimeout(quint32 timeout); 0065 0066 bool isDiscovering(); 0067 0068 QStringList uuids() const; 0069 0070 QString modalias() const; 0071 0072 QQmlListProperty<DeclarativeDevice> devices(); 0073 0074 BluezQt::AdapterPtr m_adapter; 0075 QHash<QString, DeclarativeDevice *> m_devices; 0076 0077 public Q_SLOTS: 0078 DeclarativeDevice *deviceForAddress(const QString &address) const; 0079 BluezQt::PendingCall *startDiscovery(); 0080 BluezQt::PendingCall *stopDiscovery(); 0081 BluezQt::PendingCall *removeDevice(DeclarativeDevice *device); 0082 0083 Q_SIGNALS: 0084 void adapterRemoved(DeclarativeAdapter *adapter); 0085 void adapterChanged(DeclarativeAdapter *adapter); 0086 void nameChanged(const QString &name); 0087 void systemNameChanged(const QString &name); 0088 void adapterClassChanged(quint32 adapterClass); 0089 void poweredChanged(bool powered); 0090 void discoverableChanged(bool discoverable); 0091 void discoverableTimeoutChanged(quint32 timeout); 0092 void pairableChanged(bool pairable); 0093 void pairableTimeoutChanged(quint32 timeout); 0094 void discoveringChanged(bool discovering); 0095 void uuidsChanged(const QStringList &uuids); 0096 void modaliasChanged(const QString &modalias); 0097 void deviceFound(DeclarativeDevice *device); 0098 void deviceRemoved(DeclarativeDevice *device); 0099 void deviceChanged(DeclarativeDevice *device); 0100 0101 void devicesChanged(QQmlListProperty<DeclarativeDevice> devices); 0102 0103 private Q_SLOTS: 0104 void slotDeviceAdded(BluezQt::DevicePtr device); 0105 void slotDeviceRemoved(BluezQt::DevicePtr device); 0106 0107 private: 0108 DeclarativeDevice *declarativeDeviceFromPtr(BluezQt::DevicePtr ptr) const; 0109 }; 0110 0111 #endif // DECLARATIVEADAPTER_H