From 94f862e2786c5e9b558ae6ab6f524842949c0953 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 16 Dec 2013 16:02:37 +0100 Subject: Use QLoggingCategory to categorize the various debug output streams Task-number: QTBUG-32253 Change-Id: I193162407d0fc7eca83689e31f03e1641a494ab0 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- .../qbluetoothdevicediscoveryagent_bluez.cpp | 41 +++++++--------------- 1 file changed, 12 insertions(+), 29 deletions(-) (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp') 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 #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); -- cgit v1.2.3 From 02a4f74cfefd97d88b0b1354be176a4329336004 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 15 Jan 2014 15:08:52 +0100 Subject: Emit PoweredOffError if required during device discovery start on Bluez Change-Id: I12406b2a0fef831ed2e96340fac73156dfa71848 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp') diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index 805f648a..cce27dc5 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -118,6 +118,18 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; Q_Q(QBluetoothDeviceDiscoveryAgent); + delete adapter; + adapter = 0; + emit q->error(lastError); + return; + } + + if (!propertiesReply.value().value(QStringLiteral("Powered")).toBool()) { + qCDebug(QT_BT_BLUEZ) << "Aborting device discovery due to offline Bluetooth Adapter"; + lastError = QBluetoothDeviceDiscoveryAgent::PoweredOffError; + errorString = QBluetoothDeviceDiscoveryAgent::tr("Device is powered off."); + delete adapter; + adapter = 0; emit q->error(lastError); return; } -- cgit v1.2.3 From 92609ca2efc33a091ede3e16a5f077fa227c3f1f Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 16 Jan 2014 11:23:41 +0100 Subject: Fix memory leaks in Bluez specific device and SDP discovery classes. [ChangeLog][QtBluetooth][Platform Specific Changes] Memory leaks fixed in Bluez device and service discovery implementations. Change-Id: Ibc7c883d42d81a97310ff44ba40ffa94c71f611f Reviewed-by: Fabian Bumberger Reviewed-by: Aaron McCarthy Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp') diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index 805f648a..48c8b983 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -65,6 +65,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(con QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate() { delete manager; + delete adapter; } bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const @@ -115,6 +116,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() propertiesReply.waitForFinished(); if(propertiesReply.isError()) { errorString = propertiesReply.error().message(); + delete adapter; + adapter = 0; qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString; lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; Q_Q(QBluetoothDeviceDiscoveryAgent); -- cgit v1.2.3 From b4a5e7d3c3efddff23022acdb42485ad534553eb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 17 Jan 2014 19:04:41 +0100 Subject: whitespace fixes remove trailing whitespace, expand tab Change-Id: I3361c6c431231c7463bb1dc9b53268935b22a72b Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp') diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index cce27dc5..40ee7024 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -163,7 +163,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres { const QBluetoothAddress btAddress(address); const QString btName = dict.value(QLatin1String("Name")).toString(); - quint32 btClass = dict.value(QLatin1String("Class")).toUInt(); + quint32 btClass = dict.value(QLatin1String("Class")).toUInt(); qCDebug(QT_BT_BLUEZ) << "Discovered: " << address << btName << "Num UUIDs" << dict.value(QLatin1String("UUIDs")).toStringList().count() @@ -202,7 +202,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres void QBluetoothDeviceDiscoveryAgentPrivate::_q_propertyChanged(const QString &name, const QDBusVariant &value) -{ +{ qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << name << value.variant(); if (name == QLatin1String("Discovering") && !value.variant().toBool()) { -- cgit v1.2.3 From 7f6c4f7d590bc71ab45d208abcec94f32e61a9e4 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 13 Feb 2014 12:06:43 +0100 Subject: Adjust strings for translation This includes unification of error messages, fixes for spelling mistakes, hints for translators and other forms of simplifications. Change-Id: Idd0e01614b24ff2d19133f0d19d49649d59e3f57 Reviewed-by: Fabian Bumberger --- src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp') diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index 69f09130..83b83fbd 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -130,7 +130,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() if (!propertiesReply.value().value(QStringLiteral("Powered")).toBool()) { qCDebug(QT_BT_BLUEZ) << "Aborting device discovery due to offline Bluetooth Adapter"; lastError = QBluetoothDeviceDiscoveryAgent::PoweredOffError; - errorString = QBluetoothDeviceDiscoveryAgent::tr("Device is powered off."); + errorString = QBluetoothDeviceDiscoveryAgent::tr("Device is powered off"); delete adapter; adapter = 0; emit q->error(lastError); -- cgit v1.2.3