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
>
21
#
include
"qbluetoothserver.h"
22
#
include
"qbluetooth.h"
23
24
#
if
QT_CONFIG
(
bluez
)
25
QT_FORWARD_DECLARE_CLASS
(
QSocketNotifier
)
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
39
class
ServerAcceptanceThread
;
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
59
QT_BEGIN_NAMESPACE
60
61
class
QBluetoothAddress;
62
class
QBluetoothSocket;
63
class
QBluetoothServer;
64
65
class
QBluetoothServerPrivate
66
#
ifdef
QT_OSX_BLUETOOTH
67
:
public
DarwinBluetooth
::
SocketListener
68
#
endif
69
{
70
Q_DECLARE_PUBLIC(QBluetoothServer)
71
72
public
:
73
QBluetoothServerPrivate
(
QBluetoothServiceInfo
::
Protocol
serverType
,
QBluetoothServer
*
parent
);
74
~
QBluetoothServerPrivate
();
75
76
#
if
QT_CONFIG
(
bluez
)
77
void
_q_newConnection
();
78
void
setSocketSecurityLevel
(
QBluetooth
::
SecurityFlags
requestedSecLevel
,
int
*
errnoCode
);
79
QBluetooth
::
SecurityFlags
socketSecurityLevel
()
const
;
80
static
QBluetoothSocket
*
createSocketForServer
(
81
QBluetoothServiceInfo
::
Protocol
socketType
=
QBluetoothServiceInfo
::
RfcommProtocol
);
82
#
endif
83
84
public
:
85
QBluetoothSocket *
socket
=
nullptr
;
86
87
int
maxPendingConnections
= 1;
88
QBluetooth
::
SecurityFlags
securityFlags
=
QBluetooth
::
Security
::
NoSecurity
;
89
QBluetoothServiceInfo
::
Protocol
serverType
;
90
91
protected
:
92
QBluetoothServer *
q_ptr
;
93
94
private
:
95
QBluetoothServer::Error m_lastError =
QBluetoothServer
::
NoError
;
96
#
if
QT_CONFIG
(
bluez
)
97
QSocketNotifier
*
socketNotifier
=
nullptr
;
98
#
elif
defined
(
QT_ANDROID_BLUETOOTH
)
99
ServerAcceptanceThread
*
thread
;
100
QString
m_serviceName
;
101
QBluetoothUuid
m_uuid
;
102
public
:
103
bool
isListening
()
const
;
104
bool
initiateActiveListening
(
const
QBluetoothUuid
&
uuid
,
const
QString
&
serviceName
);
105
bool
deactivateActiveListening
();
106
#
elif
defined
(
QT_WINRT_BLUETOOTH
)
107
EventRegistrationToken
connectionToken
{-1};
108
109
mutable
QMutex
pendingConnectionsMutex
;
110
QList
<
Microsoft
::
WRL
::
ComPtr
<
ABI
::
Windows
::
Networking
::
Sockets
::
IStreamSocket
>>
111
pendingConnections
;
112
113
Microsoft
::
WRL
::
ComPtr
<
ABI
::
Windows
::
Networking
::
Sockets
::
IStreamSocketListener
>
socketListener
;
114
HRESULT
handleClientConnection
(
ABI
::
Windows
::
Networking
::
Sockets
::
IStreamSocketListener
*
listener
,
115
ABI
::
Windows
::
Networking
::
Sockets
::
IStreamSocketListenerConnectionReceivedEventArgs
*
args
);
116
117
public
:
118
bool
isListening
()
const
;
119
Microsoft
::
WRL
::
ComPtr
<
ABI
::
Windows
::
Networking
::
Sockets
::
IStreamSocketListener
>
listener
() {
return
socketListener
; }
120
bool
initiateActiveListening
(
const
QString
&
serviceName
);
121
bool
deactivateActiveListening
();
122
#
elif
defined
(
QT_HARMONY_BLUETOOTH
)
123
bool
isListening
()
const
;
124
void
resetServerContext
();
125
std
::
shared_ptr
<
QtOhosBluetooth
::
QOhosBluetoothServerProxyContext
>
m_bluetoothServerProxyContext
;
126
#
endif
127
128
#
ifdef
QT_OSX_BLUETOOTH
129
130
public
:
131
132
friend
class
QBluetoothServer
;
133
friend
class
QBluetoothServiceInfoPrivate
;
134
135
private
:
136
bool
startListener
(
quint16
realPort
);
137
void
stopListener
();
138
bool
isListening
()
const
;
139
140
// SocketListener (delegate):
141
void
openNotifyRFCOMM
(
void
*
channel
)
override
;
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.
147
quint16
port
;
148
149
DarwinBluetooth
::
StrongReference
listener
;
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
165
static
void
registerServer
(
QBluetoothServerPrivate
*
server
,
quint16
port
);
166
static
QBluetoothServerPrivate
*
registeredServer
(
quint16
port
,
QBluetoothServiceInfo
::
Protocol
protocol
);
167
static
void
unregisterServer
(
QBluetoothServerPrivate
*
server
);
168
169
using
PendingConnection
=
DarwinBluetooth
::
StrongReference
;
170
QList
<
PendingConnection
>
pendingConnections
;
171
172
#
endif
// QT_OSX_BLUETOOTH
173
};
174
175
QT_END_NAMESPACE
176
177
#
endif
QBluetoothServerPrivate
Definition
qbluetoothserver_p.h:69
QBluetoothServerPrivate::q_ptr
QBluetoothServer * q_ptr
Definition
qbluetoothserver_p.h:92
QBluetoothServerPrivate::serverType
QBluetoothServiceInfo::Protocol serverType
Definition
qbluetoothserver_p.h:89
QBluetoothServerPrivate::securityFlags
QBluetooth::SecurityFlags securityFlags
Definition
qbluetoothserver_p.h:88
QBluetoothServerPrivate::~QBluetoothServerPrivate
~QBluetoothServerPrivate()
Definition
qbluetoothserver_android.cpp:30
QBluetoothServerPrivate::maxPendingConnections
int maxPendingConnections
Definition
qbluetoothserver_p.h:87
QBluetoothServerPrivate::socket
QBluetoothSocket * socket
Definition
qbluetoothserver_p.h:85
QBluetoothServer
\inmodule QtBluetooth
Definition
qbluetoothserver.h:23
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtconnectivity
src
bluetooth
qbluetoothserver_p.h
Generated on
for Qt by
1.16.1