1 | /* |
2 | * BluezQt - Asynchronous BlueZ wrapper library |
3 | * |
4 | * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> |
5 | * |
6 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #ifndef DECLARATIVEDEVICE_H |
10 | #define DECLARATIVEDEVICE_H |
11 | |
12 | #include "device.h" |
13 | #include <qqmlregistration.h> |
14 | |
15 | class DeclarativeAdapter; |
16 | class DeclarativeBattery; |
17 | class DeclarativeInput; |
18 | class DeclarativeMediaPlayer; |
19 | |
20 | class DeclarativeDevice : public QObject |
21 | { |
22 | Q_OBJECT |
23 | QML_NAMED_ELEMENT(Device) |
24 | QML_UNCREATABLE("Device cannot be created" ) |
25 | |
26 | Q_PROPERTY(QString ubi READ ubi CONSTANT) |
27 | Q_PROPERTY(QString address READ address CONSTANT) |
28 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
29 | Q_PROPERTY(QString friendlyName READ friendlyName NOTIFY friendlyNameChanged) |
30 | Q_PROPERTY(QString remoteName READ remoteName NOTIFY remoteNameChanged) |
31 | Q_PROPERTY(quint32 deviceClass READ deviceClass NOTIFY deviceClassChanged) |
32 | Q_PROPERTY(BluezQt::Device::Type type READ type NOTIFY typeChanged) |
33 | Q_PROPERTY(quint16 appearance READ appearance NOTIFY appearanceChanged) |
34 | Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) |
35 | Q_PROPERTY(bool paired READ isPaired NOTIFY pairedChanged) |
36 | Q_PROPERTY(bool trusted READ isTrusted WRITE setTrusted NOTIFY trustedChanged) |
37 | Q_PROPERTY(bool blocked READ isBlocked WRITE setBlocked NOTIFY blockedChanged) |
38 | Q_PROPERTY(bool legacyPairing READ hasLegacyPairing NOTIFY legacyPairingChanged) |
39 | Q_PROPERTY(qint16 rssi READ rssi NOTIFY rssiChanged) |
40 | Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged) |
41 | Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged) |
42 | Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged) |
43 | Q_PROPERTY(DeclarativeBattery *battery READ battery NOTIFY batteryChanged) |
44 | Q_PROPERTY(DeclarativeInput *input READ input NOTIFY inputChanged) |
45 | Q_PROPERTY(DeclarativeMediaPlayer *mediaPlayer READ mediaPlayer NOTIFY mediaPlayerChanged) |
46 | Q_PROPERTY(DeclarativeAdapter *adapter READ adapter CONSTANT) |
47 | |
48 | public: |
49 | explicit DeclarativeDevice(BluezQt::DevicePtr device, DeclarativeAdapter *adapter); |
50 | |
51 | QString ubi() const; |
52 | |
53 | QString address() const; |
54 | |
55 | QString name() const; |
56 | void setName(const QString &name); |
57 | |
58 | QString friendlyName() const; |
59 | |
60 | QString remoteName() const; |
61 | |
62 | quint32 deviceClass() const; |
63 | |
64 | BluezQt::Device::Type type() const; |
65 | |
66 | quint16 appearance() const; |
67 | |
68 | QString icon() const; |
69 | |
70 | bool isPaired() const; |
71 | |
72 | bool isTrusted() const; |
73 | void setTrusted(bool trusted); |
74 | |
75 | bool isBlocked() const; |
76 | void setBlocked(bool blocked); |
77 | |
78 | bool hasLegacyPairing() const; |
79 | |
80 | qint16 () const; |
81 | |
82 | bool isConnected() const; |
83 | |
84 | QStringList uuids() const; |
85 | |
86 | QString modalias() const; |
87 | |
88 | DeclarativeBattery *battery() const; |
89 | |
90 | DeclarativeInput *input() const; |
91 | |
92 | DeclarativeMediaPlayer *mediaPlayer() const; |
93 | |
94 | DeclarativeAdapter *adapter() const; |
95 | |
96 | public Q_SLOTS: |
97 | BluezQt::PendingCall *connectToDevice(); |
98 | BluezQt::PendingCall *disconnectFromDevice(); |
99 | BluezQt::PendingCall *connectProfile(const QString &uuid); |
100 | BluezQt::PendingCall *disconnectProfile(const QString &uuid); |
101 | BluezQt::PendingCall *pair(); |
102 | BluezQt::PendingCall *cancelPairing(); |
103 | |
104 | Q_SIGNALS: |
105 | void deviceRemoved(DeclarativeDevice *device); |
106 | void deviceChanged(DeclarativeDevice *device); |
107 | void nameChanged(const QString &name); |
108 | void friendlyNameChanged(const QString &friendlyName); |
109 | void remoteNameChanged(const QString &remoteName); |
110 | void deviceClassChanged(quint32 deviceClass); |
111 | void typeChanged(BluezQt::Device::Type type); |
112 | void appearanceChanged(quint16 appearance); |
113 | void iconChanged(const QString &icon); |
114 | void pairedChanged(bool paired); |
115 | void trustedChanged(bool trusted); |
116 | void blockedChanged(bool blocked); |
117 | void legacyPairingChanged(bool legacyPairing); |
118 | void (qint16 ); |
119 | void connectedChanged(bool connected); |
120 | void uuidsChanged(const QStringList &uuids); |
121 | void modaliasChanged(const QString &modalias); |
122 | void batteryChanged(DeclarativeBattery *battery); |
123 | void inputChanged(DeclarativeInput *input); |
124 | void mediaPlayerChanged(DeclarativeMediaPlayer *mediaPlayer); |
125 | |
126 | private: |
127 | void updateBattery(); |
128 | void updateInput(); |
129 | void updateMediaPlayer(); |
130 | |
131 | BluezQt::DevicePtr m_device; |
132 | DeclarativeAdapter *m_adapter; |
133 | DeclarativeBattery *m_battery; |
134 | DeclarativeInput *m_input; |
135 | DeclarativeMediaPlayer *m_mediaPlayer; |
136 | }; |
137 | |
138 | #endif // DECLARATIVEDEVICE_H |
139 | |