Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qbluetoothlocaldevice_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QBLUETOOTHLOCALDEVICE_P_H
6#define QBLUETOOTHLOCALDEVICE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtBluetooth/qtbluetoothglobal.h>
20
22
23#if QT_CONFIG(bluez)
24#include <QObject>
25#include <QDBusObjectPath>
26#include <QDBusMessage>
27#include <QSet>
29
34
38#endif
39
40#ifdef QT_WINRT_BLUETOOTH
42#include <winrt/Windows.Devices.Bluetooth.h>
44struct PairingWorker;
46#endif
47
48#ifdef QT_ANDROID_BLUETOOTH
49#include <jni.h>
50#include <QtCore/QJniEnvironment>
51#include <QtCore/QJniObject>
52#include <QtCore/QPair>
53#endif
54
56
58
60
61#ifdef QT_ANDROID_BLUETOOTH
64{
66public:
70
71 QJniObject *adapter();
73 static bool startDiscovery();
74 static bool cancelDiscovery();
75 static bool isDiscovering();
76 bool isValid() const;
77
78private slots:
79 void processHostModeChange(QBluetoothLocalDevice::HostMode newMode);
80 void processPairingStateChanged(const QBluetoothAddress &address,
82 void processConnectDeviceChanges(const QBluetoothAddress &address, bool isConnectEvent);
83
84private:
86 QJniObject *obj = nullptr;
87
88 int pendingPairing(const QBluetoothAddress &address);
89
90public:
92 bool pendingConnectableHostModeTransition = false;
94
95 QList<QBluetoothAddress> connectedDevices;
96};
97
98#elif QT_CONFIG(bluez)
100{
102 Q_DECLARE_PUBLIC(QBluetoothLocalDevice)
103public:
105 QBluetoothAddress localAddress = QBluetoothAddress());
107
108 QSet<QBluetoothAddress> connectedDevicesSet;
109 OrgBluezAdapter1Interface *adapter = nullptr;
110 OrgFreedesktopDBusPropertiesInterface *adapterProperties = nullptr;
113
114 QList<QBluetoothAddress> connectedDevices() const;
115
116 QBluetoothAddress localAddress;
119 OrgBluezDevice1Interface *pairingTarget = nullptr;
120 QTimer *pairingDiscoveryTimer = nullptr;
122 int pendingHostModeChange;
123
124public slots:
125 void pairingCompleted(QDBusPendingCallWatcher *);
126
127 bool isValid() const;
128
130 QBluetoothLocalDevice::Pairing targetPairing);
131
132private Q_SLOTS:
133 void PropertiesChanged(const QString &interface,
134 const QVariantMap &changed_properties,
135 const QStringList &invalidated_properties,
136 const QDBusMessage &signal);
137 void InterfacesAdded(const QDBusObjectPath &object_path,
138 InterfaceList interfaces_and_properties);
139 void InterfacesRemoved(const QDBusObjectPath &object_path,
140 const QStringList &interfaces);
141 void processPairing(const QString &objectPath, QBluetoothLocalDevice::Pairing target);
142 void pairingDiscoveryTimedOut();
143
144private:
145 void connectDeviceChanges();
146
147 QString deviceAdapterPath;
148
150
151 void initializeAdapter();
152};
153
154#elif defined(QT_WINRT_BLUETOOTH)
156{
158 Q_DECLARE_PUBLIC(QBluetoothLocalDevice)
159public:
163
164 bool isValid() const;
165
166 void updateAdapterState(QBluetoothLocalDevice::HostMode mode);
167 Q_SLOT void onAdapterRemoved(winrt::hstring id);
168 Q_SLOT void onAdapterAdded(winrt::hstring id);
169 Q_SLOT void radioModeChanged(winrt::hstring id, QBluetoothLocalDevice::HostMode mode);
170 Q_SLOT void onDeviceAdded(const QBluetoothAddress &address);
171 Q_SLOT void onDeviceRemoved(const QBluetoothAddress &address);
172
174 winrt::com_ptr<PairingWorker> mPairingWorker;
175 winrt::Windows::Devices::Bluetooth::BluetoothAdapter mAdapter;
176 winrt::hstring mDeviceId;
177 QString mAdapterName;
179 winrt::event_token mModeChangeToken;
180
181signals:
182 void updateMode(winrt::hstring id, QBluetoothLocalDevice::HostMode mode);
183};
184#elif !defined(QT_OSX_BLUETOOTH) // dummy backend
186{
187public:
190 {
191 }
192
193 bool isValid() const
194 {
195 return false;
196 }
197};
198#endif
199
201
202#endif // QBLUETOOTHLOCALDEVICE_P_H
\inmodule QtBluetooth
QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *=nullptr, QBluetoothAddress=QBluetoothAddress())
void requestPairing(const QBluetoothAddress &address, Pairing pairing)
\inmodule QtBluetooth
Pairing
This enum describes the pairing state between the two Bluetooth devices.
HostMode
This enum describes the most of the local Bluetooth device.
\inmodule QtDBus
\inmodule QtDBus
\inmodule QtCore
Definition qlist.h:74
Definition qmap.h:186
\inmodule QtCore
Definition qobject.h:90
Definition qset.h:18
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qtimer.h:20
auto signal
Combined button and popup list for selecting options.
bool startDiscovery()
QT_BEGIN_NAMESPACE void registerQBluetoothLocalDeviceMetaType()
static bool initialize()
Definition qctf.cpp:67
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char * interface
GLenum mode
GLenum target
GLhandleARB obj
[2]
GLuint GLuint64EXT address
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define Q_OBJECT
#define Q_SLOTS
#define slots
#define signals
#define Q_SLOT
QNetworkAccessManager manager