cli: use nmc_client_new_async() instead of nm_client_new_async()

This will allow us to set construct parameters to the instance, like
NM_CLIENT_INSTANCE_FLAGS.
This commit is contained in:
Thomas Haller 2019-12-06 17:09:18 +01:00
parent 0046163201
commit 3035837aa8
3 changed files with 15 additions and 4 deletions

View file

@ -4439,6 +4439,7 @@ clients_cli_nmcli_LDADD = \
shared/nm-glib-aux/libnm-glib-aux.la \
shared/nm-std-aux/libnm-std-aux.la \
shared/libcsiphash.la \
shared/nm-libnm-aux/libnm-libnm-aux.la \
libnm/libnm.la \
$(GLIB_LIBS) \
$(READLINE_LIBS)

View file

@ -13,6 +13,8 @@
#include <readline/readline.h>
#include <readline/history.h>
#include "nm-libnm-aux/nm-libnm-aux.h"
#include "nm-vpn-helpers.h"
#include "nm-client-utils.h"
@ -1216,17 +1218,22 @@ got_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
CmdCall *call = user_data;
NmCli *nmc;
nm_assert (NM_IS_CLIENT (source_object));
task = g_steal_pointer (&call->task);
nmc = g_task_get_task_data (task);
nmc->should_wait--;
nmc->client = nm_client_new_finish (res, &error);
if (!nmc->client) {
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (source_object),
res,
&error)) {
g_object_unref (source_object);
g_task_return_new_error (task, NMCLI_ERROR, NMC_RESULT_ERROR_UNKNOWN,
_("Error: Could not create NMClient object: %s."),
error->message);
} else {
nmc->client = NM_CLIENT (source_object);
call_cmd (nmc, g_steal_pointer (&task), call->cmd, call->argc, call->argv);
}
@ -1259,7 +1266,10 @@ call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, char **argv)
call->argc = argc;
call->argv = argv;
call->task = task;
nm_client_new_async (NULL, got_client, call);
nmc_client_new_async (NULL,
got_client,
call,
NULL);
}
}

View file

@ -22,11 +22,11 @@ deps = [
libnmc_base_dep,
libnmc_dep,
readline_dep,
libnm_libnm_aux_dep,
]
if enable_polkit_agent
sources += nm_polkit_listener
deps += polkit_agent_dep
endif