Commit 4af62192 authored by Thomas Haller's avatar Thomas Haller

libnm: implement nm_client_load_connections_async() by using GDBusConnection directly

parent d795bcd7
......@@ -2112,23 +2112,6 @@ nm_client_load_connections (NMClient *client,
return TRUE;
}
static void
load_connections_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
char **failures = NULL;
if (nm_remote_settings_load_connections_finish (NM_REMOTE_SETTINGS (object),
&failures, result, &error))
g_simple_async_result_set_op_res_gpointer (simple, failures, (GDestroyNotify) g_strfreev);
else
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
/**
* nm_client_load_connections_async:
* @client: the %NMClient
......@@ -2149,24 +2132,23 @@ nm_client_load_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 (filenames != NULL);
if (!_nm_client_check_nm_running (client, &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error);
return;
}
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
nm_client_load_connections_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nm_remote_settings_load_connections_async (NM_CLIENT_GET_PRIVATE (client)->settings,
filenames,
cancellable, load_connections_cb, simple);
_nm_object_dbus_call (client,
nm_client_load_connections_async,
cancellable,
callback,
user_data,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_INTERFACE_SETTINGS,
"LoadConnections",
g_variant_new ("(^as)",
filenames ?: NM_PTRARRAY_EMPTY (char *)),
G_VARIANT_TYPE ("(bas)"),
G_DBUS_CALL_FLAGS_NONE,
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
nm_dbus_connection_call_finish_variant_strip_dbus_error_cb);
}
/**
......@@ -2190,16 +2172,22 @@ nm_client_load_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_load_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) {
*failures = NULL;
return FALSE;
if (failures)
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
}
g_variant_get (ret,
"(b^as)",
NULL,
&failures);
return TRUE;
}
......
......@@ -394,71 +394,6 @@ nm_remote_settings_add_connection2 (NMRemoteSettings *self,
}
}
static void
load_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
gboolean success;
char **failures = NULL;
if (nmdbus_settings_call_load_connections_finish (NMDBUS_SETTINGS (proxy),
&success, &failures,
result, &error))
g_simple_async_result_set_op_res_gpointer (simple, failures, (GDestroyNotify) g_strfreev);
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_load_connections_async (NMRemoteSettings *settings,
char **filenames,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
NMRemoteSettingsPrivate *priv;
GSimpleAsyncResult *simple;
g_return_if_fail (NM_IS_REMOTE_SETTINGS (settings));
g_return_if_fail (filenames != NULL);
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
nm_remote_settings_load_connections_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
nmdbus_settings_call_load_connections (priv->proxy,
(const char * const *) filenames,
cancellable, load_connections_cb, simple);
}
gboolean
nm_remote_settings_load_connections_finish (NMRemoteSettings *settings,
char ***failures,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_load_connections_async), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else {
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
return TRUE;
}
}
gboolean
nm_remote_settings_reload_connections (NMRemoteSettings *settings,
GCancellable *cancellable,
......
......@@ -75,16 +75,6 @@ void nm_remote_settings_add_connection2 (NMRemoteSettings *self,
NMRemoteSettingAddConnection2Callback callback,
gpointer user_data);
void nm_remote_settings_load_connections_async (NMRemoteSettings *settings,
char **filenames,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean nm_remote_settings_load_connections_finish (NMRemoteSettings *settings,
char ***failures,
GAsyncResult *result,
GError **error);
_NM_DEPRECATED_SYNC_METHOD_INTERNAL
gboolean nm_remote_settings_reload_connections (NMRemoteSettings *settings,
GCancellable *cancellable,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment