Commit 0625f2c0 authored by Thomas Haller's avatar Thomas Haller

libnm: implement nm_client_deactivate_connection() by using GDBusConnection directly

Eventually, I will refactor libnm to no longer use gdbus-codegen and
no GDBusProxy. In preparation of that, we must stop using that
API.

As first step, change nm_client_deactivate_connection(). Note how this
was done previously:

 - nm_client_deactivate_connection() calls nm_manager_deactivate_connection()
   - nmdbus_manager_call_deactivate_connection_sync() calls g_dbus_proxy_call_sync()
     - g_dbus_proxy_call_sync() calls g_dbus_connection_call_sync()

Currently this is still a bit ugly, because NMClient doesn't directly
track the GDBusConnection nor the name owner. Instead, we need to peel
it out of the object manager. One day, that will all be nicer, but first
get rid of gdbus-codegen.
parent e6e6057a
......@@ -1476,14 +1476,24 @@ nm_client_deactivate_connection (NMClient *client,
GCancellable *cancellable,
GError **error)
{
const char *active_path;
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE);
if (!nm_client_get_nm_running (client))
return TRUE;
return nm_manager_deactivate_connection (NM_CLIENT_GET_PRIVATE (client)->manager,
active, cancellable, error);
active_path = nm_object_get_path (NM_OBJECT (active));
g_return_val_if_fail (active_path, FALSE);
return _nm_object_dbus_call_sync_void (client,
cancellable,
NM_DBUS_PATH,
NM_DBUS_INTERFACE,
"DeactivateConnection",
g_variant_new ("(o)", active_path),
G_DBUS_CALL_FLAGS_NONE,
NM_DBUS_DEFAULT_TIMEOUT_MSEC,
TRUE,
error);
}
static void
......
......@@ -1271,27 +1271,6 @@ checkpoint_added (NMManager *manager, NMCheckpoint *checkpoint)
checkpoint_info_complete (manager, info, checkpoint, NULL);
}
gboolean
nm_manager_deactivate_connection (NMManager *manager,
NMActiveConnection *active,
GCancellable *cancellable,
GError **error)
{
const char *path;
gboolean ret;
g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE);
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE);
path = nm_object_get_path (NM_OBJECT (active));
ret = nmdbus_manager_call_deactivate_connection_sync (NM_MANAGER_GET_PRIVATE (manager)->proxy,
path,
cancellable, error);
if (error && *error)
g_dbus_error_strip_remote_error (*error);
return ret;
}
static void
deactivated_cb (GObject *object,
GAsyncResult *result,
......
......@@ -180,11 +180,6 @@ NMActiveConnection *nm_manager_add_and_activate_connection_finish (NMManager *ma
GVariant **out_result,
GError **error);
_NM_DEPRECATED_SYNC_METHOD_INTERNAL
gboolean nm_manager_deactivate_connection (NMManager *manager,
NMActiveConnection *active,
GCancellable *cancellable,
GError **error);
void nm_manager_deactivate_connection_async (NMManager *manager,
NMActiveConnection *active,
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