network: Simplify EapMethodSimple constructor
We don't need an enum and a lookup table, just send the string directly.
This commit is contained in:
parent
37f5c37261
commit
a99cafbdb4
7 changed files with 24 additions and 65 deletions
|
@ -362,15 +362,11 @@ eap_method_fast_new (NMConnection *connection)
|
|||
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (self->pac_file_button), filename);
|
||||
}
|
||||
|
||||
self->em_gtc = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_GTC,
|
||||
TRUE, FALSE);
|
||||
self->em_gtc = eap_method_simple_new (connection, "gtc", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_gtc));
|
||||
g_signal_connect_object (self->em_gtc, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_mschap_v2 = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
|
||||
TRUE, FALSE);
|
||||
self->em_mschap_v2 = eap_method_simple_new (connection, "mschapv2", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_mschap_v2));
|
||||
g_signal_connect_object (self->em_mschap_v2, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
|
|
|
@ -340,21 +340,15 @@ eap_method_peap_new (NMConnection *connection)
|
|||
!filename && eap_method_ca_cert_ignore_get (EAP_METHOD (self), connection));
|
||||
}
|
||||
|
||||
self->em_mschap_v2 = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
|
||||
TRUE, FALSE);
|
||||
self->em_mschap_v2 = eap_method_simple_new (connection, "mschapv2", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_mschap_v2));
|
||||
g_signal_connect_object (self->em_mschap_v2, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_md5 = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_MD5,
|
||||
TRUE, FALSE);
|
||||
self->em_md5 = eap_method_simple_new (connection, "md5", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_md5));
|
||||
g_signal_connect_object (self->em_md5, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_gtc = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_GTC,
|
||||
TRUE, FALSE);
|
||||
self->em_gtc = eap_method_simple_new (connection, "gtc", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_gtc));
|
||||
g_signal_connect_object (self->em_gtc, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ struct _EAPMethodSimple {
|
|||
GtkEntry *username_entry;
|
||||
GtkLabel *username_label;
|
||||
|
||||
EAPMethodSimpleType type;
|
||||
gchar *name;
|
||||
gboolean phase2;
|
||||
gboolean autheap_allowed;
|
||||
|
||||
|
@ -106,22 +106,6 @@ add_to_size_group (EAPMethod *method, GtkSizeGroup *group)
|
|||
gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
} EapType;
|
||||
|
||||
/* Indexed by EAP_METHOD_SIMPLE_TYPE_* */
|
||||
static const EapType eap_table[EAP_METHOD_SIMPLE_TYPE_LAST] = {
|
||||
[EAP_METHOD_SIMPLE_TYPE_PAP] = { "pap" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_MSCHAP] = { "mschap" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2] = { "mschapv2" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_PLAIN_MSCHAP_V2] = { "mschapv2" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_MD5] = { "md5" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_PWD] = { "pwd" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_CHAP] = { "chap" },
|
||||
[EAP_METHOD_SIMPLE_TYPE_GTC] = { "gtc" },
|
||||
};
|
||||
|
||||
static void
|
||||
fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFlags prev_flags)
|
||||
{
|
||||
|
@ -129,7 +113,6 @@ fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFla
|
|||
NMSetting8021x *s_8021x;
|
||||
gboolean not_saved = FALSE;
|
||||
NMSettingSecretFlags flags;
|
||||
const EapType *eap_type;
|
||||
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
g_assert (s_8021x);
|
||||
|
@ -140,7 +123,6 @@ fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFla
|
|||
if (eap_method_get_phase2 (method) == FALSE)
|
||||
nm_setting_802_1x_clear_eap_methods (s_8021x);
|
||||
|
||||
eap_type = &eap_table[self->type];
|
||||
if (eap_method_get_phase2 (method)) {
|
||||
/* If the outer EAP method (TLS, TTLS, PEAP, etc) allows inner/phase2
|
||||
* EAP methods (which only TTLS allows) *and* the inner/phase2 method
|
||||
|
@ -148,14 +130,14 @@ fill_connection (EAPMethod *method, NMConnection *connection, NMSettingSecretFla
|
|||
* Otherwise the inner/phase2 method goes into PHASE2_AUTH.
|
||||
*/
|
||||
if (self->autheap_allowed) {
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, eap_type->name, NULL);
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, self->name, NULL);
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, NULL, NULL);
|
||||
} else {
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, eap_type->name, NULL);
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, self->name, NULL);
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, NULL, NULL);
|
||||
}
|
||||
} else
|
||||
nm_setting_802_1x_add_eap_method (s_8021x, eap_type->name);
|
||||
nm_setting_802_1x_add_eap_method (s_8021x, self->name);
|
||||
|
||||
g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (self->username_entry), NULL);
|
||||
|
||||
|
@ -281,6 +263,8 @@ eap_method_simple_dispose (GObject *object)
|
|||
{
|
||||
EAPMethodSimple *self = EAP_METHOD_SIMPLE (object);
|
||||
|
||||
g_clear_pointer (&self->name, g_free);
|
||||
|
||||
g_signal_handlers_disconnect_by_data (self, self);
|
||||
g_signal_handlers_disconnect_by_data (self->password_entry, self);
|
||||
g_signal_handlers_disconnect_by_data (self->show_password_check, self);
|
||||
|
@ -341,16 +325,15 @@ eap_method_iface_init (EAPMethodInterface *iface)
|
|||
}
|
||||
|
||||
EAPMethodSimple *
|
||||
eap_method_simple_new (NMConnection *connection, EAPMethodSimpleType type, gboolean phase2, gboolean autheap_allowed)
|
||||
eap_method_simple_new (NMConnection *connection, const gchar *name, gboolean phase2, gboolean autheap_allowed)
|
||||
{
|
||||
EAPMethodSimple *self;
|
||||
NMSetting8021x *s_8021x = NULL;
|
||||
|
||||
self = g_object_new (eap_method_simple_get_type (), NULL);
|
||||
self->type = type;
|
||||
self->name = g_strdup (name);
|
||||
self->phase2 = phase2;
|
||||
self->autheap_allowed = autheap_allowed;
|
||||
g_assert (type < EAP_METHOD_SIMPLE_TYPE_LAST);
|
||||
|
||||
g_signal_connect_swapped (self->username_entry, "changed", G_CALLBACK (changed_cb), self);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef enum {
|
|||
} EAPMethodSimpleType;
|
||||
|
||||
EAPMethodSimple *eap_method_simple_new (NMConnection *connection,
|
||||
EAPMethodSimpleType type,
|
||||
const gchar *name,
|
||||
gboolean phase2,
|
||||
gboolean autheap_allowed);
|
||||
|
||||
|
|
|
@ -355,45 +355,31 @@ eap_method_ttls_new (NMConnection *connection)
|
|||
gtk_entry_set_text (self->domain_match_entry, nm_setting_802_1x_get_domain_suffix_match (s_8021x));
|
||||
g_signal_connect_swapped (self->domain_match_entry, "changed", G_CALLBACK (changed_cb), self);
|
||||
|
||||
self->em_pap = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_PAP,
|
||||
TRUE, FALSE);
|
||||
self->em_pap = eap_method_simple_new (connection, "pap", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_pap));
|
||||
g_signal_connect_object (self->em_pap, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_mschap = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_MSCHAP,
|
||||
TRUE, FALSE);
|
||||
self->em_mschap = eap_method_simple_new (connection, "mschap", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_mschap));
|
||||
g_signal_connect_object (self->em_mschap, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_mschap_v2 = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
|
||||
TRUE, TRUE);
|
||||
self->em_mschap_v2 = eap_method_simple_new (connection, "mschapv2", TRUE, TRUE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_mschap_v2));
|
||||
g_signal_connect_object (self->em_mschap_v2, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_plain_mschap_v2 = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_PLAIN_MSCHAP_V2,
|
||||
TRUE, FALSE);
|
||||
self->em_plain_mschap_v2 = eap_method_simple_new (connection, "mschapv2", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_plain_mschap_v2));
|
||||
g_signal_connect_object (self->em_plain_mschap_v2, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_chap = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_CHAP,
|
||||
TRUE, FALSE);
|
||||
self->em_chap = eap_method_simple_new (connection, "chap", TRUE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_chap));
|
||||
g_signal_connect_object (self->em_chap, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_md5 = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_MD5,
|
||||
TRUE, TRUE);
|
||||
self->em_md5 = eap_method_simple_new (connection, "md5", TRUE, TRUE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_md5));
|
||||
g_signal_connect_object (self->em_md5, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
self->em_gtc = eap_method_simple_new (connection,
|
||||
EAP_METHOD_SIMPLE_TYPE_GTC,
|
||||
TRUE, TRUE);
|
||||
self->em_gtc = eap_method_simple_new (connection, "gtc", TRUE, TRUE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_gtc));
|
||||
g_signal_connect_object (self->em_gtc, "changed", G_CALLBACK (eap_method_emit_changed), self, G_CONNECT_SWAPPED);
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ ws_dynamic_wep_new (NMConnection *connection)
|
|||
self->em_leap = eap_method_leap_new (connection);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_leap));
|
||||
g_signal_connect_object (self->em_leap, "changed", G_CALLBACK (wireless_security_notify_changed), self, G_CONNECT_SWAPPED);
|
||||
self->em_pwd = eap_method_simple_new (connection, EAP_METHOD_SIMPLE_TYPE_PWD, FALSE, FALSE);
|
||||
self->em_pwd = eap_method_simple_new (connection, "pwd", FALSE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_pwd));
|
||||
g_signal_connect_object (self->em_pwd, "changed", G_CALLBACK (wireless_security_notify_changed), self, G_CONNECT_SWAPPED);
|
||||
self->em_fast = eap_method_fast_new (connection);
|
||||
|
|
|
@ -249,7 +249,7 @@ ws_wpa_eap_new (NMConnection *connection)
|
|||
default_method = "tls";
|
||||
}
|
||||
|
||||
self->em_md5 = eap_method_simple_new (connection, EAP_METHOD_SIMPLE_TYPE_MD5, FALSE, FALSE);
|
||||
self->em_md5 = eap_method_simple_new (connection, "md5", FALSE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_md5));
|
||||
g_signal_connect_object (self->em_md5, "changed", G_CALLBACK (wireless_security_notify_changed), self, G_CONNECT_SWAPPED);
|
||||
self->em_tls = eap_method_tls_new (connection);
|
||||
|
@ -258,7 +258,7 @@ ws_wpa_eap_new (NMConnection *connection)
|
|||
self->em_leap = eap_method_leap_new (connection);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_leap));
|
||||
g_signal_connect_object (self->em_leap, "changed", G_CALLBACK (wireless_security_notify_changed), self, G_CONNECT_SWAPPED);
|
||||
self->em_pwd = eap_method_simple_new (connection, EAP_METHOD_SIMPLE_TYPE_PWD, FALSE, FALSE);
|
||||
self->em_pwd = eap_method_simple_new (connection, "pwd", FALSE, FALSE);
|
||||
gtk_widget_show (GTK_WIDGET (self->em_pwd));
|
||||
g_signal_connect_object (self->em_pwd, "changed", G_CALLBACK (wireless_security_notify_changed), self, G_CONNECT_SWAPPED);
|
||||
self->em_fast = eap_method_fast_new (connection);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue