static GtkWidget * nag_user (CEPage *page) { WirelessSecurity *sec; sec = wireless_security_combo_get_active (CE_PAGE_WIRELESS_SECURITY (page)); return sec ? wireless_security_nag_user (sec) : NULL; }
static void dialog_response (GtkDialog *dialog, gint response, gpointer user_data) { NMAWirelessDialog *self = NMA_WIRELESS_DIALOG (user_data); NMAWirelessDialogPrivate *priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self); NMSetting *setting; GtkTreeModel *model; GtkTreeIter iter; WirelessSecurity *sec = NULL; if (response != GTK_RESPONSE_OK) goto out; if (!priv->connection) { /* Create new connection */ char *id; char *uuid; GByteArray *ssid; priv->connection = nm_connection_new (); /* Wireless setting */ setting = nm_setting_wireless_new (); ssid = validate_dialog_ssid (self); g_object_set (setting, NM_SETTING_WIRELESS_SSID, ssid, NULL); nm_connection_add_setting (priv->connection, setting); if (ssid) { id = nm_utils_ssid_to_utf8 ((char *) ssid->data, ssid->len); g_byte_array_free (ssid, TRUE); } else id = NULL; /* Connection setting */ setting = nm_setting_connection_new (); uuid = nm_utils_uuid_generate (); /* FIXME: don't autoconnect until the connection is successful at least once */ /* Don't autoconnect adhoc networks by default for now */ g_object_set (setting, NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_ID, id, NM_SETTING_CONNECTION_AUTOCONNECT, !priv->adhoc_create, NULL); g_free (uuid); g_free (id); nm_connection_add_setting (priv->connection, setting); /* IPv4 setting */ if (priv->adhoc_create) { g_object_set (setting, NM_SETTING_WIRELESS_MODE, "adhoc", NULL); setting = nm_setting_ip4_config_new (); g_object_set (setting, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED, NULL); nm_connection_add_setting (priv->connection, setting); } } model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo)); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter); gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1); if (sec && !priv->nag_ignored) { GtkWidget *nag_dialog; /* Nag the user about certificates or whatever. Only destroy the dialog * if no nagging was done. */ nag_dialog = wireless_security_nag_user (sec); if (nag_dialog) { gtk_window_set_transient_for (GTK_WINDOW (nag_dialog), GTK_WINDOW (dialog)); g_signal_connect (nag_dialog, "response", G_CALLBACK (nag_dialog_response_cb), dialog); return; } } /* Fill security */ if (sec) { wireless_security_fill_connection (sec, priv->connection); wireless_security_unref (sec); } else { /* Unencrypted */ setting = nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS); g_object_set (setting, NM_SETTING_WIRELESS_SEC, NULL, NULL); } out: g_signal_emit (self, signals[DONE], 0, response); nm_utils_dialog_done (); /* FIXME: clear security? */ }