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
24typedef QMap<QString, QVariantMap> InterfaceList;
25typedef QMap<QDBusObjectPath, InterfaceList> ManagedObjectList;
26typedef QMap<quint16, QDBusVariant> ManufacturerDataList;
27typedef QMap<QString, QDBusVariant> ServiceDataList;
28
29QT_DECL_METATYPE_EXTERN(InterfaceList, /* not exported */)
30QT_DECL_METATYPE_EXTERN(ManufacturerDataList, /* not exported */)
31QT_DECL_METATYPE_EXTERN(ServiceDataList, /* not exported */)
32QT_DECL_METATYPE_EXTERN(ManagedObjectList, /* not exported */)
33
34QT_BEGIN_NAMESPACE
35
36void initializeBluez5();
37bool isBluez5();
38
39// exported for unit test purposes
40Q_BLUETOOTH_PRIVATE_EXPORT QVersionNumber bluetoothdVersion();
41
42QString sanitizeNameForDBus(const QString& text);
43
44QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok);
45
46QString adapterWithDBusPeripheralInterface(const QBluetoothAddress &localAddress);
47
48class QtBluezDiscoveryManagerPrivate;
49class QtBluezDiscoveryManager : public QObject
50{
51 Q_OBJECT
52public:
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
62signals:
63 void discoveryInterrupted(const QString &adapterPath);
64
65private 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
73private:
74 void removeAdapterFromMonitoring(const QString &dbusPath);
75
76 QtBluezDiscoveryManagerPrivate *d;
77};
78
79QT_END_NAMESPACE
80
81#endif
82

source code of qtconnectivity/src/bluetooth/bluez/bluez5_helper_p.h