From 883f34853474fd8ea142f6c640810ed2562f09dc Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 27 Jul 2017 15:32:05 +0200 Subject: [PATCH] libnm: update property in the manager after connectivity check Currently, after a client performs a connectivity check it cannot access the up-to-date value of the manager.connectivity property right away, but it must wait that the queued PropertiesChanged signal is processed, which is cumbersome. Arguably, clients already receive the new connectivity value as the result of the connectivity check call, so they don't have to read it from the object; however it would be better if the right value of the object property was available immediately as well. https://bugzilla.gnome.org/show_bug.cgi?id=784629 (cherry picked from commit b799de281bc01073c31dd2c86171b29c8132441c) --- libnm/nm-manager.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 294b9de18a..da69df9bba 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -576,8 +576,13 @@ nm_manager_check_connectivity (NMManager *manager, if (nmdbus_manager_call_check_connectivity_sync (priv->proxy, &connectivity, - cancellable, error)) + cancellable, error)) { + if (connectivity != priv->connectivity) { + priv->connectivity = connectivity; + g_object_notify (G_OBJECT (manager), NM_MANAGER_CONNECTIVITY); + } return connectivity; + } else { if (error && *error) g_dbus_error_strip_remote_error (*error); @@ -593,12 +598,21 @@ check_connectivity_cb (GObject *object, GSimpleAsyncResult *simple = user_data; guint32 connectivity; GError *error = NULL; + NMManager *manager; + NMManagerPrivate *priv; if (nmdbus_manager_call_check_connectivity_finish (NMDBUS_MANAGER (object), &connectivity, - result, &error)) + result, &error)) { g_simple_async_result_set_op_res_gssize (simple, connectivity); - else { + + manager = NM_MANAGER (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); + priv = NM_MANAGER_GET_PRIVATE (manager); + if (connectivity != priv->connectivity) { + priv->connectivity = connectivity; + g_object_notify (G_OBJECT (manager), NM_MANAGER_CONNECTIVITY); + } + } else { g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); }