mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-20 08:31:47 +00:00
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.
This commit is contained in:
parent
a87b5a15df
commit
94ae8449c9
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue