Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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;
93 QList<QPair<QBluetoothAddress, bool> > pendingPairings;
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;
112 QMap<QString, OrgFreedesktopDBusPropertiesInterface *> deviceChangeMonitors;
113
114 QList<QBluetoothAddress> connectedDevices() const;
115
116 QBluetoothAddress localAddress;
119 OrgBluezDevice1Interface *pairingTarget = nullptr;
120 QTimer *pairingDiscoveryTimer = nullptr;
122 int pendingHostModeChange;
123 bool pairingRequestCanceled = false;
124
125public slots:
126 void pairingCompleted(QDBusPendingCallWatcher *);
127
128 bool isValid() const;
129
131 QBluetoothLocalDevice::Pairing targetPairing);
132
133private Q_SLOTS:
134 void PropertiesChanged(const QString &interface,
135 const QVariantMap &changed_properties,
136 const QStringList &invalidated_properties,
137 const QDBusMessage &signal);
138 void InterfacesAdded(const QDBusObjectPath &object_path,
139 InterfaceList interfaces_and_properties);
140 void InterfacesRemoved(const QDBusObjectPath &object_path,
141 const QStringList &interfaces);
142 void processPairing(const QString &objectPath, QBluetoothLocalDevice::Pairing target);
143 void pairingDiscoveryTimedOut();
144
145private:
146 void connectDeviceChanges();
147
148 QString deviceAdapterPath;
149
151
152 void initializeAdapter();
153};
154
155#elif defined(QT_WINRT_BLUETOOTH)
157{
159 Q_DECLARE_PUBLIC(QBluetoothLocalDevice)
160public:
164
165 bool isValid() const;
166
167 void updateAdapterState(QBluetoothLocalDevice::HostMode mode);
168 Q_SLOT void onAdapterRemoved(winrt::hstring id);
169 Q_SLOT void onAdapterAdded(winrt::hstring id);
170 Q_SLOT void radioModeChanged(winrt::hstring id, QBluetoothLocalDevice::HostMode mode);
171 Q_SLOT void onDeviceAdded(const QBluetoothAddress &address);
172 Q_SLOT void onDeviceRemoved(const QBluetoothAddress &address);
173
175 winrt::com_ptr<PairingWorker> mPairingWorker;
176 winrt::Windows::Devices::Bluetooth::BluetoothAdapter mAdapter;
177 winrt::hstring mDeviceId;
178 QString mAdapterName;
180 winrt::event_token mModeChangeToken;
181
182signals:
183 void updateMode(winrt::hstring id, QBluetoothLocalDevice::HostMode mode);
184};
185#elif !defined(QT_OSX_BLUETOOTH) // dummy backend
187{
188public:
193
194 bool isValid() const
195 {
196 return false;
197 }
198};
199#endif
200
202
203#endif // QBLUETOOTHLOCALDEVICE_P_H
\inmodule QtBluetooth
QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *, const QBluetoothAddress &=QBluetoothAddress())
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
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\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:94
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