|
|
587dbb |
From f419966808475cb6c0f0ba2f63967876218ffdaf Mon Sep 17 00:00:00 2001
|
|
|
587dbb |
From: Julian Andres Klode <julian.klode@canonical.com>
|
|
|
587dbb |
Date: Tue, 12 Oct 2021 12:01:50 +0200
|
|
|
587dbb |
Subject: [PATCH 1/2] gnetworkmonitornm: Stop using removed PropertiesChanged
|
|
|
587dbb |
signal
|
|
|
587dbb |
|
|
|
587dbb |
Use the org.freedesktop.DBus.Properties interface to listen
|
|
|
587dbb |
to PropertiesChanged signals on /org/freedesktop/NetworkManager.
|
|
|
587dbb |
|
|
|
587dbb |
NetworkManager used to provide its own legacy PropertiesChanged
|
|
|
587dbb |
signal, but that was dropped in
|
|
|
587dbb |
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/853
|
|
|
587dbb |
|
|
|
587dbb |
This requires NetworkManager >= 1.2 (2016)
|
|
|
587dbb |
|
|
|
587dbb |
Fixes: #2505
|
|
|
587dbb |
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1946196
|
|
|
587dbb |
---
|
|
|
587dbb |
gio/gnetworkmonitornm.c | 29 +++++++----------------------
|
|
|
587dbb |
1 file changed, 7 insertions(+), 22 deletions(-)
|
|
|
587dbb |
|
|
|
587dbb |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
587dbb |
index 5a36a0ba1..6a6d1d666 100644
|
|
|
587dbb |
--- a/gio/gnetworkmonitornm.c
|
|
|
587dbb |
+++ b/gio/gnetworkmonitornm.c
|
|
|
587dbb |
@@ -267,29 +267,14 @@ update_cached_property (GDBusProxy *proxy,
|
|
|
587dbb |
}
|
|
|
587dbb |
|
|
|
587dbb |
static void
|
|
|
587dbb |
-proxy_signal_cb (GDBusProxy *proxy,
|
|
|
587dbb |
- const gchar *sender_name,
|
|
|
587dbb |
- const gchar *signal_name,
|
|
|
587dbb |
- GVariant *parameters,
|
|
|
587dbb |
- GNetworkMonitorNM *nm)
|
|
|
587dbb |
+proxy_properties_changed_cb (GDBusProxy *proxy,
|
|
|
587dbb |
+ GVariant *changed_properties,
|
|
|
587dbb |
+ GStrv invalidated_properties,
|
|
|
587dbb |
+ GNetworkMonitorNM *nm)
|
|
|
587dbb |
{
|
|
|
587dbb |
- GVariant *asv;
|
|
|
587dbb |
GVariantDict *dict;
|
|
|
587dbb |
|
|
|
587dbb |
- if (g_strcmp0 (signal_name, "PropertiesChanged") != 0)
|
|
|
587dbb |
- return;
|
|
|
587dbb |
-
|
|
|
587dbb |
- g_variant_get (parameters, "(@a{sv})", &asv;;
|
|
|
587dbb |
- if (!asv)
|
|
|
587dbb |
- return;
|
|
|
587dbb |
-
|
|
|
587dbb |
- dict = g_variant_dict_new (asv);
|
|
|
587dbb |
- g_variant_unref (asv);
|
|
|
587dbb |
- if (!dict)
|
|
|
587dbb |
- {
|
|
|
587dbb |
- g_warning ("Failed to handle PropertiesChanged signal from NetworkManager");
|
|
|
587dbb |
- return;
|
|
|
587dbb |
- }
|
|
|
587dbb |
+ dict = g_variant_dict_new (changed_properties);
|
|
|
587dbb |
|
|
|
587dbb |
update_cached_property (nm->priv->proxy, "Connectivity", dict);
|
|
|
587dbb |
|
|
|
587dbb |
@@ -361,8 +346,8 @@ g_network_monitor_nm_initable_init (GInitable *initable,
|
|
|
587dbb |
return FALSE;
|
|
|
587dbb |
}
|
|
|
587dbb |
|
|
|
587dbb |
- nm->priv->signal_id = g_signal_connect (G_OBJECT (proxy), "g-signal",
|
|
|
587dbb |
- G_CALLBACK (proxy_signal_cb), nm);
|
|
|
587dbb |
+ nm->priv->signal_id = g_signal_connect (G_OBJECT (proxy), "g-properties-changed",
|
|
|
587dbb |
+ G_CALLBACK (proxy_properties_changed_cb), nm);
|
|
|
587dbb |
nm->priv->proxy = proxy;
|
|
|
587dbb |
sync_properties (nm, FALSE);
|
|
|
587dbb |
|
|
|
587dbb |
--
|
|
|
587dbb |
GitLab
|
|
|
587dbb |
|
|
|
587dbb |
|
|
|
587dbb |
From 643fc7ea49e818310f6b3f6e4ebe621c7a4d6bd7 Mon Sep 17 00:00:00 2001
|
|
|
587dbb |
From: Julian Andres Klode <julian.klode@canonical.com>
|
|
|
587dbb |
Date: Tue, 12 Oct 2021 17:31:42 +0200
|
|
|
587dbb |
Subject: [PATCH 2/2] gnetworkmonitornm: Do not re-update cached property
|
|
|
587dbb |
|
|
|
587dbb |
GDBusProxy already takes care of updating the cached property
|
|
|
587dbb |
before emitting the signal, so there is no need to do this
|
|
|
587dbb |
a second time ourselves.
|
|
|
587dbb |
---
|
|
|
587dbb |
gio/gnetworkmonitornm.c | 22 ----------------------
|
|
|
587dbb |
1 file changed, 22 deletions(-)
|
|
|
587dbb |
|
|
|
587dbb |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
587dbb |
index 6a6d1d666..a8040fb36 100644
|
|
|
587dbb |
--- a/gio/gnetworkmonitornm.c
|
|
|
587dbb |
+++ b/gio/gnetworkmonitornm.c
|
|
|
587dbb |
@@ -252,34 +252,12 @@ sync_properties (GNetworkMonitorNM *nm,
|
|
|
587dbb |
}
|
|
|
587dbb |
}
|
|
|
587dbb |
|
|
|
587dbb |
-static void
|
|
|
587dbb |
-update_cached_property (GDBusProxy *proxy,
|
|
|
587dbb |
- const char *property_name,
|
|
|
587dbb |
- GVariantDict *dict)
|
|
|
587dbb |
-{
|
|
|
587dbb |
- GVariant *v;
|
|
|
587dbb |
-
|
|
|
587dbb |
- v = g_variant_dict_lookup_value (dict, property_name, NULL);
|
|
|
587dbb |
- if (!v)
|
|
|
587dbb |
- return;
|
|
|
587dbb |
- g_dbus_proxy_set_cached_property (proxy, property_name, v);
|
|
|
587dbb |
- g_variant_unref (v);
|
|
|
587dbb |
-}
|
|
|
587dbb |
-
|
|
|
587dbb |
static void
|
|
|
587dbb |
proxy_properties_changed_cb (GDBusProxy *proxy,
|
|
|
587dbb |
GVariant *changed_properties,
|
|
|
587dbb |
GStrv invalidated_properties,
|
|
|
587dbb |
GNetworkMonitorNM *nm)
|
|
|
587dbb |
{
|
|
|
587dbb |
- GVariantDict *dict;
|
|
|
587dbb |
-
|
|
|
587dbb |
- dict = g_variant_dict_new (changed_properties);
|
|
|
587dbb |
-
|
|
|
587dbb |
- update_cached_property (nm->priv->proxy, "Connectivity", dict);
|
|
|
587dbb |
-
|
|
|
587dbb |
- g_variant_dict_unref (dict);
|
|
|
587dbb |
-
|
|
|
587dbb |
sync_properties (nm, TRUE);
|
|
|
587dbb |
}
|
|
|
587dbb |
|
|
|
587dbb |
--
|
|
|
587dbb |
GitLab
|
|
|
587dbb |
|