about summary refs log tree commit diff
path: root/src/dns/nm-dns-systemd-resolved.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dns/nm-dns-systemd-resolved.c')
-rw-r--r--src/dns/nm-dns-systemd-resolved.c76
1 files changed, 25 insertions, 51 deletions
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c
index 5d262ba3..69b3e45e 100644
--- a/src/dns/nm-dns-systemd-resolved.c
+++ b/src/dns/nm-dns-systemd-resolved.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
  * Copyright (C) 2010 Dan Williams <dcbw@redhat.com>
  * Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net>
@@ -32,6 +31,7 @@
 #include <linux/if.h>
 
 #include "nm-glib-aux/nm-c-list.h"
+#include "nm-glib-aux/nm-dbus-aux.h"
 #include "nm-core-internal.h"
 #include "platform/nm-platform.h"
 #include "nm-utils.h"
@@ -304,18 +304,12 @@ send_updates (NMDnsSystemdResolved *self)
 		_LOGT ("send-updates: no name owner. Try start service...");
 		priv->try_start_blocked = TRUE;
 
-		g_dbus_connection_call (priv->dbus_connection,
-		                        DBUS_SERVICE_DBUS,
-		                        DBUS_PATH_DBUS,
-		                        DBUS_INTERFACE_DBUS,
-		                        "StartServiceByName",
-		                        g_variant_new ("(su)", SYSTEMD_RESOLVED_DBUS_SERVICE, 0u),
-		                        G_VARIANT_TYPE ("(u)"),
-		                        G_DBUS_CALL_FLAGS_NONE,
-		                        -1,
-		                        NULL,
-		                        NULL,
-		                        NULL);
+		nm_dbus_connection_call_start_service_by_name (priv->dbus_connection,
+		                                               SYSTEMD_RESOLVED_DBUS_SERVICE,
+		                                               -1,
+		                                               NULL,
+		                                               NULL,
+		                                               NULL);
 		return;
 	}
 
@@ -474,24 +468,17 @@ name_owner_changed_cb (GDBusConnection *connection,
 }
 
 static void
-get_name_owner_cb (GObject *source,
-                   GAsyncResult *res,
+get_name_owner_cb (const char *name_owner,
+                   GError *error,
                    gpointer user_data)
 {
 	NMDnsSystemdResolved *self;
 	NMDnsSystemdResolvedPrivate *priv;
-	gs_unref_variant GVariant *ret = NULL;
-	gs_free_error GError *error = NULL;
-	const char *owner = NULL;
 
-	ret = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), res, &error);
-	if (   !ret
+	if (   !name_owner
 	    && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
 		return;
 
-	if (ret)
-		g_variant_get (ret, "(&s)", &owner);
-
 	self = user_data;
 	priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
 
@@ -499,7 +486,7 @@ get_name_owner_cb (GObject *source,
 
 	priv->dbus_initied = TRUE;
 
-	name_owner_changed (self, owner);
+	name_owner_changed (self, name_owner);
 }
 
 /*****************************************************************************/
@@ -527,35 +514,24 @@ nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self)
 
 	c_list_init (&priv->request_queue_lst_head);
 
-	priv->dbus_connection = nm_g_object_ref (nm_dbus_manager_get_dbus_connection (nm_dbus_manager_get ()));
+	priv->dbus_connection = nm_g_object_ref (NM_MAIN_DBUS_CONNECTION_GET);
 	if (!priv->dbus_connection) {
 		_LOGD ("no D-Bus connection");
 		return;
 	}
 
-	priv->name_owner_changed_id = g_dbus_connection_signal_subscribe (priv->dbus_connection,
-	                                                                  DBUS_SERVICE_DBUS,
-	                                                                  DBUS_INTERFACE_DBUS,
-	                                                                  "NameOwnerChanged",
-	                                                                  DBUS_PATH_DBUS,
-	                                                                  SYSTEMD_RESOLVED_DBUS_SERVICE,
-	                                                                  G_DBUS_SIGNAL_FLAGS_NONE,
-	                                                                  name_owner_changed_cb,
-	                                                                  self,
-	                                                                  NULL);
+	priv->name_owner_changed_id = nm_dbus_connection_signal_subscribe_name_owner_changed (priv->dbus_connection,
+	                                                                                      SYSTEMD_RESOLVED_DBUS_SERVICE,
+	                                                                                      name_owner_changed_cb,
+	                                                                                      self,
+	                                                                                      NULL);
 	priv->cancellable = g_cancellable_new ();
-	g_dbus_connection_call (priv->dbus_connection,
-	                        DBUS_SERVICE_DBUS,
-	                        DBUS_PATH_DBUS,
-	                        DBUS_INTERFACE_DBUS,
-	                        "GetNameOwner",
-	                        g_variant_new ("(s)", SYSTEMD_RESOLVED_DBUS_SERVICE),
-	                        G_VARIANT_TYPE ("(s)"),
-	                        G_DBUS_CALL_FLAGS_NONE,
-	                        -1,
-	                        priv->cancellable,
-	                        get_name_owner_cb,
-	                        self);
+	nm_dbus_connection_call_get_name_owner (priv->dbus_connection,
+	                                        SYSTEMD_RESOLVED_DBUS_SERVICE,
+	                                        -1,
+	                                        priv->cancellable,
+	                                        get_name_owner_cb,
+	                                        self);
 }
 
 NMDnsPlugin *
@@ -572,10 +548,8 @@ dispose (GObject *object)
 
 	free_pending_updates (self);
 
-	if (priv->name_owner_changed_id != 0) {
-		g_dbus_connection_signal_unsubscribe (priv->dbus_connection,
-		                                      nm_steal_int (&priv->name_owner_changed_id));
-	}
+	nm_clear_g_dbus_connection_signal (priv->dbus_connection,
+	                                   &priv->name_owner_changed_id);
 
 	nm_clear_g_cancellable (&priv->cancellable);