Commit eaddc227 authored by Thomas Haller's avatar Thomas Haller

libnm: implement nm_client_deactivate_connection_async() by using GDBusConnection directly

parent 0625f2c0
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <libudev.h> #include <libudev.h>
#include "nm-glib-aux/nm-dbus-aux.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-manager.h" #include "nm-manager.h"
#include "nm-dns-manager.h" #include "nm-dns-manager.h"
...@@ -1496,22 +1497,6 @@ nm_client_deactivate_connection (NMClient *client, ...@@ -1496,22 +1497,6 @@ nm_client_deactivate_connection (NMClient *client,
error); error);
} }
static void
deactivated_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nm_manager_deactivate_connection_finish (NM_MANAGER (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_deactivate_connection_async: * nm_client_deactivate_connection_async:
* @client: a #NMClient * @client: a #NMClient
...@@ -1529,26 +1514,27 @@ nm_client_deactivate_connection_async (NMClient *client, ...@@ -1529,26 +1514,27 @@ nm_client_deactivate_connection_async (NMClient *client,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; const char *active_path;
g_return_if_fail (NM_IS_CLIENT (client)); g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active)); g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active));
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data, active_path = nm_object_get_path (NM_OBJECT (active));
nm_client_deactivate_connection_async); g_return_if_fail (active_path);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable); _nm_object_dbus_call (client,
nm_client_deactivate_connection_async,
if (!_nm_client_check_nm_running (client, NULL)) { cancellable,
g_simple_async_result_set_op_res_gboolean (simple, TRUE); callback,
g_simple_async_result_complete_in_idle (simple); user_data,
g_object_unref (simple); NM_DBUS_PATH,
return; NM_DBUS_INTERFACE,
} "DeactivateConnection",
g_variant_new ("(o)", active_path),
nm_manager_deactivate_connection_async (NM_CLIENT_GET_PRIVATE (client)->manager, G_VARIANT_TYPE ("()"),
active, G_DBUS_CALL_FLAGS_NONE,
cancellable, deactivated_cb, simple); NM_DBUS_DEFAULT_TIMEOUT_MSEC,
nm_dbus_connection_call_finish_void_strip_dbus_error_cb);
} }
/** /**
...@@ -1566,16 +1552,10 @@ nm_client_deactivate_connection_finish (NMClient *client, ...@@ -1566,16 +1552,10 @@ nm_client_deactivate_connection_finish (NMClient *client,
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
GSimpleAsyncResult *simple;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); 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_deactivate_connection_async), FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result); return g_task_propagate_boolean (G_TASK (result), error);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return g_simple_async_result_get_op_res_gboolean (simple);
} }
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -1271,66 +1271,6 @@ checkpoint_added (NMManager *manager, NMCheckpoint *checkpoint) ...@@ -1271,66 +1271,6 @@ checkpoint_added (NMManager *manager, NMCheckpoint *checkpoint)
checkpoint_info_complete (manager, info, checkpoint, NULL); checkpoint_info_complete (manager, info, checkpoint, NULL);
} }
static void
deactivated_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple = user_data;
GError *error = NULL;
if (nmdbus_manager_call_deactivate_connection_finish (NMDBUS_MANAGER (object),
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_manager_deactivate_connection_async (NMManager *manager,
NMActiveConnection *active,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
const char *path;
GSimpleAsyncResult *simple;
g_return_if_fail (NM_IS_MANAGER (manager));
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active));
simple = g_simple_async_result_new (G_OBJECT (manager), callback, user_data,
nm_manager_deactivate_connection_async);
if (cancellable)
g_simple_async_result_set_check_cancellable (simple, cancellable);
path = nm_object_get_path (NM_OBJECT (active));
nmdbus_manager_call_deactivate_connection (NM_MANAGER_GET_PRIVATE (manager)->proxy,
path,
cancellable,
deactivated_cb, simple);
}
gboolean
nm_manager_deactivate_connection_finish (NMManager *manager,
GAsyncResult *result,
GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (manager), nm_manager_deactivate_connection_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);
}
/*****************************************************************************/ /*****************************************************************************/
static void static void
......
...@@ -180,15 +180,6 @@ NMActiveConnection *nm_manager_add_and_activate_connection_finish (NMManager *ma ...@@ -180,15 +180,6 @@ NMActiveConnection *nm_manager_add_and_activate_connection_finish (NMManager *ma
GVariant **out_result, GVariant **out_result,
GError **error); GError **error);
void nm_manager_deactivate_connection_async (NMManager *manager,
NMActiveConnection *active,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean nm_manager_deactivate_connection_finish (NMManager *manager,
GAsyncResult *result,
GError **error);
const GPtrArray *nm_manager_get_checkpoints (NMManager *manager); const GPtrArray *nm_manager_get_checkpoints (NMManager *manager);
void nm_manager_checkpoint_create (NMManager *manager, void nm_manager_checkpoint_create (NMManager *manager,
const GPtrArray *devices, const GPtrArray *devices,
......
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