summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_osx.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/qbluetoothserver_osx.mm')
-rw-r--r--src/bluetooth/qbluetoothserver_osx.mm107
1 files changed, 44 insertions, 63 deletions
diff --git a/src/bluetooth/qbluetoothserver_osx.mm b/src/bluetooth/qbluetoothserver_osx.mm
index 894209ba..6b82dd04 100644
--- a/src/bluetooth/qbluetoothserver_osx.mm
+++ b/src/bluetooth/qbluetoothserver_osx.mm
@@ -1,40 +1,32 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -60,8 +52,9 @@
#include <QtCore/qmutex.h>
// Import, since Obj-C headers do not have inclusion guards.
-#import <IOBluetooth/objc/IOBluetoothRFCOMMChannel.h>
-#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
+#include <Foundation/Foundation.h>
+// Only after Foundation.h
+#include "osx/corebluetoothwrapper_p.h"
#include <limits>
@@ -95,11 +88,9 @@ QBluetoothServerPrivate::QBluetoothServerPrivate(QSInfo::Protocol type, QBluetoo
port(0),
maxPendingConnections(1)
{
- Q_ASSERT_X(q_ptr, "QBluetoothServerPrivate", "invalid q_ptr (null)");
- if (serverType == QSInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << "QBluetoothServerPrivate::QBluetoothServerPrivate(), "
- "unknown protocol";
- }
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ if (serverType == QSInfo::UnknownProtocol)
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown protocol";
}
QBluetoothServerPrivate::~QBluetoothServerPrivate()
@@ -117,11 +108,10 @@ void QBluetoothServerPrivate::_q_newConnection()
bool QBluetoothServerPrivate::startListener(quint16 realPort)
{
- Q_ASSERT_X(realPort, "startListener", "invalid port");
+ Q_ASSERT_X(realPort, Q_FUNC_INFO, "invalid port");
if (serverType == QSInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << "QBluetoothServerPrivate::startListener(), "
- "invalid protocol";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
return false;
}
@@ -147,9 +137,9 @@ void QBluetoothServerPrivate::stopListener()
void QBluetoothServerPrivate::openNotify(IOBluetoothRFCOMMChannel *channel)
{
- Q_ASSERT_X(listener, "openNotify", "invalid listener (nil)");
- Q_ASSERT_X(channel, "openNotify", "invalid channel (nil)");
- Q_ASSERT_X(q_ptr, "openNotify", "invalid q_ptr (null)");
+ Q_ASSERT_X(listener, Q_FUNC_INFO, "invalid listener (nil)");
+ Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
PendingConnection newConnection(channel, true);
pendingConnections.append(newConnection);
@@ -159,9 +149,9 @@ void QBluetoothServerPrivate::openNotify(IOBluetoothRFCOMMChannel *channel)
void QBluetoothServerPrivate::openNotify(IOBluetoothL2CAPChannel *channel)
{
- Q_ASSERT_X(listener, "openNotify", "invalid listener (nil)");
- Q_ASSERT_X(channel, "openNotify", "invalid channel (nil)");
- Q_ASSERT_X(q_ptr, "openNotify", "invalid q_ptr (null)");
+ Q_ASSERT_X(listener, Q_FUNC_INFO, "invalid listener (nil)");
+ Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
PendingConnection newConnection(channel, true);
pendingConnections.append(newConnection);
@@ -212,20 +202,18 @@ quint16 QBluetoothServerPrivate::findFreePSM()
void QBluetoothServerPrivate::registerServer(QBluetoothServerPrivate *server, quint16 port)
{
// External lock is required + port must be free.
- Q_ASSERT_X(server, "registerServer", "invalid server (null)");
+ Q_ASSERT_X(server, Q_FUNC_INFO, "invalid server (null)");
const QSInfo::Protocol type = server->serverType;
if (type == QSInfo::RfcommProtocol) {
- Q_ASSERT_X(!channelIsBusy(port), "registerServer",
- "port is busy");
+ Q_ASSERT_X(!channelIsBusy(port), Q_FUNC_INFO, "port is busy");
busyChannels()[port] = server;
} else if (type == QSInfo::L2capProtocol) {
- Q_ASSERT_X(!psmIsBusy(port), "registerServer",
- "port is busy");
+ Q_ASSERT_X(!psmIsBusy(port), Q_FUNC_INFO, "port is busy");
busyPSMs()[port] = server;
} else {
- qCWarning(QT_BT_OSX) << "can not register a server with unknown "
- "protocol type";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "can not register a server "
+ "with unknown protocol type";
}
}
@@ -241,8 +229,7 @@ QBluetoothServerPrivate *QBluetoothServerPrivate::registeredServer(quint16 port,
if (it != busyPSMs().end())
return it.value();
} else {
- qCWarning(QT_BT_OSX) << "QBluetoothServerPrivate::registeredServer(), "
- "invalid protocol";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
}
return Q_NULLPTR;
@@ -259,20 +246,17 @@ void QBluetoothServerPrivate::unregisterServer(QBluetoothServerPrivate *server)
if (it != busyChannels().end()) {
busyChannels().erase(it);
} else {
- qCWarning(QT_BT_OSX) << "QBluetoothServerPrivate::unregisterServer(), "
- "server is not registered";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "server is not registered";
}
} else if (type == QSInfo::L2capProtocol) {
ServerMapIterator it = busyPSMs().find(port);
if (it != busyPSMs().end()) {
busyPSMs().erase(it);
} else {
- qCWarning(QT_BT_OSX) << "QBluetoothServerPrivate::unregisterServer(), "
- "server is not registered";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "server is not registered";
}
} else {
- qCWarning(QT_BT_OSX) << "QBluetoothServerPrivate::unregisterServer(), "
- "invalid protocol";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
}
}
@@ -303,15 +287,14 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
typedef QBluetoothServerPrivate::ObjCListener ObjCListener;
if (d_ptr->listener) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen() ",
- "already in listen mode, "
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "already in listen mode, "
"close server first";
return false;
}
const QBluetoothLocalDevice device(address);
if (!device.isValid()) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen(), device does not support Bluetooth or "
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "device does not support Bluetooth or "
<< address.toString()
<< " is not a valid local adapter";
d_ptr->lastError = UnknownError;
@@ -321,8 +304,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
const QBluetoothLocalDevice::HostMode hostMode = device.hostMode();
if (hostMode == QBluetoothLocalDevice::HostPoweredOff) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen(), "
- "bluetooth device is powered off";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "Bluetooth device is powered off";
d_ptr->lastError = PoweredOffError;
emit error(PoweredOffError);
return false;
@@ -331,8 +313,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
const QSInfo::Protocol type = d_ptr->serverType;
if (type == QSInfo::UnknownProtocol) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen(), "
- "invalid protocol";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
d_ptr->lastError = UnsupportedProtocolError;
emit error(d_ptr->lastError);
return false;
@@ -346,13 +327,13 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
if (port) {
if (type == QSInfo::RfcommProtocol) {
if (d_ptr->channelIsBusy(port)) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen(), server port: "
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO <<"server port: "
<< port << "already registered";
d_ptr->lastError = ServiceAlreadyRegisteredError;
}
} else {
if (d_ptr->psmIsBusy(port)) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen(), server port: "
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "server port: "
<< port << "already registered";
d_ptr->lastError = ServiceAlreadyRegisteredError;
}
@@ -368,7 +349,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
}
if (!port) {
- qCWarning(QT_BT_OSX) << "QBluetoothServer::listen(), all ports are busy";
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "all ports are busy";
d_ptr->lastError = ServiceAlreadyRegisteredError;
emit error(d_ptr->lastError);
return false;