From ba56814fa4f0ca4a20d8448dcee95e5bf7c9d3a5 Mon Sep 17 00:00:00 2001 From: Alex Blasche <alexander.blasche@qt.io> Date: Wed, 5 Apr 2017 16:01:38 +0200 Subject: [PATCH] Replace custom QT_BLUEZ_BLUETOOTH against the related feature define Change-Id: I4fbb948841a610640acaf87364e2157e31782836 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/bluetooth/bluetooth.pro | 1 - src/bluetooth/qbluetoothdevicediscoveryagent.h | 2 +- src/bluetooth/qbluetoothdevicediscoveryagent_p.h | 6 +++--- src/bluetooth/qbluetoothglobal.h | 1 + src/bluetooth/qbluetoothlocaldevice_p.h | 4 ++-- src/bluetooth/qbluetoothserver.h | 2 +- src/bluetooth/qbluetoothserver_p.h | 6 +++--- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 4 ++-- src/bluetooth/qbluetoothservicediscoveryagent.h | 4 ++-- src/bluetooth/qbluetoothservicediscoveryagent_p.h | 8 ++++---- src/bluetooth/qbluetoothserviceinfo_p.h | 2 +- src/bluetooth/qbluetoothsocket_bluez.cpp | 2 +- src/bluetooth/qbluetoothsocket_p.h | 4 ++-- src/bluetooth/qbluetoothtransfermanager.cpp | 4 ++-- src/bluetooth/qleadvertiser_p.h | 6 +++--- src/bluetooth/qlowenergycontroller_p.h | 6 +++--- .../qbluetoothdevicediscoveryagent.pro | 4 ---- .../tst_qbluetoothdevicediscoveryagent.cpp | 6 +++--- tests/auto/qbluetoothsocket/qbluetoothsocket.pro | 2 -- tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp | 2 +- 20 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro index 03cbb8d0..6d3dacc3 100644 --- a/src/bluetooth/bluetooth.pro +++ b/src/bluetooth/bluetooth.pro @@ -80,7 +80,6 @@ SOURCES += \ qtConfig(bluez) { QT_FOR_PRIVATE += dbus - DEFINES += QT_BLUEZ_BLUETOOTH include(bluez/bluez.pri) diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.h b/src/bluetooth/qbluetoothdevicediscoveryagent.h index 84087605..17827656 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent.h +++ b/src/bluetooth/qbluetoothdevicediscoveryagent.h @@ -120,7 +120,7 @@ private: Q_DECLARE_PRIVATE(QBluetoothDeviceDiscoveryAgent) QBluetoothDeviceDiscoveryAgentPrivate *d_ptr; -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) Q_PRIVATE_SLOT(d_func(), void _q_deviceFound(const QString &address, const QVariantMap &dict)) Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged(const QString &name, const QDBusVariant &value)) Q_PRIVATE_SLOT(d_func(), void _q_InterfacesAdded(const QDBusObjectPath &path, InterfaceList interfaceList)) diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h index de8006be..45764c1a 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h @@ -63,7 +63,7 @@ #include <QtBluetooth/QBluetoothAddress> #include <QtBluetooth/QBluetoothLocalDevice> -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) #include "bluez/bluez5_helper_p.h" class OrgBluezManagerInterface; @@ -103,7 +103,7 @@ public: void stop(); bool isActive() const; -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) void _q_deviceFound(const QString &address, const QVariantMap &dict); void _q_propertyChanged(const QString &name, const QDBusVariant &value); void _q_InterfacesAdded(const QDBusObjectPath &object_path, @@ -141,7 +141,7 @@ private: QTimer *leScanTimeout; bool pendingCancel, pendingStart; -#elif defined(QT_BLUEZ_BLUETOOTH) +#elif QT_CONFIG(bluez) QBluetoothAddress m_adapterAddress; bool pendingCancel; bool pendingStart; diff --git a/src/bluetooth/qbluetoothglobal.h b/src/bluetooth/qbluetoothglobal.h index 3576b4ef..45867e94 100644 --- a/src/bluetooth/qbluetoothglobal.h +++ b/src/bluetooth/qbluetoothglobal.h @@ -40,6 +40,7 @@ #define QTBLUETOOTH_H #include <QtCore/qglobal.h> +#include <QtBluetooth/qtbluetooth-config.h> // for feature detection QT_BEGIN_NAMESPACE diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h index d369a959..acd88083 100644 --- a/src/bluetooth/qbluetoothlocaldevice_p.h +++ b/src/bluetooth/qbluetoothlocaldevice_p.h @@ -55,7 +55,7 @@ #include "qbluetoothlocaldevice.h" -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) #include <QObject> #include <QDBusContext> #include <QDBusObjectPath> @@ -128,7 +128,7 @@ public: QList<QBluetoothAddress> connectedDevices; }; -#elif defined(QT_BLUEZ_BLUETOOTH) +#elif QT_CONFIG(bluez) class QBluetoothLocalDevicePrivate : public QObject, protected QDBusContext { Q_OBJECT diff --git a/src/bluetooth/qbluetoothserver.h b/src/bluetooth/qbluetoothserver.h index e54c4452..568ca3d9 100644 --- a/src/bluetooth/qbluetoothserver.h +++ b/src/bluetooth/qbluetoothserver.h @@ -105,7 +105,7 @@ protected: private: Q_DECLARE_PRIVATE(QBluetoothServer) -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) Q_PRIVATE_SLOT(d_func(), void _q_newConnection()) #endif }; diff --git a/src/bluetooth/qbluetoothserver_p.h b/src/bluetooth/qbluetoothserver_p.h index 833c781b..4abadc72 100644 --- a/src/bluetooth/qbluetoothserver_p.h +++ b/src/bluetooth/qbluetoothserver_p.h @@ -57,7 +57,7 @@ #include "qbluetoothserver.h" #include "qbluetooth.h" -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) QT_FORWARD_DECLARE_CLASS(QSocketNotifier) #endif @@ -92,7 +92,7 @@ public: QBluetoothServerPrivate(QBluetoothServiceInfo::Protocol serverType); ~QBluetoothServerPrivate(); -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) void _q_newConnection(); void setSocketSecurityLevel(QBluetooth::SecurityFlags requestedSecLevel, int *errnoCode); QBluetooth::SecurityFlags socketSecurityLevel() const; @@ -110,7 +110,7 @@ protected: private: QBluetoothServer::Error m_lastError; -#if defined(QT_BLUEZ_BLUETOOTH) +#if QT_CONFIG(bluez) QSocketNotifier *socketNotifier; #elif defined(QT_ANDROID_BLUETOOTH) ServerAcceptanceThread *thread; diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index ed9e9d63..8998d608 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -313,7 +313,7 @@ void QBluetoothServiceDiscoveryAgent::start(DiscoveryMode mode) if (d->discoveryState() == QBluetoothServiceDiscoveryAgentPrivate::Inactive && d->error != InvalidBluetoothAdapterError) { -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) // done to avoid repeated parsing for adapter address // on Bluez5 d->foundHostAdapterPath.clear(); @@ -426,7 +426,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery() Q_Q(QBluetoothServiceDiscoveryAgent); if (!deviceDiscoveryAgent) { -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(m_deviceAdapterAddress, q); #else deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(q); diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.h b/src/bluetooth/qbluetoothservicediscoveryagent.h index 7bc656ce..ba0b91b8 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.h +++ b/src/bluetooth/qbluetoothservicediscoveryagent.h @@ -48,7 +48,7 @@ #include <QtBluetooth/QBluetoothUuid> #include <QtBluetooth/QBluetoothDeviceDiscoveryAgent> -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) #include <QtCore/qprocess.h> #endif @@ -117,7 +117,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)) Q_PRIVATE_SLOT(d_func(), void _q_serviceDiscoveryFinished()) -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) Q_PRIVATE_SLOT(d_func(), void _q_discoveredServices(QDBusPendingCallWatcher*)) Q_PRIVATE_SLOT(d_func(), void _q_createdDevice(QDBusPendingCallWatcher*)) Q_PRIVATE_SLOT(d_func(), void _q_foundDevice(QDBusPendingCallWatcher*)) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/bluetooth/qbluetoothservicediscoveryagent_p.h index ef5db720..9a8da5e3 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h +++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h @@ -59,7 +59,7 @@ #include <QStack> #include <QStringList> -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) class OrgBluezManagerInterface; class OrgBluezAdapterInterface; class OrgBluezDeviceInterface; @@ -122,7 +122,7 @@ public: void _q_deviceDiscovered(const QBluetoothDeviceInfo &info); void _q_serviceDiscoveryFinished(); void _q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error); -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) void _q_discoveredServices(QDBusPendingCallWatcher *watcher); void _q_createdDevice(QDBusPendingCallWatcher *watcher); void _q_foundDevice(QDBusPendingCallWatcher *watcher); @@ -151,7 +151,7 @@ private: void stop(); bool isDuplicatedService(const QBluetoothServiceInfo &serviceInfo) const; -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) void startBluez5(const QBluetoothAddress &address); void runExternalSdpScan(const QBluetoothAddress &remoteAddress, const QBluetoothAddress &localAddress); @@ -179,7 +179,7 @@ private: QBluetoothServiceDiscoveryAgent::DiscoveryMode mode; bool singleDevice; -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) QString foundHostAdapterPath; OrgBluezManagerInterface *manager; OrgFreedesktopDBusObjectManagerInterface *managerBluez5; diff --git a/src/bluetooth/qbluetoothserviceinfo_p.h b/src/bluetooth/qbluetoothserviceinfo_p.h index 2e223a7b..ea695b56 100644 --- a/src/bluetooth/qbluetoothserviceinfo_p.h +++ b/src/bluetooth/qbluetoothserviceinfo_p.h @@ -104,7 +104,7 @@ public: QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const; int serverChannel() const; private: -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) bool ensureSdpConnection(const QBluetoothAddress &localAdapter = QBluetoothAddress()); OrgBluezServiceInterface *service; diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index 83d8c308..f430d3b4 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -185,7 +185,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, // only Linux (of all platforms supported by this library) supports this type // of socket. -#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE) +#if QT_CONFIG(bluez) && !defined(QT_BLUEZ_NO_BTLE) if (lowEnergySocketType) { addr.l2_cid = htobs(port); addr.l2_bdaddr_type = lowEnergySocketType; diff --git a/src/bluetooth/qbluetoothsocket_p.h b/src/bluetooth/qbluetoothsocket_p.h index 0be07b5f..956f8f02 100644 --- a/src/bluetooth/qbluetoothsocket_p.h +++ b/src/bluetooth/qbluetoothsocket_p.h @@ -226,7 +226,7 @@ private slots: void handleError(QBluetoothSocket::SocketError error); #endif // QT_WINRT_BLUETOOTH -#if defined(QT_BLUEZ_BLUETOOTH) +#if QT_CONFIG(bluez) private slots: void _q_readNotify(); void _q_writeNotify(); @@ -241,7 +241,7 @@ private: HRESULT handleConnectOpFinished(ABI::Windows::Foundation::IAsyncAction *action, ABI::Windows::Foundation::AsyncStatus status); #endif -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) public: quint8 lowEnergySocketType; #endif diff --git a/src/bluetooth/qbluetoothtransfermanager.cpp b/src/bluetooth/qbluetoothtransfermanager.cpp index ab05902f..165faceb 100644 --- a/src/bluetooth/qbluetoothtransfermanager.cpp +++ b/src/bluetooth/qbluetoothtransfermanager.cpp @@ -40,7 +40,7 @@ #include "qbluetoothtransfermanager.h" #include "qbluetoothtransferrequest.h" #include "qbluetoothtransferreply.h" -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) #include "qbluetoothtransferreply_bluez_p.h" #elif QT_OSX_BLUETOOTH #include "qbluetoothtransferreply_osx_p.h" @@ -112,7 +112,7 @@ QBluetoothTransferManager::~QBluetoothTransferManager() QBluetoothTransferReply *QBluetoothTransferManager::put(const QBluetoothTransferRequest &request, QIODevice *data) { -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) QBluetoothTransferReplyBluez *rep = new QBluetoothTransferReplyBluez(data, request, this); connect(rep, SIGNAL(finished(QBluetoothTransferReply*)), this, SIGNAL(finished(QBluetoothTransferReply*))); return rep; diff --git a/src/bluetooth/qleadvertiser_p.h b/src/bluetooth/qleadvertiser_p.h index 8e71844e..922fdf64 100644 --- a/src/bluetooth/qleadvertiser_p.h +++ b/src/bluetooth/qleadvertiser_p.h @@ -54,7 +54,7 @@ #include "qlowenergyadvertisingdata.h" #include "qlowenergyadvertisingparameters.h" -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) #include "bluez/bluez_data_p.h" #endif @@ -94,7 +94,7 @@ private: }; -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) struct AdvData; struct AdvParams; class HciManager; @@ -147,7 +147,7 @@ private: bool m_sendPowerLevel; bool m_disableCommandFinished; }; -#endif // QT_BLUEZ_BLUETOOTH +#endif // QT_CONFIG(bluez) QT_END_NAMESPACE diff --git a/src/bluetooth/qlowenergycontroller_p.h b/src/bluetooth/qlowenergycontroller_p.h index 1c309c95..5fcc46a4 100644 --- a/src/bluetooth/qlowenergycontroller_p.h +++ b/src/bluetooth/qlowenergycontroller_p.h @@ -77,7 +77,7 @@ QT_END_NAMESPACE #include "qlowenergycontroller.h" #include "qlowenergyserviceprivate_p.h" -#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE) +#if QT_CONFIG(bluez) && !defined(QT_BLUEZ_NO_BTLE) #include <QtBluetooth/QBluetoothSocket> #elif defined(QT_ANDROID_BLUETOOTH) #include <QtAndroidExtras/QAndroidJniObject> @@ -96,7 +96,7 @@ QT_BEGIN_NAMESPACE class QLowEnergyServiceData; class QTimer; -#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE) +#if QT_CONFIG(bluez) && !defined(QT_BLUEZ_NO_BTLE) class HciManager; class LeCmacCalculator; class QSocketNotifier; @@ -209,7 +209,7 @@ public: QLowEnergyController::RemoteAddressType addressType; private: -#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE) +#if QT_CONFIG(bluez) && !defined(QT_BLUEZ_NO_BTLE) quint16 connectionHandle = 0; QBluetoothSocket *l2cpSocket; struct Request { diff --git a/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro b/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro index cb7b4179..900bb5e9 100644 --- a/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro +++ b/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro @@ -4,7 +4,3 @@ CONFIG += testcase QT = core concurrent bluetooth-private testlib osx:QT += widgets - -qtConfig(bluez) { - DEFINES += QT_BLUEZ_BLUETOOTH -} diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp index efc4d8a6..c75004d6 100644 --- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp +++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp @@ -96,7 +96,7 @@ tst_QBluetoothDeviceDiscoveryAgent::~tst_QBluetoothDeviceDiscoveryAgent() { } -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) // This section was adopted from tst_qloggingcategory.cpp QString logMessage; @@ -133,7 +133,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::initTestCase() qRegisterMetaType<QBluetoothDeviceInfo>(); qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::InquiryType>(); -#ifdef QT_BLUEZ_BLUETOOTH +#if QT_CONFIG(bluez) // To distinguish Bluez 4 and 5 we peek into the debug output // of first Bluetooth ctor. It executes a runtime test and prints the result // as logging output. This avoids more complex runtime detection logic within this unit test. @@ -495,7 +495,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_discoveryTimeout() QCOMPARE(agent.lowEnergyDiscoveryTimeout(), 25000); agent.setLowEnergyDiscoveryTimeout(20000); QCOMPARE(agent.lowEnergyDiscoveryTimeout(), 20000); -#elif defined(QT_BLUEZ_BLUETOOTH) +#elif QT_CONFIG(bluez) if (isBluez5Runtime) { QCOMPARE(agent.lowEnergyDiscoveryTimeout(), 20000); agent.setLowEnergyDiscoveryTimeout(-1); // negative ignored diff --git a/tests/auto/qbluetoothsocket/qbluetoothsocket.pro b/tests/auto/qbluetoothsocket/qbluetoothsocket.pro index b73d9311..32fc6558 100644 --- a/tests/auto/qbluetoothsocket/qbluetoothsocket.pro +++ b/tests/auto/qbluetoothsocket/qbluetoothsocket.pro @@ -13,6 +13,4 @@ osx { DEFINES += QT_OSX_BLUETOOTH } else: android { DEFINES += QT_ANDROID_BLUETOOTH -} else: qtConfig(bluez) { - DEFINES += QT_BLUEZ_BLUETOOTH } diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp index 566a5c5b..fa4629ac 100644 --- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp +++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp @@ -505,7 +505,7 @@ void tst_QBluetoothSocket::tst_preferredSecurityFlags() //test default values #if defined(QT_ANDROID_BLUETOOTH) | defined(QT_OSX_BLUETOOTH) QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Secure); -#elif defined(QT_BLUEZ_BLUETOOTH) +#elif QT_CONFIG(bluez) QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Authorization); #else QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::NoSecurity); -- GitLab