From f6f79aa433b0c062ed14ebb698cb4c2685bf4f21 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 19 Sep 2014 10:45:12 -0400 Subject: libnm: simplify private D-Bus connection tracking dcbw points out that g_dbus_connection_get_unique_name() can be used to distinguish private from bus connections without us needing to keep track ourselves. --- libnm/nm-dbus-helpers.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'libnm/nm-dbus-helpers.c') diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index 9fe38dd499..10f5913305 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -24,7 +24,6 @@ #include "nm-dbus-helpers.h" #include "nm-dbus-interface.h" -#define NM_DBUS_PRIVATE_CONNECTION_TAG "libnm-private-connection" static GBusType nm_bus = G_BUS_TYPE_SYSTEM; GBusType @@ -54,13 +53,8 @@ _nm_dbus_new_connection (GCancellable *cancellable, GError **error) connection = g_dbus_connection_new_for_address_sync ("unix:path=" NMRUNDIR "/private", G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, NULL, cancellable, &local); - if (connection) { - /* Mark this connection as private */ - g_object_set_data (G_OBJECT (connection), - NM_DBUS_PRIVATE_CONNECTION_TAG, - GUINT_TO_POINTER (TRUE)); + if (connection) return connection; - } if (g_error_matches (local, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_propagate_error (error, local); @@ -98,11 +92,6 @@ new_connection_async_got_private (GObject *source, GAsyncResult *result, gpointe connection = g_dbus_connection_new_for_address_finish (result, &error); if (connection) { - /* Mark this connection as private */ - g_object_set_data (G_OBJECT (connection), - NM_DBUS_PRIVATE_CONNECTION_TAG, - GUINT_TO_POINTER (TRUE)); - g_simple_async_result_set_op_res_gpointer (simple, connection, g_object_unref); g_simple_async_result_complete (simple); g_object_unref (simple); @@ -164,7 +153,7 @@ _nm_dbus_new_connection_finish (GAsyncResult *result, gboolean _nm_dbus_is_connection_private (GDBusConnection *connection) { - return !!g_object_get_data (G_OBJECT (connection), NM_DBUS_PRIVATE_CONNECTION_TAG); + return g_dbus_connection_get_unique_name (connection) == NULL; } static GHashTable *proxy_types; -- cgit v1.2.1