From d9aaed9b40bed5f0abdb20f424bf325478420161 Mon Sep 17 00:00:00 2001
From: Karsten Sperling Opdal <karsten.sperling.opdal@laerdal.com>
Date: Fri, 15 Dec 2023 22:02:44 +0100
Subject: [PATCH] QTBUG-114666 Properties changed now using freedesktop dbus

---
 .../networkmanager/qnetworkmanagerservice.cpp | 97 +++++++++++++------
 .../networkmanager/qnetworkmanagerservice.h   | 14 +--
 2 files changed, 73 insertions(+), 38 deletions(-)

diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
index 2d6cba1791..3abc941207 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -92,18 +92,18 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                   QLatin1String(NM_DBUS_PATH),
-                                  QLatin1String(NM_DBUS_INTERFACE),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QNetworkManagerInterface::~QNetworkManagerInterface()
 {
     QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
                                   QLatin1String(NM_DBUS_PATH),
-                                  QLatin1String(NM_DBUS_INTERFACE),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
     QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
                                   QLatin1String(NM_DBUS_PATH),
                                   QLatin1String(NM_DBUS_INTERFACE),
@@ -123,9 +123,9 @@ bool QNetworkManagerInterface::setConnections()
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                   QLatin1String(NM_DBUS_PATH),
-                                  QLatin1String(NM_DBUS_INTERFACE),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 
     bool allOk = false;
     if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
@@ -226,8 +226,13 @@ QString QNetworkManagerInterface::version() const
     return QString();
 }
 
-void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerInterface::setProperties(const QString &interfaceName,
+                                             const QVariantMap &map,
+                                             const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
         propertyMap.insert(i.key(),i.value());
 
@@ -321,8 +326,13 @@ quint32 QNetworkManagerInterfaceAccessPoint::strength() const
     return 0;
 }
 
-void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerInterfaceAccessPoint::setProperties(const QString &interfaceName,
+                                                        const QVariantMap &map,
+                                                        const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
         propertyMap.insert(i.key(),i.value());
 }
@@ -351,18 +361,18 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                   deviceObjectPath,
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
 {
     QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
                                   path(),
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QString QNetworkManagerInterfaceDevice::udi() const
@@ -407,8 +417,13 @@ QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
     return QDBusObjectPath();
 }
 
-void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerInterfaceDevice::setProperties(const QString &interfaceName,
+                                                   const QVariantMap &map,
+                                                   const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+    
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
         if (i.key() == QLatin1String("AvailableConnections")) { //Device
             const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(i.value());
@@ -450,18 +465,18 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                   ifaceDevicePath,
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
 {
     QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
                                   path(),
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QString QNetworkManagerInterfaceDeviceWired::hwAddress() const
@@ -502,8 +517,13 @@ QStringList QNetworkManagerInterfaceDeviceWired::availableConnections()
     return list;
 }
 
-void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerInterfaceDeviceWired::setProperties(const QString &interfaceName,
+                                              const QVariantMap &map,
+                                              const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
         propertyMap.insert(i.key(),i.value());
         if (i.key() == QLatin1String("Carrier"))
@@ -544,18 +564,18 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                  interfacePath,
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
 {
     QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
                                   path(),
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 bool QNetworkManagerInterfaceDeviceWireless::setConnections()
@@ -614,8 +634,13 @@ void QNetworkManagerInterfaceDeviceWireless::requestScan()
     asyncCall(QLatin1String("RequestScan"));
 }
 
-void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerInterfaceDeviceWireless::setProperties(const QString &interfaceName,
+                                                           const QVariantMap &map,
+                                                           const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
         propertyMap.insert(i.key(),i.value());
         if (i.key() == QLatin1String("ActiveAccessPoint")) //DeviceWireless
@@ -646,9 +671,9 @@ QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const Q
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                   ifaceDevicePath,
-                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem()
@@ -675,8 +700,13 @@ QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceD
     return QNetworkManagerInterfaceDeviceModem::None;
 }
 
-void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerInterfaceDeviceModem::setProperties(const QString &interfaceName,
+                                                        const QVariantMap &map,
+                                                        const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
         propertyMap.insert(i.key(),i.value());
     Q_EMIT propertiesChanged(map);
@@ -914,18 +944,18 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &
 
     QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                   activeConnectionObjectPath,
-                                  QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
 {
     QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
                                   path(),
-                                  QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
+                                  QLatin1String(DBUS_PROPERTIES_INTERFACE),
                                   QLatin1String("PropertiesChanged"),
-                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+                                  this,SLOT(setProperties(QString,QVariantMap,QStringList)));
 }
 
 QDBusObjectPath QNetworkManagerConnectionActive::connection() const
@@ -980,8 +1010,13 @@ bool QNetworkManagerConnectionActive::default6Route() const
     return false;
 }
 
-void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
+void QNetworkManagerConnectionActive::setProperties(const QString &interfaceName,
+                                                    const QVariantMap &map,
+                                                    const QStringList &invalidatedProperties)
 {
+    Q_UNUSED(interfaceName);
+    Q_UNUSED(invalidatedProperties);
+
     for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
         propertyMap.insert(i.key(),i.value());
         if (i.key() == QLatin1String("State")) {
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index bff7a71097..2970d2d57c 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -178,7 +178,7 @@ Q_SIGNALS:
     void devicesListReady();
 
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 
 private:
     QVariantMap propertyMap;
@@ -247,7 +247,7 @@ Q_SIGNALS:
     void propertiesReady();
 
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 
 private:
     QVariantMap propertyMap;
@@ -276,7 +276,7 @@ Q_SIGNALS:
     void connectionsChanged(QStringList);
     void propertiesReady();
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 private:
     QVariantMap propertyMap;
 };
@@ -302,7 +302,7 @@ Q_SIGNALS:
     void carrierChanged(bool);
 
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 
 private:
     QVariantMap propertyMap;
@@ -343,7 +343,7 @@ Q_SIGNALS:
     void propertiesReady();
 
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 
 private:
     QVariantMap propertyMap;
@@ -378,7 +378,7 @@ Q_SIGNALS:
     void propertiesReady();
 
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 
 private:
     QVariantMap propertyMap;
@@ -467,7 +467,7 @@ Q_SIGNALS:
     void propertiesReady();
 
 private Q_SLOTS:
-    void propertiesSwap(QMap<QString,QVariant>);
+    void setProperties(const QString&,const QVariantMap&,const QStringList&);
 
 private:
     QVariantMap propertyMap;
-- 
2.34.1

