| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
| 3 |  | 
| 4 | #ifndef BLUEZ5_HELPER_H | 
| 5 | #define BLUEZ5_HELPER_H | 
| 6 |  | 
| 7 | // | 
| 8 | //  W A R N I N G | 
| 9 | //  ------------- | 
| 10 | // | 
| 11 | // This file is not part of the Qt API.  It exists purely as an | 
| 12 | // implementation detail.  This header file may change from version to | 
| 13 | // version without notice, or even be removed. | 
| 14 | // | 
| 15 | // We mean it. | 
| 16 | // | 
| 17 |  | 
| 18 | #include <QtCore/QObject> | 
| 19 | #include <QtDBus/QtDBus> | 
| 20 | #include <QtBluetooth/QBluetoothUuid> | 
| 21 | #include <QtBluetooth/QBluetoothAddress> | 
| 22 | #include <QtBluetooth/private/qtbluetoothglobal_p.h> | 
| 23 |  | 
| 24 | typedef QMap<QString, QVariantMap> InterfaceList; | 
| 25 | typedef QMap<QDBusObjectPath, InterfaceList> ManagedObjectList; | 
| 26 | typedef QMap<quint16, QDBusVariant> ManufacturerDataList; | 
| 27 | typedef QMap<QString, QDBusVariant> ServiceDataList; | 
| 28 |  | 
| 29 | QT_DECL_METATYPE_EXTERN(InterfaceList, /* not exported */) | 
| 30 | QT_DECL_METATYPE_EXTERN(ManufacturerDataList, /* not exported */) | 
| 31 | QT_DECL_METATYPE_EXTERN(ServiceDataList, /* not exported */) | 
| 32 | QT_DECL_METATYPE_EXTERN(ManagedObjectList, /* not exported */) | 
| 33 |  | 
| 34 | QT_BEGIN_NAMESPACE | 
| 35 |  | 
| 36 | void initializeBluez5(); | 
| 37 | bool isBluez5(); | 
| 38 |  | 
| 39 | // exported for unit test purposes | 
| 40 | Q_BLUETOOTH_EXPORT QVersionNumber bluetoothdVersion(); | 
| 41 |  | 
| 42 | QString sanitizeNameForDBus(const QString& text); | 
| 43 |  | 
| 44 | QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok); | 
| 45 |  | 
| 46 | QString adapterWithDBusPeripheralInterface(const QBluetoothAddress &localAddress); | 
| 47 |  | 
| 48 | class QtBluezDiscoveryManagerPrivate; | 
| 49 | class QtBluezDiscoveryManager : public QObject | 
| 50 | { | 
| 51 |     Q_OBJECT | 
| 52 | public: | 
| 53 |     QtBluezDiscoveryManager(QObject* parent = nullptr); | 
| 54 |     ~QtBluezDiscoveryManager(); | 
| 55 |     static QtBluezDiscoveryManager *instance(); | 
| 56 |  | 
| 57 |     bool registerDiscoveryInterest(const QString &adapterPath); | 
| 58 |     void unregisterDiscoveryInterest(const QString &adapterPath); | 
| 59 |  | 
| 60 |     //void dumpState() const; | 
| 61 |  | 
| 62 | signals: | 
| 63 |     void discoveryInterrupted(const QString &adapterPath); | 
| 64 |  | 
| 65 | private slots: | 
| 66 |     void InterfacesRemoved(const QDBusObjectPath &object_path, | 
| 67 |                            const QStringList &interfaces); | 
| 68 |     void PropertiesChanged(const QString &interface, | 
| 69 |                            const QVariantMap &changed_properties, | 
| 70 |                            const QStringList &invalidated_properties, | 
| 71 |                            const QDBusMessage &msg); | 
| 72 |  | 
| 73 | private: | 
| 74 |     void removeAdapterFromMonitoring(const QString &dbusPath); | 
| 75 |  | 
| 76 |     QtBluezDiscoveryManagerPrivate *d; | 
| 77 | }; | 
| 78 |  | 
| 79 | QT_END_NAMESPACE | 
| 80 |  | 
| 81 | #endif | 
| 82 |  |