Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qbluetoothserver_p.h
Go to the documentation of this file.
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 QBLUETOOTHSERVER_P_H
5#define QBLUETOOTHSERVER_P_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 <QtGlobal>
19#include <QList>
20#include <QtBluetooth/QBluetoothSocket>
22#include "qbluetooth.h"
23
24#if QT_CONFIG(bluez)
26#endif
27
28#ifdef QT_HARMONY_BLUETOOTH
29#include <QtBluetooth/private/qbluetoothserver_ohos_p.h>
30
31#include <memory>
32#endif
33
34#ifdef QT_ANDROID_BLUETOOTH
35#include <QtCore/QJniEnvironment>
36#include <QtCore/QJniObject>
37#include <QtBluetooth/QBluetoothUuid>
38
40#endif
41
42#ifdef QT_WINRT_BLUETOOTH
43#include <QtCore/QMutex>
44
45#include <wrl.h>
46// No forward declares because QBluetoothServerPrivate::listener does not work with them
47#include <windows.networking.sockets.h>
48#endif
49
50#ifdef QT_OSX_BLUETOOTH
51
52#include "darwin/btdelegates_p.h"
53#include "darwin/btraii_p.h"
54
55#include <QtCore/QMutex>
56
57#endif // QT_OSX_BLUETOOTH
58
60
61class QBluetoothAddress;
62class QBluetoothSocket;
63class QBluetoothServer;
64
66#ifdef QT_OSX_BLUETOOTH
68#endif
69{
70 Q_DECLARE_PUBLIC(QBluetoothServer)
71
72public:
75
76#if QT_CONFIG(bluez)
77 void _q_newConnection();
82#endif
83
84public:
85 QBluetoothSocket *socket = nullptr;
86
90
91protected:
92 QBluetoothServer *q_ptr;
93
94private:
95 QBluetoothServer::Error m_lastError = QBluetoothServer::NoError;
96#if QT_CONFIG(bluez)
98#elif defined(QT_ANDROID_BLUETOOTH)
102public:
103 bool isListening() const;
106#elif defined(QT_WINRT_BLUETOOTH)
108
112
116
117public:
118 bool isListening() const;
122#elif defined(QT_HARMONY_BLUETOOTH)
123 bool isListening() const;
124 void resetServerContext();
126#endif
127
128#ifdef QT_OSX_BLUETOOTH
129
130public:
131
132 friend class QBluetoothServer;
133 friend class QBluetoothServiceInfoPrivate;
134
135private:
137 void stopListener();
138 bool isListening() const;
139
140 // SocketListener (delegate):
142 void openNotifyL2CAP(void *channel) override;
143
144 // Either a "temporary" channelID/PSM assigned by QBluetoothServer::listen,
145 // or a real channelID/PSM returned by IOBluetooth after we've registered
146 // a service.
148
150
151 // These static functions below
152 // deal with differences between bluetooth sockets
153 // (bluez and QtBluetooth's API) and IOBluetooth, where it's not possible
154 // to have a real PSM/channelID _before_ a service is registered,
155 // the solution - "fake" ports.
156 // These functions require external locking - using channelMapMutex.
157 static QMutex &channelMapMutex();
158
159 static bool channelIsBusy(quint16 channelID);
160 static quint16 findFreeChannel();
161
162 static bool psmIsBusy(quint16 psm);
163 static quint16 findFreePSM();
164
168
171
172#endif // QT_OSX_BLUETOOTH
173};
174
175QT_END_NAMESPACE
176
177#endif
QBluetoothServiceInfo::Protocol serverType
QBluetooth::SecurityFlags securityFlags
QBluetoothSocket * socket
\inmodule QtBluetooth
Combined button and popup list for selecting options.