BluezQt

declarativedevice.h
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
15class DeclarativeAdapter;
16class DeclarativeBattery;
17class DeclarativeInput;
18class DeclarativeMediaPlayer;
19
20class DeclarativeDevice : public QObject
21{
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
48public:
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 rssi() 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
96public 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
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 rssiChanged(qint16 rssi);
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
126private:
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
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.