From 46ef9029bc6d300bf04873ce51a196a9b0e0ec29 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 7 Jan 2014 14:55:52 -0500 Subject: [PATCH] tui: fix activation of "new" Wi-Fi networks When activating a never-before-used Wi-Fi network, we need to call nm_client_add_and_activate_connection(), not nm_client_activate_connection(). (We still pass a NULL connection, since NM will attempt to auto-fill it for us, and will succeed as long as it's not an 802.1x connection.) --- tui/nmtui-connect.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/tui/nmtui-connect.c b/tui/nmtui-connect.c index 5facc0725b..9f17e64797 100644 --- a/tui/nmtui-connect.c +++ b/tui/nmtui-connect.c @@ -90,10 +90,10 @@ activate_ac_state_changed (GObject *object, } static void -activation_callback (NMClient *client, - NMActiveConnection *ac, - GError *error, - gpointer user_data) +activate_callback (NMClient *client, + NMActiveConnection *ac, + GError *error, + gpointer user_data) { NmtSyncOp *op = user_data; @@ -107,6 +107,17 @@ activation_callback (NMClient *client, G_CALLBACK (activate_ac_state_changed), op); } +static void +add_and_activate_callback (NMClient *client, + NMActiveConnection *ac, + const char *new_connection_path, + GError *error, + gpointer user_data) +{ + /* We don't care about @new_connection_path, so... */ + activate_callback (client, ac, error, user_data); +} + static void activate_connection (NMConnection *connection, NMDevice *device, @@ -116,6 +127,7 @@ activate_connection (NMConnection *connection, NMSecretAgent *agent; NmtNewtWidget *label; NmtSyncOp op; + const char *specific_object_path; GError *error = NULL; form = g_object_new (NMT_TYPE_NEWT_FORM, NULL); @@ -126,13 +138,21 @@ activate_connection (NMConnection *connection, nm_secret_agent_register (agent); g_signal_connect (agent, "request-secrets", G_CALLBACK (secrets_requested), NULL); + specific_object_path = specific_object ? nm_object_get_path (specific_object) : NULL; + /* FIXME: cancel button */ nmt_sync_op_init (&op); - nm_client_activate_connection (nm_client, - connection, device, - specific_object ? nm_object_get_path (specific_object) : NULL, - activation_callback, &op); + if (connection) { + nm_client_activate_connection (nm_client, + connection, device, specific_object_path, + activate_callback, &op); + } else { + nm_client_add_and_activate_connection (nm_client, + NULL, device, specific_object_path, + add_and_activate_callback, &op); + } + nmt_newt_form_show (form); if (!nmt_sync_op_wait_boolean (&op, &error)) {