summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-16 23:24:36 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-16 23:24:43 +0200
commitaabce3a08d1a65f8abc4872bd91a6dfd45cf7fd6 (patch)
tree457dc8b600e0a4db7654708d921ef4ae398ae0d0 /src/bluetooth/qbluetoothsocket.cpp
parentb956fda0a1fa5813eb147e85ffc98e25d7177481 (diff)
parent9dba73f30505ed7c220055788fba3cd201848fdb (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'src/bluetooth/qbluetoothsocket.cpp')
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index 8504ebd9..d396ca84 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -207,7 +207,7 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT)
Although some platforms may differ the socket must generally be connected to guarantee
the return of a valid port number.
- On Android and OS X, this feature is not supported and returns 0.
+ On Android and \macos, this feature is not supported and returns 0.
*/
/*!
@@ -338,6 +338,15 @@ void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, Op
}
d->connectToService(service.device().address(), service.serviceUuid(), openMode);
#else
+ // Report this problem early:
+ if (socketType() == QBluetoothServiceInfo::UnknownProtocol) {
+ qCWarning(QT_BT) << "QBluetoothSocket::connectToService cannot "
+ "connect with 'UnknownProtocol' type";
+ d->errorString = tr("Socket type not supported");
+ setSocketError(QBluetoothSocket::UnsupportedProtocolError);
+ return;
+ }
+
if (service.protocolServiceMultiplexer() > 0) {
if (!d->ensureNativeSocket(QBluetoothServiceInfo::L2capProtocol)) {
d->errorString = tr("Unknown socket error");
@@ -407,6 +416,15 @@ void QBluetoothSocket::connectToService(const QBluetoothAddress &address, const
}
d->connectToService(address, uuid, openMode);
#else
+ // Report this problem early, prevent device discovery:
+ if (socketType() == QBluetoothServiceInfo::UnknownProtocol) {
+ qCWarning(QT_BT) << "QBluetoothSocket::connectToService cannot "
+ "connect with 'UnknownProtocol' type";
+ d->errorString = tr("Socket type not supported");
+ setSocketError(QBluetoothSocket::UnsupportedProtocolError);
+ return;
+ }
+
QBluetoothServiceInfo service;
QBluetoothDeviceInfo device(address, QString(), QBluetoothDeviceInfo::MiscellaneousDevice);
service.setDevice(device);
@@ -444,6 +462,15 @@ void QBluetoothSocket::connectToService(const QBluetoothAddress &address, quint1
setSocketError(QBluetoothSocket::ServiceNotFoundError);
qCWarning(QT_BT) << "Connecting to port is not supported";
#else
+ // Report this problem early:
+ if (socketType() == QBluetoothServiceInfo::UnknownProtocol) {
+ qCWarning(QT_BT) << "QBluetoothSocket::connectToService cannot "
+ "connect with 'UnknownProtocol' type";
+ d->errorString = tr("Socket type not supported");
+ setSocketError(QBluetoothSocket::UnsupportedProtocolError);
+ return;
+ }
+
if (state() != QBluetoothSocket::UnconnectedState) {
qCWarning(QT_BT) << "QBluetoothSocket::connectToService called on busy socket";
d->errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
@@ -504,7 +531,7 @@ QString QBluetoothSocket::errorString() const
On Bluez this property is set to QBluetooth::Authorization by default.
- On OS X, this value is ignored as the platform does not permit access
+ On \macos, this value is ignored as the platform does not permit access
to the security parameter of the socket. By default the platform prefers
secure/encrypted connections though and therefore this function always
returns \l QBluetooth::Secure.
@@ -538,7 +565,7 @@ void QBluetoothSocket::setPreferredSecurityFlags(QBluetooth::SecurityFlags flags
during or after the connection has been established. If such a change happens
it is not reflected in the value of this flag.
- On OS X, this flag is always set to \l QBluetooth::Secure.
+ On \macos, this flag is always set to \l QBluetooth::Secure.
\sa setPreferredSecurityFlags()