BluezQt

declarativeadapter.h
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2015 David Rosca <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7  */
8 
9 #ifndef DECLARATIVEADAPTER_H
10 #define DECLARATIVEADAPTER_H
11 
12 #include <QQmlListProperty>
13 
14 #include "adapter.h"
15 
16 class DeclarativeDevice;
17 
18 class DeclarativeAdapter : public QObject
19 {
20  Q_OBJECT
21 
22  Q_PROPERTY(QString ubi READ ubi CONSTANT)
23  Q_PROPERTY(QString address READ address CONSTANT)
24  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
25  Q_PROPERTY(QString systemName READ systemName NOTIFY systemNameChanged)
26  Q_PROPERTY(quint32 adapterClass READ adapterClass NOTIFY adapterClassChanged)
27  Q_PROPERTY(bool powered READ isPowered WRITE setPowered NOTIFY poweredChanged)
28  Q_PROPERTY(bool discoverable READ isDiscoverable WRITE setDiscoverable NOTIFY discoverableChanged)
29  Q_PROPERTY(quint32 discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged)
30  Q_PROPERTY(bool pairable READ isPairable WRITE setPairable NOTIFY pairableChanged)
31  Q_PROPERTY(quint32 pairableTimeout READ pairableTimeout WRITE setPairableTimeout NOTIFY pairableTimeoutChanged)
32  Q_PROPERTY(bool discovering READ isDiscovering NOTIFY discoveringChanged)
33  Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged)
34  Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged)
35  Q_PROPERTY(QQmlListProperty<DeclarativeDevice> devices READ devices NOTIFY devicesChanged)
36 
37 public:
38  explicit DeclarativeAdapter(BluezQt::AdapterPtr adapter, QObject *parent = nullptr);
39 
40  QString ubi() const;
41 
42  QString address() const;
43 
44  QString name() const;
45  void setName(const QString &name);
46 
47  QString systemName() const;
48 
49  quint32 adapterClass() const;
50 
51  bool isPowered() const;
52  void setPowered(bool powered);
53 
54  bool isDiscoverable() const;
55  void setDiscoverable(bool discoverable);
56 
57  quint32 discoverableTimeout() const;
58  void setDiscoverableTimeout(quint32 timeout);
59 
60  bool isPairable() const;
61  void setPairable(bool pairable);
62 
63  quint32 pairableTimeout() const;
64  void setPairableTimeout(quint32 timeout);
65 
66  bool isDiscovering();
67 
68  QStringList uuids() const;
69 
70  QString modalias() const;
71 
73 
74  BluezQt::AdapterPtr m_adapter;
76 
77 public Q_SLOTS:
78  DeclarativeDevice *deviceForAddress(const QString &address) const;
79  BluezQt::PendingCall *startDiscovery();
80  BluezQt::PendingCall *stopDiscovery();
81  BluezQt::PendingCall *removeDevice(DeclarativeDevice *device);
82 
83 Q_SIGNALS:
84  void adapterRemoved(DeclarativeAdapter *adapter);
85  void adapterChanged(DeclarativeAdapter *adapter);
86  void nameChanged(const QString &name);
87  void systemNameChanged(const QString &name);
88  void adapterClassChanged(quint32 adapterClass);
89  void poweredChanged(bool powered);
90  void discoverableChanged(bool discoverable);
91  void discoverableTimeoutChanged(quint32 timeout);
92  void pairableChanged(bool pairable);
93  void pairableTimeoutChanged(quint32 timeout);
94  void discoveringChanged(bool discovering);
95  void uuidsChanged(const QStringList &uuids);
96  void modaliasChanged(const QString &modalias);
97  void deviceFound(DeclarativeDevice *device);
98  void deviceRemoved(DeclarativeDevice *device);
99  void deviceChanged(DeclarativeDevice *device);
100 
101  void devicesChanged(QQmlListProperty<DeclarativeDevice> devices);
102 
103 private Q_SLOTS:
104  void slotDeviceAdded(BluezQt::DevicePtr device);
105  void slotDeviceRemoved(BluezQt::DevicePtr device);
106 
107 private:
108  DeclarativeDevice *declarativeDeviceFromPtr(BluezQt::DevicePtr ptr) const;
109 };
110 
111 #endif // DECLARATIVEADAPTER_H
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
PostalAddress address(const QVariant &location)
Q_SIGNALSQ_SIGNALS
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.