File indexing completed on 2024-10-13 06:33:17
0001 /* 0002 * SPDX-FileCopyrightText: 2014-2015 David Rosca <nowrep@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef DEVICEINTERFACE_H 0008 #define DEVICEINTERFACE_H 0009 0010 #include "object.h" 0011 0012 #include <QDBusAbstractAdaptor> 0013 #include <QStringList> 0014 0015 class QDBusMessage; 0016 class QDBusObjectPath; 0017 class MediaTransportInterface; 0018 0019 class DeviceObject : public QObject 0020 { 0021 public: 0022 explicit DeviceObject(const QDBusObjectPath &path, QObject *parent = nullptr); 0023 }; 0024 0025 class DeviceInterface : public QDBusAbstractAdaptor, public Object 0026 { 0027 Q_OBJECT 0028 Q_CLASSINFO("D-Bus Interface", "org.bluez.Device1") 0029 Q_PROPERTY(QString Address READ address) 0030 Q_PROPERTY(QString Name READ name) 0031 Q_PROPERTY(QString Alias READ alias WRITE setAlias) 0032 Q_PROPERTY(QString Icon READ icon) 0033 Q_PROPERTY(quint32 Class READ deviceClass) 0034 Q_PROPERTY(quint16 Appearance READ appearance) 0035 Q_PROPERTY(bool Paired READ paired) 0036 Q_PROPERTY(bool Connected READ connected) 0037 Q_PROPERTY(bool Trusted READ trusted WRITE setTrusted) 0038 Q_PROPERTY(bool Blocked READ blocked WRITE setBlocked) 0039 Q_PROPERTY(QDBusObjectPath Adapter READ adapter) 0040 Q_PROPERTY(bool LegacyPairing READ legacyPairing) 0041 Q_PROPERTY(qint16 RSSI READ rssi) 0042 Q_PROPERTY(QStringList UUIDs READ uuids) 0043 Q_PROPERTY(QString Modalias READ modalias) 0044 0045 public: 0046 explicit DeviceInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent = nullptr); 0047 0048 QString address() const; 0049 0050 QString name() const; 0051 0052 QString alias() const; 0053 void setAlias(const QString &alias); 0054 0055 QString icon() const; 0056 0057 quint32 deviceClass() const; 0058 0059 quint16 appearance() const; 0060 0061 bool paired() const; 0062 0063 bool connected() const; 0064 0065 bool trusted() const; 0066 void setTrusted(bool trusted); 0067 0068 bool blocked() const; 0069 void setBlocked(bool blocked); 0070 0071 QDBusObjectPath adapter() const; 0072 0073 bool legacyPairing() const; 0074 0075 qint16 rssi() const; 0076 0077 QStringList uuids() const; 0078 0079 QString modalias() const; 0080 0081 MediaTransportInterface *mediaTransport() const; 0082 0083 public Q_SLOTS: 0084 void Connect(); 0085 void Disconnect(); 0086 void ConnectProfile(const QString &uuid, const QDBusMessage &msg); 0087 void DisconnectProfile(const QString &uuid, const QDBusMessage &msg); 0088 void Pair(); 0089 void CancelPairing(); 0090 0091 private: 0092 void connectMediaPlayer(); 0093 void disconnectMediaPlayer(); 0094 void connectMediaTransport(); 0095 void disconnectMediaTransport(); 0096 0097 QStringList m_connectedUuids; 0098 Object *m_mediaPlayer = nullptr; 0099 MediaTransportInterface *m_mediaTransport = nullptr; 0100 0101 friend class DeviceManager; 0102 }; 0103 0104 #endif // DEVICEINTERFACE_H