diff options
23 files changed, 190 insertions, 225 deletions
diff --git a/examples/bluetooth/scanner/qmlscanner.cpp b/examples/bluetooth/scanner/qmlscanner.cpp index 3602674b..47d0bb26 100644 --- a/examples/bluetooth/scanner/qmlscanner.cpp +++ b/examples/bluetooth/scanner/qmlscanner.cpp @@ -41,9 +41,11 @@ #include <QtGui/QGuiApplication> #include <QtQuick/QQuickView> #include <QtQml/QQmlEngine> +#include <QtCore/QLoggingCategory> int main(int argc, char *argv[]) { + //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); QGuiApplication application(argc, argv); const QString mainQmlApp = QLatin1String("qrc:/scanner.qml"); QQuickView view; diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro index 993f3646..c1553936 100644 --- a/src/bluetooth/bluetooth.pro +++ b/src/bluetooth/bluetooth.pro @@ -73,7 +73,7 @@ config_bluez:qtHaveModule(dbus) { qbluetoothtransferreply_bluez.cpp } else:CONFIG(blackberry) { - DEFINES += QT_QNX_BLUETOOTH #BT_BBPPSDEBUG + DEFINES += QT_QNX_BLUETOOTH include(qnx/qnx.pri) diff --git a/src/bluetooth/qbluetooth.cpp b/src/bluetooth/qbluetooth.cpp index 02ca7636..29b14822 100644 --- a/src/bluetooth/qbluetooth.cpp +++ b/src/bluetooth/qbluetooth.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include <QtCore/QLoggingCategory> #include <QtBluetooth/qbluetooth.h> QT_BEGIN_NAMESPACE @@ -76,4 +77,8 @@ namespace QBluetooth { */ } +Q_LOGGING_CATEGORY(QT_BT, "qt.bluetooth") +Q_LOGGING_CATEGORY(QT_BT_BLUEZ, "qt.bluetooth.bluez") +Q_LOGGING_CATEGORY(QT_BT_QNX, "qt.bluetooth.qnx") + QT_END_NAMESPACE diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index 257ebf3d..805f648a 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include <QtCore/QLoggingCategory> #include "qbluetoothdevicediscoveryagent.h" #include "qbluetoothdevicediscoveryagent_p.h" #include "qbluetoothaddress.h" @@ -48,10 +49,10 @@ #include "bluez/adapter_p.h" #include "bluez/device_p.h" -//#define QT_DEVICEDISCOVERY_DEBUG - QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(const QBluetoothAddress &deviceAdapter) : lastError(QBluetoothDeviceDiscoveryAgent::NoError), m_adapterAddress(deviceAdapter), pendingCancel(false), pendingStart(false), adapter(0) @@ -94,9 +95,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() if (reply.isError()) { errorString = reply.error().message(); -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << "ERROR: " << errorString; -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; Q_Q(QBluetoothDeviceDiscoveryAgent); emit q->error(lastError); @@ -116,9 +115,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() propertiesReply.waitForFinished(); if(propertiesReply.isError()) { errorString = propertiesReply.error().message(); -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << "ERROR: " << errorString; -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; Q_Q(QBluetoothDeviceDiscoveryAgent); emit q->error(lastError); @@ -133,9 +130,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; Q_Q(QBluetoothDeviceDiscoveryAgent); emit q->error(lastError); -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << "ERROR: " << errorString; -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString; return; } } @@ -143,9 +138,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() void QBluetoothDeviceDiscoveryAgentPrivate::stop() { if (adapter) { -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO; -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO; pendingCancel = true; pendingStart = false; QDBusPendingReply<> reply = adapter->StopDiscovery(); @@ -160,13 +153,11 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres const QString btName = dict.value(QLatin1String("Name")).toString(); quint32 btClass = dict.value(QLatin1String("Class")).toUInt(); -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << "Discovered: " << address << btName + qCDebug(QT_BT_BLUEZ) << "Discovered: " << address << btName << "Num UUIDs" << dict.value(QLatin1String("UUIDs")).toStringList().count() << "total device" << discoveredDevices.count() << "cached" << dict.value(QLatin1String("Cached")).toBool() << "RSSI" << dict.value(QLatin1String("RSSI")).toInt(); -#endif QBluetoothDeviceInfo device(btAddress, btName, btClass); if(dict.value(QLatin1String("RSSI")).isValid()) @@ -180,24 +171,18 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres for(int i = 0; i < discoveredDevices.size(); i++){ if(discoveredDevices[i].address() == device.address()) { if(discoveredDevices[i] == device) { -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << "Duplicate: " << address; -#endif + qCDebug(QT_BT_BLUEZ) << "Duplicate: " << address; return; } discoveredDevices.replace(i, device); Q_Q(QBluetoothDeviceDiscoveryAgent); -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << "Updated: " << address; -#endif + qCDebug(QT_BT_BLUEZ) << "Updated: " << address; emit q->deviceDiscovered(device); return; // this works if the list doesn't contain duplicates. Don't let it. } } -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << "Emit: " << address; -#endif + qCDebug(QT_BT_BLUEZ) << "Emit: " << address; discoveredDevices.append(device); Q_Q(QBluetoothDeviceDiscoveryAgent); emit q->deviceDiscovered(device); @@ -206,9 +191,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres void QBluetoothDeviceDiscoveryAgentPrivate::_q_propertyChanged(const QString &name, const QDBusVariant &value) { -#ifdef QT_DEVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << name << value.variant(); -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << name << value.variant(); if (name == QLatin1String("Discovering") && !value.variant().toBool()) { Q_Q(QBluetoothDeviceDiscoveryAgent); diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp index f782e364..cf91efc8 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp @@ -92,9 +92,9 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() m_currentOp = Start; if (m_rdfd != -1) { - qBBBluetoothDebug() << "RDev FD still open"; + qCDebug(QT_BT_QNX) << "RDev FD still open"; } else if ((m_rdfd = qt_safe_open("/pps/services/bluetooth/remote_devices/.all", O_RDONLY)) == -1) { - qWarning() << Q_FUNC_INFO << "rdfd - failed to open /pps/services/bluetooth/remote_devices/.all" + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "rdfd - failed to open /pps/services/bluetooth/remote_devices/.all" << m_rdfd; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; errorString = "Cannot open remote device socket"; @@ -104,7 +104,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() } else { m_rdNotifier = new QSocketNotifier(m_rdfd, QSocketNotifier::Read, this); if (!m_rdNotifier) { - qWarning() << Q_FUNC_INFO << "failed to connect to m_rdNotifier"; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "failed to connect to m_rdNotifier"; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; errorString = "Cannot connect to Bluetooth socket notifier"; emit q->error(lastError); @@ -118,7 +118,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() m_finishedTimer.start(10000); connect(m_rdNotifier, SIGNAL(activated(int)), this, SLOT(remoteDevicesChanged(int))); } else { - qWarning() << "Could not write to control FD"; + qCWarning(QT_BT_QNX) << "Could not write to control FD"; m_active = false; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; errorString = "Cannot start device inquiry"; @@ -138,7 +138,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop() } m_currentOp = Cancel; - qBBBluetoothDebug() << "Stopping device search"; + qCDebug(QT_BT_QNX) << "Stopping device search"; ppsSendControlMessage("cancel_device_search",this); if (m_rdNotifier) { @@ -195,7 +195,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::remoteDevicesChanged(int fd) //Starts the timer again m_finishedTimer.start(7000); if (!deviceAddr.isNull()) { - qBBBluetoothDebug() << "Device discovered: " << deviceName << deviceAddr.toString(); + qCDebug(QT_BT_QNX) << "Device discovered: " << deviceName << deviceAddr.toString(); discoveredDevices.append(deviceInfo); if (!updated)//We are not allowed to emit a signal with the updated version emit q_ptr->deviceDiscovered(discoveredDevices.last()); @@ -209,7 +209,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result) if (result.dat.size() > 0 && result.dat.first() == QStringLiteral("EOK")) { //Do nothing. We can not be certain, that the device search is over yet } else if (result.error == 16) { - qBBBluetoothDebug() << "Could not start device inquire bc resource is busy"; + qCDebug(QT_BT_QNX) << "Could not start device inquire bc resource is busy"; if (m_nextOp == None) { //We try again ppsSendControlMessage("cancel_device_search",this); QTimer::singleShot(5000, this, SLOT(startDeviceSearch())); @@ -217,7 +217,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result) } return; } else { - qWarning("A PPS Bluetooth error occurred:"); + qCWarning(QT_BT_QNX) << "A PPS Bluetooth error occurred:"; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; errorString = result.errorMsg; Q_EMIT q_ptr->error(QBluetoothDeviceDiscoveryAgent::InputOutputError); @@ -225,7 +225,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result) } processNextOp(); } else if (result.msg == QStringLiteral("cancel_device_search") && m_currentOp == Cancel && !isFinished) { - qBBBluetoothDebug() << "Cancel device search"; + qCDebug(QT_BT_QNX) << "Cancel device search"; // if (!result.errorMsg.isEmpty()) { // lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; // errorString = result.errorMsg; @@ -239,14 +239,14 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result) void QBluetoothDeviceDiscoveryAgentPrivate::controlEvent(ppsResult result) { if (result.msg == QStringLiteral("device_added")) { - qBBBluetoothDebug() << "Device was added" << result.dat.first(); + qCDebug(QT_BT_QNX) << "Device was added" << result.dat.first(); } } void QBluetoothDeviceDiscoveryAgentPrivate::finished() { if (m_active) { - qBBBluetoothDebug() << "Device discovery finished"; + qCDebug(QT_BT_QNX) << "Device discovery finished"; isFinished = true; stop(); q_ptr->finished(); diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp index 7a8e882b..f10ec133 100644 --- a/src/bluetooth/qbluetoothdeviceinfo.cpp +++ b/src/bluetooth/qbluetoothdeviceinfo.cpp @@ -42,8 +42,6 @@ #include "qbluetoothdeviceinfo.h" #include "qbluetoothdeviceinfo_p.h" -#include <QDebug> - QT_BEGIN_NAMESPACE /*! diff --git a/src/bluetooth/qbluetoothlocaldevice.cpp b/src/bluetooth/qbluetoothlocaldevice.cpp index 9661adcb..2981f3e0 100644 --- a/src/bluetooth/qbluetoothlocaldevice.cpp +++ b/src/bluetooth/qbluetoothlocaldevice.cpp @@ -44,7 +44,6 @@ #include "qbluetoothaddress.h" #include <QtCore/QString> -#include <QDebug> QT_BEGIN_NAMESPACE diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp index 62df930a..c4601947 100644 --- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ - -#include <QDBusContext> +#include <QtCore/QLoggingCategory> +#include <QtDBus/QDBusContext> #include "qbluetoothlocaldevice.h" #include "qbluetoothaddress.h" @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + static const QLatin1String agentPath("/qt/agent"); QBluetoothLocalDevice::QBluetoothLocalDevice(QObject *parent) : @@ -194,7 +196,7 @@ static inline OrgBluezDeviceInterface *getDevice(const QBluetoothAddress &addres QDBusPendingReply<QDBusObjectPath> reply = d_ptr->adapter->FindDevice(address.toString()); reply.waitForFinished(); if(reply.isError()){ - qWarning() << Q_FUNC_INFO << "reply failed" << reply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "reply failed" << reply.error(); return 0; } @@ -230,7 +232,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai if(!res){ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); - qWarning() << "Failed to register agent"; + qCWarning(QT_BT_BLUEZ) << "Failed to register agent"; return; } } @@ -245,7 +247,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai QDBusPendingReply<> deviceReply = device->SetProperty(QLatin1String("Trusted"), QDBusVariant(true)); deviceReply.waitForFinished(); if(deviceReply.isError()){ - qWarning() << Q_FUNC_INFO << "reply failed" << deviceReply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "reply failed" << deviceReply.error(); QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; @@ -264,7 +266,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai QDBusPendingReply<> deviceReply = device->SetProperty(QLatin1String("Trusted"), QDBusVariant(false)); deviceReply.waitForFinished(); if(deviceReply.isError()){ - qWarning() << Q_FUNC_INFO << "reply failed" << deviceReply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "reply failed" << deviceReply.error(); QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; @@ -283,14 +285,14 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), d_ptr, SLOT(pairingCompleted(QDBusPendingCallWatcher*))); if(reply.isError()) - qWarning() << Q_FUNC_INFO << reply.error() << d_ptr->agent_path; + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << reply.error() << d_ptr->agent_path; } } else if(pairing == Unpaired) { QDBusPendingReply<QDBusObjectPath> reply = this->d_ptr->adapter->FindDevice(address.toString()); reply.waitForFinished(); if(reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed to find device" << reply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "failed to find device" << reply.error(); QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; @@ -298,7 +300,7 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai QDBusPendingReply<> removeReply = this->d_ptr->adapter->RemoveDevice(reply.value()); removeReply.waitForFinished(); if(removeReply.isError()){ - qWarning() << Q_FUNC_INFO << "failed to remove device" << removeReply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "failed to remove device" << removeReply.error(); QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); } else { @@ -437,7 +439,7 @@ QString QBluetoothLocalDevicePrivate::RequestPinCode(const QDBusObjectPath &in0) { Q_UNUSED(in0) Q_Q(QBluetoothLocalDevice); - //qDebug() << Q_FUNC_INFO << in0.path(); + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << in0.path(); // seeded in constructor, 6 digit pin QString pin = QString::fromLatin1("%1").arg(qrand()&1000000); pin = QString::fromLatin1("%1").arg(pin, 6, QLatin1Char('0')); @@ -452,7 +454,7 @@ void QBluetoothLocalDevicePrivate::pairingCompleted(QDBusPendingCallWatcher *wat QDBusPendingReply<> reply = *watcher; if(reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed to create pairing" << reply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "failed to create pairing" << reply.error(); emit q->error(QBluetoothLocalDevice::PairingError); delete watcher; return; @@ -461,7 +463,7 @@ void QBluetoothLocalDevicePrivate::pairingCompleted(QDBusPendingCallWatcher *wat QDBusPendingReply<QDBusObjectPath> findReply = adapter->FindDevice(address.toString()); findReply.waitForFinished(); if(findReply.isError()) { - qWarning() << Q_FUNC_INFO << "failed to find device" << findReply.error(); + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << "failed to find device" << findReply.error(); emit q->error(QBluetoothLocalDevice::PairingError); delete watcher; return; @@ -487,19 +489,19 @@ void QBluetoothLocalDevicePrivate::Authorize(const QDBusObjectPath &in0, const Q Q_UNUSED(in0) Q_UNUSED(in1) //TODO implement this - //qDebug() << "Got authorize for" << in0.path() << in1; + qCDebug(QT_BT_BLUEZ) << "Got authorize for" << in0.path() << in1; } void QBluetoothLocalDevicePrivate::Cancel() { //TODO implement this - //qDebug() << Q_FUNC_INFO; + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO; } void QBluetoothLocalDevicePrivate::Release() { //TODO implement this - //qDebug() << Q_FUNC_INFO; + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO; } @@ -507,7 +509,7 @@ void QBluetoothLocalDevicePrivate::ConfirmModeChange(const QString &in0) { Q_UNUSED(in0) //TODO implement this - //qDebug() << Q_FUNC_INFO << in0; + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << in0; } void QBluetoothLocalDevicePrivate::DisplayPasskey(const QDBusObjectPath &in0, uint in1, uchar in2) @@ -516,13 +518,13 @@ void QBluetoothLocalDevicePrivate::DisplayPasskey(const QDBusObjectPath &in0, ui Q_UNUSED(in1) Q_UNUSED(in2) //TODO implement this - //qDebug() << Q_FUNC_INFO << in0.path() << in1 << in2; + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << in0.path() << in1 << in2; } uint QBluetoothLocalDevicePrivate::RequestPasskey(const QDBusObjectPath &in0) { Q_UNUSED(in0); - //qDebug() << Q_FUNC_INFO; + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO; return qrand()&0x1000000; } @@ -541,7 +543,7 @@ void QBluetoothLocalDevicePrivate::PropertyChanged(QString property, QDBusVarian QDBusPendingReply<QVariantMap> reply = adapter->GetProperties(); reply.waitForFinished(); if (reply.isError()){ - qWarning() << "Failed to get bluetooth properties for mode change"; + qCWarning(QT_BT_BLUEZ) << "Failed to get bluetooth properties for mode change"; return; } diff --git a/src/bluetooth/qbluetoothlocaldevice_qnx.cpp b/src/bluetooth/qbluetoothlocaldevice_qnx.cpp index 780639f6..bba92199 100644 --- a/src/bluetooth/qbluetoothlocaldevice_qnx.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_qnx.cpp @@ -194,7 +194,7 @@ void QBluetoothLocalDevicePrivate::setHostMode(QBluetoothLocalDevice::HostMode m } //If the device is in PowerOff state and the profile is changed then the power has to be turned on if (currentHostMode == QBluetoothLocalDevice::HostPoweredOff) { - qBBBluetoothDebug() << "Powering on"; + qCDebug(QT_BT_QNX) << "Powering on"; powerOn(); } @@ -258,9 +258,9 @@ void QBluetoothLocalDevicePrivate::setAccess(int access) void QBluetoothLocalDevicePrivate::controlReply(ppsResult result) { - qBBBluetoothDebug() << Q_FUNC_INFO << result.msg << result.dat; + qCDebug(QT_BT_QNX) << Q_FUNC_INFO << result.msg << result.dat; if (!result.errorMsg.isEmpty()) { - qWarning() << Q_FUNC_INFO << result.errorMsg; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << result.errorMsg; if (result.msg == QStringLiteral("initiate_pairing")) q_ptr->error(QBluetoothLocalDevice::PairingError); else @@ -270,16 +270,16 @@ void QBluetoothLocalDevicePrivate::controlReply(ppsResult result) void QBluetoothLocalDevicePrivate::controlEvent(ppsResult result) { - qBBBluetoothDebug() << Q_FUNC_INFO << "Control Event" << result.msg; + qCDebug(QT_BT_QNX) << Q_FUNC_INFO << "Control Event" << result.msg; if (result.msg == QStringLiteral("access_changed")) { if (__newHostMode == -1 && result.dat.size() > 1 && result.dat.first() == QStringLiteral("level")) { QBluetoothLocalDevice::HostMode newHostMode = hostMode(); - qBBBluetoothDebug() << "New Host mode" << newHostMode; + qCDebug(QT_BT_QNX) << "New Host mode" << newHostMode; Q_EMIT q_ptr->hostModeStateChanged(newHostMode); } } else if (result.msg == QStringLiteral("pairing_complete")) { - qBBBluetoothDebug() << "pairing completed"; + qCDebug(QT_BT_QNX) << "pairing completed"; if (result.dat.contains(QStringLiteral("addr"))) { const QBluetoothAddress address = QBluetoothAddress( result.dat.at(result.dat.indexOf(QStringLiteral("addr")) + 1)); @@ -290,18 +290,18 @@ void QBluetoothLocalDevicePrivate::controlEvent(ppsResult result) result.dat.at(result.dat.indexOf(QStringLiteral("trusted")) + 1) == QStringLiteral("true")) { pairingStatus = QBluetoothLocalDevice::AuthorizedPaired; } - qBBBluetoothDebug() << "pairing completed" << address.toString(); + qCDebug(QT_BT_QNX) << "pairing completed" << address.toString(); Q_EMIT q_ptr->pairingFinished(address, pairingStatus); } } else if (result.msg == QStringLiteral("device_deleted")) { - qBBBluetoothDebug() << "device deleted"; + qCDebug(QT_BT_QNX) << "device deleted"; if (result.dat.contains(QStringLiteral("addr"))) { const QBluetoothAddress address = QBluetoothAddress( result.dat.at(result.dat.indexOf(QStringLiteral("addr")) + 1)); Q_EMIT q_ptr->pairingFinished(address, QBluetoothLocalDevice::Unpaired); } } else if (result.msg == QStringLiteral("radio_shutdown")) { - qBBBluetoothDebug() << "radio shutdown"; + qCDebug(QT_BT_QNX) << "radio shutdown"; Q_EMIT q_ptr->hostModeStateChanged(QBluetoothLocalDevice::HostPoweredOff); } } diff --git a/src/bluetooth/qbluetoothserver_bluez.cpp b/src/bluetooth/qbluetoothserver_bluez.cpp index e8457183..cf50d140 100644 --- a/src/bluetooth/qbluetoothserver_bluez.cpp +++ b/src/bluetooth/qbluetoothserver_bluez.cpp @@ -43,10 +43,9 @@ #include "qbluetoothserver_p.h" #include "qbluetoothsocket.h" +#include <QtCore/QLoggingCategory> #include <QtCore/QSocketNotifier> -#include <QtCore/QDebug> - #include <bluetooth/bluetooth.h> #include <bluetooth/rfcomm.h> #include <bluetooth/l2cap.h> @@ -55,6 +54,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + static inline void convertAddress(quint64 from, quint8 (&to)[6]) { to[0] = (from >> 0) & 0xff; @@ -252,11 +253,11 @@ void QBluetoothServer::setSecurityFlags(QBluetooth::SecurityFlags security) if (security.testFlag(QBluetooth::Secure)) lm |= RFCOMM_LM_SECURE; - //qDebug() << hex << "Setting lm to" << lm << security; + qCDebug(QT_BT_BLUEZ()) << hex << "Setting lm to" << lm << security; if (setsockopt(d->socket->socketDescriptor(), SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm)) < 0){ - qWarning() << "Failed to set socket option, closing socket for safety" << errno; - qWarning() << "Error: " << strerror(errno); + qCWarning(QT_BT_BLUEZ) << "Failed to set socket option, closing socket for safety" << errno; + qCWarning(QT_BT_BLUEZ) << "Error: " << strerror(errno); d->m_lastError = InputOutputError; emit error(d->m_lastError); d->socket->close(); @@ -272,8 +273,8 @@ void QBluetoothServer::setSecurityFlags(QBluetooth::SecurityFlags security) lm |= L2CAP_LM_SECURE; if (setsockopt(d->socket->socketDescriptor(), SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm)) < 0){ - qWarning() << "Failed to set socket option, closing socket for safety" << errno; - qWarning() << "Error: " << strerror(errno); + qCWarning(QT_BT_BLUEZ) << "Failed to set socket option, closing socket for safety" << errno; + qCWarning(QT_BT_BLUEZ) << "Error: " << strerror(errno); d->m_lastError = InputOutputError; emit error(d->m_lastError); d->socket->close(); @@ -292,7 +293,7 @@ QBluetooth::SecurityFlags QBluetoothServer::securityFlags() const if (d->serverType == QBluetoothServiceInfo::RfcommProtocol) { if (getsockopt(d->socket->socketDescriptor(), SOL_RFCOMM, RFCOMM_LM, &lm, (socklen_t *)&len) < 0) { - qWarning() << "Failed to get security flags" << strerror(errno); + qCWarning(QT_BT_BLUEZ) << "Failed to get security flags" << strerror(errno); return QBluetooth::NoSecurity; } @@ -309,7 +310,7 @@ QBluetooth::SecurityFlags QBluetoothServer::securityFlags() const security |= QBluetooth::Authorization; } else { if (getsockopt(d->socket->socketDescriptor(), SOL_L2CAP, L2CAP_LM, &lm, (socklen_t *)&len) < 0) { - qWarning() << "Failed to get security flags" << strerror(errno); + qCWarning(QT_BT_BLUEZ) << "Failed to get security flags" << strerror(errno); return QBluetooth::NoSecurity; } diff --git a/src/bluetooth/qbluetoothserver_qnx.cpp b/src/bluetooth/qbluetoothserver_qnx.cpp index d937a275..9a16694f 100644 --- a/src/bluetooth/qbluetoothserver_qnx.cpp +++ b/src/bluetooth/qbluetoothserver_qnx.cpp @@ -73,19 +73,19 @@ void QBluetoothServerPrivate::controlReply(ppsResult result) Q_Q(QBluetoothServer); if (result.msg == QStringLiteral("register_server")) { - qBBBluetoothDebug() << "SPP: Server registration succesfull"; + qCDebug(QT_BT_QNX) << "SPP: Server registration succesfull"; } else if (result.msg == QStringLiteral("get_mount_point_path")) { - qBBBluetoothDebug() << "SPP: Mount point for server" << result.dat.first(); + qCDebug(QT_BT_QNX) << "SPP: Mount point for server" << result.dat.first(); int socketFD = ::open(result.dat.first().toStdString().c_str(), O_RDWR | O_NONBLOCK); if (socketFD == -1) { m_lastError = QBluetoothServer::InputOutputError; emit q->error(m_lastError); - qWarning() << Q_FUNC_INFO << "RFCOMM Server: Could not open socket FD" << errno; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "RFCOMM Server: Could not open socket FD" << errno; } else { if (!socket) { // Should never happen - qWarning() << "Socket not valid"; + qCWarning(QT_BT_QNX) << "Socket not valid"; m_lastError = QBluetoothServer::UnknownError; emit q->error(m_lastError); return; @@ -106,10 +106,10 @@ void QBluetoothServerPrivate::controlEvent(ppsResult result) { Q_Q(QBluetoothServer); if (result.msg == QStringLiteral("service_connected")) { - qBBBluetoothDebug() << "SPP: Server: Sending request for mount point path"; - qBBBluetoothDebug() << result.dat; + qCDebug(QT_BT_QNX) << "SPP: Server: Sending request for mount point path"; + qCDebug(QT_BT_QNX) << result.dat; for (int i=0; i<result.dat.size(); i++) { - qBBBluetoothDebug() << result.dat.at(i); + qCDebug(QT_BT_QNX) << result.dat.at(i); } if (result.dat.contains(QStringLiteral("addr")) && result.dat.contains(QStringLiteral("uuid")) @@ -117,13 +117,13 @@ void QBluetoothServerPrivate::controlEvent(ppsResult result) nextClientAddress = result.dat.at(result.dat.indexOf(QStringLiteral("addr")) + 1); m_uuid = QBluetoothUuid(result.dat.at(result.dat.indexOf(QStringLiteral("uuid")) + 1)); int subtype = result.dat.at(result.dat.indexOf(QStringLiteral("subtype")) + 1).toInt(); - qBBBluetoothDebug() << "Getting mount point path" << m_uuid << nextClientAddress<< subtype; + qCDebug(QT_BT_QNX) << "Getting mount point path" << m_uuid << nextClientAddress<< subtype; ppsSendControlMessage("get_mount_point_path", 0x1101, m_uuid, nextClientAddress, m_serviceName, this, BT_SPP_SERVER_SUBTYPE); } else { m_lastError = QBluetoothServer::InputOutputError; emit q->error(m_lastError); - qWarning() << Q_FUNC_INFO << "address not specified in service connect reply"; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "address not specified in service connect reply"; } } } @@ -174,9 +174,9 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port) if (__fakeServerPorts.key(port) == 0) { __fakeServerPorts[d] = port; - qBBBluetoothDebug() << "Port" << port << "registered"; + qCDebug(QT_BT_QNX) << "Port" << port << "registered"; } else { - qWarning() << "server with port" << port << "already registered or port invalid"; + qCWarning(QT_BT_QNX) << "server with port" << port << "already registered or port invalid"; d->m_lastError = ServiceAlreadyRegisteredError; emit error(d->m_lastError); return false; diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp index 1d86fed7..7d7e1bb4 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp @@ -46,16 +46,13 @@ #include "bluez/adapter_p.h" #include "bluez/device_p.h" +#include <QtCore/QLoggingCategory> #include <QtDBus/QDBusPendingCallWatcher> -//#define QT_SERVICEDISCOVERY_DEBUG - -#ifdef QT_SERVICEDISCOVERY_DEBUG -#include <QtCore/QDebug> -#endif - QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &deviceAdapter) : error(QBluetoothServiceDiscoveryAgent::NoError), state(Inactive), deviceDiscoveryAgent(0), mode(QBluetoothServiceDiscoveryAgent::MinimalDiscovery), singleDevice(false), @@ -75,9 +72,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr { Q_Q(QBluetoothServiceDiscoveryAgent); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Full discovery on: " << address.toString(); -#endif + qCDebug(QT_BT_BLUEZ) << "Full discovery on: " << address.toString(); manager = new OrgBluezManagerInterface(QLatin1String("org.bluez"), QLatin1String("/"), QDBusConnection::systemBus()); @@ -110,9 +105,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr void QBluetoothServiceDiscoveryAgentPrivate::stop() { -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << "Stop called"; -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "Stop called"; if(device){ QDBusPendingReply<> reply = device->CancelDiscovery(); reply.waitForFinished(); @@ -122,7 +115,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::stop() Q_Q(QBluetoothServiceDiscoveryAgent); emit q->canceled(); -// qDebug() << "Stop done"; + qCDebug(QT_BT_BLUEZ) << "Stop done"; } } @@ -132,17 +125,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWa const QBluetoothAddress &address = watcher->property("_q_BTaddress").value<QBluetoothAddress>(); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << "created" << address.toString(); -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "created" << address.toString(); QDBusPendingReply<QDBusObjectPath> deviceObjectPath = *watcher; if (deviceObjectPath.isError()) { if (deviceObjectPath.error().name() != QLatin1String("org.bluez.Error.AlreadyExists")) { _q_serviceDiscoveryFinished(); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Create device failed Error: " << error << deviceObjectPath.error().name(); -#endif + qCDebug(QT_BT_BLUEZ) << "Create device failed Error: " << error << deviceObjectPath.error().name(); return; } @@ -155,9 +144,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWa emit q->error(error); } _q_serviceDiscoveryFinished(); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Can't find device after creation Error: " << error << deviceObjectPath.error().name(); -#endif + qCDebug(QT_BT_BLUEZ) << "Can't find device after creation Error: " << error << deviceObjectPath.error().name(); return; } } @@ -169,9 +156,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWa QDBusPendingReply<QVariantMap> deviceReply = device->GetProperties(); deviceReply.waitForFinished(); if (deviceReply.isError()) { -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "GetProperties error: " << error << deviceObjectPath.error().name(); -#endif + qCDebug(QT_BT_BLUEZ) << "GetProperties error: " << error << deviceObjectPath.error().name(); return; } QVariantMap v = deviceReply.value(); @@ -181,9 +166,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWa foreach (const QBluetoothUuid &uuid, uuidFilter) pattern += uuid.toString().remove(QLatin1Char('{')).remove(QLatin1Char('}')) + QLatin1Char(' '); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO << "Discover: " << pattern.trimmed(); -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "Discover: " << pattern.trimmed(); QDBusPendingReply<ServiceMap> discoverReply = device->DiscoverServices(pattern.trimmed()); watcher = new QDBusPendingCallWatcher(discoverReply, q); QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), @@ -193,15 +176,11 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_createdDevice(QDBusPendingCallWa void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingCallWatcher *watcher) { -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << Q_FUNC_INFO; -#endif + qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO; QDBusPendingReply<ServiceMap> reply = *watcher; if (reply.isError()) { -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "discoveredServices error: " << error << reply.error().message(); -#endif + qCDebug(QT_BT_BLUEZ) << "discoveredServices error: " << error << reply.error().message(); watcher->deleteLater(); if (singleDevice) { Q_Q(QBluetoothServiceDiscoveryAgent); @@ -215,16 +194,12 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC ServiceMap map = reply.value(); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Parsing xml" << discoveredDevices.at(0).address().toString() << discoveredDevices.count() << map.count(); -#endif + qCDebug(QT_BT_BLUEZ) << "Parsing xml" << discoveredDevices.at(0).address().toString() << discoveredDevices.count() << map.count(); foreach (const QString &record, reply.value()) { QXmlStreamReader xml(record); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Service xml" << record; -#endif + qCDebug(QT_BT_BLUEZ) << "Service xml" << record; QBluetoothServiceInfo serviceInfo; serviceInfo.setDevice(discoveredDevices.at(0)); @@ -251,15 +226,11 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC Q_Q(QBluetoothServiceDiscoveryAgent); discoveredServices.append(serviceInfo); -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Discovered services" << discoveredDevices.at(0).address().toString(); -#endif + qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString(); emit q->serviceDiscovered(serviceInfo); // could stop discovery, check for state if(discoveryState() == Inactive){ -#ifdef QT_SERVICEDISCOVERY_DEBUG - qDebug() << "Exit discovery after stop"; -#endif + qCDebug(QT_BT_BLUEZ) << "Exit discovery after stop"; break; } } @@ -323,9 +294,9 @@ QVariant QBluetoothServiceDiscoveryAgentPrivate::readAttributeValue(QXmlStreamRe return QVariant::fromValue<QBluetoothServiceInfo::Sequence>(sequence); } else { - qWarning("unknown attribute type %s %s", - xml.name().toString().toLocal8Bit().constData(), - xml.attributes().value(QLatin1String("value")).toString().toLocal8Bit().constData()); + qCWarning(QT_BT_BLUEZ) << "unknown attribute type" + << xml.name().toString() + << xml.attributes().value(QLatin1String("value")).toString(); Q_ASSERT(false); xml.skipCurrentElement(); return QVariant(); diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp index 4c18f0e0..03c23df0 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp @@ -74,14 +74,14 @@ QBluetoothServiceDiscoveryAgentPrivate::~QBluetoothServiceDiscoveryAgentPrivate( void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &address) { Q_Q(QBluetoothServiceDiscoveryAgent); - qBBBluetoothDebug() << "Starting Service discovery for" << address.toString(); + qCDebug(QT_BT_QNX) << "Starting Service discovery for" << address.toString(); QByteArray filePath = QByteArray("/pps/services/bluetooth/remote_devices/").append(address.toString().toUtf8().constData()); if ((m_rdfd = qt_safe_open(filePath.constData(), O_RDONLY)) == -1) { if (QFile::exists(filePath + QLatin1String("-00")) || QFile::exists(filePath + QLatin1String("-01"))) { - qBBBluetoothDebug() << "LE device discovered...skipping"; + qCDebug(QT_BT_QNX) << "LE device discovered...skipping"; } else { - qWarning() << "Failed to open " << filePath; + qCWarning(QT_BT_QNX) << "Failed to open " << filePath; error = QBluetoothServiceDiscoveryAgent::InputOutputError; errorString = QStringLiteral("Failed to open remote device file"); q->error(error); @@ -95,7 +95,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr if (rdNotifier) { connect(rdNotifier, SIGNAL(activated(int)), this, SLOT(remoteDevicesChanged(int))); } else { - qWarning() << "Service Discovery: Failed to connect to rdNotifier"; + qCWarning(QT_BT_QNX) << "Service Discovery: Failed to connect to rdNotifier"; error = QBluetoothServiceDiscoveryAgent::InputOutputError; errorString = QStringLiteral("Failed to connect to rdNotifier"); q->error(error); @@ -145,7 +145,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::remoteDevicesChanged(int fd) if (next_service == 0) break; - qBBBluetoothDebug() << Q_FUNC_INFO << "Service" << next_service; + qCDebug(QT_BT_QNX) << Q_FUNC_INFO << "Service" << next_service; QBluetoothServiceInfo serviceInfo; serviceInfo.setDevice(discoveredDevices.at(0)); @@ -192,13 +192,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::remoteDevicesChanged(int fd) && sInfo.serviceUuid() == serviceInfo.serviceUuid() && sInfo.serviceClassUuids() == serviceInfo.serviceClassUuids()) { entryExists = true; - //qBBBluetoothDebug() << "Entry exists" << serviceInfo.serviceClassUuids().first() << sInfo.serviceClassUuids().first(); + //qCDebug(QT_BT_QNX) << "Entry exists" << serviceInfo.serviceClassUuids().first() << sInfo.serviceClassUuids().first(); break; } } if (!entryExists) { - qBBBluetoothDebug() << "Adding service" << next_service << " " << serviceInfo.socketProtocol(); + qCDebug(QT_BT_QNX) << "Adding service" << next_service << " " << serviceInfo.socketProtocol(); discoveredServices << serviceInfo; q_ptr->serviceDiscovered(serviceInfo); } @@ -209,13 +209,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::remoteDevicesChanged(int fd) void QBluetoothServiceDiscoveryAgentPrivate::controlReply(ppsResult result) { - qBBBluetoothDebug() << "Control reply" << result.msg << result.dat; + qCDebug(QT_BT_QNX) << "Control reply" << result.msg << result.dat; if (!m_queryTimer.isActive()) return; m_queryTimer.stop(); Q_Q(QBluetoothServiceDiscoveryAgent); if (!result.errorMsg.isEmpty()) { - qWarning() << Q_FUNC_INFO << result.errorMsg; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << result.errorMsg; errorString = result.errorMsg; error = QBluetoothServiceDiscoveryAgent::InputOutputError; q->error(error); @@ -226,13 +226,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::controlReply(ppsResult result) void QBluetoothServiceDiscoveryAgentPrivate::controlEvent(ppsResult result) { - qBBBluetoothDebug() << "Control event" << result.msg << result.dat; + qCDebug(QT_BT_QNX) << "Control event" << result.msg << result.dat; if (!m_queryTimer.isActive()) return; m_queryTimer.stop(); Q_Q(QBluetoothServiceDiscoveryAgent); if (!result.errorMsg.isEmpty()) { - qWarning() << Q_FUNC_INFO << result.errorMsg; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << result.errorMsg; errorString = result.errorMsg; error = QBluetoothServiceDiscoveryAgent::InputOutputError; q->error(error); diff --git a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp index d8344589..b9120c07 100644 --- a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp @@ -45,10 +45,13 @@ #include "bluez/manager_p.h" #include "bluez/service_p.h" +#include <QtCore/QLoggingCategory> #include <QtCore/QXmlStreamWriter> QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + static void writeAttribute(QXmlStreamWriter *stream, const QVariant &attribute) { const QString unsignedFormat(QLatin1String("0x%1")); @@ -163,7 +166,7 @@ static void writeAttribute(QXmlStreamWriter *stream, const QVariant &attribute) } break; default: - qWarning() << "Unknown variant type", attribute.userType(); + qCWarning(QT_BT_BLUEZ) << "Unknown variant type", attribute.userType(); } } @@ -234,7 +237,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca unregisterService(); if (!ensureSdpConnection(localAdapter)) { - qWarning() << "SDP not connected. Cannot register"; + qCWarning(QT_BT_BLUEZ) << "SDP not connected. Cannot register"; return false; } @@ -263,13 +266,13 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca stream.writeEndDocument(); -// qDebug() << xmlServiceRecord; + qCDebug(QT_BT_BLUEZ) << xmlServiceRecord; if (!registered) { QDBusPendingReply<uint> reply = service->AddRecord(xmlServiceRecord); reply.waitForFinished(); if (reply.isError()) { - qWarning() << "AddRecord returned error" << reply.error(); + qCWarning(QT_BT_BLUEZ) << "AddRecord returned error" << reply.error(); return false; } @@ -278,7 +281,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca QDBusPendingReply<> reply = service->UpdateRecord(serviceRecord, xmlServiceRecord); reply.waitForFinished(); if (reply.isError()) { - qWarning() << "UpdateRecord returned error" << reply.error(); + qCWarning(QT_BT_BLUEZ) << "UpdateRecord returned error" << reply.error(); return false; } } diff --git a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp index b744feff..0ce566e3 100644 --- a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp @@ -75,7 +75,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress& loca { Q_UNUSED(localAdapter); //QNX always uses default local adapter if (protocolDescriptor(QBluetoothUuid::Rfcomm).isEmpty()) { - qWarning() << Q_FUNC_INFO << "Only SPP services can be registered on QNX"; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "Only SPP services can be registered on QNX"; return false; } diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp index 96ed9dae..4b3cdd21 100644 --- a/src/bluetooth/qbluetoothsocket.cpp +++ b/src/bluetooth/qbluetoothsocket.cpp @@ -48,11 +48,14 @@ #include "qbluetoothservicediscoveryagent.h" -#include <QDebug> +#include <QtCore/QLoggingCategory> #include <QSocketNotifier> QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT) +Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX) + /*! \class QBluetoothSocket \inmodule QtBluetooth @@ -318,10 +321,10 @@ void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, Op } else { // try doing service discovery to see if we can find the socket if(service.serviceUuid().isNull()){ - qWarning() << "No port, no PSM, and no UUID provided, unable to connect"; + qCWarning(QT_BT) << "No port, no PSM, and no UUID provided, unable to connect"; return; } - //qDebug() << "Need a port/psm, doing discovery"; + qCDebug(QT_BT) << "Need a port/psm, doing discovery"; doDeviceDiscovery(service, openMode); } #endif @@ -389,7 +392,7 @@ void QBluetoothSocket::connectToService(const QBluetoothAddress &address, quint1 d->socketError = QBluetoothSocket::ServiceNotFoundError; d->errorString = tr("Connecting to port is not supported on QNX"); Q_EMIT error(d->socketError); - qWarning("Connecting to port is not supported"); + qCWarning(QT_BT_QNX) << "Connecting to port is not supported"; #else setOpenMode(openMode); d->connectToService(address, port, openMode); @@ -482,7 +485,7 @@ void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, O Q_D(QBluetoothSocket); setSocketState(QBluetoothSocket::ServiceLookupState); - //qDebug() << "Starting discovery"; + qCDebug(QT_BT) << "Starting discovery"; if(d->discoveryAgent) { delete d->discoveryAgent; @@ -506,7 +509,7 @@ void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, O // we have to ID the service somehow Q_ASSERT(!d->discoveryAgent->uuidFilter().isEmpty()); - //qDebug() << "UUID filter" << d->discoveryAgent->uuidFilter(); + qCDebug(QT_BT) << "UUID filter" << d->discoveryAgent->uuidFilter(); d->discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); } @@ -514,7 +517,7 @@ void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, O void QBluetoothSocket::serviceDiscovered(const QBluetoothServiceInfo &service) { Q_D(QBluetoothSocket); - //qDebug() << "FOUND SERVICE!" << service; + qCDebug(QT_BT) << "FOUND SERVICE!" << service; if(service.protocolServiceMultiplexer() != 0 || service.serverChannel() != 0) { connectToService(service, d->openMode); d->discoveryAgent->deleteLater(); @@ -524,10 +527,10 @@ void QBluetoothSocket::serviceDiscovered(const QBluetoothServiceInfo &service) void QBluetoothSocket::discoveryFinished() { - //qDebug() << "Socket discovery finished"; + qCDebug(QT_BT) << "Socket discovery finished"; Q_D(QBluetoothSocket); - if(d->discoveryAgent){ - //qDebug() << "Didn't find any"; + if (d->discoveryAgent){ + qCDebug(QT_BT) << "Didn't find any"; emit error(QBluetoothSocket::ServiceNotFoundError); d->discoveryAgent->deleteLater(); d->discoveryAgent = 0; diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index c6f332e3..a3048546 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -48,6 +48,7 @@ #include <qplatformdefs.h> +#include <QtCore/QLoggingCategory> #include <bluetooth/bluetooth.h> #include <bluetooth/rfcomm.h> #include <bluetooth/l2cap.h> @@ -60,6 +61,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + QBluetoothSocketPrivate::QBluetoothSocketPrivate() : socket(-1), socketType(QBluetoothServiceInfo::UnknownProtocol), @@ -228,7 +231,7 @@ void QBluetoothSocketPrivate::_q_readNotify() readNotifier->setEnabled(false); connectWriteNotifier->setEnabled(false); errorString = QString::fromLocal8Bit(strerror(errsv)); - qWarning() << Q_FUNC_INFO << socket << "error:" << readFromDevice << errorString; + qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << socket << "error:" << readFromDevice << errorString; if(errsv == EHOSTDOWN) emit q->error(QBluetoothSocket::HostNotFoundError); else @@ -358,7 +361,7 @@ QString QBluetoothSocketPrivate::peerName() const convertAddress(addr.l2_bdaddr.b, bdaddr); } else { - qWarning("peerName() called on socket of known type"); + qCWarning(QT_BT_BLUEZ) << "peerName() called on socket of known type"; return QString(); } diff --git a/src/bluetooth/qbluetoothsocket_qnx.cpp b/src/bluetooth/qbluetoothsocket_qnx.cpp index 6e14ae13..f242e4d9 100644 --- a/src/bluetooth/qbluetoothsocket_qnx.cpp +++ b/src/bluetooth/qbluetoothsocket_qnx.cpp @@ -74,7 +74,7 @@ bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, QBluetoothUuid uuid, QIODevice::OpenMode openMode) { Q_UNUSED(openMode); - qBBBluetoothDebug() << "Connecting socket"; + qCDebug(QT_BT_QNX) << "Connecting socket"; if (isServerSocket) { m_peerAddress = address; m_uuid = uuid; @@ -82,7 +82,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, } if (state != QBluetoothSocket::UnconnectedState) { - qBBBluetoothDebug() << "Socket already connected"; + qCDebug(QT_BT_QNX) << "Socket already connected"; return; } state = QBluetoothSocket::ConnectingState; @@ -144,7 +144,7 @@ void QBluetoothSocketPrivate::_q_readNotify() readNotifier->setEnabled(false); connectWriteNotifier->setEnabled(false); errorString = QString::fromLocal8Bit(strerror(errsv)); - qWarning() << Q_FUNC_INFO << socket << " error:" << readFromDevice << errorString; //TODO Try if this actually works + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << socket << " error:" << readFromDevice << errorString; //TODO Try if this actually works emit q->error(QBluetoothSocket::UnknownSocketError); q->disconnectFromService(); @@ -159,7 +159,7 @@ void QBluetoothSocketPrivate::_q_readNotify() void QBluetoothSocketPrivate::abort() { Q_Q(QBluetoothSocket); - qBBBluetoothDebug() << "Disconnecting service"; + qCDebug(QT_BT_QNX) << "Disconnecting service"; if (q->state() != QBluetoothSocket::ClosingState) ppsSendControlMessage("disconnect_service", 0x1101, m_uuid, m_peerAddress.toString(), QString(), 0, isServerSocket ? BT_SPP_SERVER_SUBTYPE : BT_SPP_CLIENT_SUBTYPE); @@ -213,7 +213,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize) if (q->openMode() & QIODevice::Unbuffered) { if (::write(socket, data, maxSize) != maxSize) { socketError = QBluetoothSocket::NetworkError; - qWarning() << Q_FUNC_INFO << "Socket error"; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "Socket error"; Q_EMIT q->error(socketError); } @@ -300,34 +300,34 @@ void QBluetoothSocketPrivate::controlReply(ppsResult result) if (result.msg == QStringLiteral("connect_service")) { if (!result.errorMsg.isEmpty()) { - qWarning() << Q_FUNC_INFO << "Error connecting to service:" << result.errorMsg; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "Error connecting to service:" << result.errorMsg; errorString = result.errorMsg; socketError = QBluetoothSocket::UnknownSocketError; emit q->error(QBluetoothSocket::UnknownSocketError); q->setSocketState(QBluetoothSocket::UnconnectedState); return; } else { - qBBBluetoothDebug() << Q_FUNC_INFO << "Sending request for mount point"; + qCDebug(QT_BT_QNX) << Q_FUNC_INFO << "Sending request for mount point"; ppsSendControlMessage("get_mount_point_path", 0x1101, m_uuid, m_peerAddress.toString(), QString(), this, BT_SPP_CLIENT_SUBTYPE); } } else if (result.msg == QStringLiteral("get_mount_point_path")) { QString path; path = result.dat.first(); - qBBBluetoothDebug() << Q_FUNC_INFO << "PATH is" << path; + qCDebug(QT_BT_QNX) << Q_FUNC_INFO << "PATH is" << path; if (!result.errorMsg.isEmpty()) { - qWarning() << Q_FUNC_INFO << result.errorMsg; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << result.errorMsg; errorString = result.errorMsg; socketError = QBluetoothSocket::UnknownSocketError; emit q->error(QBluetoothSocket::UnknownSocketError); q->setSocketState(QBluetoothSocket::UnconnectedState); return; } else { - qBBBluetoothDebug() << "Mount point path is:" << path; + qCDebug(QT_BT_QNX) << "Mount point path is:" << path; socket = ::open(path.toStdString().c_str(), O_RDWR); if (socket == -1) { errorString = QString::fromLocal8Bit(strerror(errno)); - qWarning() << Q_FUNC_INFO << socket << " error:" << errno << errorString; //TODO Try if this actually works + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << socket << " error:" << errno << errorString; //TODO Try if this actually works emit q->error(QBluetoothSocket::UnknownSocketError); q->disconnectFromService(); diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp index 0634f080..19be6d48 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp +++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp @@ -49,6 +49,7 @@ #include "bluez/obex_transfer_p.h" #include "qbluetoothtransferreply.h" +#include <QtCore/QLoggingCategory> #include <QFuture> #include <QFutureWatcher> #include <QtConcurrentRun> @@ -57,6 +58,8 @@ static const QLatin1String agentPath("/qt/agent"); QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) + QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, const QBluetoothTransferRequest &request, QBluetoothTransferManager *parent) : QBluetoothTransferReply(parent), tempfile(0), source(input), @@ -76,7 +79,7 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, con bool res = QDBusConnection::sessionBus().registerObject(m_agent_path, this); if(!res) - qWarning() << "Failed Creating dbus objects"; + qCWarning(QT_BT_BLUEZ) << "Failed Creating dbus objects"; qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply*"); QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection); @@ -100,7 +103,7 @@ bool QBluetoothTransferReplyBluez::start() if(!file){ tempfile = new QTemporaryFile(this ); tempfile->open(); -// qDebug() << "Not a QFile, making a copy" << tempfile->fileName(); + qCDebug(QT_BT_BLUEZ) << "Not a QFile, making a copy" << tempfile->fileName(); QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(); QObject::connect(watcher, SIGNAL(finished()), this, SLOT(copyDone())); @@ -272,7 +275,7 @@ void QBluetoothTransferReplyBluez::abort() QDBusPendingReply<> reply = xfer->Cancel(); reply.waitForFinished(); if(reply.isError()){ - qWarning() << "Failed to abort transfer" << reply.error(); + qCWarning(QT_BT_BLUEZ) << "Failed to abort transfer" << reply.error(); } delete xfer; } diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp index b3425300..a0fada75 100644 --- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp +++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp @@ -150,14 +150,14 @@ bool QBluetoothTransferReplyQnx::copyToTempFile(QIODevice *to, QIODevice *from) void QBluetoothTransferReplyQnx::copyDone() { - qBBBluetoothDebug() << "Copy done"; + qCDebug(QT_BT_QNX) << "Copy done"; startOPP(tempfile->fileName()); QObject::sender()->deleteLater(); } void QBluetoothTransferReplyQnx::startOPP(QString filename) { - qBBBluetoothDebug() << "Sending Push object command"; + qCDebug(QT_BT_QNX) << "Sending Push object command"; ppsSendOpp("push_object", filename.toUtf8(), request().address(), this); } @@ -182,7 +182,7 @@ void QBluetoothTransferReplyQnx::controlReply(ppsResult result) void QBluetoothTransferReplyQnx::controlEvent(ppsResult result) { if (result.msg == QStringLiteral("opp_cancelled")) { - qBBBluetoothDebug() << "opp cancelled" << result.errorMsg << result.error; + qCDebug(QT_BT_QNX) << "opp cancelled" << result.errorMsg << result.error; if (m_running) return; m_finished = true; @@ -203,18 +203,18 @@ void QBluetoothTransferReplyQnx::controlEvent(ppsResult result) bool ok; qint64 sentBytes = result.dat.at(result.dat.indexOf(QStringLiteral("sent")) + 1).toDouble(&ok); if (!ok) { - qWarning() << "Could not convert sent bytes"; + qCWarning(QT_BT_QNX) << "Could not convert sent bytes"; return; } qint64 totalBytes = result.dat.at(result.dat.indexOf(QStringLiteral("total")) + 1).toDouble(&ok); if (!ok) { - qWarning() << "Could not convert total bytes"; + qCWarning(QT_BT_QNX) << "Could not convert total bytes"; return; } - qBBBluetoothDebug() << "opp update" << sentBytes << totalBytes; + qCDebug(QT_BT_QNX) << "opp update" << sentBytes << totalBytes; Q_EMIT transferProgress(sentBytes, totalBytes); } else if (result.msg == QStringLiteral("opp_complete")) { - qBBBluetoothDebug() << "opp complete"; + qCDebug(QT_BT_QNX) << "opp complete"; m_finished = true; m_running = false; Q_EMIT finished(this); diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp index fcf5a5f7..63f5e0e8 100644 --- a/src/bluetooth/qbluetoothuuid.cpp +++ b/src/bluetooth/qbluetoothuuid.cpp @@ -42,13 +42,8 @@ #include "qbluetoothuuid.h" #include <QStringList> - -#include <QDebug> - #include <QtEndian> -//#include <arpa/inet.h> -//#include <netinet/in.h> #include <string.h> QT_BEGIN_NAMESPACE diff --git a/src/bluetooth/qnx/ppshelpers.cpp b/src/bluetooth/qnx/ppshelpers.cpp index 4acb36ef..9b1d3e4b 100644 --- a/src/bluetooth/qnx/ppshelpers.cpp +++ b/src/bluetooth/qnx/ppshelpers.cpp @@ -99,12 +99,12 @@ void ppsRegisterControl() count++; if (count == 1) { if (ppsCtrlFD != -1) { - qBBBluetoothDebug() << "PPS control FD not properly deinitialized"; + qCDebug(QT_BT_QNX) << "PPS control FD not properly deinitialized"; return; } ppsCtrlFD = qt_safe_open(btControlFDPath, O_RDWR | O_SYNC); if (ppsCtrlFD == -1) { - qWarning() << Q_FUNC_INFO << "ppsCtrlFD - failed to qt_safe_open" << btControlFDPath; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "ppsCtrlFD - failed to qt_safe_open" << btControlFDPath; } else { ppsCtrlNotifier = new QSocketNotifier(ppsCtrlFD, QSocketNotifier::Read); QObject::connect(ppsCtrlNotifier, SIGNAL(activated(int)), &bbSocketNotifier, SLOT(distribute())); @@ -140,11 +140,11 @@ pps_encoder_t *beginCtrlMessage(const char *msg, QObject *sender) bool endCtrlMessage(pps_encoder_t *encoder) { - qBBBluetoothDebug() << "writing" << pps_encoder_buffer(encoder); + qCDebug(QT_BT_QNX) << "writing" << pps_encoder_buffer(encoder); if (pps_encoder_buffer(encoder) != 0) { int res = qt_safe_write(ppsCtrlFD, pps_encoder_buffer(encoder), pps_encoder_length(encoder)); if (res == -1) { - qWarning() << Q_FUNC_INFO << "Error when writing to control FD. Is Bluetooth powerd on?" + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "Error when writing to control FD. Is Bluetooth powerd on?" << errno << ppsCtrlFD << count; return false; } @@ -206,7 +206,7 @@ void ppsDecodeControlResponse() qt_safe_read(ppsCtrlFD, &buf, sizeof(buf) ); if (buf[0] != '@') return; - qBBBluetoothDebug() << "CTRL Response" << buf; + qCDebug(QT_BT_QNX) << "CTRL Response" << buf; pps_decoder_t ppsDecoder; pps_decoder_initialize(&ppsDecoder, 0); @@ -266,16 +266,16 @@ void ppsDecodeControlResponse() } } } else { - qBBBluetoothDebug() << "Control Response: No node type" << result.msg; + qCDebug(QT_BT_QNX) << "Control Response: No node type" << result.msg; } } pps_decoder_cleanup(&ppsDecoder); } if (result.msg == QStringLiteral("radio_init")) { - qBBBluetoothDebug() << "Radio initialized"; + qCDebug(QT_BT_QNX) << "Radio initialized"; } else if (result.msg == QStringLiteral("access_changed") && __newHostMode != -1) { - qBBBluetoothDebug() << "Access changed after radio init"; + qCDebug(QT_BT_QNX) << "Access changed after radio init"; ppsSendControlMessage("set_access", QStringLiteral("{\"access\":%1}").arg(__newHostMode), 0); __newHostMode = -1; } @@ -285,7 +285,7 @@ void ppsDecodeControlResponse() if (wMessage.second != 0) wMessage.second->metaObject()->invokeMethod(wMessage.second, "controlReply", Q_ARG(ppsResult, result)); } else if (resType == EVENT) { - //qBBBluetoothDebug() << "Distributing event" << result.msg; + //qCDebug(QT_BT_QNX) << "Distributing event" << result.msg; for (int i=0; i < evtRegistration.size(); i++) { if (result.msg == evtRegistration.at(i).first) evtRegistration.at(i).second->metaObject()->invokeMethod(evtRegistration.at(i).second, "controlEvent", Q_ARG(ppsResult, result)); @@ -312,7 +312,7 @@ QVariant ppsReadSetting(const char *property) int settingsFD; char buf[ppsBufferSize]; if ((settingsFD = qt_safe_open(btSettingsFDPath, O_RDONLY)) == -1) { - qWarning() << Q_FUNC_INFO << "failed to open "<< btSettingsFDPath; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "failed to open "<< btSettingsFDPath; return QVariant(); } @@ -329,31 +329,31 @@ QVariant ppsReadSetting(const char *property) const char *dat; if (pps_decoder_get_string(&decoder, property, &dat) == PPS_DECODER_OK) { result = QString::fromUtf8(dat); - qBBBluetoothDebug() << "Read setting" << result; + qCDebug(QT_BT_QNX) << "Read setting" << result; } else { - qWarning() << Q_FUNC_INFO << "could not read"<< property; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "could not read"<< property; return QVariant(); } } else if (nodeType == PPS_TYPE_BOOL) { bool dat; if (pps_decoder_get_bool(&decoder, property, &dat) == PPS_DECODER_OK) { result = dat; - qBBBluetoothDebug() << "Read setting" << result; + qCDebug(QT_BT_QNX) << "Read setting" << result; } else { - qWarning() << Q_FUNC_INFO << "could not read"<< property; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "could not read"<< property; return QVariant(); } } else if (nodeType == PPS_TYPE_NUMBER) { int dat; if (pps_decoder_get_int(&decoder, property, &dat) == PPS_DECODER_OK) { result = dat; - qBBBluetoothDebug() << "Read setting" << result; + qCDebug(QT_BT_QNX) << "Read setting" << result; } else { - qWarning() << Q_FUNC_INFO << "could not read"<< property; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "could not read"<< property; return QVariant(); } } else { - qBBBluetoothDebug() << Q_FUNC_INFO << "unrecognized entry for settings"; + qCDebug(QT_BT_QNX) << Q_FUNC_INFO << "unrecognized entry for settings"; } } pps_decoder_cleanup(&decoder); @@ -369,7 +369,7 @@ QVariant ppsRemoteDeviceStatus(const QByteArray &address, const char *property) filename.append(address); if ((rmFD = qt_safe_open(filename.constData(), O_RDONLY)) < 0) { - qWarning() << Q_FUNC_INFO << "failed to open "<< btRemoteDevFDPath << address; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "failed to open "<< btRemoteDevFDPath << address; return false; } @@ -392,7 +392,7 @@ QVariant ppsRemoteDeviceStatus(const QByteArray &address, const char *property) pps_decoder_get_bool(&ppsDecoder,property,&dat); res = QVariant(dat); } else { - qBBBluetoothDebug() << "RDStatus: No node type" << property; + qCDebug(QT_BT_QNX) << "RDStatus: No node type" << property; } } pps_decoder_cleanup(&ppsDecoder); @@ -408,11 +408,11 @@ bool ppsReadRemoteDevice(int fd, pps_decoder_t *decoder, QBluetoothAddress *btAd addr_buf[17] = '\0'; if (qt_safe_read(fd, &buf, sizeof(buf)) == -1) { - qWarning() << Q_FUNC_INFO << "Could not qt_safe_read from pps remote device file"; + qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "Could not qt_safe_read from pps remote device file"; return false; } - qBBBluetoothDebug() << "Remote device" << buf; + qCDebug(QT_BT_QNX) << "Remote device" << buf; //the address of the BT device is stored at the beginning of the qt_safe_read if (buf[0] != '-') { diff --git a/src/bluetooth/qnx/ppshelpers_p.h b/src/bluetooth/qnx/ppshelpers_p.h index 1633bab8..0eaea981 100644 --- a/src/bluetooth/qnx/ppshelpers_p.h +++ b/src/bluetooth/qnx/ppshelpers_p.h @@ -57,23 +57,20 @@ #include <errno.h> #include <sys/pps.h> -#include <QSocketNotifier> -#include <QStringList> +#include <QtCore/QLoggingCategory> +#include <QtCore/QSocketNotifier> +#include <QtCore/QStringList> #include <QtBluetooth/qbluetoothuuid.h> #include <QtBluetooth/qbluetoothaddress.h> -#ifdef BT_BBPPSDEBUG -#define qBBBluetoothDebug qDebug -#else -#define qBBBluetoothDebug QT_NO_QDEBUG_MACRO -#endif - #define BT_SPP_SERVER_SUBTYPE 1 #define BT_SPP_CLIENT_SUBTYPE 2 QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX) + class BBSocketNotifier : public QObject { Q_OBJECT |