summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-09-19 10:45:12 -0400
committerDan Winship <danw@gnome.org>2014-09-19 10:45:12 -0400
commitf6f79aa433b0c062ed14ebb698cb4c2685bf4f21 (patch)
tree706eabaad1d2c11c61019554d313892ef4bd1915
parent8f7b1e87c24999e3f28ac2d45c4f4bb8b2dcdaac (diff)
downloadNetworkManager-f6f79aa433b0c062ed14ebb698cb4c2685bf4f21.tar.gz
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.
-rw-r--r--libnm/nm-dbus-helpers.c15
1 files changed, 2 insertions, 13 deletions
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;