summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-07-19 12:53:30 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-07-25 11:16:14 +0000
commitb20db00c080ff87c5b2a4d1fff2eac7cd694539c (patch)
tree29f86bc324e91ec47249a73f279d1b48c5189ff2
parent28eeb7afc27e99deeb52eefe10cdd458c7621698 (diff)
Add separate interfaces for QBluetoothSocketPrivate on Linux
Uses the new QBluetoothSocketBasePrivate interface to separate the Linux implementations from other platforms. On Linux, there will be the existing raw socket implementation and a BlueZ5 DBus implementation. The DBus implementation is required for very recent Bluez5 deployments (v5.4x+) which restrict access to traditional SDP discovery means like sdptool. For now the DBus implementation is non-existing/dysfunctional. Task-number: QTBUG-68550 Change-Id: Idd248ecdb2a443a95cde521ced929218d40df3fe Reviewed-by: Lubomir I. Ivanov <neolit123@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/bluetooth/bluetooth.pro7
-rw-r--r--src/bluetooth/bluez/bluetoothmanagement.cpp2
-rw-r--r--src/bluetooth/bluez/hcimanager.cpp2
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp12
-rw-r--r--src/bluetooth/qbluetoothsocket.h2
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp52
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez_p.h101
-rw-r--r--src/bluetooth/qbluetoothsocket_bluezdbus.cpp159
-rw-r--r--src/bluetooth/qbluetoothsocket_bluezdbus_p.h98
-rw-r--r--src/bluetooth/qbluetoothsocket_p.h31
-rw-r--r--src/bluetooth/qbluetoothsocketbase_p.h23
-rw-r--r--src/bluetooth/qleadvertiser_bluez.cpp2
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp2
13 files changed, 431 insertions, 62 deletions
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index 28470835..65c46559 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -96,13 +96,18 @@ qtConfig(bluez) {
include(bluez/bluez.pri)
PRIVATE_HEADERS += \
- qbluetoothtransferreply_bluez_p.h
+ qbluetoothtransferreply_bluez_p.h \
+ qbluetoothsocket_bluez_p.h \
+ qbluetoothsocket_bluezdbus_p.h
+
+ PRIVATE_HEADERS -= qbluetoothsocket_p.h
SOURCES += \
qbluetoothserviceinfo_bluez.cpp \
qbluetoothdevicediscoveryagent_bluez.cpp\
qbluetoothservicediscoveryagent_bluez.cpp \
qbluetoothsocket_bluez.cpp \
+ qbluetoothsocket_bluezdbus.cpp \
qbluetoothserver_bluez.cpp \
qbluetoothlocaldevice_bluez.cpp \
qbluetoothtransferreply_bluez.cpp \
diff --git a/src/bluetooth/bluez/bluetoothmanagement.cpp b/src/bluetooth/bluez/bluetoothmanagement.cpp
index 9df74b34..3f97f75c 100644
--- a/src/bluetooth/bluez/bluetoothmanagement.cpp
+++ b/src/bluetooth/bluez/bluetoothmanagement.cpp
@@ -43,7 +43,7 @@
#include "bluetoothmanagement_p.h"
#include "bluez_data_p.h"
-#include "../qbluetoothsocket_p.h"
+#include "../qbluetoothsocketbase_p.h"
#include <unistd.h>
#include <sys/prctl.h>
diff --git a/src/bluetooth/bluez/hcimanager.cpp b/src/bluetooth/bluez/hcimanager.cpp
index be62c881..bdb74ae0 100644
--- a/src/bluetooth/bluez/hcimanager.cpp
+++ b/src/bluetooth/bluez/hcimanager.cpp
@@ -40,7 +40,7 @@
#include "hcimanager_p.h"
-#include "qbluetoothsocket_p.h"
+#include "qbluetoothsocketbase_p.h"
#include "qlowenergyconnectionparameters.h"
#include <QtCore/qloggingcategory.h>
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index 6a5178db..1b187f4f 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -39,7 +39,11 @@
****************************************************************************/
#include "qbluetoothsocket.h"
+#if QT_CONFIG(bluez)
+#include "qbluetoothsocket_bluez_p.h"
+#else
#include "qbluetoothsocket_p.h"
+#endif
#include "qbluetoothdeviceinfo.h"
#include "qbluetoothserviceinfo.h"
@@ -252,7 +256,11 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT)
QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, QObject *parent)
: QIODevice(parent)
{
+#if QT_CONFIG(bluez)
+ d_ptr = new QBluetoothSocketPrivateBluez();
+#else
d_ptr = new QBluetoothSocketPrivate();
+#endif
d_ptr->q_ptr = this;
Q_D(QBluetoothSocketBase);
@@ -267,7 +275,11 @@ QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, Q
QBluetoothSocket::QBluetoothSocket(QObject *parent)
: QIODevice(parent)
{
+#if QT_CONFIG(bluez)
+ d_ptr = new QBluetoothSocketPrivateBluez();
+#else
d_ptr = new QBluetoothSocketPrivate();
+#endif
d_ptr->q_ptr = this;
setOpenMode(QIODevice::NotOpen);
}
diff --git a/src/bluetooth/qbluetoothsocket.h b/src/bluetooth/qbluetoothsocket.h
index e7e59abf..17e046ba 100644
--- a/src/bluetooth/qbluetoothsocket.h
+++ b/src/bluetooth/qbluetoothsocket.h
@@ -71,6 +71,8 @@ class Q_BLUETOOTH_EXPORT QBluetoothSocket : public QIODevice
friend class QBluetoothServer;
friend class QBluetoothServerPrivate;
friend class QBluetoothSocketPrivate;
+ friend class QBluetoothSocketPrivateBluez;
+ friend class QBluetoothSocketPrivateBluezDBus;
public:
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp
index 4fb51567..10c31e71 100644
--- a/src/bluetooth/qbluetoothsocket_bluez.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluez.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qbluetoothsocket.h"
-#include "qbluetoothsocket_p.h"
+#include "qbluetoothsocket_bluez_p.h"
#include "bluez/manager_p.h"
#include "bluez/adapter_p.h"
@@ -62,30 +62,30 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ)
-QBluetoothSocketPrivate::QBluetoothSocketPrivate()
+QBluetoothSocketPrivateBluez::QBluetoothSocketPrivateBluez()
: QBluetoothSocketBasePrivate()
{
secFlags = QBluetooth::Authorization;
}
-QBluetoothSocketPrivate::~QBluetoothSocketPrivate()
+QBluetoothSocketPrivateBluez::~QBluetoothSocketPrivateBluez()
{
delete readNotifier;
- readNotifier = 0;
+ readNotifier = nullptr;
delete connectWriteNotifier;
- connectWriteNotifier = 0;
+ connectWriteNotifier = nullptr;
}
-bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol type)
+bool QBluetoothSocketPrivateBluez::ensureNativeSocket(QBluetoothServiceInfo::Protocol type)
{
if (socket != -1) {
if (socketType == type)
return true;
delete readNotifier;
- readNotifier = 0;
+ readNotifier = nullptr;
delete connectWriteNotifier;
- connectWriteNotifier = 0;
+ connectWriteNotifier = nullptr;
QT_CLOSE(socket);
}
@@ -121,7 +121,7 @@ bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol
return true;
}
-void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode)
+void QBluetoothSocketPrivateBluez::connectToService(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode)
{
Q_Q(QBluetoothSocket);
int result = -1;
@@ -206,7 +206,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
}
}
-void QBluetoothSocketPrivate::_q_writeNotify()
+void QBluetoothSocketPrivateBluez::_q_writeNotify()
{
Q_Q(QBluetoothSocket);
if(connecting && state == QBluetoothSocket::ConnectingState){
@@ -267,7 +267,7 @@ void QBluetoothSocketPrivate::_q_writeNotify()
}
}
-void QBluetoothSocketPrivate::_q_readNotify()
+void QBluetoothSocketPrivateBluez::_q_readNotify()
{
Q_Q(QBluetoothSocket);
char *writePointer = buffer.reserve(QPRIVATELINEARBUFFER_BUFFERSIZE);
@@ -294,7 +294,7 @@ void QBluetoothSocketPrivate::_q_readNotify()
}
}
-void QBluetoothSocketPrivate::abort()
+void QBluetoothSocketPrivateBluez::abort()
{
delete readNotifier;
readNotifier = 0;
@@ -308,7 +308,7 @@ void QBluetoothSocketPrivate::abort()
socket = -1;
}
-QString QBluetoothSocketPrivate::localName() const
+QString QBluetoothSocketPrivateBluez::localName() const
{
const QBluetoothAddress address = localAddress();
if (address.isNull())
@@ -318,7 +318,7 @@ QString QBluetoothSocketPrivate::localName() const
return device.name();
}
-QBluetoothAddress QBluetoothSocketPrivate::localAddress() const
+QBluetoothAddress QBluetoothSocketPrivateBluez::localAddress() const
{
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
sockaddr_rc addr;
@@ -337,7 +337,7 @@ QBluetoothAddress QBluetoothSocketPrivate::localAddress() const
return QBluetoothAddress();
}
-quint16 QBluetoothSocketPrivate::localPort() const
+quint16 QBluetoothSocketPrivateBluez::localPort() const
{
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
sockaddr_rc addr;
@@ -356,7 +356,7 @@ quint16 QBluetoothSocketPrivate::localPort() const
return 0;
}
-QString QBluetoothSocketPrivate::peerName() const
+QString QBluetoothSocketPrivateBluez::peerName() const
{
quint64 bdaddr;
@@ -444,7 +444,7 @@ QString QBluetoothSocketPrivate::peerName() const
}
}
-QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
+QBluetoothAddress QBluetoothSocketPrivateBluez::peerAddress() const
{
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
sockaddr_rc addr;
@@ -463,7 +463,7 @@ QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
return QBluetoothAddress();
}
-quint16 QBluetoothSocketPrivate::peerPort() const
+quint16 QBluetoothSocketPrivateBluez::peerPort() const
{
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
sockaddr_rc addr;
@@ -482,7 +482,7 @@ quint16 QBluetoothSocketPrivate::peerPort() const
return 0;
}
-qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
+qint64 QBluetoothSocketPrivateBluez::writeData(const char *data, qint64 maxSize)
{
Q_Q(QBluetoothSocket);
@@ -527,7 +527,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
}
}
-qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize)
+qint64 QBluetoothSocketPrivateBluez::readData(char *data, qint64 maxSize)
{
Q_Q(QBluetoothSocket);
@@ -545,7 +545,7 @@ qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize)
return 0;
}
-void QBluetoothSocketPrivate::close()
+void QBluetoothSocketPrivateBluez::close()
{
if (txBuffer.size() > 0)
connectWriteNotifier->setEnabled(true);
@@ -553,7 +553,7 @@ void QBluetoothSocketPrivate::close()
abort();
}
-bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType_,
+bool QBluetoothSocketPrivateBluez::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType_,
QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode)
{
Q_Q(QBluetoothSocket);
@@ -581,17 +581,17 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo
return true;
}
-qint64 QBluetoothSocketPrivate::bytesAvailable() const
+qint64 QBluetoothSocketPrivateBluez::bytesAvailable() const
{
return buffer.size();
}
-qint64 QBluetoothSocketPrivate::bytesToWrite() const
+qint64 QBluetoothSocketPrivateBluez::bytesToWrite() const
{
return txBuffer.size();
}
-bool QBluetoothSocketPrivate::canReadLine() const
+bool QBluetoothSocketPrivateBluez::canReadLine() const
{
return buffer.canReadLine();
}
diff --git a/src/bluetooth/qbluetoothsocket_bluez_p.h b/src/bluetooth/qbluetoothsocket_bluez_p.h
new file mode 100644
index 00000000..b356ac7b
--- /dev/null
+++ b/src/bluetooth/qbluetoothsocket_bluez_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBLUETOOTHSOCKET_BLUEZ_H
+#define QBLUETOOTHSOCKET_BLUEZ_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qbluetoothsocketbase_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothSocketPrivateBluez final: public QBluetoothSocketBasePrivate
+{
+ Q_OBJECT
+
+public:
+ QBluetoothSocketPrivateBluez();
+ ~QBluetoothSocketPrivateBluez();
+
+ void connectToService(const QBluetoothAddress &address,
+ quint16 port,
+ QIODevice::OpenMode openMode);
+
+ bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type);
+
+ QString localName() const;
+ QBluetoothAddress localAddress() const;
+ quint16 localPort() const;
+
+ QString peerName() const;
+ QBluetoothAddress peerAddress() const;
+ quint16 peerPort() const;
+
+ void abort();
+ void close();
+
+ qint64 writeData(const char *data, qint64 maxSize);
+ qint64 readData(char *data, qint64 maxSize);
+
+ bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
+ QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState,
+ QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite);
+
+ qint64 bytesAvailable() const;
+ bool canReadLine() const;
+ qint64 bytesToWrite() const;
+
+private slots:
+ void _q_readNotify();
+ void _q_writeNotify();
+};
+
+QT_END_NAMESPACE
+
+#endif // QBLUETOOTHSOCKET_BLUEZ_H
diff --git a/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
new file mode 100644
index 00000000..2dbbd425
--- /dev/null
+++ b/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothsocket.h"
+#include "qbluetoothsocket_bluezdbus_p.h"
+
+QT_BEGIN_NAMESPACE
+QBluetoothSocketPrivateBluezDBus::QBluetoothSocketPrivateBluezDBus()
+{
+ secFlags = QBluetooth::NoSecurity;
+}
+
+QBluetoothSocketPrivateBluezDBus::~QBluetoothSocketPrivateBluezDBus()
+{
+}
+
+bool QBluetoothSocketPrivateBluezDBus::ensureNativeSocket(QBluetoothServiceInfo::Protocol type)
+{
+ socketType = type;
+ return false;
+}
+
+void QBluetoothSocketPrivateBluezDBus::connectToService(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode)
+{
+ Q_UNUSED(openMode);
+ Q_UNUSED(address);
+ Q_UNUSED(port);
+}
+
+void QBluetoothSocketPrivateBluezDBus::abort()
+{
+}
+
+QString QBluetoothSocketPrivateBluezDBus::localName() const
+{
+ return QString();
+}
+
+QBluetoothAddress QBluetoothSocketPrivateBluezDBus::localAddress() const
+{
+ return QBluetoothAddress();
+}
+
+quint16 QBluetoothSocketPrivateBluezDBus::localPort() const
+{
+ return 0;
+}
+
+QString QBluetoothSocketPrivateBluezDBus::peerName() const
+{
+ return QString();
+}
+
+QBluetoothAddress QBluetoothSocketPrivateBluezDBus::peerAddress() const
+{
+ return QBluetoothAddress();
+}
+
+quint16 QBluetoothSocketPrivateBluezDBus::peerPort() const
+{
+ return 0;
+}
+
+qint64 QBluetoothSocketPrivateBluezDBus::writeData(const char *data, qint64 maxSize)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(maxSize);
+
+ Q_Q(QBluetoothSocket);
+
+ if (state != QBluetoothSocket::ConnectedState) {
+ errorString = QBluetoothSocket::tr("Cannot write while not connected");
+ q->setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
+ return -1;
+}
+
+qint64 QBluetoothSocketPrivateBluezDBus::readData(char *data, qint64 maxSize)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(maxSize);
+
+ Q_Q(QBluetoothSocket);
+
+ if (state != QBluetoothSocket::ConnectedState) {
+ errorString = QBluetoothSocket::tr("Cannot read while not connected");
+ q->setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
+
+ return -1;
+}
+
+void QBluetoothSocketPrivateBluezDBus::close()
+{
+}
+
+bool QBluetoothSocketPrivateBluezDBus::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
+ QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode)
+{
+ Q_UNUSED(socketDescriptor);
+ Q_UNUSED(socketType)
+ Q_UNUSED(socketState);
+ Q_UNUSED(openMode);
+ return false;
+}
+
+qint64 QBluetoothSocketPrivateBluezDBus::bytesAvailable() const
+{
+ return 0;
+}
+
+bool QBluetoothSocketPrivateBluezDBus::canReadLine() const
+{
+ return false;
+}
+
+qint64 QBluetoothSocketPrivateBluezDBus::bytesToWrite() const
+{
+ return 0;
+}
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothsocket_bluezdbus_p.h b/src/bluetooth/qbluetoothsocket_bluezdbus_p.h
new file mode 100644
index 00000000..74af8bbe
--- /dev/null
+++ b/src/bluetooth/qbluetoothsocket_bluezdbus_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBLUETOOTHSOCKET_BLUEZDBUS_H
+#define QBLUETOOTHSOCKET_BLUEZDBUS_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qbluetoothsocketbase_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothSocketPrivateBluezDBus final: public QBluetoothSocketBasePrivate
+{
+ Q_OBJECT
+
+public:
+ QBluetoothSocketPrivateBluezDBus();
+ ~QBluetoothSocketPrivateBluezDBus();
+
+ void connectToService(const QBluetoothAddress &address,
+ quint16 port,
+ QIODevice::OpenMode openMode);
+
+ bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type);
+
+ QString localName() const;
+ QBluetoothAddress localAddress() const;
+ quint16 localPort() const;
+
+ QString peerName() const;
+ QBluetoothAddress peerAddress() const;
+ quint16 peerPort() const;
+
+ void abort();
+ void close();
+
+ qint64 writeData(const char *data, qint64 maxSize);
+ qint64 readData(char *data, qint64 maxSize);
+
+ bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
+ QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState,
+ QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite);
+
+ qint64 bytesAvailable() const;
+ bool canReadLine() const;
+ qint64 bytesToWrite() const;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QBLUETOOTHSOCKET_BLUEZDBUS_H
diff --git a/src/bluetooth/qbluetoothsocket_p.h b/src/bluetooth/qbluetoothsocket_p.h
index 6b002959..6c3bedf3 100644
--- a/src/bluetooth/qbluetoothsocket_p.h
+++ b/src/bluetooth/qbluetoothsocket_p.h
@@ -168,44 +168,14 @@ private slots:
void handleError(QBluetoothSocket::SocketError error);
#endif // QT_WINRT_BLUETOOTH
-#if QT_CONFIG(bluez)
-private slots:
- void _q_readNotify();
- void _q_writeNotify();
-#endif
-
private:
#ifdef QT_WINRT_BLUETOOTH
HRESULT handleConnectOpFinished(ABI::Windows::Foundation::IAsyncAction *action,
ABI::Windows::Foundation::AsyncStatus status);
#endif
-
-
};
-static inline void convertAddress(const quint64 from, quint8 (&to)[6])
-{
- to[0] = (from >> 0) & 0xff;
- to[1] = (from >> 8) & 0xff;
- to[2] = (from >> 16) & 0xff;
- to[3] = (from >> 24) & 0xff;
- to[4] = (from >> 32) & 0xff;
- to[5] = (from >> 40) & 0xff;
-}
-
-static inline quint64 convertAddress(const quint8 (&from)[6], quint64 *to = 0)
-{
- const quint64 result = (quint64(from[0]) << 0) |
- (quint64(from[1]) << 8) |
- (quint64(from[2]) << 16) |
- (quint64(from[3]) << 24) |
- (quint64(from[4]) << 32) |
- (quint64(from[5]) << 40);
- if (to)
- *to = result;
- return result;
-}
#ifdef Q_OS_ANDROID
// QTBUG-61392 related
@@ -218,5 +188,4 @@ extern bool useReverseUuidWorkAroundConnect;
QT_END_NAMESPACE
-
#endif
diff --git a/src/bluetooth/qbluetoothsocketbase_p.h b/src/bluetooth/qbluetoothsocketbase_p.h
index c2c6a1f7..c393c940 100644
--- a/src/bluetooth/qbluetoothsocketbase_p.h
+++ b/src/bluetooth/qbluetoothsocketbase_p.h
@@ -168,6 +168,29 @@ public:
#endif
};
+static inline void convertAddress(const quint64 from, quint8 (&to)[6])
+{
+ to[0] = (from >> 0) & 0xff;
+ to[1] = (from >> 8) & 0xff;
+ to[2] = (from >> 16) & 0xff;
+ to[3] = (from >> 24) & 0xff;
+ to[4] = (from >> 32) & 0xff;
+ to[5] = (from >> 40) & 0xff;
+}
+
+static inline quint64 convertAddress(const quint8 (&from)[6], quint64 *to = nullptr)
+{
+ const quint64 result = (quint64(from[0]) << 0) |
+ (quint64(from[1]) << 8) |
+ (quint64(from[2]) << 16) |
+ (quint64(from[3]) << 24) |
+ (quint64(from[4]) << 32) |
+ (quint64(from[5]) << 40);
+ if (to)
+ *to = result;
+ return result;
+}
+
#else // QT_OSX_BLUETOOTH
// QBluetoothSocketPrivate on macOS can not contain
diff --git a/src/bluetooth/qleadvertiser_bluez.cpp b/src/bluetooth/qleadvertiser_bluez.cpp
index b964f620..bff5a590 100644
--- a/src/bluetooth/qleadvertiser_bluez.cpp
+++ b/src/bluetooth/qleadvertiser_bluez.cpp
@@ -41,7 +41,7 @@
#include "bluez/bluez_data_p.h"
#include "bluez/hcimanager_p.h"
-#include "qbluetoothsocket_p.h"
+#include "qbluetoothsocketbase_p.h"
#include <QtCore/qloggingcategory.h>
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index d288f3ad..502f42ad 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -40,7 +40,7 @@
#include "lecmaccalculator_p.h"
#include "qlowenergycontroller_bluez_p.h"
-#include "qbluetoothsocket_p.h"
+#include "qbluetoothsocketbase_p.h"
#include "qleadvertiser_p.h"
#include "bluez/bluez_data_p.h"
#include "bluez/hcimanager_p.h"