From bcf6ef95b8304c6cf7a1b79337d7d9b151dfe492 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 3 Feb 2017 09:38:14 +0100 Subject: winrt: Use custom setSocketDescriptor function We have to use a similar approach to the one that is used on android as the ComPtr cannot reliably passed as an int. Change-Id: Ia52c78d4725fb3240eafa62fcb55531a282c0cd3 Reviewed-by: Maurice Kalinowski --- src/bluetooth/qbluetoothsocket_winrt.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/bluetooth/qbluetoothsocket_winrt.cpp') diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp index fb0587cc..323200cd 100644 --- a/src/bluetooth/qbluetoothsocket_winrt.cpp +++ b/src/bluetooth/qbluetoothsocket_winrt.cpp @@ -538,17 +538,23 @@ void QBluetoothSocketPrivate::close() bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode) +{ + Q_UNUSED(socketDescriptor); + Q_UNUSED(socketType) + Q_UNUSED(socketState); + Q_UNUSED(openMode); + qCWarning(QT_BT_WINRT) << "No socket descriptor support on WinRT."; + return false; +} + +bool QBluetoothSocketPrivate::setSocketDescriptor(ComPtr socketPtr, QBluetoothServiceInfo::Protocol socketType, + QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode) { Q_Q(QBluetoothSocket); - if (socketType != QBluetoothServiceInfo::RfcommProtocol) + if (socketType != QBluetoothServiceInfo::RfcommProtocol || !socketPtr) return false; - m_socketObject = nullptr; - socket = -1; - - m_socketObject = reinterpret_cast(qintptr(socketDescriptor)); - if (!m_socketObject) - return false; + m_socketObject = socketPtr; socket = qintptr(m_socketObject.Get()); m_worker->setSocket(m_socketObject); if (socketState == QBluetoothSocket::ConnectedState) -- cgit v1.2.3