diff options
author | Thomas Haller <thaller@redhat.com> | 2019-10-07 09:30:29 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-10-16 08:56:00 +0200 |
commit | 356f1f6f333d2012674aa5742f58c9bba0b12d57 (patch) | |
tree | 92eb31c0524f7fa5bb24f298ebf6d8b784209d29 | |
parent | 89c1007f924f99c2b16d8a766352630437acdbec (diff) | |
download | NetworkManager-356f1f6f333d2012674aa5742f58c9bba0b12d57.tar.gz |
libnm: implement nm_client_reload_connections_async() by using GDBusConnection directly
-rw-r--r-- | libnm/nm-client.c | 56 | ||||
-rw-r--r-- | libnm/nm-remote-settings.c | 58 | ||||
-rw-r--r-- | libnm/nm-remote-settings.h | 8 |
3 files changed, 20 insertions, 102 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c index d5146106b2..1eae24db90 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -2232,22 +2232,6 @@ nm_client_reload_connections (NMClient *client, return TRUE; } -static void -reload_connections_cb (GObject *object, GAsyncResult *result, gpointer user_data) -{ - GSimpleAsyncResult *simple = user_data; - GError *error = NULL; - - if (nm_remote_settings_reload_connections_finish (NM_REMOTE_SETTINGS (object), - result, &error)) - g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else - g_simple_async_result_take_error (simple, error); - - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - /** * nm_client_reload_connections_async: * @client: the #NMClient @@ -2265,22 +2249,22 @@ nm_client_reload_connections_async (NMClient *client, GAsyncReadyCallback callback, gpointer user_data) { - GSimpleAsyncResult *simple; - GError *error = NULL; - g_return_if_fail (NM_IS_CLIENT (client)); + g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); - if (!_nm_client_check_nm_running (client, &error)) { - g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error); - return; - } - - simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data, - nm_client_reload_connections_async); - if (cancellable) - g_simple_async_result_set_check_cancellable (simple, cancellable); - nm_remote_settings_reload_connections_async (NM_CLIENT_GET_PRIVATE (client)->settings, - cancellable, reload_connections_cb, simple); + _nm_object_dbus_call (client, + nm_client_reload_connections_async, + cancellable, + callback, + user_data, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_INTERFACE_SETTINGS, + "ReloadConnections", + g_variant_new ("()"), + G_VARIANT_TYPE ("(b)"), + G_DBUS_CALL_FLAGS_NONE, + NM_DBUS_DEFAULT_TIMEOUT_MSEC, + nm_dbus_connection_call_finish_variant_strip_dbus_error_cb); } /** @@ -2298,16 +2282,16 @@ nm_client_reload_connections_finish (NMClient *client, GAsyncResult *result, GError **error) { - GSimpleAsyncResult *simple; + gs_unref_variant GVariant *ret = NULL; g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); - g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE); + g_return_val_if_fail (nm_g_task_is_valid (result, client, nm_client_reload_connections_async), FALSE); - simple = G_SIMPLE_ASYNC_RESULT (result); - if (g_simple_async_result_propagate_error (simple, error)) + ret = g_task_propagate_pointer (G_TASK (result), error); + if (!ret) return FALSE; - else - return g_simple_async_result_get_op_res_gboolean (simple); + + return TRUE; } /*****************************************************************************/ diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index e6055726e7..b941bde69f 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -394,64 +394,6 @@ nm_remote_settings_add_connection2 (NMRemoteSettings *self, } } -static void -reload_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) -{ - GSimpleAsyncResult *simple = user_data; - gboolean success; - GError *error = NULL; - - if (nmdbus_settings_call_reload_connections_finish (NMDBUS_SETTINGS (proxy), - &success, - result, &error)) - g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else { - g_dbus_error_strip_remote_error (error); - g_simple_async_result_take_error (simple, error); - } - - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -void -nm_remote_settings_reload_connections_async (NMRemoteSettings *settings, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - NMRemoteSettingsPrivate *priv; - GSimpleAsyncResult *simple; - - g_return_if_fail (NM_IS_REMOTE_SETTINGS (settings)); - - priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); - - simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data, - nm_remote_settings_reload_connections_async); - if (cancellable) - g_simple_async_result_set_check_cancellable (simple, cancellable); - - nmdbus_settings_call_reload_connections (priv->proxy, cancellable, - reload_connections_cb, simple); -} - -gboolean -nm_remote_settings_reload_connections_finish (NMRemoteSettings *settings, - GAsyncResult *result, - GError **error) -{ - GSimpleAsyncResult *simple; - - g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_reload_connections_async), FALSE); - - simple = G_SIMPLE_ASYNC_RESULT (result); - if (g_simple_async_result_propagate_error (simple, error)) - return FALSE; - else - return g_simple_async_result_get_op_res_gboolean (simple); -} - gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings, const char *hostname, diff --git a/libnm/nm-remote-settings.h b/libnm/nm-remote-settings.h index c78f00e9bd..0d391e5fb0 100644 --- a/libnm/nm-remote-settings.h +++ b/libnm/nm-remote-settings.h @@ -75,14 +75,6 @@ void nm_remote_settings_add_connection2 (NMRemoteSettings *self, NMRemoteSettingAddConnection2Callback callback, gpointer user_data); -void nm_remote_settings_reload_connections_async (NMRemoteSettings *settings, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean nm_remote_settings_reload_connections_finish (NMRemoteSettings *settings, - GAsyncResult *result, - GError **error); - _NM_DEPRECATED_SYNC_METHOD_INTERNAL gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings, const char *hostname, |