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
qbluetoothsocket_macos_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 QBLUETOOTHSOCKET_OSX_P_H
5#define QBLUETOOTHSOCKET_OSX_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#ifdef QT_OSX_BLUETOOTH
19
20#include "qbluetoothsocketbase_p.h"
21#include "qbluetoothserviceinfo.h"
22#include "darwin/btdelegates_p.h"
23#include "qbluetoothsocket.h"
24#include "darwin/btraii_p.h"
25
26#ifndef QPRIVATELINEARBUFFER_BUFFERSIZE
27#define QPRIVATELINEARBUFFER_BUFFERSIZE Q_INT64_C(16384)
28#endif
29// The order is important: bytearray before buffer:
30#include <QtCore/qbytearray.h>
31#include "qprivatelinearbuffer_p.h"
32
33#include <QtCore/qglobal.h>
34#include <QtCore/QIODevice>
35#include <QtCore/QList>
36#include <QtCore/QObject>
37#include <QtCore/QScopedPointer>
38#include <QtCore/QString>
39
40QT_BEGIN_NAMESPACE
41
42class QBluetoothAddress;
43
44class QBluetoothSocketPrivateDarwin : public QBluetoothSocketBasePrivate, public DarwinBluetooth::ChannelDelegate
45{
46 friend class QBluetoothSocket;
47 friend class QBluetoothServer;
48
49public:
50 QBluetoothSocketPrivateDarwin();
51 ~QBluetoothSocketPrivateDarwin();
52
53 //
54 bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type) override;
55
56 QString localName() const override;
57 QBluetoothAddress localAddress() const override;
58 quint16 localPort() const override;
59
60 QString peerName() const override;
61 QBluetoothAddress peerAddress() const override;
62 quint16 peerPort() const override;
63
64 void abort() override;
65 void close() override;
66
67 qint64 writeData(const char *data, qint64 maxSize) override;
68 qint64 readData(char *data, qint64 maxSize) override;
69
70 qint64 bytesAvailable() const override;
71 bool canReadLine() const override;
72 qint64 bytesToWrite() const override;
73
74 bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
75 QBluetoothSocket::SocketState socketState,
76 QBluetoothSocket::OpenMode openMode) override;
77
78 void connectToServiceHelper(const QBluetoothAddress &address, quint16 port,
79 QIODevice::OpenMode openMode) override;
80 void connectToService(const QBluetoothServiceInfo &service,
81 QIODevice::OpenMode openMode) override;
82 void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid,
83 QIODevice::OpenMode openMode) override;
84
85 void connectToService(const QBluetoothAddress &address, quint16 port,
86 QIODevice::OpenMode openMode) override;
87
88 void _q_writeNotify();
89
90private:
91 // Create a socket from an external source (without connectToService).
92 bool setRFCOMChannel(void *channel);
93 bool setL2CAPChannel(void *channel);
94
95 // L2CAP and RFCOMM delegate
96 void setChannelError(IOReturn errorCode) override;
97 void channelOpenComplete() override;
98 void channelClosed() override;
99 void readChannelData(void *data, std::size_t size) override;
100 void writeComplete() override;
101
102 QList<char> writeChunk;
103
104 using L2CAPChannel = DarwinBluetooth::ScopedPointer;
105 L2CAPChannel l2capChannel;
106
107 using RFCOMMChannel = L2CAPChannel;
108 RFCOMMChannel rfcommChannel;
109 // A trick to deal with channel open too fast (synchronously).
110 bool isConnecting = false;
111};
112
113QT_END_NAMESPACE
114
115#endif
116
117#endif
QMap< quint16, QBluetoothServerPrivate * > & busyPSMs()
QMap< quint16, QBluetoothServerPrivate * > & busyChannels()
QMap< quint16, QBluetoothServerPrivate * >::iterator ServerMapIterator