|
|
e533e2 |
From c48c984d39afeae84b0cad515f08f83c711fd9c4 Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Philip Withnall <withnall@endlessm.com>
|
|
|
e533e2 |
Date: Thu, 13 Sep 2018 10:25:05 +0100
|
|
|
e533e2 |
Subject: [PATCH 1/9] gnetworkmonitornm: Set a GError properly on an error
|
|
|
e533e2 |
handling path
|
|
|
e533e2 |
MIME-Version: 1.0
|
|
|
e533e2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
e533e2 |
Content-Transfer-Encoding: 8bit
|
|
|
e533e2 |
|
|
|
e533e2 |
All the other initialisation failure paths set a GError, but this one
|
|
|
e533e2 |
didn’t. Set a GError to avoid breaking the invariant that returning
|
|
|
e533e2 |
FALSE should always have a GError set.
|
|
|
e533e2 |
|
|
|
e533e2 |
Signed-off-by: Philip Withnall <withnall@endlessm.com>
|
|
|
e533e2 |
|
|
|
e533e2 |
https://gitlab.gnome.org/GNOME/glib/issues/1523
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 2 ++
|
|
|
e533e2 |
1 file changed, 2 insertions(+)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 20a86571f..5bc8c925a 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -309,6 +309,8 @@ g_network_monitor_nm_initable_init (GInitable *initable,
|
|
|
e533e2 |
|
|
|
e533e2 |
if (!name_owner)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
e533e2 |
+ _("NetworkManager not running"));
|
|
|
e533e2 |
g_object_unref (proxy);
|
|
|
e533e2 |
return FALSE;
|
|
|
e533e2 |
}
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From d139986b1f213a7e1c1e3968ad2d8270f820bd57 Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Antonio Larrosa <alarrosa@suse.com>
|
|
|
e533e2 |
Date: Tue, 12 Mar 2019 18:35:10 +0100
|
|
|
e533e2 |
Subject: [PATCH 2/9] Handle an UNKNOWN NetworkManager connectivity as NONE
|
|
|
e533e2 |
|
|
|
e533e2 |
nm_conn_to_g_conn already handles UNKNOWN like NONE (returning
|
|
|
e533e2 |
G_NETWORK_CONNECTIVITY_LOCAL in both cases). So in sync_properties
|
|
|
e533e2 |
we should also set new_connectivity to G_NETWORK_CONNECTIVITY_LOCAL
|
|
|
e533e2 |
for both NM_CONNECTIVITY_UNKNOWN and NM_CONNECTIVITY_NONE.
|
|
|
e533e2 |
|
|
|
e533e2 |
This has the added benefit that when NetworkManager returns the network
|
|
|
e533e2 |
connectivity is UNKNOWN, we set network_available to FALSE as it should
|
|
|
e533e2 |
be. Previously, there were cases in a laptop with no network access,
|
|
|
e533e2 |
that g_network_monitor_get_network_available returned true, which was
|
|
|
e533e2 |
wrong and is also fixed with this commit.
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 3 ++-
|
|
|
e533e2 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 5bc8c925a..4e2a35e8a 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -167,7 +167,8 @@ sync_properties (GNetworkMonitorNM *nm,
|
|
|
e533e2 |
nm_connectivity = g_variant_get_uint32 (v);
|
|
|
e533e2 |
g_variant_unref (v);
|
|
|
e533e2 |
|
|
|
e533e2 |
- if (nm_connectivity == NM_CONNECTIVITY_NONE)
|
|
|
e533e2 |
+ if (nm_connectivity == NM_CONNECTIVITY_UNKNOWN ||
|
|
|
e533e2 |
+ nm_connectivity == NM_CONNECTIVITY_NONE)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
new_network_available = FALSE;
|
|
|
e533e2 |
new_network_metered = FALSE;
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From 5b4e6f9813cf90c690d8974635b0aeff8f5d2c5d Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Fabrice Bellet <fabrice@bellet.info>
|
|
|
e533e2 |
Date: Mon, 29 Apr 2019 12:05:54 +0000
|
|
|
e533e2 |
Subject: [PATCH 3/9] gnetworkmonitornm: Fix network available detection
|
|
|
e533e2 |
|
|
|
e533e2 |
The network-available property can be asserted by querying the NMState
|
|
|
e533e2 |
describing the current overval network state, instead of the
|
|
|
e533e2 |
NMConnectivityState. The advantage of the NMState is that is reflects
|
|
|
e533e2 |
immediately the network state modification, while the connectivity
|
|
|
e533e2 |
state is tested at a fixed frequency.
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 39 ++++++++++++++++++++++++++++++++++++---
|
|
|
e533e2 |
1 file changed, 36 insertions(+), 3 deletions(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 4e2a35e8a..7bb480f54 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -52,6 +52,19 @@ typedef enum {
|
|
|
e533e2 |
NM_CONNECTIVITY_FULL
|
|
|
e533e2 |
} NMConnectivityState;
|
|
|
e533e2 |
|
|
|
e533e2 |
+/* Copied from https://developer.gnome.org/libnm-util/stable/libnm-util-NetworkManager.html#NMState;
|
|
|
e533e2 |
+ * used inline to avoid a NetworkManager dependency from GLib. */
|
|
|
e533e2 |
+typedef enum {
|
|
|
e533e2 |
+ NM_STATE_UNKNOWN = 0,
|
|
|
e533e2 |
+ NM_STATE_ASLEEP = 10,
|
|
|
e533e2 |
+ NM_STATE_DISCONNECTED = 20,
|
|
|
e533e2 |
+ NM_STATE_DISCONNECTING = 30,
|
|
|
e533e2 |
+ NM_STATE_CONNECTING = 40,
|
|
|
e533e2 |
+ NM_STATE_CONNECTED_LOCAL = 50,
|
|
|
e533e2 |
+ NM_STATE_CONNECTED_SITE = 60,
|
|
|
e533e2 |
+ NM_STATE_CONNECTED_GLOBAL = 70,
|
|
|
e533e2 |
+} NMState;
|
|
|
e533e2 |
+
|
|
|
e533e2 |
struct _GNetworkMonitorNMPrivate
|
|
|
e533e2 |
{
|
|
|
e533e2 |
GDBusProxy *proxy;
|
|
|
e533e2 |
@@ -155,11 +168,19 @@ sync_properties (GNetworkMonitorNM *nm,
|
|
|
e533e2 |
gboolean emit_signals)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
GVariant *v;
|
|
|
e533e2 |
+ NMState nm_state;
|
|
|
e533e2 |
NMConnectivityState nm_connectivity;
|
|
|
e533e2 |
gboolean new_network_available;
|
|
|
e533e2 |
gboolean new_network_metered;
|
|
|
e533e2 |
GNetworkConnectivity new_connectivity;
|
|
|
e533e2 |
|
|
|
e533e2 |
+ v = g_dbus_proxy_get_cached_property (nm->priv->proxy, "State");
|
|
|
e533e2 |
+ if (!v)
|
|
|
e533e2 |
+ return;
|
|
|
e533e2 |
+
|
|
|
e533e2 |
+ nm_state = g_variant_get_uint32 (v);
|
|
|
e533e2 |
+ g_variant_unref (v);
|
|
|
e533e2 |
+
|
|
|
e533e2 |
v = g_dbus_proxy_get_cached_property (nm->priv->proxy, "Connectivity");
|
|
|
e533e2 |
if (!v)
|
|
|
e533e2 |
return;
|
|
|
e533e2 |
@@ -167,14 +188,26 @@ sync_properties (GNetworkMonitorNM *nm,
|
|
|
e533e2 |
nm_connectivity = g_variant_get_uint32 (v);
|
|
|
e533e2 |
g_variant_unref (v);
|
|
|
e533e2 |
|
|
|
e533e2 |
- if (nm_connectivity == NM_CONNECTIVITY_UNKNOWN ||
|
|
|
e533e2 |
- nm_connectivity == NM_CONNECTIVITY_NONE)
|
|
|
e533e2 |
+ if (nm_state <= NM_STATE_CONNECTED_LOCAL)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
new_network_available = FALSE;
|
|
|
e533e2 |
new_network_metered = FALSE;
|
|
|
e533e2 |
new_connectivity = G_NETWORK_CONNECTIVITY_LOCAL;
|
|
|
e533e2 |
}
|
|
|
e533e2 |
- else
|
|
|
e533e2 |
+ else if (nm_state <= NM_STATE_CONNECTED_SITE)
|
|
|
e533e2 |
+ {
|
|
|
e533e2 |
+ new_network_available = FALSE;
|
|
|
e533e2 |
+ new_network_metered = FALSE;
|
|
|
e533e2 |
+ if (nm_connectivity == NM_CONNECTIVITY_PORTAL)
|
|
|
e533e2 |
+ {
|
|
|
e533e2 |
+ new_connectivity = G_NETWORK_CONNECTIVITY_PORTAL;
|
|
|
e533e2 |
+ }
|
|
|
e533e2 |
+ else
|
|
|
e533e2 |
+ {
|
|
|
e533e2 |
+ new_connectivity = G_NETWORK_CONNECTIVITY_LIMITED;
|
|
|
e533e2 |
+ }
|
|
|
e533e2 |
+ }
|
|
|
e533e2 |
+ else /* nm_state == NM_STATE_CONNECTED_FULL */
|
|
|
e533e2 |
{
|
|
|
e533e2 |
|
|
|
e533e2 |
/* this is only available post NM 1.0 */
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From 96fba295771d600e4f0f522400b2fb9b1ff42cee Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Philip Withnall <withnall@endlessm.com>
|
|
|
e533e2 |
Date: Fri, 31 May 2019 11:19:07 +0100
|
|
|
e533e2 |
Subject: [PATCH 4/9] gnetworkmonitornm: Consider NM_STATE_CONNECTED_SITE to be
|
|
|
e533e2 |
available
|
|
|
e533e2 |
|
|
|
e533e2 |
`NM_STATE_CONNECTED_SITE` is documented to mean that a default route is
|
|
|
e533e2 |
available, but that the internet connectivity check failed. A default
|
|
|
e533e2 |
route being available is compatible with the documentation for
|
|
|
e533e2 |
GNetworkMonitor:network-available, which should be true if the system
|
|
|
e533e2 |
has a default route for at least one of IPv4 and IPv6.
|
|
|
e533e2 |
|
|
|
e533e2 |
https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html
|
|
|
e533e2 |
|
|
|
e533e2 |
Signed-off-by: Philip Withnall <withnall@endlessm.com>
|
|
|
e533e2 |
|
|
|
e533e2 |
Fixes: #1788
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 2 +-
|
|
|
e533e2 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 7bb480f54..9013fd49c 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -196,7 +196,7 @@ sync_properties (GNetworkMonitorNM *nm,
|
|
|
e533e2 |
}
|
|
|
e533e2 |
else if (nm_state <= NM_STATE_CONNECTED_SITE)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
- new_network_available = FALSE;
|
|
|
e533e2 |
+ new_network_available = TRUE;
|
|
|
e533e2 |
new_network_metered = FALSE;
|
|
|
e533e2 |
if (nm_connectivity == NM_CONNECTIVITY_PORTAL)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From 74e5f472c838115f0ba19ac501805cb5b2ca837f Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Bastien Nocera <hadess@hadess.net>
|
|
|
e533e2 |
Date: Mon, 29 Jul 2019 17:25:21 +0200
|
|
|
e533e2 |
Subject: [PATCH 5/9] gnetworkmonitornm: Disconnect g-signal from proxy
|
|
|
e533e2 |
|
|
|
e533e2 |
So that we're sure never to receive a signal if something is keeping the
|
|
|
e533e2 |
proxy alive.
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 12 ++++++++++--
|
|
|
e533e2 |
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 9013fd49c..52073fac9 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -68,6 +68,7 @@ typedef enum {
|
|
|
e533e2 |
struct _GNetworkMonitorNMPrivate
|
|
|
e533e2 |
{
|
|
|
e533e2 |
GDBusProxy *proxy;
|
|
|
e533e2 |
+ guint signal_id;
|
|
|
e533e2 |
|
|
|
e533e2 |
GNetworkConnectivity connectivity;
|
|
|
e533e2 |
gboolean network_available;
|
|
|
e533e2 |
@@ -360,8 +361,8 @@ g_network_monitor_nm_initable_init (GInitable *initable,
|
|
|
e533e2 |
return FALSE;
|
|
|
e533e2 |
}
|
|
|
e533e2 |
|
|
|
e533e2 |
- g_signal_connect (G_OBJECT (proxy), "g-signal",
|
|
|
e533e2 |
- G_CALLBACK (proxy_signal_cb), nm);
|
|
|
e533e2 |
+ nm->priv->signal_id = g_signal_connect (G_OBJECT (proxy), "g-signal",
|
|
|
e533e2 |
+ G_CALLBACK (proxy_signal_cb), nm);
|
|
|
e533e2 |
nm->priv->proxy = proxy;
|
|
|
e533e2 |
sync_properties (nm, FALSE);
|
|
|
e533e2 |
|
|
|
e533e2 |
@@ -373,6 +374,13 @@ g_network_monitor_nm_finalize (GObject *object)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
GNetworkMonitorNM *nm = G_NETWORK_MONITOR_NM (object);
|
|
|
e533e2 |
|
|
|
e533e2 |
+ if (nm->priv->proxy != NULL &&
|
|
|
e533e2 |
+ nm->priv->signal_id != 0)
|
|
|
e533e2 |
+ {
|
|
|
e533e2 |
+ g_signal_handler_disconnect (nm->priv->proxy,
|
|
|
e533e2 |
+ nm->priv->signal_id);
|
|
|
e533e2 |
+ nm->priv->signal_id = 0;
|
|
|
e533e2 |
+ }
|
|
|
e533e2 |
g_clear_object (&nm->priv->proxy);
|
|
|
e533e2 |
|
|
|
e533e2 |
G_OBJECT_CLASS (g_network_monitor_nm_parent_class)->finalize (object);
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From eeaf1de6e695afd971d67137caa8e39e1c1267df Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Bastien Nocera <hadess@hadess.net>
|
|
|
e533e2 |
Date: Mon, 29 Jul 2019 17:26:20 +0200
|
|
|
e533e2 |
Subject: [PATCH 6/9] gnetworkmonitornm: Arguments to g-signal's callback are
|
|
|
e533e2 |
const
|
|
|
e533e2 |
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 4 ++--
|
|
|
e533e2 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 52073fac9..479653a51 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -268,8 +268,8 @@ update_cached_property (GDBusProxy *proxy,
|
|
|
e533e2 |
|
|
|
e533e2 |
static void
|
|
|
e533e2 |
proxy_signal_cb (GDBusProxy *proxy,
|
|
|
e533e2 |
- gchar *sender_name,
|
|
|
e533e2 |
- gchar *signal_name,
|
|
|
e533e2 |
+ const gchar *sender_name,
|
|
|
e533e2 |
+ const gchar *signal_name,
|
|
|
e533e2 |
GVariant *parameters,
|
|
|
e533e2 |
GNetworkMonitorNM *nm)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From 46d70700c85e4419942c8a3d08bd0bf842702c4a Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Bastien Nocera <hadess@hadess.net>
|
|
|
e533e2 |
Date: Mon, 29 Jul 2019 17:26:47 +0200
|
|
|
e533e2 |
Subject: [PATCH 7/9] gnetworkmonitornm: Remove double-space
|
|
|
e533e2 |
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 2 +-
|
|
|
e533e2 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 479653a51..5a36a0ba1 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -391,7 +391,7 @@ g_network_monitor_nm_class_init (GNetworkMonitorNMClass *nl_class)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
GObjectClass *gobject_class = G_OBJECT_CLASS (nl_class);
|
|
|
e533e2 |
|
|
|
e533e2 |
- gobject_class->finalize = g_network_monitor_nm_finalize;
|
|
|
e533e2 |
+ gobject_class->finalize = g_network_monitor_nm_finalize;
|
|
|
e533e2 |
gobject_class->get_property = g_network_monitor_nm_get_property;
|
|
|
e533e2 |
|
|
|
e533e2 |
g_object_class_override_property (gobject_class, PROP_NETWORK_AVAILABLE, "network-available");
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From 72291aac3dac7a8ed4c85eb41608f3f5f9ad7681 Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Julian Andres Klode <julian.klode@canonical.com>
|
|
|
e533e2 |
Date: Tue, 12 Oct 2021 12:01:50 +0200
|
|
|
e533e2 |
Subject: [PATCH 8/9] gnetworkmonitornm: Stop using removed PropertiesChanged
|
|
|
e533e2 |
signal
|
|
|
e533e2 |
|
|
|
e533e2 |
Use the org.freedesktop.DBus.Properties interface to listen
|
|
|
e533e2 |
to PropertiesChanged signals on /org/freedesktop/NetworkManager.
|
|
|
e533e2 |
|
|
|
e533e2 |
NetworkManager used to provide its own legacy PropertiesChanged
|
|
|
e533e2 |
signal, but that was dropped in
|
|
|
e533e2 |
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/853
|
|
|
e533e2 |
|
|
|
e533e2 |
This requires NetworkManager >= 1.2 (2016)
|
|
|
e533e2 |
|
|
|
e533e2 |
Fixes: #2505
|
|
|
e533e2 |
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1946196
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 29 +++++++----------------------
|
|
|
e533e2 |
1 file changed, 7 insertions(+), 22 deletions(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 5a36a0ba1..6a6d1d666 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -267,29 +267,14 @@ update_cached_property (GDBusProxy *proxy,
|
|
|
e533e2 |
}
|
|
|
e533e2 |
|
|
|
e533e2 |
static void
|
|
|
e533e2 |
-proxy_signal_cb (GDBusProxy *proxy,
|
|
|
e533e2 |
- const gchar *sender_name,
|
|
|
e533e2 |
- const gchar *signal_name,
|
|
|
e533e2 |
- GVariant *parameters,
|
|
|
e533e2 |
- GNetworkMonitorNM *nm)
|
|
|
e533e2 |
+proxy_properties_changed_cb (GDBusProxy *proxy,
|
|
|
e533e2 |
+ GVariant *changed_properties,
|
|
|
e533e2 |
+ GStrv invalidated_properties,
|
|
|
e533e2 |
+ GNetworkMonitorNM *nm)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
- GVariant *asv;
|
|
|
e533e2 |
GVariantDict *dict;
|
|
|
e533e2 |
|
|
|
e533e2 |
- if (g_strcmp0 (signal_name, "PropertiesChanged") != 0)
|
|
|
e533e2 |
- return;
|
|
|
e533e2 |
-
|
|
|
e533e2 |
- g_variant_get (parameters, "(@a{sv})", &asv;;
|
|
|
e533e2 |
- if (!asv)
|
|
|
e533e2 |
- return;
|
|
|
e533e2 |
-
|
|
|
e533e2 |
- dict = g_variant_dict_new (asv);
|
|
|
e533e2 |
- g_variant_unref (asv);
|
|
|
e533e2 |
- if (!dict)
|
|
|
e533e2 |
- {
|
|
|
e533e2 |
- g_warning ("Failed to handle PropertiesChanged signal from NetworkManager");
|
|
|
e533e2 |
- return;
|
|
|
e533e2 |
- }
|
|
|
e533e2 |
+ dict = g_variant_dict_new (changed_properties);
|
|
|
e533e2 |
|
|
|
e533e2 |
update_cached_property (nm->priv->proxy, "Connectivity", dict);
|
|
|
e533e2 |
|
|
|
e533e2 |
@@ -361,8 +346,8 @@ g_network_monitor_nm_initable_init (GInitable *initable,
|
|
|
e533e2 |
return FALSE;
|
|
|
e533e2 |
}
|
|
|
e533e2 |
|
|
|
e533e2 |
- nm->priv->signal_id = g_signal_connect (G_OBJECT (proxy), "g-signal",
|
|
|
e533e2 |
- G_CALLBACK (proxy_signal_cb), nm);
|
|
|
e533e2 |
+ nm->priv->signal_id = g_signal_connect (G_OBJECT (proxy), "g-properties-changed",
|
|
|
e533e2 |
+ G_CALLBACK (proxy_properties_changed_cb), nm);
|
|
|
e533e2 |
nm->priv->proxy = proxy;
|
|
|
e533e2 |
sync_properties (nm, FALSE);
|
|
|
e533e2 |
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|
|
|
e533e2 |
|
|
|
e533e2 |
From 3bafff71d7588285763f603b23c830722a2169d1 Mon Sep 17 00:00:00 2001
|
|
|
e533e2 |
From: Julian Andres Klode <julian.klode@canonical.com>
|
|
|
e533e2 |
Date: Tue, 12 Oct 2021 17:31:42 +0200
|
|
|
e533e2 |
Subject: [PATCH 9/9] gnetworkmonitornm: Do not re-update cached property
|
|
|
e533e2 |
|
|
|
e533e2 |
GDBusProxy already takes care of updating the cached property
|
|
|
e533e2 |
before emitting the signal, so there is no need to do this
|
|
|
e533e2 |
a second time ourselves.
|
|
|
e533e2 |
---
|
|
|
e533e2 |
gio/gnetworkmonitornm.c | 22 ----------------------
|
|
|
e533e2 |
1 file changed, 22 deletions(-)
|
|
|
e533e2 |
|
|
|
e533e2 |
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
index 6a6d1d666..a8040fb36 100644
|
|
|
e533e2 |
--- a/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
+++ b/gio/gnetworkmonitornm.c
|
|
|
e533e2 |
@@ -252,34 +252,12 @@ sync_properties (GNetworkMonitorNM *nm,
|
|
|
e533e2 |
}
|
|
|
e533e2 |
}
|
|
|
e533e2 |
|
|
|
e533e2 |
-static void
|
|
|
e533e2 |
-update_cached_property (GDBusProxy *proxy,
|
|
|
e533e2 |
- const char *property_name,
|
|
|
e533e2 |
- GVariantDict *dict)
|
|
|
e533e2 |
-{
|
|
|
e533e2 |
- GVariant *v;
|
|
|
e533e2 |
-
|
|
|
e533e2 |
- v = g_variant_dict_lookup_value (dict, property_name, NULL);
|
|
|
e533e2 |
- if (!v)
|
|
|
e533e2 |
- return;
|
|
|
e533e2 |
- g_dbus_proxy_set_cached_property (proxy, property_name, v);
|
|
|
e533e2 |
- g_variant_unref (v);
|
|
|
e533e2 |
-}
|
|
|
e533e2 |
-
|
|
|
e533e2 |
static void
|
|
|
e533e2 |
proxy_properties_changed_cb (GDBusProxy *proxy,
|
|
|
e533e2 |
GVariant *changed_properties,
|
|
|
e533e2 |
GStrv invalidated_properties,
|
|
|
e533e2 |
GNetworkMonitorNM *nm)
|
|
|
e533e2 |
{
|
|
|
e533e2 |
- GVariantDict *dict;
|
|
|
e533e2 |
-
|
|
|
e533e2 |
- dict = g_variant_dict_new (changed_properties);
|
|
|
e533e2 |
-
|
|
|
e533e2 |
- update_cached_property (nm->priv->proxy, "Connectivity", dict);
|
|
|
e533e2 |
-
|
|
|
e533e2 |
- g_variant_dict_unref (dict);
|
|
|
e533e2 |
-
|
|
|
e533e2 |
sync_properties (nm, TRUE);
|
|
|
e533e2 |
}
|
|
|
e533e2 |
|
|
|
e533e2 |
--
|
|
|
e533e2 |
2.33.1
|