about summary refs log tree commit diff
path: root/clients/nm-online.c
diff options
context:
space:
mode:
Diffstat (limited to 'clients/nm-online.c')
-rw-r--r--clients/nm-online.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/clients/nm-online.c b/clients/nm-online.c
index de9c3794..8370f964 100644
--- a/clients/nm-online.c
+++ b/clients/nm-online.c
@@ -23,6 +23,8 @@
 #include <getopt.h>
 #include <locale.h>
 
+#include "nm-libnm-aux/nm-libnm-aux.h"
+
 #define PROGRESS_STEPS 15
 
 #define EXIT_NONE               -1
@@ -198,13 +200,16 @@ got_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
 	OnlineData *data = user_data;
 	gs_free_error GError *error = NULL;
-	NMClient *client;
+
+	nm_assert (NM_IS_CLIENT (source_object));
+	nm_assert (NM_CLIENT (source_object) == data->client);
 
 	nm_clear_g_source (&data->client_new_timeout_id);
 	g_clear_object (&data->client_new_cancellable);
 
-	client = nm_client_new_finish (res, &error);
-	if (!client) {
+	if (!g_async_initable_init_finish (G_ASYNC_INITABLE (source_object),
+	                                   res,
+	                                   &error)) {
 		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
 			return;
 		data->quiet = TRUE;
@@ -214,8 +219,6 @@ got_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
 		return;
 	}
 
-	data->client = client;
-
 	if (quit_if_connected (data))
 		return;
 
@@ -230,7 +233,7 @@ main (int argc, char *argv[])
 	OnlineData data = {
 		.retval = EXIT_FAILURE_UNSPECIFIED,
 	};
-	int t_secs = 30;
+	int t_secs;
 	GOptionContext *opt_ctx = NULL;
 	gboolean success;
 	GOptionEntry options[] = {
@@ -248,6 +251,8 @@ main (int argc, char *argv[])
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
+	t_secs = _nm_utils_ascii_str_to_int64 (g_getenv ("NM_ONLINE_TIMEOUT"), 10, 0, G_MAXINT, 30);
+
 	data.start_timestamp_ms = _now_ms ();
 
 	opt_ctx = g_option_context_new (NULL);
@@ -285,7 +290,12 @@ main (int argc, char *argv[])
 	data.client_new_cancellable = g_cancellable_new ();
 
 	data.client_new_timeout_id = g_timeout_add_seconds (30, got_client_timeout, &data);
-	nm_client_new_async (data.client_new_cancellable, got_client, &data);
+
+	data.client = nmc_client_new_async (data.client_new_cancellable,
+	                                    got_client,
+	                                    &data,
+	                                    NM_CLIENT_INSTANCE_FLAGS, (guint) NM_CLIENT_INSTANCE_FLAGS_NO_AUTO_FETCH_PERMISSIONS,
+	                                    NULL);
 
 	g_main_loop_run (data.loop);
 
@@ -295,7 +305,7 @@ main (int argc, char *argv[])
 	nm_clear_g_signal_handler (data.client, &data.client_notify_id);
 	g_clear_object (&data.client);
 
-	g_clear_pointer (&data.loop, g_main_loop_unref);
+	nm_clear_pointer (&data.loop, g_main_loop_unref);
 
 	if (!data.quiet)
 		_print_progress (data.wait_startup, -1, NM_MAX (0, data.end_timestamp_ms - _now_ms ()), data.retval);