diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-04-29 14:42:08 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-05-04 09:09:03 +0000 |
commit | 4fbef973df2812be48f64cb9829f94fba240a73c (patch) | |
tree | c883dc34172072e184a49957f7e17d3709f40143 | |
parent | de21bd71db6e9ccc75191bc2a84ebc45a6936cd6 (diff) |
Add detection for running Bluez 4 daemon
So far we tried to detect Bluez5. If we couldn't find it the code
automatically assumed Bluez4. That's not always true though as
the Bluez daemon (bluetoothd) may not actually be running.
In such cases we print a warning from now on.
Change-Id: I6bf803ab21cb8906bb786bc0549db8e1bb3a0a3b
Task-number: QTBUG-45750
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
-rw-r--r-- | src/bluetooth/bluez/bluez5_helper.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp index e4cb37d6..28b5c12d 100644 --- a/src/bluetooth/bluez/bluez5_helper.cpp +++ b/src/bluetooth/bluez/bluez5_helper.cpp @@ -38,6 +38,7 @@ #include "objectmanager_p.h" #include "properties_p.h" #include "adapter1_bluez5_p.h" +#include "manager_p.h" QT_BEGIN_NAMESPACE @@ -47,7 +48,8 @@ typedef enum Bluez5TestResultType { BluezVersionUnknown, BluezVersion4, - BluezVersion5 + BluezVersion5, + BluezNotAvailable } Bluez5TestResult; Q_GLOBAL_STATIC_WITH_ARGS(Bluez5TestResult, bluezVersion, (BluezVersionUnknown)); @@ -65,8 +67,20 @@ bool isBluez5() QDBusPendingReply<ManagedObjectList> reply = manager.GetManagedObjects(); reply.waitForFinished(); if (reply.isError()) { - *bluezVersion() = BluezVersion4; - qCDebug(QT_BT_BLUEZ) << "Bluez 4 detected."; + // not Bluez 5.x + OrgBluezManagerInterface manager_bluez4(QStringLiteral("org.bluez"), + QStringLiteral("/"), + QDBusConnection::systemBus()); + QDBusPendingReply<QList<QDBusObjectPath> > reply + = manager_bluez4.ListAdapters(); + reply.waitForFinished(); + if (reply.isError()) { + *bluezVersion() = BluezNotAvailable; + qWarning() << "Cannot find a running Bluez. Please check the Bluez installation."; + } else { + *bluezVersion() = BluezVersion4; + qCDebug(QT_BT_BLUEZ) << "Bluez 4 detected."; + } } else { *bluezVersion() = BluezVersion5; qCDebug(QT_BT_BLUEZ) << "Bluez 5 detected."; |