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
qbluetoothsocketbase_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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 QBLUETOOTHSOCKETBASEPRIVATE_P_H
5#define QBLUETOOTHSOCKETBASEPRIVATE_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 <qglobal.h>
19#include <QObject>
20#include <QtBluetooth/qbluetoothsocket.h>
21
22#if defined(QT_ANDROID_BLUETOOTH)
23#include <QtCore/QJniObject>
24#endif
25
26#if defined(QT_WINRT_BLUETOOTH)
27#include <QtCore/QMutex>
28
29#include <wrl.h>
30
31namespace ABI {
32 namespace Windows {
33 namespace Networking {
34 namespace Sockets {
35 struct IStreamSocket;
36 }
37 }
38 namespace Foundation {
39 struct IAsyncAction;
40 enum class AsyncStatus;
41 }
42 }
43}
44#endif // QT_WINRT_BLUETOOTH
45
46#ifndef QPRIVATELINEARBUFFER_BUFFERSIZE
47#define QPRIVATELINEARBUFFER_BUFFERSIZE Q_INT64_C(16384)
48#endif
50
53
55
57{
59
60public:
61 explicit QBluetoothSocketBasePrivate(QObject *parent = nullptr);
63
65
66 virtual QString localName() const = 0;
67 virtual QBluetoothAddress localAddress() const = 0;
68 virtual quint16 localPort() const = 0;
69
70 virtual QString peerName() const = 0;
71 virtual QBluetoothAddress peerAddress() const = 0;
72 virtual quint16 peerPort() const = 0;
73
74 virtual void abort() = 0;
75 virtual void close() = 0;
76
77 virtual qint64 writeData(const char *data, qint64 maxSize) = 0;
78 virtual qint64 readData(char *data, qint64 maxSize) = 0;
79
80 virtual qint64 bytesAvailable() const = 0;
81 virtual bool canReadLine() const = 0;
82 virtual qint64 bytesToWrite() const = 0;
83
86 QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite) = 0;
87
88
89#if defined(QT_ANDROID_BLUETOOTH)
90 virtual void connectToServiceHelper(const QBluetoothAddress &address, const QBluetoothUuid &uuid,
91 QIODevice::OpenMode openMode) = 0;
92#else
94 QIODevice::OpenMode openMode) = 0;
95#endif
96 virtual void connectToService(const QBluetoothServiceInfo &service,
97 QIODevice::OpenMode openMode) = 0;
98 virtual void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid,
99 QIODevice::OpenMode openMode) = 0;
101 QIODevice::OpenMode openMode) = 0;
102
103#ifdef QT_ANDROID_BLUETOOTH
106 QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite) = 0;
107#elif defined(QT_WINRT_BLUETOOTH)
111 QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite) = 0;
112#endif
113
114public:
117 int socket = -1;
123 bool connecting = false;
124
126 QBluetoothSocket::OpenMode openMode;
127 QBluetooth::SecurityFlags secFlags;
128
130
131protected:
132 Q_DECLARE_PUBLIC(QBluetoothSocket)
134
135#if QT_CONFIG(bluez)
136public:
137 quint8 lowEnergySocketType = 0;
138#endif
139};
140
141static inline void convertAddress(const quint64 from, quint8 (&to)[6])
142{
143 to[0] = (from >> 0) & 0xff;
144 to[1] = (from >> 8) & 0xff;
145 to[2] = (from >> 16) & 0xff;
146 to[3] = (from >> 24) & 0xff;
147 to[4] = (from >> 32) & 0xff;
148 to[5] = (from >> 40) & 0xff;
149}
150
151static inline quint64 convertAddress(const quint8 (&from)[6], quint64 *to = nullptr)
152{
153 const quint64 result = (quint64(from[0]) << 0) |
154 (quint64(from[1]) << 8) |
155 (quint64(from[2]) << 16) |
156 (quint64(from[3]) << 24) |
157 (quint64(from[4]) << 32) |
158 (quint64(from[5]) << 40);
159 if (to)
160 *to = result;
161 return result;
162}
163
165
166#endif // QBLUETOOTHSOCKETBASE_P_H
\inmodule QtBluetooth
\inmodule QtBluetooth
Protocol
This enum describes the socket protocol used by the service.
virtual QString peerName() const =0
virtual QBluetoothAddress peerAddress() const =0
virtual void connectToService(const QBluetoothServiceInfo &service, QIODevice::OpenMode openMode)=0
virtual bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetoothSocket::SocketState socketState=QBluetoothSocket::SocketState::ConnectedState, QBluetoothSocket::OpenMode openMode=QBluetoothSocket::ReadWrite)=0
virtual void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, QIODevice::OpenMode openMode)=0
QBluetoothSocket::OpenMode openMode
virtual qint64 bytesAvailable() const =0
QBluetooth::SecurityFlags secFlags
virtual qint64 bytesToWrite() const =0
virtual QString localName() const =0
QBluetoothServiceDiscoveryAgent * discoveryAgent
QBluetoothSocket::SocketError socketError
virtual QBluetoothAddress localAddress() const =0
QBluetoothServiceInfo::Protocol socketType
virtual bool canReadLine() const =0
virtual qint64 readData(char *data, qint64 maxSize)=0
virtual qint64 writeData(const char *data, qint64 maxSize)=0
QBluetoothSocket::SocketState state
virtual quint16 localPort() const =0
virtual void connectToService(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode)=0
virtual void connectToServiceHelper(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode)=0
QBluetoothSocketBasePrivate(QObject *parent=nullptr)
virtual quint16 peerPort() const =0
virtual bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type)=0
\inmodule QtBluetooth
SocketState
This enum describes the state of the Bluetooth socket.
SocketError
This enum describes Bluetooth socket error types.
\inmodule QtBluetooth
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
static void convertAddress(const quint64 from, quint8(&to)[6])
QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem)
EGLOutputPortEXT port
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLuint GLuint64EXT address
GLuint64EXT * result
[6]
#define Q_OBJECT
unsigned short quint16
Definition qtypes.h:48
unsigned long long quint64
Definition qtypes.h:61
long long qint64
Definition qtypes.h:60
unsigned char quint8
Definition qtypes.h:46