From 94ae8449c9ab072ecc8f97ea2b128a4ee101e31a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 3 Dec 2012 15:23:02 -0600 Subject: [PATCH] cli: let libnm-glib create our bus connection libnm-glib handles connecting to the bus automatically if NULL is passed for the bus object. Do that; plus this lets us use the private bus connection if present. --- cli/src/connections.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/cli/src/connections.c b/cli/src/connections.c index 4b96712ed9..993a71ee67 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -1869,8 +1869,6 @@ get_connections_cb (NMRemoteSettings *settings, gpointer user_data) NMCResultCode do_connections (NmCli *nmc, int argc, char **argv) { - DBusGConnection *bus; - GError *error = NULL; int i = 0; gboolean real_cmd = FALSE; @@ -1899,17 +1897,8 @@ do_connections (NmCli *nmc, int argc, char **argv) args_info.argc = argc; args_info.argv = argv; - /* connect to DBus' system bus */ - bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (error || !bus) { - g_string_printf (nmc->return_text, _("Error: could not connect to D-Bus.")); - nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; - nmc->should_wait = FALSE; - return nmc->return_value; - } - /* get system settings */ - if (!(nmc->system_settings = nm_remote_settings_new (bus))) { + if (!(nmc->system_settings = nm_remote_settings_new (NULL))) { g_string_printf (nmc->return_text, _("Error: Could not get system settings.")); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; nmc->should_wait = FALSE; @@ -1930,9 +1919,6 @@ do_connections (NmCli *nmc, int argc, char **argv) g_signal_connect (nmc->system_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ, G_CALLBACK (get_connections_cb), &args_info); - - dbus_g_connection_unref (bus); - /* The rest will be done in get_connection_cb() callback. * We need to wait for signals that connections are read. */