Hello community, here is the log from the commit of package bluez-qt for openSUSE:Factory checked in at 2020-01-14 20:59:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/bluez-qt (Old) and /work/SRC/openSUSE:Factory/.bluez-qt.new.6675 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "bluez-qt" Tue Jan 14 20:59:15 2020 rev:60 rq:763430 version:5.66.0 Changes: -------- --- /work/SRC/openSUSE:Factory/bluez-qt/bluez-qt.changes 2019-12-18 14:39:52.929707094 +0100 +++ /work/SRC/openSUSE:Factory/.bluez-qt.new.6675/bluez-qt.changes 2020-01-14 20:59:20.882542480 +0100 @@ -1,0 +2,12 @@ +Sun Jan 5 09:01:54 UTC 2020 - Christophe Giboudeaux <[email protected]> + +- Update to 5.66.0 + * New feature release + * For more details please see: + * https://www.kde.org/announcements/kde-frameworks-5.66.0.php +- Changes since 5.65.0: + * Port QRegExp to QRegularExpression + * Add Battery1 interface + * Update the obsolete projects.kde.org URL + +------------------------------------------------------------------- Old: ---- bluez-qt-5.65.0.tar.xz bluez-qt-5.65.0.tar.xz.sig New: ---- bluez-qt-5.66.0.tar.xz bluez-qt-5.66.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ bluez-qt.spec ++++++ --- /var/tmp/diff_new_pack.No6Ir6/_old 2020-01-14 20:59:21.930542964 +0100 +++ /var/tmp/diff_new_pack.No6Ir6/_new 2020-01-14 20:59:21.934542966 +0100 @@ -1,7 +1,7 @@ # # spec file for package bluez-qt # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %define sonum 6 %define _libname KF5BluezQt -%define _tar_path 5.65 +%define _tar_path 5.66 # Full KF5 version (e.g. 5.33.0) %{!?_kf5_version: %global _kf5_version %{version}} # Last major and minor KF5 version (e.g. 5.33) @@ -26,7 +26,7 @@ # Only needed for the package signature condition %bcond_without lang Name: bluez-qt -Version: 5.65.0 +Version: 5.66.0 Release: 0 Summary: Async Bluez wrapper library License: LGPL-2.1-or-later ++++++ bluez-qt-5.65.0.tar.xz -> bluez-qt-5.66.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/CMakeLists.txt new/bluez-qt-5.66.0/CMakeLists.txt --- old/bluez-qt-5.65.0/CMakeLists.txt 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/CMakeLists.txt 2020-01-04 00:09:10.000000000 +0100 @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.65.0") # handled by release scripts +set(KF5_VERSION "5.66.0") # handled by release scripts project(BluezQt VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.65.0 NO_MODULE) -set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") +find_package(ECM 5.66.0 NO_MODULE) +set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) @@ -35,7 +35,7 @@ ) # Dependencies -set(REQUIRED_QT_VERSION 5.11.0) +set(REQUIRED_QT_VERSION 5.12.0) # Required Qt5 components to build this framework find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core DBus Network) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/CMakeLists.txt new/bluez-qt-5.66.0/autotests/CMakeLists.txt --- old/bluez-qt-5.65.0/autotests/CMakeLists.txt 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/CMakeLists.txt 2020-01-04 00:09:10.000000000 +0100 @@ -8,6 +8,7 @@ qt5_add_dbus_interface(bluezqt_autotests_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.freedesktop.DBus.Properties.xml dbusproperties_tst) qt5_add_dbus_interface(bluezqt_autotests_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Adapter1.xml bluezadapter1_tst) +qt5_add_dbus_interface(bluezqt_autotests_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Battery1.xml bluezbattery1_tst) qt5_add_dbus_interface(bluezqt_autotests_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Device1.xml bluezdevice1_tst) qt5_add_dbus_interface(bluezqt_autotests_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.MediaPlayer1.xml bluezmediaplayer1_tst) qt5_add_dbus_interface(bluezqt_autotests_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.MediaTransport1.xml bluezmediatransport1_tst) @@ -28,6 +29,7 @@ agentmanagertest obexmanagertest adaptertest + batterytest devicetest inputtest mediaplayertest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/autotests.cpp new/bluez-qt-5.66.0/autotests/autotests.cpp --- old/bluez-qt-5.65.0/autotests/autotests.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/autotests.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -21,6 +21,7 @@ #include "autotests.h" #include "device.h" #include "adapter.h" +#include "battery.h" #include "mediaplayer.h" #include "mediaplayertrack.h" #include "mediatransport.h" @@ -176,6 +177,7 @@ { qRegisterMetaType<BluezQt::DevicePtr>("DevicePtr"); qRegisterMetaType<BluezQt::AdapterPtr>("AdapterPtr"); + qRegisterMetaType<BluezQt::BatteryPtr>("BatteryPtr"); qRegisterMetaType<BluezQt::MediaPlayerPtr>("MediaPlayerPtr"); qRegisterMetaType<BluezQt::MediaTransportPtr>("MediaTransportPtr"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/batterytest.cpp new/bluez-qt-5.66.0/autotests/batterytest.cpp --- old/bluez-qt-5.65.0/autotests/batterytest.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/batterytest.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "batterytest.h" +#include "autotests.h" +#include "pendingcall.h" +#include "initmanagerjob.h" + +#include <QTest> + +namespace BluezQt +{ +extern void bluezqt_initFakeBluezTestRun(); +} + +using namespace BluezQt; + +BatteryTest::BatteryTest() + : m_manager(nullptr) +{ + Autotests::registerMetatypes(); +} + +void BatteryTest::initTestCase() +{ + QDBusConnection connection = QDBusConnection::sessionBus(); + QString service = QStringLiteral("org.kde.bluezqt.fakebluez"); + + bluezqt_initFakeBluezTestRun(); + + FakeBluez::start(); + FakeBluez::runTest(QStringLiteral("bluez-standard")); + + // Create adapter + QString adapter = QStringLiteral("/org/bluez/hci0"); + QVariantMap adapterProps; + adapterProps[QStringLiteral("Path")] = QVariant::fromValue(QDBusObjectPath(adapter)); + adapterProps[QStringLiteral("Address")] = QStringLiteral("1C:E5:C3:BC:94:7E"); + adapterProps[QStringLiteral("Name")] = QStringLiteral("TestAdapter"); + FakeBluez::runAction(QStringLiteral("devicemanager"), QStringLiteral("create-adapter"), adapterProps); + + // Create devices + QVariantMap deviceProps; + QVariantMap batteryProps; + + QString device1 = adapter + QLatin1String("/dev_40_79_6A_0C_39_75"); + deviceProps[QStringLiteral("Path")] = QVariant::fromValue(QDBusObjectPath(device1)); + deviceProps[QStringLiteral("Adapter")] = QVariant::fromValue(QDBusObjectPath(adapter)); + deviceProps[QStringLiteral("Address")] = QStringLiteral("40:79:6A:0C:39:75"); + deviceProps[QStringLiteral("Name")] = QStringLiteral("TestDevice"); + deviceProps[QStringLiteral("UUIDs")] = QStringList(QStringLiteral("00001124-0000-1000-8000-00805F9B34FB")); + batteryProps[QStringLiteral("Percentage")] = uchar(42); + deviceProps[QStringLiteral("Battery")] = batteryProps; + FakeBluez::runAction(QStringLiteral("devicemanager"), QStringLiteral("create-device"), deviceProps); + + QString device2 = adapter + QLatin1String("/dev_50_79_6A_0C_39_75"); + deviceProps[QStringLiteral("Path")] = QVariant::fromValue(QDBusObjectPath(device2)); + deviceProps[QStringLiteral("Adapter")] = QVariant::fromValue(QDBusObjectPath(adapter)); + deviceProps[QStringLiteral("Address")] = QStringLiteral("50:79:6A:0C:39:75"); + deviceProps[QStringLiteral("Name")] = QStringLiteral("TestDevice2"); + deviceProps[QStringLiteral("UUIDs")] = QStringList(QStringLiteral("00001124-0000-1000-8000-00805F9B34FB")); + batteryProps[QStringLiteral("Percentage")] = uchar(0); + deviceProps[QStringLiteral("Battery")] = batteryProps; + FakeBluez::runAction(QStringLiteral("devicemanager"), QStringLiteral("create-device"), deviceProps); + + QString device3 = adapter + QLatin1String("/dev_60_79_6B_0C_39_55"); + deviceProps[QStringLiteral("Path")] = QVariant::fromValue(QDBusObjectPath(device3)); + deviceProps[QStringLiteral("Adapter")] = QVariant::fromValue(QDBusObjectPath(adapter)); + deviceProps[QStringLiteral("Address")] = QStringLiteral("60:79:6B:0C:39:55"); + deviceProps[QStringLiteral("Name")] = QStringLiteral("TestDevice3"); + deviceProps[QStringLiteral("UUIDs")] = QStringList(QStringLiteral("00001124-0000-1000-8000-00805F9B34FB")); + batteryProps[QStringLiteral("Percentage")] = uchar(99); + deviceProps[QStringLiteral("Battery")] = batteryProps; + FakeBluez::runAction(QStringLiteral("devicemanager"), QStringLiteral("create-device"), deviceProps); + + QString device4 = adapter + QLatin1String("/dev_70_79_6B_0C_39_55"); + deviceProps[QStringLiteral("Path")] = QVariant::fromValue(QDBusObjectPath(device4)); + deviceProps[QStringLiteral("Adapter")] = QVariant::fromValue(QDBusObjectPath(adapter)); + deviceProps[QStringLiteral("Address")] = QStringLiteral("70:79:6B:0C:39:55"); + deviceProps[QStringLiteral("Name")] = QStringLiteral("TestDevice4"); + deviceProps[QStringLiteral("UUIDs")] = QStringList(QStringLiteral("00001124-0000-1000-8000-00805F9B34FB")); + batteryProps[QStringLiteral("Percentage")] = uchar(100); + deviceProps[QStringLiteral("Battery")] = batteryProps; + FakeBluez::runAction(QStringLiteral("devicemanager"), QStringLiteral("create-device"), deviceProps); + + m_manager = new Manager(); + InitManagerJob *initJob = m_manager->init(); + initJob->exec(); + QVERIFY(!initJob->error()); + + for (DevicePtr device : m_manager->devices()) { + QVERIFY(device->battery()); + + BatteryUnit u; + u.device = device; + u.dbusBattery = new org::bluez::Battery1(service, + device->ubi(), + connection, + this); + m_units.append(u); + } + + QCOMPARE(m_manager->adapters().count(), 1); + QCOMPARE(m_manager->devices().count(), 4); +} + +void BatteryTest::cleanupTestCase() +{ + for (const BatteryUnit &unit : m_units) { + delete unit.dbusBattery; + } + + delete m_manager; + + FakeBluez::stop(); +} + +void BatteryTest::getPropertiesTest() +{ + for (const BatteryUnit &unit : m_units) { + QCOMPARE(unit.device->battery()->percentage(), unit.dbusBattery->percentage()); + } +} + +QTEST_MAIN(BatteryTest) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/batterytest.h new/bluez-qt-5.66.0/autotests/batterytest.h --- old/bluez-qt-5.65.0/autotests/batterytest.h 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/batterytest.h 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BATTERYTEST_H +#define BATTERYTEST_H + +#include <QObject> + +#include "bluezbattery1_tst.h" + +#include "manager.h" +#include "device.h" +#include "battery.h" + +class BatteryTest : public QObject +{ + Q_OBJECT + +public: + explicit BatteryTest(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + + void getPropertiesTest(); + +private: + struct BatteryUnit + { + BluezQt::DevicePtr device; + org::bluez::Battery1 *dbusBattery; + }; + + BluezQt::Manager *m_manager; + QList<BatteryUnit> m_units; +}; + +#endif // BATTERYTEST_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/fakebluez/CMakeLists.txt new/bluez-qt-5.66.0/autotests/fakebluez/CMakeLists.txt --- old/bluez-qt-5.65.0/autotests/fakebluez/CMakeLists.txt 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/fakebluez/CMakeLists.txt 2020-01-04 00:09:10.000000000 +0100 @@ -9,6 +9,7 @@ devicemanager.cpp adapterinterface.cpp deviceinterface.cpp + batteryinterface.cpp inputinterface.cpp mediaplayerinterface.cpp mediatransportinterface.cpp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/fakebluez/batteryinterface.cpp new/bluez-qt-5.66.0/autotests/fakebluez/batteryinterface.cpp --- old/bluez-qt-5.65.0/autotests/fakebluez/batteryinterface.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/fakebluez/batteryinterface.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "batteryinterface.h" + +#include <QDBusConnection> + +// BatteryObject +BatteryObject::BatteryObject(const QDBusObjectPath &path, QObject *parent) + : QObject(parent) +{ + QDBusConnection::sessionBus().registerObject(path.path(), this); +} + +// BatteryInterface +BatteryInterface::BatteryInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + setPath(path); + setObjectParent(parent); + setProperties(properties); + setName(QStringLiteral("org.bluez.Battery1")); +} + +uchar BatteryInterface::percentage() const +{ + return Object::property(QStringLiteral("Percentage")).value<uchar>(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/fakebluez/batteryinterface.h new/bluez-qt-5.66.0/autotests/fakebluez/batteryinterface.h --- old/bluez-qt-5.65.0/autotests/fakebluez/batteryinterface.h 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/fakebluez/batteryinterface.h 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BATTERYINTERFACE_H +#define BATTERYINTERFACE_H + +#include "object.h" + +#include <QDBusAbstractAdaptor> + +class QDBusMessage; +class QDBusObjectPath; + +class BatteryObject : public QObject +{ +public: + explicit BatteryObject(const QDBusObjectPath &path, QObject *parent = nullptr); +}; + +class BatteryInterface : public QDBusAbstractAdaptor, public Object +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.bluez.Battery1") + Q_PROPERTY(uchar Percentage READ percentage) + +public: + explicit BatteryInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent = nullptr); + + uchar percentage() const; +}; + +#endif // BATTERYINTERFACE_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/fakebluez/deviceinterface.cpp new/bluez-qt-5.66.0/autotests/fakebluez/deviceinterface.cpp --- old/bluez-qt-5.65.0/autotests/fakebluez/deviceinterface.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/fakebluez/deviceinterface.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -20,6 +20,7 @@ #include "deviceinterface.h" #include "objectmanager.h" +#include "batteryinterface.h" #include "mediaplayerinterface.h" #include "mediatransportinterface.h" #include "inputinterface.h" @@ -50,6 +51,19 @@ // Alias needs special handling setAlias(properties.value(QStringLiteral("Alias")).toString()); + // Create Battery1 + if (properties.contains(QStringLiteral("Battery"))) { + const QVariantMap &inputProps = qdbus_cast<QVariantMap>(properties.value(QStringLiteral("Battery"))); + BatteryInterface *input = new BatteryInterface(path, inputProps, parent); + + ObjectManager *manager = ObjectManager::self(); + manager->addObject(input); + + QVariantMap props = properties; + props.remove(QStringLiteral("Battery")); + setProperties(props); + } + // Create Input1 if (properties.contains(QStringLiteral("Input"))) { const QVariantMap &inputProps = qdbus_cast<QVariantMap>(properties.value(QStringLiteral("Input"))); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/autotests/interfaces/org.bluez.Battery1.xml new/bluez-qt-5.66.0/autotests/interfaces/org.bluez.Battery1.xml --- old/bluez-qt-5.65.0/autotests/interfaces/org.bluez.Battery1.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/autotests/interfaces/org.bluez.Battery1.xml 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.bluez.Battery1"> + <property name="Percentage" type="y" access="read"/> + </interface> +</node> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/CMakeLists.txt new/bluez-qt-5.66.0/src/CMakeLists.txt --- old/bluez-qt-5.65.0/src/CMakeLists.txt 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/CMakeLists.txt 2020-01-04 00:09:10.000000000 +0100 @@ -4,6 +4,7 @@ manager_p.cpp adapter.cpp adapter_p.cpp + battery.cpp device.cpp device_p.cpp gattapplication.cpp @@ -67,6 +68,7 @@ qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.freedesktop.DBus.Properties.xml dbusproperties) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Adapter1.xml bluezadapter1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.AgentManager1.xml bluezagentmanager1) +qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.Battery1.xml bluezbattery1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.GattCharacteristic1.xml bluezgattcharacteristic1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.GattManager1.xml bluezgattmanager1) qt5_add_dbus_interface(bluezqt_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.bluez.ProfileManager1.xml bluezprofilemanager1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/battery.cpp new/bluez-qt-5.66.0/src/battery.cpp --- old/bluez-qt-5.65.0/src/battery.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/src/battery.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,80 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "battery.h" +#include "battery_p.h" +#include "utils.h" +#include "macros.h" + +#include <QVariantMap> + +namespace BluezQt +{ + +BatteryPrivate::BatteryPrivate(const QString &path, const QVariantMap &properties) + : QObject() + , m_path(path) +{ + // Init properties + m_percentage = properties.value(QStringLiteral("Percentage")).toInt(); +} + +void BatteryPrivate::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated) +{ + Q_UNUSED(invalidated) + + if (interface != Strings::orgBluezBattery1()) { + return; + } + + QVariantMap::const_iterator i; + for (i = changed.constBegin(); i != changed.constEnd(); ++i) { + const QVariant &value = i.value(); + const QString &property = i.key(); + + if (property == QLatin1String("Percentage")) { + PROPERTY_CHANGED2(m_percentage, value.toInt(), percentageChanged) + } + } +} + +Battery::Battery(const QString &path, const QVariantMap &properties) + : d(new BatteryPrivate(path, properties)) +{ +} + +Battery::~Battery() +{ + delete d; +} + +BatteryPtr Battery::toSharedPtr() const +{ + return d->q.toStrongRef(); +} + +int Battery::percentage() const +{ + return d->m_percentage; +} + +} // namespace BluezQt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/battery.h new/bluez-qt-5.66.0/src/battery.h --- old/bluez-qt-5.65.0/src/battery.h 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/src/battery.h 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,83 @@ +/* + * BluezQt - Asynchronous BlueZ wrapper library + * + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BLUEZQT_BATTERY_H +#define BLUEZQT_BATTERY_H + +#include <QObject> + +#include "types.h" +#include "bluezqt_export.h" + +namespace BluezQt +{ + +/** + * @class BluezQt::Battery battery.h <BluezQt/Battery> + * + * %Device battery. + * + * This class represents a battery interface. + */ +class BLUEZQT_EXPORT Battery : public QObject +{ + Q_OBJECT + Q_PROPERTY(int percentage READ percentage NOTIFY percentageChanged) + +public: + /** + * Destroys a Battery object. + */ + ~Battery(); + + /** + * Returns a shared pointer from this. + * + * @return BatteryPtr + */ + BatteryPtr toSharedPtr() const; + + /** + * Returns the battery percentage. + * + * @return battery percentage + */ + int percentage() const; + +Q_SIGNALS: + /** + * Indicates that battery's percentage has changed. + */ + void percentageChanged(int percentage); + +private: + explicit Battery(const QString &path, const QVariantMap &properties); + + class BatteryPrivate *const d; + + friend class BatteryPrivate; + friend class DevicePrivate; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_BATTERY_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/battery_p.h new/bluez-qt-5.66.0/src/battery_p.h --- old/bluez-qt-5.65.0/src/battery_p.h 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/src/battery_p.h 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,50 @@ +/* + * BluezQt - Asynchronous Bluez wrapper library + * + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BLUEZQT_BATTERY_P_H +#define BLUEZQT_BATTERY_P_H + +#include <QObject> + +#include "battery.h" + +namespace BluezQt +{ + +class BatteryPrivate : public QObject +{ + Q_OBJECT + +public: + explicit BatteryPrivate(const QString &path, const QVariantMap &properties); + + void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated); + + QWeakPointer<Battery> q; + + QString m_path; + int m_percentage = 0; +}; + +} // namespace BluezQt + +#endif // BLUEZQT_BATTERY_P_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/device.cpp new/bluez-qt-5.66.0/src/device.cpp --- old/bluez-qt-5.65.0/src/device.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/device.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -164,6 +164,11 @@ return d->m_modalias; } +BatteryPtr Device::battery() const +{ + return d->m_battery; +} + InputPtr Device::input() const { return d->m_input; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/device.h new/bluez-qt-5.66.0/src/device.h --- old/bluez-qt-5.65.0/src/device.h 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/device.h 2020-01-04 00:09:10.000000000 +0100 @@ -62,6 +62,7 @@ Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged) Q_PROPERTY(QStringList uuids READ uuids NOTIFY uuidsChanged) Q_PROPERTY(QString modalias READ modalias NOTIFY modaliasChanged) + Q_PROPERTY(BatteryPtr battery READ battery NOTIFY batteryChanged) Q_PROPERTY(InputPtr input READ input NOTIFY inputChanged) Q_PROPERTY(MediaPlayerPtr mediaPlayer READ mediaPlayer NOTIFY mediaPlayerChanged) Q_PROPERTY(MediaTransportPtr mediaTransport READ mediaTransport NOTIFY mediaTransportChanged) @@ -298,6 +299,14 @@ QString modalias() const; /** + * Returns the battery interface for the device. + * + * @return null if device has no battery + * @since 5.66 + */ + BatteryPtr battery() const; + + /** * Returns the input interface for the device. * * Only input devices will have valid input interface. @@ -510,6 +519,11 @@ void modaliasChanged(const QString &modalias); /** + * Indicates that device's battery has changed. + */ + void batteryChanged(BatteryPtr battery); + + /** * Indicates that device's input have changed. */ void inputChanged(InputPtr input); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/device_p.cpp new/bluez-qt-5.66.0/src/device_p.cpp --- old/bluez-qt-5.65.0/src/device_p.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/device_p.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -23,6 +23,8 @@ #include "device_p.h" #include "device.h" #include "adapter.h" +#include "battery.h" +#include "battery_p.h" #include "input.h" #include "input_p.h" #include "mediaplayer.h" @@ -87,7 +89,12 @@ QVariantMapMap::const_iterator it; for (it = interfaces.constBegin(); it != interfaces.constEnd(); ++it) { - if (it.key() == Strings::orgBluezInput1()) { + if (it.key() == Strings::orgBluezBattery1()) { + m_battery = BatteryPtr(new Battery(path, it.value())); + m_battery->d->q = m_battery.toWeakRef(); + Q_EMIT q.lock()->batteryChanged(m_battery); + changed = true; + } else if (it.key() == Strings::orgBluezInput1()) { m_input = InputPtr(new Input(path, it.value())); m_input->d->q = m_input.toWeakRef(); Q_EMIT q.lock()->inputChanged(m_input); @@ -115,7 +122,11 @@ bool changed = false; for (const QString &interface : interfaces) { - if (interface == Strings::orgBluezInput1() && m_input && m_input->d->m_path == path) { + if (interface == Strings::orgBluezBattery1() && m_battery && m_battery->d->m_path == path) { + m_battery.clear(); + Q_EMIT q.lock()->batteryChanged(m_battery); + changed = true; + } else if (interface == Strings::orgBluezInput1() && m_input && m_input->d->m_path == path) { m_input.clear(); Q_EMIT q.lock()->inputChanged(m_input); changed = true; @@ -142,7 +153,9 @@ void DevicePrivate::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated) { - if (interface == Strings::orgBluezInput1() && m_input) { + if (interface == Strings::orgBluezBattery1() && m_battery) { + m_battery->d->propertiesChanged(interface, changed, invalidated); + } else if (interface == Strings::orgBluezInput1() && m_input) { m_input->d->propertiesChanged(interface, changed, invalidated); } else if (interface == Strings::orgBluezMediaPlayer1() && m_mediaPlayer) { m_mediaPlayer->d->propertiesChanged(interface, changed, invalidated); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/device_p.h new/bluez-qt-5.66.0/src/device_p.h --- old/bluez-qt-5.65.0/src/device_p.h 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/device_p.h 2020-01-04 00:09:10.000000000 +0100 @@ -74,6 +74,7 @@ bool m_connected; QStringList m_uuids; QString m_modalias; + BatteryPtr m_battery; InputPtr m_input; MediaPlayerPtr m_mediaPlayer; MediaTransportPtr m_mediaTransport; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/CMakeLists.txt new/bluez-qt-5.66.0/src/imports/CMakeLists.txt --- old/bluez-qt-5.65.0/src/imports/CMakeLists.txt 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/CMakeLists.txt 2020-01-04 00:09:10.000000000 +0100 @@ -1,6 +1,7 @@ set(bluezqtextensionplugin_SRCS declarativemanager.cpp declarativeadapter.cpp + declarativebattery.cpp declarativedevice.cpp declarativeinput.cpp declarativemediaplayer.cpp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/bluezqtextensionplugin.cpp new/bluez-qt-5.66.0/src/imports/bluezqtextensionplugin.cpp --- old/bluez-qt-5.65.0/src/imports/bluezqtextensionplugin.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/bluezqtextensionplugin.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -23,6 +23,7 @@ #include "bluezqtextensionplugin.h" #include "declarativemanager.h" #include "declarativeadapter.h" +#include "declarativebattery.h" #include "declarativedevice.h" #include "declarativeinput.h" #include "declarativemediaplayer.h" @@ -78,6 +79,7 @@ qmlRegisterSingletonType<DeclarativeManager>(uri, 1, 0, "Manager", manager_singleton); qmlRegisterType<DeclarativeDevicesModel>(uri, 1, 0, "DevicesModelPrivate"); qmlRegisterUncreatableType<DeclarativeAdapter>(uri, 1, 0, "Adapter", QStringLiteral("Adapter cannot be created")); + qmlRegisterUncreatableType<DeclarativeBattery>(uri, 1, 0, "Battery", QStringLiteral("Battery cannot be created")); qmlRegisterUncreatableType<DeclarativeDevice>(uri, 1, 0, "Device", QStringLiteral("Device cannot be created")); qmlRegisterUncreatableType<DeclarativeInput>(uri, 1, 0, "Input", QStringLiteral("Input cannot be created")); qmlRegisterUncreatableType<DeclarativeMediaPlayer>(uri, 1, 0, "MediaPlayer", QStringLiteral("MediaPlayer cannot be created")); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/declarativebattery.cpp new/bluez-qt-5.66.0/src/imports/declarativebattery.cpp --- old/bluez-qt-5.65.0/src/imports/declarativebattery.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/declarativebattery.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,35 @@ +/* + * BluezQt - Asynchronous BlueZ wrapper library + * + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "declarativebattery.h" + +DeclarativeBattery::DeclarativeBattery(const BluezQt::BatteryPtr &battery, QObject *parent) + : QObject(parent) + , m_battery(battery) +{ + connect(m_battery.data(), &BluezQt::Battery::percentageChanged, this, &DeclarativeBattery::percentageChanged); +} + +int DeclarativeBattery::percentage() const +{ + return m_battery->percentage(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/declarativebattery.h new/bluez-qt-5.66.0/src/imports/declarativebattery.h --- old/bluez-qt-5.65.0/src/imports/declarativebattery.h 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/declarativebattery.h 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,45 @@ +/* + * BluezQt - Asynchronous BlueZ wrapper library + * + * Copyright (C) 2019 Kai Uwe Broulik <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef DECLARATIVEBATTERY_H +#define DECLARATIVEBATTERY_H + +#include "battery.h" + +class DeclarativeBattery : public QObject +{ + Q_OBJECT + Q_PROPERTY(int percentage READ percentage NOTIFY percentageChanged) + +public: + explicit DeclarativeBattery(const BluezQt::BatteryPtr &battery, QObject *parent = nullptr); + + int percentage() const; + +Q_SIGNALS: + void percentageChanged(int percentage); + +private: + BluezQt::BatteryPtr m_battery; +}; + +#endif // DECLARATIVEBATTERY_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/declarativedevice.cpp new/bluez-qt-5.66.0/src/imports/declarativedevice.cpp --- old/bluez-qt-5.65.0/src/imports/declarativedevice.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/declarativedevice.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -22,6 +22,7 @@ #include "declarativedevice.h" #include "declarativeadapter.h" +#include "declarativebattery.h" #include "declarativeinput.h" #include "declarativemediaplayer.h" @@ -31,6 +32,7 @@ : QObject(adapter) , m_device(device) , m_adapter(adapter) + , m_battery(nullptr) , m_input(nullptr) , m_mediaPlayer(nullptr) { @@ -51,6 +53,7 @@ connect(m_device.data(), &BluezQt::Device::modaliasChanged, this, &DeclarativeDevice::modaliasChanged); connect(m_device.data(), &BluezQt::Device::mediaPlayerChanged, this, &DeclarativeDevice::updateMediaPlayer); connect(m_device.data(), &BluezQt::Device::inputChanged, this, &DeclarativeDevice::updateInput); + connect(m_device.data(), &BluezQt::Device::batteryChanged, this, &DeclarativeDevice::updateBattery); connect(m_device.data(), &BluezQt::Device::deviceRemoved, this, [this]() { Q_EMIT deviceRemoved(this); @@ -164,6 +167,11 @@ return m_device->modalias(); } +DeclarativeBattery *DeclarativeDevice::battery() const +{ + return m_battery; +} + DeclarativeInput *DeclarativeDevice::input() const { return m_input; @@ -209,6 +217,20 @@ return m_device->cancelPairing(); } +void DeclarativeDevice::updateBattery() +{ + if (m_battery) { + m_battery->deleteLater(); + m_battery = nullptr; + } + + if (m_device->battery()) { + m_battery = new DeclarativeBattery(m_device->battery(), this); + } + + Q_EMIT batteryChanged(m_battery); +} + void DeclarativeDevice::updateInput() { if (m_input) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/declarativedevice.h new/bluez-qt-5.66.0/src/imports/declarativedevice.h --- old/bluez-qt-5.65.0/src/imports/declarativedevice.h 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/declarativedevice.h 2020-01-04 00:09:10.000000000 +0100 @@ -26,6 +26,7 @@ #include "device.h" class DeclarativeAdapter; +class DeclarativeBattery; class DeclarativeInput; class DeclarativeMediaPlayer; @@ -94,6 +95,8 @@ QString modalias() const; + DeclarativeBattery *battery() const; + DeclarativeInput *input() const; DeclarativeMediaPlayer *mediaPlayer() const; @@ -126,15 +129,18 @@ void connectedChanged(bool connected); void uuidsChanged(const QStringList &uuids); void modaliasChanged(const QString &modalias); + void batteryChanged(DeclarativeBattery *battery); void inputChanged(DeclarativeInput *input); void mediaPlayerChanged(DeclarativeMediaPlayer *mediaPlayer); private: + void updateBattery(); void updateInput(); void updateMediaPlayer(); BluezQt::DevicePtr m_device; DeclarativeAdapter *m_adapter; + DeclarativeBattery *m_battery; DeclarativeInput *m_input; DeclarativeMediaPlayer *m_mediaPlayer; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/declarativedevicesmodel.cpp new/bluez-qt-5.66.0/src/imports/declarativedevicesmodel.cpp --- old/bluez-qt-5.65.0/src/imports/declarativedevicesmodel.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/declarativedevicesmodel.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -23,6 +23,7 @@ #include "declarativedevicesmodel.h" #include "declarativemanager.h" #include "declarativeadapter.h" +#include "declarativebattery.h" #include "declarativedevice.h" #include "declarativemediaplayer.h" @@ -52,6 +53,7 @@ roles[DeviceRole] = QByteArrayLiteral("Device"); roles[AdapterRole] = QByteArrayLiteral("Adapter"); roles[MediaPlayerRole] = QByteArrayLiteral("MediaPlayer"); + roles[BatteryRole] = QByteArrayLiteral("Battery"); return roles; } @@ -76,9 +78,13 @@ if (DeclarativeDevice *device = m_manager->declarativeDeviceFromPtr(dev)) { return QVariant::fromValue(device->mediaPlayer()); } - // fallthrough - Q_FALLTHROUGH(); - default: - return QSortFilterProxyModel::data(index, role); + break; + case BatteryRole: + if (DeclarativeDevice *device = m_manager->declarativeDeviceFromPtr(dev)) { + return QVariant::fromValue(device->battery()); + } + break; } + + return QSortFilterProxyModel::data(index, role); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/imports/declarativedevicesmodel.h new/bluez-qt-5.66.0/src/imports/declarativedevicesmodel.h --- old/bluez-qt-5.65.0/src/imports/declarativedevicesmodel.h 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/imports/declarativedevicesmodel.h 2020-01-04 00:09:10.000000000 +0100 @@ -38,7 +38,8 @@ enum DeclarativeDeviceRoles { DeviceRole = BluezQt::DevicesModel::LastRole + 1, AdapterRole = BluezQt::DevicesModel::LastRole + 2, - MediaPlayerRole = BluezQt::DevicesModel::LastRole + 3 + MediaPlayerRole = BluezQt::DevicesModel::LastRole + 3, + BatteryRole = BluezQt::DevicesModel::LastRole + 4 }; explicit DeclarativeDevicesModel(QObject *parent = nullptr); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/interfaces/org.bluez.Battery1.xml new/bluez-qt-5.66.0/src/interfaces/org.bluez.Battery1.xml --- old/bluez-qt-5.65.0/src/interfaces/org.bluez.Battery1.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/bluez-qt-5.66.0/src/interfaces/org.bluez.Battery1.xml 2020-01-04 00:09:10.000000000 +0100 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.bluez.Battery1"> + <property name="Percentage" type="y" access="read"/> + </interface> +</node> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/types.h new/bluez-qt-5.66.0/src/types.h --- old/bluez-qt-5.65.0/src/types.h 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/types.h 2020-01-04 00:09:10.000000000 +0100 @@ -30,6 +30,7 @@ class Manager; class Adapter; +class Battery; class Device; class Input; class GattManager; @@ -55,6 +56,7 @@ typedef QSharedPointer<BluezQt::Manager> ManagerPtr; typedef QSharedPointer<BluezQt::Adapter> AdapterPtr; +typedef QSharedPointer<BluezQt::Battery> BatteryPtr; typedef QSharedPointer<BluezQt::Device> DevicePtr; typedef QSharedPointer<BluezQt::Input> InputPtr; typedef QSharedPointer<BluezQt::GattManager> GattManagerPtr; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/utils.cpp new/bluez-qt-5.66.0/src/utils.cpp --- old/bluez-qt-5.65.0/src/utils.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/utils.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -42,6 +42,7 @@ QString orgFreedesktopDBusProperties; QString orgBluez; QString orgBluezAdapter1; + QString orgBluezBattery1; QString orgBluezDevice1; QString orgBluezInput1; QString orgBluezGattManager1; @@ -67,6 +68,7 @@ orgFreedesktopDBusProperties = QStringLiteral("org.freedesktop.DBus.Properties"); orgBluez = QStringLiteral("org.bluez"); orgBluezAdapter1 = QStringLiteral("org.bluez.Adapter1"); + orgBluezBattery1 = QStringLiteral("org.bluez.Battery1"); orgBluezDevice1 = QStringLiteral("org.bluez.Device1"); orgBluezInput1 = QStringLiteral("org.bluez.Input1"); orgBluezGattManager1 = QStringLiteral("org.bluez.GattManager1"); @@ -113,6 +115,11 @@ return globalData->orgBluezAdapter1; } +QString Strings::orgBluezBattery1() +{ + return globalData->orgBluezBattery1; +} + QString Strings::orgBluezDevice1() { return globalData->orgBluezDevice1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/src/utils.h new/bluez-qt-5.66.0/src/utils.h --- old/bluez-qt-5.65.0/src/utils.h 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/src/utils.h 2020-01-04 00:09:10.000000000 +0100 @@ -39,6 +39,7 @@ QString orgFreedesktopDBusProperties(); QString orgBluez(); QString orgBluezAdapter1(); +QString orgBluezBattery1(); QString orgBluezDevice1(); QString orgBluezInput1(); QString orgBluezGattManager1(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/tools/bluezapi2qt/CppGenerator.cpp new/bluez-qt-5.66.0/tools/bluezapi2qt/CppGenerator.cpp --- old/bluez-qt-5.65.0/tools/bluezapi2qt/CppGenerator.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/tools/bluezapi2qt/CppGenerator.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -20,10 +20,11 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ -#include "CppGenerator.h" - #include <QDebug> #include <QFile> +#include <QRegularExpression> + +#include "CppGenerator.h" #include "BluezApiParser.h" #include "TypeAnnotation.h" @@ -204,7 +205,8 @@ QString CppGenerator::interfaceToClassName(const QString &interface) { - auto className = interface.mid(interface.lastIndexOf(QRegExp(QStringLiteral("\\.[A-Z]\\w+")))+1); + const int index = interface.lastIndexOf(QRegularExpression(QStringLiteral("\\.[A-Z]\\w+"))) + 1; + auto className = interface.mid(index); while (className.back() > L'0' && className.back() <= L'9') { className.remove(className.size()-1, 1); } @@ -217,10 +219,11 @@ QString str(string); //str.replace(0, 1, string.at(0).toLower()); - QRegExp rx(QStringLiteral("^([A-Z]+)"), Qt::CaseSensitive, QRegExp::RegExp2); - if (rx.indexIn(string) != -1) { - QString caps = rx.capturedTexts().last(); - for (int i = 0; i < caps.size()-1; ++i) { + const QRegularExpression rx(QStringLiteral("^([A-Z]+)")); + QRegularExpressionMatch match = rx.match(string); + if (match.hasMatch()) { + QString matchedStr = match.captured(); + for (int i = 0; i < matchedStr.size() - 1; ++i) { str.replace(i, 1, str.at(i).toLower()); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/tools/bluezapi2qt/Interface.cpp new/bluez-qt-5.66.0/tools/bluezapi2qt/Interface.cpp --- old/bluez-qt-5.65.0/tools/bluezapi2qt/Interface.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/tools/bluezapi2qt/Interface.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -22,6 +22,8 @@ #include "Interface.h" +#include <QRegularExpression> + Interface::Interface() { } @@ -123,25 +125,28 @@ void Interface::parseService(const QString &line) { - QRegExp rx(QStringLiteral("Service\\t+(.+)"), Qt::CaseSensitive, QRegExp::RegExp2); - if (rx.indexIn(line) != -1) { - m_service = rx.capturedTexts().last(); + const QRegularExpression rx(QStringLiteral("Service\\t+(.+)")); + QRegularExpressionMatch match = rx.match(line); + if (match.hasMatch()) { + m_service = match.captured(); } } void Interface::parseInterface(const QString &line) { - QRegExp rx(QStringLiteral("Interface\\t+(.+)"), Qt::CaseSensitive, QRegExp::RegExp2); - if (rx.indexIn(line) != -1) { - m_name = rx.capturedTexts().last(); + const QRegularExpression rx(QStringLiteral("Interface\\t+(.+)")); + QRegularExpressionMatch match = rx.match(line); + if (match.hasMatch()) { + m_name = match.captured(); } } void Interface::parseObjectPath(const QString &line) { - QRegExp rx(QStringLiteral("Object path\\t+(.+)"), Qt::CaseSensitive, QRegExp::RegExp2); - if (rx.indexIn(line) != -1) { - m_objectPath = rx.capturedTexts().last(); + const QRegularExpression rx(QStringLiteral("Object path\\t+(.+)")); + QRegularExpressionMatch match = rx.match(line); + if (match.hasMatch()) { + m_objectPath = match.captured(); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/tools/bluezapi2qt/Method.cpp new/bluez-qt-5.66.0/tools/bluezapi2qt/Method.cpp --- old/bluez-qt-5.65.0/tools/bluezapi2qt/Method.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/tools/bluezapi2qt/Method.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -20,6 +20,8 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ +#include <QRegularExpression> + #include "Method.h" Method::Method() @@ -101,11 +103,11 @@ return QString(); } - QRegExp rx(QStringLiteral("([A-Z][a-z0-9]+)+")); - if (rx.indexIn(m_name, 1) == -1) { + const QRegularExpression rx(QStringLiteral("([A-Z][a-z0-9]+)+")); + QRegularExpressionMatch match = rx.match(m_name, 1); + if (!match.hasMatch()) { return QStringLiteral("value"); } - QStringList list = rx.capturedTexts(); - return list.last().toLower(); + return match.captured().toLower(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/tools/bluezapi2qt/Methods.cpp new/bluez-qt-5.66.0/tools/bluezapi2qt/Methods.cpp --- old/bluez-qt-5.65.0/tools/bluezapi2qt/Methods.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/tools/bluezapi2qt/Methods.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -23,6 +23,16 @@ #include "Methods.h" #include <QStringList> +#include <QRegularExpression> + +static const QRegularExpression rx(QStringLiteral( + "\\t+" // preceding tabs + "(?:(.+) )?" // return types - Argh! LE Advertising Manager does not specify return type + "([A-Z]\\w+)" // method name + "\\(([^\\)]*)\\)" // parameters + "(?: \\[(.*)\\])?" // tags + "(?: \\((.*)\\))?" // limitations + ), QRegularExpression::CaseInsensitiveOption); Methods::Methods() { @@ -30,40 +40,22 @@ bool Methods::isMethod(const QString &line) { - QRegExp rx(QStringLiteral( - "\\t+" // preceding tabs - "(?:(.+) )?" // return types - Argh! LE Advertising Manager does not specify return type - "([A-Z]\\w+)" // method name - "\\(([^\\)]*)\\)" // parameters - "(?: \\[(.*)\\])?" // tags - "(?: \\((.*)\\))?" // limitations - ), Qt::CaseInsensitive, QRegExp::RegExp2); - // Check if we match a method - return (rx.indexIn(line) != -1); + return (rx.match(line).hasMatch()); } void Methods::parse(const QString &line) { - QRegExp rx(QStringLiteral( - "\\t+" // preceding tabs - "(?:(.+) )?" // return types - Argh! LE Advertising Manager does not specify return type - "([A-Z]\\w+)" // method name - "\\(([^\\)]*)\\)" // parameters - "(?: \\[(.*)\\])?" // tags - "(?: \\((.*)\\))?" // limitations - ), Qt::CaseInsensitive, QRegExp::RegExp2); - // Check if we match a method - if (rx.indexIn(line) != -1) { - QStringList list = rx.capturedTexts(); + QRegularExpressionMatch match = rx.match(line); + if (match.hasMatch()) { m_methods.emplace_back(Method()); m_currentMethod = &m_methods.back(); - m_currentMethod->m_outParameterStrings = list.at(1).toLower().split(QStringLiteral(", "), QString::SkipEmptyParts); - m_currentMethod->m_name = list.at(2); - m_currentMethod->m_inParameterStrings = list.at(3).split(QStringLiteral(", "), QString::SkipEmptyParts); - m_currentMethod->m_stringTags = list.at(4).toLower().split(QStringLiteral(", "), QString::SkipEmptyParts); - m_currentMethod->m_limitation = list.at(5).toLower(); + m_currentMethod->m_outParameterStrings = match.captured(1).toLower().split(QStringLiteral(", "), QString::SkipEmptyParts); + m_currentMethod->m_name = match.captured(2); + m_currentMethod->m_inParameterStrings = match.captured(3).split(QStringLiteral(", "), QString::SkipEmptyParts); + m_currentMethod->m_stringTags = match.captured(4).toLower().split(QStringLiteral(", "), QString::SkipEmptyParts); + m_currentMethod->m_limitation = match.captured(5).toLower(); } else if (m_currentMethod) { // Skip first empty line if (line.isEmpty() && m_currentMethod->m_comment.isEmpty()) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bluez-qt-5.65.0/tools/bluezapi2qt/Properties.cpp new/bluez-qt-5.66.0/tools/bluezapi2qt/Properties.cpp --- old/bluez-qt-5.65.0/tools/bluezapi2qt/Properties.cpp 2019-12-07 20:40:41.000000000 +0100 +++ new/bluez-qt-5.66.0/tools/bluezapi2qt/Properties.cpp 2020-01-04 00:09:10.000000000 +0100 @@ -22,7 +22,7 @@ #include "Properties.h" -#include <QRegExp> +#include <QRegularExpression> #include <QStringList> Properties::Properties() @@ -31,25 +31,25 @@ void Properties::parse(const QString &line) { - QRegExp rx(QStringLiteral( - "(?:Properties|^)" // Properties keyword or start of line - "\\t{1,2}" // preceding tabs (max 2) - "([a-z1-6{}_]+)" // type name - " " // space - "([A-Z]\\w+)" // method name - "(?: \\[(.*)\\])?" // tags - "(?: \\((.*)\\))?" // limitations - ), Qt::CaseSensitive, QRegExp::RegExp2); + const QRegularExpression rx(QStringLiteral( + "(?:Properties|^)" // Properties keyword or start of line + "\\t{1,2}" // preceding tabs (max 2) + "([a-z1-6{}_]+)" // type name + " " // space + "([A-Z]\\w+)" // method name + "(?: \\[(.*)\\])?" // tags + "(?: \\((.*)\\))?" // limitations + ), QRegularExpression::CaseInsensitiveOption); + QRegularExpressionMatch match = rx.match(line); // Check if we match a property - if (rx.indexIn(line) != -1) { - QStringList list = rx.capturedTexts(); + if (match.hasMatch()) { m_properties.emplace_back(Property()); m_currentProperty = &m_properties.back(); - m_currentProperty->m_type = list.at(1).toLower(); - m_currentProperty->m_name = list.at(2); - m_currentProperty->m_stringTags = list.at(3).toLower().split(QStringLiteral(", "), QString::SkipEmptyParts); - m_currentProperty->m_limitation = list.at(4).toLower(); + m_currentProperty->m_type = match.captured(1).toLower(); + m_currentProperty->m_name = match.captured(2); + m_currentProperty->m_stringTags = match.captured(3).toLower().split(QStringLiteral(", "), QString::SkipEmptyParts); + m_currentProperty->m_limitation = match.captured(4).toLower(); } else if (m_currentProperty) { // Skip first empty line if (line.isEmpty() && m_currentProperty->m_comment.isEmpty()) {
