9#ifndef DECLARATIVEADAPTER_H
10#define DECLARATIVEADAPTER_H
12#include <QQmlListProperty>
13#include <qqmlregistration.h>
16#include "declarativedevice.h"
17#include "pendingcall.h"
19class DeclarativeAdapter :
public QObject
22 QML_NAMED_ELEMENT(Adapter)
23 QML_UNCREATABLE(
"Adapter cannot be created")
26 Q_PROPERTY(QString address READ address CONSTANT)
27 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
28 Q_PROPERTY(QString systemName READ systemName NOTIFY systemNameChanged)
29 Q_PROPERTY(quint32 adapterClass READ adapterClass NOTIFY adapterClassChanged)
30 Q_PROPERTY(
bool powered READ isPowered WRITE setPowered NOTIFY poweredChanged)
31 Q_PROPERTY(
bool discoverable READ isDiscoverable WRITE setDiscoverable NOTIFY discoverableChanged)
32 Q_PROPERTY(quint32 discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged)
33 Q_PROPERTY(
bool pairable READ isPairable WRITE setPairable NOTIFY pairableChanged)
34 Q_PROPERTY(quint32 pairableTimeout READ pairableTimeout WRITE setPairableTimeout NOTIFY pairableTimeoutChanged)
35 Q_PROPERTY(
bool discovering READ isDiscovering NOTIFY discoveringChanged)
36 Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged)
37 Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged)
38 Q_PROPERTY(QQmlListProperty<DeclarativeDevice> devices READ devices NOTIFY devicesChanged)
41 explicit DeclarativeAdapter(BluezQt::AdapterPtr adapter,
QObject *
parent =
nullptr);
45 QString address() const;
48 void setName(const QString &name);
50 QString systemName() const;
52 quint32 adapterClass() const;
54 bool isPowered() const;
55 void setPowered(
bool powered);
57 bool isDiscoverable() const;
58 void setDiscoverable(
bool discoverable);
60 quint32 discoverableTimeout() const;
61 void setDiscoverableTimeout(quint32 timeout);
63 bool isPairable() const;
64 void setPairable(
bool pairable);
66 quint32 pairableTimeout() const;
67 void setPairableTimeout(quint32 timeout);
71 QStringList uuids() const;
73 QString modalias() const;
75 QQmlListProperty<DeclarativeDevice> devices();
77 BluezQt::AdapterPtr m_adapter;
78 QHash<QString, DeclarativeDevice *> m_devices;
81 DeclarativeDevice *deviceForAddress(const QString &address) const;
82 BluezQt::PendingCall *startDiscovery();
83 BluezQt::PendingCall *stopDiscovery();
84 BluezQt::PendingCall *removeDevice(DeclarativeDevice *device);
87 void adapterRemoved(DeclarativeAdapter *adapter);
88 void adapterChanged(DeclarativeAdapter *adapter);
89 void nameChanged(const QString &name);
90 void systemNameChanged(const QString &name);
91 void adapterClassChanged(quint32 adapterClass);
92 void poweredChanged(
bool powered);
93 void discoverableChanged(
bool discoverable);
94 void discoverableTimeoutChanged(quint32 timeout);
95 void pairableChanged(
bool pairable);
96 void pairableTimeoutChanged(quint32 timeout);
97 void discoveringChanged(
bool discovering);
98 void uuidsChanged(const QStringList &uuids);
99 void modaliasChanged(const QString &modalias);
100 void deviceFound(DeclarativeDevice *device);
101 void deviceRemoved(DeclarativeDevice *device);
102 void deviceChanged(DeclarativeDevice *device);
104 void devicesChanged(QQmlListProperty<DeclarativeDevice> devices);
107 void slotDeviceAdded(BluezQt::DevicePtr device);
108 void slotDeviceRemoved(BluezQt::DevicePtr device);
111 DeclarativeDevice *declarativeDeviceFromPtr(BluezQt::DevicePtr ptr) const;
QObject * parent() const const