diff options
Diffstat (limited to 'libnm/nm-client.c')
-rw-r--r-- | libnm/nm-client.c | 423 |
1 files changed, 214 insertions, 209 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c index a5ddc53f59..f390988f08 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -19,7 +19,6 @@ * Copyright 2007 - 2013 Red Hat, Inc. */ -#include <dbus/dbus-glib.h> #include <string.h> #include <nm-utils.h> @@ -27,12 +26,11 @@ #include "nm-device-ethernet.h" #include "nm-device-wifi.h" #include "nm-device-private.h" -#include "nm-types-private.h" +#include "nm-types.h" #include "nm-object-private.h" #include "nm-active-connection.h" #include "nm-vpn-connection.h" #include "nm-object-cache.h" -#include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled); @@ -50,7 +48,7 @@ G_DEFINE_TYPE_WITH_CODE (NMClient, nm_client, NM_TYPE_OBJECT, #define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate)) typedef struct { - DBusGProxy *client_proxy; + GDBusProxy *client_proxy; char *version; NMState state; gboolean startup; @@ -60,7 +58,7 @@ typedef struct { NMActiveConnection *primary_connection; NMActiveConnection *activating_connection; - DBusGProxyCall *perm_call; + gboolean perm_call; GHashTable *permissions; /* Activations waiting for their NMActiveConnection @@ -166,7 +164,8 @@ wireless_enabled_cb (GObject *object, GParamSpec *pspec, gpointer user_data) poke_wireless_devices_with_rf_status (NM_CLIENT (object)); } -static void client_recheck_permissions (DBusGProxy *proxy, gpointer user_data); +static void client_dbus_signal (GDBusProxy *proxy, const char *sender_name, const char *signal_name, + GVariant *parameters, gpointer user_data); static void active_connections_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data); static void object_creation_failed_cb (GObject *object, GError *error, char *failed_path); @@ -199,12 +198,8 @@ init_dbus_properties (NMObject *object) property_info); /* Permissions */ - dbus_g_proxy_add_signal (priv->client_proxy, "CheckPermissions", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->client_proxy, - "CheckPermissions", - G_CALLBACK (client_recheck_permissions), - object, - NULL); + g_signal_connect (priv->client_proxy, "g-signal", + G_CALLBACK (client_dbus_signal), object); g_signal_connect (object, "notify::" NM_OBJECT_NM_RUNNING, G_CALLBACK (nm_running_changed_cb), NULL); @@ -273,7 +268,7 @@ nm_permission_result_to_client (const char *nm) } static void -update_permissions (NMClient *self, GHashTable *permissions) +update_permissions (NMClient *self, GVariant *permissions) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); GHashTableIter iter; @@ -287,11 +282,14 @@ update_permissions (NMClient *self, GHashTable *permissions) g_hash_table_remove_all (priv->permissions); if (permissions) { + GVariantIter viter; + const char *pkey, *pvalue; + /* Process new permissions */ - g_hash_table_iter_init (&iter, permissions); - while (g_hash_table_iter_next (&iter, &key, &value)) { - perm = nm_permission_to_client ((const char *) key); - perm_result = nm_permission_result_to_client ((const char *) value); + g_variant_iter_init (&viter, permissions); + while (g_variant_iter_next (&viter, "{&s&s}", &pkey, &pvalue)) { + perm = nm_permission_to_client (pkey); + perm_result = nm_permission_result_to_client (pvalue); if (perm) { g_hash_table_insert (priv->permissions, GUINT_TO_POINTER (perm), @@ -328,50 +326,83 @@ update_permissions (NMClient *self, GHashTable *permissions) static gboolean get_permissions_sync (NMClient *self, GError **error) { - gboolean success; - GHashTable *permissions = NULL; - - success = dbus_g_proxy_call_with_timeout (NM_CLIENT_GET_PRIVATE (self)->client_proxy, - "GetPermissions", 3000, error, - G_TYPE_INVALID, - DBUS_TYPE_G_MAP_OF_STRING, &permissions, G_TYPE_INVALID); - update_permissions (self, success ? permissions : NULL); - if (permissions) - g_hash_table_destroy (permissions); - - return success; + GVariant *ret, *permissions; + + ret = g_dbus_proxy_call_sync (NM_CLIENT_GET_PRIVATE (self)->client_proxy, + "GetPermissions", + NULL, + G_DBUS_CALL_FLAGS_NONE, 3000, + NULL, error); + if (ret) { + g_variant_get (ret, "(@a{ss})", &permissions); + update_permissions (self, permissions); + g_variant_unref (permissions); + g_variant_unref (ret); + return TRUE; + } else { + update_permissions (self, NULL); + return FALSE; + } } static void -get_permissions_reply (DBusGProxy *proxy, - DBusGProxyCall *call, +get_permissions_reply (GObject *object, + GAsyncResult *result, gpointer user_data) { + GDBusProxy *proxy = G_DBUS_PROXY (object); NMClient *self = NM_CLIENT (user_data); - GHashTable *permissions; - GError *error = NULL; + NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); + GVariant *ret, *permissions; - dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_MAP_OF_STRING, &permissions, - G_TYPE_INVALID); - NM_CLIENT_GET_PRIVATE (self)->perm_call = NULL; - update_permissions (NM_CLIENT (user_data), error ? NULL : permissions); - g_clear_error (&error); + /* If we are holding the last ref on @self, then abort */ + g_object_add_weak_pointer (G_OBJECT (self), (gpointer *) &self); + g_object_unref (self); + if (!self) + return; + g_object_remove_weak_pointer (G_OBJECT (self), (gpointer *) &self); + + ret = g_dbus_proxy_call_finish (proxy, result, NULL); + if (ret) { + g_variant_get (ret, "(a{ss})", &permissions); + update_permissions (self, permissions); + g_variant_unref (permissions); + g_variant_unref (ret); + } else + update_permissions (self, NULL); + + priv->perm_call = FALSE; } static void -client_recheck_permissions (DBusGProxy *proxy, gpointer user_data) +client_recheck_permissions (NMClient *self) { - NMClient *self = NM_CLIENT (user_data); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); if (!priv->perm_call) { - priv->perm_call = dbus_g_proxy_begin_call (NM_CLIENT_GET_PRIVATE (self)->client_proxy, "GetPermissions", - get_permissions_reply, self, NULL, - G_TYPE_INVALID); + priv->perm_call = TRUE; + g_dbus_proxy_call (NM_CLIENT_GET_PRIVATE (self)->client_proxy, + "GetPermissions", + NULL, + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + get_permissions_reply, g_object_ref (self)); } } +static void +client_dbus_signal (GDBusProxy *proxy, + const char *sender_name, + const char *signal_name, + GVariant *parameters, + gpointer user_data) +{ + if (strcmp (signal_name, "CheckPermissions") != 0) + return; + + client_recheck_permissions (NM_CLIENT (user_data)); +} + /** * nm_client_get_devices: * @client: a #NMClient @@ -559,24 +590,23 @@ recheck_pending_activations (NMClient *self, const char *failed_path, GError *er } static void -activate_cb (DBusGProxy *proxy, - DBusGProxyCall *call, +activate_cb (GObject *object, + GAsyncResult *result, gpointer user_data) { ActivateInfo *info = user_data; - char *path; + GVariant *ret; GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_OBJECT_PATH, &path, - G_TYPE_INVALID); - if (error) { + ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), result, &error); + if (ret) { + g_variant_get (ret, "(o)", &info->active_path); + g_variant_unref (ret); + recheck_pending_activations (info->client, NULL, NULL); + } else { activate_info_complete (info, NULL, error); activate_info_free (info); g_clear_error (&error); - } else { - info->active_path = path; - recheck_pending_activations (info->client, NULL, NULL); } } @@ -653,35 +683,35 @@ nm_client_activate_connection (NMClient *client, return; } - dbus_g_proxy_begin_call (priv->client_proxy, "ActivateConnection", - activate_cb, info, NULL, - DBUS_TYPE_G_OBJECT_PATH, connection ? nm_connection_get_path (connection) : "/", - DBUS_TYPE_G_OBJECT_PATH, device ? nm_object_get_path (NM_OBJECT (device)) : "/", - DBUS_TYPE_G_OBJECT_PATH, specific_object ? specific_object : "/", - G_TYPE_INVALID); + g_dbus_proxy_call (priv->client_proxy, + "ActivateConnection", + g_variant_new ("(ooo)", + connection ? nm_connection_get_path (connection) : "/", + device ? nm_object_get_path (NM_OBJECT (device)) : "/", + specific_object ? specific_object : "/"), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + activate_cb, info); } static void -add_activate_cb (DBusGProxy *proxy, - DBusGProxyCall *call, +add_activate_cb (GObject *object, + GAsyncResult *result, gpointer user_data) { ActivateInfo *info = user_data; - char *connection_path; - char *active_path; + GVariant *ret; GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_OBJECT_PATH, &connection_path, - DBUS_TYPE_G_OBJECT_PATH, &active_path, - G_TYPE_INVALID); - if (error) { + ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), result, &error); + if (ret) { + g_variant_get (ret, "(oo)", &info->new_connection_path, &info->active_path); + g_variant_unref (ret); + recheck_pending_activations (info->client, NULL, NULL); + } else { activate_info_complete (info, NULL, error); activate_info_free (info); - } else { - info->new_connection_path = connection_path; - info->active_path = active_path; - recheck_pending_activations (info->client, NULL, NULL); + g_clear_error (&error); } } @@ -717,7 +747,7 @@ nm_client_add_and_activate_connection (NMClient *client, { NMClientPrivate *priv; ActivateInfo *info; - GHashTable *hash = NULL; + GVariant *dict = NULL; g_return_if_fail (NM_IS_CLIENT (client)); g_return_if_fail (NM_IS_DEVICE (device)); @@ -728,24 +758,27 @@ nm_client_add_and_activate_connection (NMClient *client, info->client = client; if (partial) - hash = nm_connection_to_hash (partial, NM_SETTING_HASH_FLAG_ALL); - if (!hash) - hash = g_hash_table_new (g_str_hash, g_str_equal); + dict = nm_connection_to_variant (partial, NM_SETTING_HASH_FLAG_ALL); + if (!dict) + dict = g_variant_new_array (G_VARIANT_TYPE_VARDICT, NULL, 0); priv = NM_CLIENT_GET_PRIVATE (client); priv->pending_activations = g_slist_prepend (priv->pending_activations, info); if (nm_client_get_manager_running (client)) { - dbus_g_proxy_begin_call (priv->client_proxy, "AddAndActivateConnection", - add_activate_cb, info, NULL, - DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash, - DBUS_TYPE_G_OBJECT_PATH, nm_object_get_path (NM_OBJECT (device)), - DBUS_TYPE_G_OBJECT_PATH, specific_object ? specific_object : "/", - G_TYPE_INVALID); + g_dbus_proxy_call (priv->client_proxy, + "AddAndActivateConnection", + g_variant_new ("(a{sv}oo)", + dict, + nm_object_get_path (NM_OBJECT (device)), + specific_object ? specific_object : "/"), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + add_activate_cb, info); } else info->idle_id = g_idle_add (activate_nm_not_running, info); - g_hash_table_unref (hash); + g_variant_unref (dict); } static void @@ -773,6 +806,7 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) { NMClientPrivate *priv; const char *path; + GVariant *ret; GError *error = NULL; g_return_if_fail (NM_IS_CLIENT (client)); @@ -783,10 +817,14 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) return; path = nm_object_get_path (NM_OBJECT (active)); - if (!dbus_g_proxy_call (priv->client_proxy, "DeactivateConnection", &error, - DBUS_TYPE_G_OBJECT_PATH, path, - G_TYPE_INVALID, - G_TYPE_INVALID)) { + ret = g_dbus_proxy_call_sync (priv->client_proxy, + "DeactivateConnection", + g_variant_new ("(o)", path), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, &error); + if (ret) + g_variant_unref (ret); + else { g_warning ("Could not deactivate connection '%s': %s", path, error->message); g_error_free (error); } @@ -842,20 +880,15 @@ nm_client_wireless_get_enabled (NMClient *client) void nm_client_wireless_set_enabled (NMClient *client, gboolean enabled) { - GValue value = G_VALUE_INIT; - g_return_if_fail (NM_IS_CLIENT (client)); if (!nm_client_get_manager_running (client)) return; - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, enabled); - _nm_object_set_property (NM_OBJECT (client), NM_DBUS_INTERFACE, "WirelessEnabled", - &value); + "b", enabled); } /** @@ -900,20 +933,15 @@ nm_client_wwan_get_enabled (NMClient *client) void nm_client_wwan_set_enabled (NMClient *client, gboolean enabled) { - GValue value = G_VALUE_INIT; - g_return_if_fail (NM_IS_CLIENT (client)); if (!nm_client_get_manager_running (client)) return; - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, enabled); - _nm_object_set_property (NM_OBJECT (client), NM_DBUS_INTERFACE, "WwanEnabled", - &value); + "b", enabled); } /** @@ -958,20 +986,15 @@ nm_client_wimax_get_enabled (NMClient *client) void nm_client_wimax_set_enabled (NMClient *client, gboolean enabled) { - GValue value = G_VALUE_INIT; - g_return_if_fail (NM_IS_CLIENT (client)); if (!nm_client_get_manager_running (client)) return; - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, enabled); - _nm_object_set_property (NM_OBJECT (client), NM_DBUS_INTERFACE, "WimaxEnabled", - &value); + "b", enabled); } /** @@ -1070,6 +1093,7 @@ nm_client_networking_get_enabled (NMClient *client) void nm_client_networking_set_enabled (NMClient *client, gboolean enable) { + GVariant *ret; GError *err = NULL; g_return_if_fail (NM_IS_CLIENT (client)); @@ -1077,10 +1101,14 @@ nm_client_networking_set_enabled (NMClient *client, gboolean enable) if (!nm_client_get_manager_running (client)) return; - if (!dbus_g_proxy_call (NM_CLIENT_GET_PRIVATE (client)->client_proxy, "Enable", &err, - G_TYPE_BOOLEAN, enable, - G_TYPE_INVALID, - G_TYPE_INVALID)) { + ret = g_dbus_proxy_call_sync (NM_CLIENT_GET_PRIVATE (client)->client_proxy, + "Enable", + g_variant_new ("(b)", enable), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, &err); + if (ret) + g_variant_unref (ret); + else { g_warning ("Error enabling/disabling networking: %s", err->message); g_error_free (err); } @@ -1140,6 +1168,7 @@ gboolean nm_client_get_logging (NMClient *client, char **level, char **domains, GError **error) { NMClientPrivate *priv; + GVariant *ret; g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (level == NULL || *level == NULL, FALSE); @@ -1158,11 +1187,17 @@ nm_client_get_logging (NMClient *client, char **level, char **domains, GError ** if (!level && !domains) return TRUE; - return dbus_g_proxy_call (priv->client_proxy, "GetLogging", error, - G_TYPE_INVALID, - G_TYPE_STRING, level, - G_TYPE_STRING, domains, - G_TYPE_INVALID); + ret = g_dbus_proxy_call_sync (priv->client_proxy, + "GetLogging", + NULL, + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, error); + if (ret) { + g_variant_get (ret, "(ss)", level, domains); + g_variant_unref (ret); + return TRUE; + } else + return FALSE; } /** @@ -1181,6 +1216,7 @@ gboolean nm_client_set_logging (NMClient *client, const char *level, const char *domains, GError **error) { NMClientPrivate *priv; + GVariant *ret; g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -1197,11 +1233,18 @@ nm_client_set_logging (NMClient *client, const char *level, const char *domains, if (!level && !domains) return TRUE; - return dbus_g_proxy_call (priv->client_proxy, "SetLogging", error, - G_TYPE_STRING, level ? level : "", - G_TYPE_STRING, domains ? domains : "", - G_TYPE_INVALID, - G_TYPE_INVALID); + ret = g_dbus_proxy_call_sync (priv->client_proxy, + "SetLogging", + g_variant_new ("(ss)", + level ? level : "", + domains ? domains : ""), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, error); + if (ret) { + g_variant_unref (ret); + return TRUE; + } else + return FALSE; } /** @@ -1346,7 +1389,7 @@ nm_running_changed_cb (GObject *object, } else { _nm_object_suppress_property_updates (NM_OBJECT (client), FALSE); _nm_object_reload_properties_async (NM_OBJECT (client), updated_properties, client); - client_recheck_permissions (priv->client_proxy, client); + client_recheck_permissions (client); } } @@ -1391,71 +1434,48 @@ nm_client_check_connectivity (NMClient *client, { NMClientPrivate *priv; NMConnectivityState connectivity; + GVariant *ret; g_return_val_if_fail (NM_IS_CLIENT (client), NM_CONNECTIVITY_UNKNOWN); priv = NM_CLIENT_GET_PRIVATE (client); - if (!dbus_g_proxy_call (priv->client_proxy, "CheckConnectivity", error, - G_TYPE_INVALID, - G_TYPE_UINT, &connectivity, - G_TYPE_INVALID)) + ret = g_dbus_proxy_call_sync (priv->client_proxy, + "CheckConnectivity", + NULL, + G_DBUS_CALL_FLAGS_NONE, -1, + cancellable, error); + if (ret) { + g_variant_get (ret, "(u)", &connectivity); + g_variant_unref (ret); + } else connectivity = NM_CONNECTIVITY_UNKNOWN; return connectivity; } -typedef struct { - NMClient *client; - DBusGProxyCall *call; - GCancellable *cancellable; - guint cancelled_id; - NMConnectivityState connectivity; -} CheckConnectivityData; - static void -check_connectivity_data_free (CheckConnectivityData *ccd) -{ - if (ccd->cancellable) { - if (ccd->cancelled_id) - g_signal_handler_disconnect (ccd->cancellable, ccd->cancelled_id); - g_object_unref (ccd->cancellable); - } - - g_slice_free (CheckConnectivityData, ccd); -} - -static void -check_connectivity_cb (DBusGProxy *proxy, - DBusGProxyCall *call, +check_connectivity_cb (GObject *object, + GAsyncResult *result, gpointer user_data) { GSimpleAsyncResult *simple = user_data; - CheckConnectivityData *ccd = g_simple_async_result_get_op_res_gpointer (simple); + GVariant *ret; GError *error = NULL; - if (!dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_UINT, &ccd->connectivity, - G_TYPE_INVALID)) + ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), result, &error); + if (ret) { + guint connectivity; + + g_variant_get (ret, "(u)", &connectivity); + g_variant_unref (ret); + g_simple_async_result_set_op_res_gssize (simple, connectivity); + } else g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); } -static void -check_connectivity_cancelled_cb (GCancellable *cancellable, - gpointer user_data) -{ - GSimpleAsyncResult *simple = user_data; - CheckConnectivityData *ccd = g_simple_async_result_get_op_res_gpointer (simple); - - g_signal_handler_disconnect (cancellable, ccd->cancelled_id); - ccd->cancelled_id = 0; - - dbus_g_proxy_cancel_call (NM_CLIENT_GET_PRIVATE (ccd->client)->client_proxy, ccd->call); - g_simple_async_result_complete_in_idle (simple); -} - /** * nm_client_check_connectivity_async: * @client: an #NMClient @@ -1476,29 +1496,18 @@ nm_client_check_connectivity_async (NMClient *client, { NMClientPrivate *priv; GSimpleAsyncResult *simple; - CheckConnectivityData *ccd; g_return_if_fail (NM_IS_CLIENT (client)); priv = NM_CLIENT_GET_PRIVATE (client); - ccd = g_slice_new (CheckConnectivityData); - ccd->client = client; - simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data, nm_client_check_connectivity_async); - g_simple_async_result_set_op_res_gpointer (simple, ccd, (GDestroyNotify) check_connectivity_data_free); - - if (cancellable) { - ccd->cancellable = g_object_ref (cancellable); - ccd->cancelled_id = g_signal_connect (cancellable, "cancelled", - G_CALLBACK (check_connectivity_cancelled_cb), - simple); - g_simple_async_result_set_check_cancellable (simple, cancellable); - } - - ccd->call = dbus_g_proxy_begin_call (priv->client_proxy, "CheckConnectivity", - check_connectivity_cb, simple, NULL, - G_TYPE_INVALID); + g_dbus_proxy_call (priv->client_proxy, + "CheckConnectivity", + NULL, + G_DBUS_CALL_FLAGS_NONE, -1, + cancellable, + check_connectivity_cb, simple); } /** @@ -1518,17 +1527,14 @@ nm_client_check_connectivity_finish (NMClient *client, GError **error) { GSimpleAsyncResult *simple; - CheckConnectivityData *ccd; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (client), nm_client_check_connectivity_async), NM_CONNECTIVITY_UNKNOWN); simple = G_SIMPLE_ASYNC_RESULT (result); - ccd = g_simple_async_result_get_op_res_gpointer (simple); if (g_simple_async_result_propagate_error (simple, error)) return NM_CONNECTIVITY_UNKNOWN; - - return ccd->connectivity; + return (NMConnectivityState) g_simple_async_result_get_op_res_gssize (simple); } /****************************************************************/ @@ -1560,15 +1566,15 @@ nm_client_new (GCancellable *cancellable, } static void -client_inited (GObject *source, GAsyncResult *result, gpointer user_data) +client_inited (GObject *object, GAsyncResult *result, gpointer user_data) { GSimpleAsyncResult *simple = user_data; GError *error = NULL; - if (!g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error)) + if (!g_async_initable_new_finish (G_ASYNC_INITABLE (object), result, &error)) g_simple_async_result_take_error (simple, error); else - g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref); + g_simple_async_result_set_op_res_gpointer (simple, object, g_object_unref); g_simple_async_result_complete (simple); g_object_unref (simple); } @@ -1719,30 +1725,31 @@ init_async_complete (NMClientInitData *init_data) } static void -init_async_got_permissions (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) +init_async_got_permissions (GObject *object, GAsyncResult *result, gpointer user_data) { NMClientInitData *init_data = user_data; - GHashTable *permissions; - GError *error = NULL; - - dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_MAP_OF_STRING, &permissions, - G_TYPE_INVALID); - update_permissions (init_data->client, error ? NULL : permissions); - if (error) - g_simple_async_result_take_error (init_data->result, error); + GVariant *ret, *permissions; + + ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), result, NULL); + if (ret) { + g_variant_get (ret, "(a{ss})", &permissions); + update_permissions (init_data->client, permissions); + g_variant_unref (permissions); + g_variant_unref (ret); + } else + update_permissions (init_data->client, NULL); init_async_complete (init_data); } static void -init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_data) +init_async_parent_inited (GObject *object, GAsyncResult *result, gpointer user_data) { NMClientInitData *init_data = user_data; NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (init_data->client); GError *error = NULL; - if (!nm_client_parent_async_initable_iface->init_finish (G_ASYNC_INITABLE (source), result, &error)) { + if (!nm_client_parent_async_initable_iface->init_finish (G_ASYNC_INITABLE (object), result, &error)) { g_simple_async_result_take_error (init_data->result, error); init_async_complete (init_data); return; @@ -1753,9 +1760,12 @@ init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_d return; } - dbus_g_proxy_begin_call (priv->client_proxy, "GetPermissions", - init_async_got_permissions, init_data, NULL, - G_TYPE_INVALID); + g_dbus_proxy_call (priv->client_proxy, + "GetPermissions", + NULL, + G_DBUS_CALL_FLAGS_NONE, 3000, + NULL, + init_async_got_permissions, init_data); } static void @@ -1799,11 +1809,6 @@ dispose (GObject *object) NMClient *client = NM_CLIENT (object); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); - if (priv->perm_call) { - dbus_g_proxy_cancel_call (priv->client_proxy, priv->perm_call); - priv->perm_call = NULL; - } - g_clear_object (&priv->client_proxy); free_devices (client, FALSE); |