Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -4,7 +4,7 @@ project(BluezQt VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.59.0 NO_MODULE) +find_package(ECM 5.49.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) Index: autotests/fakebluez/gattmanagerinterface.h =================================================================== --- autotests/fakebluez/gattmanagerinterface.h +++ autotests/fakebluez/gattmanagerinterface.h @@ -41,7 +41,7 @@ void UnregisterApplication(const QDBusObjectPath &path, const QDBusMessage &msg); private: - void runGetObjectsAction(const QVariantMap &properties); + void runGetObjectsAction(); void runReadCharcAction(const QVariantMap &properties); void runWriteCharcAction(const QVariantMap &properties); Index: autotests/fakebluez/gattmanagerinterface.cpp =================================================================== --- autotests/fakebluez/gattmanagerinterface.cpp +++ autotests/fakebluez/gattmanagerinterface.cpp @@ -37,7 +37,7 @@ void GattManagerInterface::runAction(const QString &actionName, const QVariantMap &properties) { if (actionName == QLatin1String("get-objects")) { - runGetObjectsAction(properties); + runGetObjectsAction(); } else if (actionName == QLatin1String("read-charc")) { runReadCharcAction(properties); } else if (actionName == QLatin1String("write-charc")) { @@ -59,7 +59,7 @@ } } -void GattManagerInterface::runGetObjectsAction(const QVariantMap &properties) +void GattManagerInterface::runGetObjectsAction() { QDBusMessage call = QDBusMessage::createMethodCall(m_service, m_application.path(), Index: autotests/gattmanagertest.cpp =================================================================== --- autotests/gattmanagertest.cpp +++ autotests/gattmanagertest.cpp @@ -66,7 +66,7 @@ m_adapter = manager->adapters().at(0); QVERIFY(m_adapter->gattManager()); - m_application = new TestApplication(this); + m_application = new TestApplication(QStringLiteral("/org/kde/bluez-qt"), this); auto service = new GattService(QStringLiteral("ad100000-d901-11e8-9f8b-f2801f1b9fd1"), true, m_application); m_characteristic = new GattCharacteristic(QStringLiteral("ad10e100-d901-11e8-9f8b-f2801f1b9fd1"), service); m_adapter->gattManager()->registerApplication(m_application)->waitForFinished(); Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt +++ src/CMakeLists.txt @@ -12,6 +12,7 @@ gattcharacteristic_p.cpp gattcharacteristicadaptor.cpp gattmanager.cpp + gattmanager_p.cpp gattservice.cpp gattservice_p.cpp gattserviceadaptor.cpp Index: src/gattapplication.h =================================================================== --- src/gattapplication.h +++ src/gattapplication.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -44,7 +44,7 @@ * * @param parent */ - explicit GattApplication(QObject *parent = nullptr); + explicit GattApplication(const QString &objectPathPrefix, QObject *parent = nullptr); /** * Destroys a GattApplication object. Index: src/gattapplication.cpp =================================================================== --- src/gattapplication.cpp +++ src/gattapplication.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,9 +35,9 @@ namespace BluezQt { -GattApplication::GattApplication(QObject *parent) : - ObjectManager(parent), - d(new GattApplicationPrivate()) +GattApplication::GattApplication(const QString &objectPathPrefix, QObject *parent) + : ObjectManager(parent) + , d(new GattApplicationPrivate(objectPathPrefix)) { } @@ -50,8 +50,8 @@ { DBusManagerStruct objects; - auto serviceAdaptors = findChildren(); - auto charcAdaptors = findChildren(); + const auto serviceAdaptors = findChildren(); + const auto charcAdaptors = findChildren(); for (const GattServiceAdaptor *serviceAdaptor : serviceAdaptors) { QVariantMap properties; @@ -61,7 +61,7 @@ properties.insert(QString::fromLatin1(propertyName), serviceAdaptor->property(propertyName)); } - GattService* service = qobject_cast(serviceAdaptor->parent()); + GattService *service = qobject_cast(serviceAdaptor->parent()); if (service) { objects[service->objectPath()].insert(QStringLiteral("org.bluez.GattService1"), properties); } Index: src/gattapplication_p.h =================================================================== --- src/gattapplication_p.h +++ src/gattapplication_p.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,7 +30,7 @@ class GattApplicationPrivate { public: - GattApplicationPrivate(); + GattApplicationPrivate(const QString &objectPathPrefix); QDBusObjectPath m_objectPath; }; Index: src/gattapplication_p.cpp =================================================================== --- src/gattapplication_p.cpp +++ src/gattapplication_p.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,10 +25,10 @@ namespace BluezQt { -GattApplicationPrivate::GattApplicationPrivate() +GattApplicationPrivate::GattApplicationPrivate(const QString &objectPathPrefix) { static uint8_t appNumber = 0; - m_objectPath.setPath(QStringLiteral("/org/bluez/app") + QString::number(appNumber++)); + m_objectPath.setPath(objectPathPrefix + QStringLiteral("/app") + QString::number(appNumber++)); } } // namespace BluezQt Index: src/gattcharacteristic.h =================================================================== --- src/gattcharacteristic.h +++ src/gattcharacteristic.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: src/gattcharacteristic.cpp =================================================================== --- src/gattcharacteristic.cpp +++ src/gattcharacteristic.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,8 +28,8 @@ { GattCharacteristic::GattCharacteristic(const QString &uuid, GattService *service) - : QObject(service), - d(new GattCharacterisiticPrivate(uuid, service)) + : QObject(service) + , d(new GattCharacterisiticPrivate(uuid, service)) { } @@ -47,7 +47,7 @@ return d->m_value; } -void GattCharacteristic::writeValue(const QByteArray& value) +void GattCharacteristic::writeValue(const QByteArray &value) { d->m_value = value; emit valueWritten(d->m_value); Index: src/gattcharacteristic_p.h =================================================================== --- src/gattcharacteristic_p.h +++ src/gattcharacteristic_p.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ QString m_uuid; const GattService *m_service; QDBusObjectPath m_objectPath; - QByteArray m_value; + QByteArray m_value; GattCharacteristic::ReadCallback m_readCallback = nullptr; }; Index: src/gattcharacteristic_p.cpp =================================================================== --- src/gattcharacteristic_p.cpp +++ src/gattcharacteristic_p.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,8 +27,8 @@ { GattCharacterisiticPrivate::GattCharacterisiticPrivate(const QString &uuid, const GattService *service) - : m_uuid(uuid), - m_service(service) + : m_uuid(uuid) + , m_service(service) { static uint8_t charcNumber = 0; m_objectPath.setPath(m_service->objectPath().path() + QStringLiteral("/char") + QString::number(charcNumber++)); Index: src/gattcharacteristicadaptor.h =================================================================== --- src/gattcharacteristicadaptor.h +++ src/gattcharacteristicadaptor.h @@ -55,7 +55,7 @@ void StopNotify(); private: - GattCharacteristic* m_gattCharacteristic; + GattCharacteristic *m_gattCharacteristic; }; } // namespace BluezQt Index: src/gattcharacteristicadaptor.cpp =================================================================== --- src/gattcharacteristicadaptor.cpp +++ src/gattcharacteristicadaptor.cpp @@ -55,6 +55,7 @@ { return m_gattCharacteristic->readValue(); } + void GattCharacteristicAdaptor::WriteValue(const QByteArray &value, const QVariantMap &/*options*/) { m_gattCharacteristic->writeValue(value); Index: src/gattmanager.h =================================================================== --- src/gattmanager.h +++ src/gattmanager.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,8 +27,6 @@ #include "bluezqt_dbustypes.h" #include "bluezqt_export.h" -class QDBusInterface; - namespace BluezQt { @@ -102,7 +100,7 @@ private: explicit GattManager(const QString &path, QObject *parent = nullptr); - QDBusInterface *m_dbusInterface = nullptr; + class GattManagerPrivate *const d; friend class AdapterPrivate; }; Index: src/gattmanager.cpp =================================================================== --- src/gattmanager.cpp +++ src/gattmanager.cpp @@ -25,11 +25,11 @@ #include "gattapplication.h" #include "gattcharacteristic.h" #include "gattcharacteristicadaptor.h" +#include "gattmanager_p.h" #include "gattservice.h" #include "gattserviceadaptor.h" #include "objectmanageradaptor.h" #include "pendingcall.h" -#include "propertiesadaptor.h" #include "utils.h" #include "debug.h" @@ -41,34 +41,25 @@ GattManager::GattManager(const QString &path, QObject *parent) : QObject(parent) + , d(new GattManagerPrivate(path)) { - m_dbusInterface = new QDBusInterface(Strings::orgBluez(), - path, - QStringLiteral("org.bluez.GattManager1"), - DBusConnection::orgBluez(), - this); } GattManager::~GattManager() { + delete d; } PendingCall *GattManager::registerApplication(GattApplication *application) { Q_ASSERT(application); - for (auto child : application->children()) { - GattService* service = qobject_cast(child); - if (!service) { - continue; - } + const auto services = application->findChildren(); + for (auto service : services) { new GattServiceAdaptor(service); - for (auto serviceChild : service->children()) { - GattCharacteristic* charc = qobject_cast(serviceChild); - if (!charc) { - continue; - } + const auto charcs = service->findChildren(); + for (auto charc : charcs) { new GattCharacteristicAdaptor(charc); if (!DBusConnection::orgBluez().registerObject(charc->objectPath().path(), charc, @@ -94,7 +85,7 @@ QList argumentList; argumentList << QVariant::fromValue(application->objectPath()) << QVariantMap(); - return new PendingCall(m_dbusInterface->asyncCallWithArgumentList(QStringLiteral("RegisterApplication"), argumentList), + return new PendingCall(d->m_dbusInterface->asyncCallWithArgumentList(QStringLiteral("RegisterApplication"), argumentList), PendingCall::ReturnVoid, this); } @@ -106,7 +97,7 @@ QList argumentList; argumentList << QVariant::fromValue(application->objectPath()); - return new PendingCall(m_dbusInterface->asyncCallWithArgumentList(QStringLiteral("UnregisterApplication"), argumentList), + return new PendingCall(d->m_dbusInterface->asyncCallWithArgumentList(QStringLiteral("UnregisterApplication"), argumentList), PendingCall::ReturnVoid, this); } Index: src/gattmanager_p.h =================================================================== --- src/gattmanager_p.h +++ src/gattmanager_p.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,17 +22,19 @@ #pragma once -#include +class QDBusInterface; +class QString; namespace BluezQt { -class GattApplicationPrivate +class GattManagerPrivate { public: - GattApplicationPrivate(); + GattManagerPrivate(const QString &path); + ~GattManagerPrivate(); - QDBusObjectPath m_objectPath; + QDBusInterface *m_dbusInterface = nullptr; }; } // namespace BluezQt Index: src/gattmanager_p.cpp =================================================================== --- src/gattmanager_p.cpp +++ src/gattmanager_p.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,31 +20,25 @@ * License along with this library. If not, see . */ -#include "gattserviceadaptor.h" +#include "gattmanager_p.h" +#include "utils.h" -#include "gattservice.h" -#include "request.h" - -#include -#include +#include namespace BluezQt { -GattServiceAdaptor::GattServiceAdaptor(GattService *parent) - : QDBusAbstractAdaptor(parent) - , m_gattService(parent) -{ -} - -QString GattServiceAdaptor::uuid() const +GattManagerPrivate::GattManagerPrivate(const QString &path) { - return m_gattService->uuid(); + m_dbusInterface = new QDBusInterface(Strings::orgBluez(), + path, + QStringLiteral("org.bluez.GattManager1"), + DBusConnection::orgBluez()); } -bool GattServiceAdaptor::primary() const +GattManagerPrivate::~GattManagerPrivate() { - return m_gattService->isPrimary(); + delete m_dbusInterface; } } // namespace BluezQt Index: src/gattservice.h =================================================================== --- src/gattservice.h +++ src/gattservice.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: src/gattservice.cpp =================================================================== --- src/gattservice.cpp +++ src/gattservice.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,8 +28,8 @@ { GattService::GattService(const QString &uuid, bool isPrimary, GattApplication *parent) - : QObject(parent), - d(new GattServicePrivate(uuid, isPrimary, parent->objectPath().path())) + : QObject(parent) + , d(new GattServicePrivate(uuid, isPrimary, parent->objectPath().path())) { } Index: src/gattservice_p.h =================================================================== --- src/gattservice_p.h +++ src/gattservice_p.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous BlueZ wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: src/gattservice_p.cpp =================================================================== --- src/gattservice_p.cpp +++ src/gattservice_p.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,8 +26,8 @@ { GattServicePrivate::GattServicePrivate(const QString &uuid, bool isPrimary, const QString &appPath) - : m_uuid(uuid), - m_isPrimary(isPrimary) + : m_uuid(uuid) + , m_isPrimary(isPrimary) { static uint8_t serviceNumber = 0; m_objectPath.setPath(appPath + QStringLiteral("/service") + QString::number(serviceNumber++)); Index: src/gattserviceadaptor.h =================================================================== --- src/gattserviceadaptor.h +++ src/gattserviceadaptor.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: src/gattserviceadaptor.cpp =================================================================== --- src/gattserviceadaptor.cpp +++ src/gattserviceadaptor.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: src/objectmanageradaptor.h =================================================================== --- src/objectmanageradaptor.h +++ src/objectmanageradaptor.h @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: src/objectmanageradaptor.cpp =================================================================== --- src/objectmanageradaptor.cpp +++ src/objectmanageradaptor.cpp @@ -1,7 +1,7 @@ /* * BluezQt - Asynchronous Bluez wrapper library * - * Copyright (C) 2018 Manuel Weichselbaumer + * Copyright (C) 2019 Manuel Weichselbaumer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Index: tests/leserver.cpp =================================================================== --- tests/leserver.cpp +++ tests/leserver.cpp @@ -45,7 +45,7 @@ auto call = m_manager->usableAdapter()->leAdvertisingManager()->registerAdvertisement(advertisement); connect(call, &PendingCall::finished, this, &LeServer::onCallFinished); - auto application = new GattApplication(this); + auto application = new GattApplication(QStringLiteral("/org/kde/bluez-qt"), this); auto service = new GattService(QStringLiteral("ad100000-d901-11e8-9f8b-f2801f1b9fd1"), true, application); new GattCharacteristic(QStringLiteral("ad10e100-d901-11e8-9f8b-f2801f1b9fd1"), service); auto call2 = m_manager->usableAdapter()->gattManager()->registerApplication(application);