GtkWidget * ws_802_1x_auth_combo_init (WirelessSecurity *sec, const char *combo_name, const char *combo_label, GCallback auth_combo_changed_cb, NMConnection *connection, gboolean is_editor, gboolean secrets_only) { GtkWidget *combo, *widget; GtkListStore *auth_model; GtkTreeIter iter; EAPMethodSimple *em_md5; EAPMethodTLS *em_tls; EAPMethodLEAP *em_leap; EAPMethodFAST *em_fast; EAPMethodTTLS *em_ttls; EAPMethodPEAP *em_peap; const char *default_method = NULL, *ctype = NULL; int active = -1, item = 0; gboolean wired = FALSE; /* Grab the default EAP method out of the security object */ if (connection) { NMSettingConnection *s_con; NMSetting8021x *s_8021x; s_con = nm_connection_get_setting_connection (connection); if (s_con) ctype = nm_setting_connection_get_connection_type (s_con); if ( (g_strcmp0 (ctype, NM_SETTING_WIRED_SETTING_NAME) == 0) || nm_connection_get_setting_wired (connection)) wired = TRUE; s_8021x = nm_connection_get_setting_802_1x (connection); if (s_8021x && nm_setting_802_1x_get_num_eap_methods (s_8021x)) default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0); } auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ()); if (wired) { em_md5 = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_MD5, FALSE, is_editor, secrets_only); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("MD5"), AUTH_METHOD_COLUMN, em_md5, -1); eap_method_unref (EAP_METHOD (em_md5)); if (default_method && (active < 0) && !strcmp (default_method, "md5")) active = item; item++; } em_tls = eap_method_tls_new (sec, connection, FALSE, secrets_only); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("TLS"), AUTH_METHOD_COLUMN, em_tls, -1); eap_method_unref (EAP_METHOD (em_tls)); if (default_method && (active < 0) && !strcmp (default_method, "tls")) active = item; item++; if (!wired) { em_leap = eap_method_leap_new (sec, connection, secrets_only); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("LEAP"), AUTH_METHOD_COLUMN, em_leap, -1); eap_method_unref (EAP_METHOD (em_leap)); if (default_method && (active < 0) && !strcmp (default_method, "leap")) active = item; item++; } em_fast = eap_method_fast_new (sec, connection, is_editor, secrets_only); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("FAST"), AUTH_METHOD_COLUMN, em_fast, -1); eap_method_unref (EAP_METHOD (em_fast)); if (default_method && (active < 0) && !strcmp (default_method, "fast")) active = item; item++; em_ttls = eap_method_ttls_new (sec, connection, is_editor, secrets_only); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("Tunneled TLS"), AUTH_METHOD_COLUMN, em_ttls, -1); eap_method_unref (EAP_METHOD (em_ttls)); if (default_method && (active < 0) && !strcmp (default_method, "ttls")) active = item; item++; em_peap = eap_method_peap_new (sec, connection, is_editor, secrets_only); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"), AUTH_METHOD_COLUMN, em_peap, -1); eap_method_unref (EAP_METHOD (em_peap)); if (default_method && (active < 0) && !strcmp (default_method, "peap")) active = item; item++; combo = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); g_assert (combo); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); g_object_unref (G_OBJECT (auth_model)); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active < 0 ? 0 : (guint32) active); g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec); if (secrets_only) { gtk_widget_hide (combo); widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_label)); gtk_widget_hide (widget); } return combo; }
GtkWidget * ws_802_1x_auth_combo_init (WirelessSecurity *sec, const char *combo_name, GCallback auth_combo_changed_cb, NMConnection *connection) { GtkWidget *combo; GtkListStore *auth_model; GtkTreeIter iter; EAPMethodTLS *em_tls; EAPMethodLEAP *em_leap; EAPMethodTTLS *em_ttls; EAPMethodPEAP *em_peap; const char *default_method = NULL; int active = -1, item = 0; gboolean wired = FALSE; /* Grab the default EAP method out of the security object */ if (connection) { NMSettingConnection *s_con; NMSetting8021x *s_8021x; s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); g_assert (s_con); if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRED_SETTING_NAME)) wired = TRUE; s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X); if (s_8021x && nm_setting_802_1x_get_num_eap_methods (s_8021x)) default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0); } auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ()); em_tls = eap_method_tls_new (sec, connection, FALSE); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("TLS"), AUTH_METHOD_COLUMN, em_tls, -1); eap_method_unref (EAP_METHOD (em_tls)); if (default_method && (active < 0) && !strcmp (default_method, "tls")) active = item; item++; if (!wired) { em_leap = eap_method_leap_new (sec, connection); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("LEAP"), AUTH_METHOD_COLUMN, em_leap, -1); eap_method_unref (EAP_METHOD (em_leap)); if (default_method && (active < 0) && !strcmp (default_method, "leap")) active = item; item++; } em_ttls = eap_method_ttls_new (sec, connection); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("Tunneled TLS"), AUTH_METHOD_COLUMN, em_ttls, -1); eap_method_unref (EAP_METHOD (em_ttls)); if (default_method && (active < 0) && !strcmp (default_method, "ttls")) active = item; item++; em_peap = eap_method_peap_new (sec, connection); gtk_list_store_append (auth_model, &iter); gtk_list_store_set (auth_model, &iter, AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"), AUTH_METHOD_COLUMN, em_peap, -1); eap_method_unref (EAP_METHOD (em_peap)); if (default_method && (active < 0) && !strcmp (default_method, "peap")) active = item; item++; combo = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); g_assert (combo); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); g_object_unref (G_OBJECT (auth_model)); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active < 0 ? 0 : (guint32) active); g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec); return combo; }