[gnome-control-center] network: Refactor how username/passwords are retained when switching EAP methods
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Refactor how username/passwords are retained when switching EAP methods
- Date: Fri, 31 Jan 2020 14:18:44 +0000 (UTC)
commit b964283fb0f51881c321c6ee50185edd8685520b
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Dec 2 17:10:24 2019 +1300
network: Refactor how username/passwords are retained when switching EAP methods
This was previously done by storing the value inside the WirelessSecurity class.
This stopped the subclasses from becoming Gtk widgets.
The "always_ask" code was removed as it didn't seem to actually retain when
switching. This might need to be fixed at a later time.
panels/network/wireless-security/eap-method-fast.c | 73 +++++++++++---
panels/network/wireless-security/eap-method-fast.h | 5 +-
panels/network/wireless-security/eap-method-leap.c | 74 +++++++-------
panels/network/wireless-security/eap-method-leap.h | 5 +-
panels/network/wireless-security/eap-method-peap.c | 76 ++++++++++++---
panels/network/wireless-security/eap-method-peap.h | 5 +-
.../network/wireless-security/eap-method-simple.c | 101 ++++++++++----------
.../network/wireless-security/eap-method-simple.h | 5 +-
panels/network/wireless-security/eap-method-tls.c | 69 ++++++++++++++
panels/network/wireless-security/eap-method-ttls.c | 88 +++++++++++++----
panels/network/wireless-security/eap-method-ttls.h | 5 +-
panels/network/wireless-security/eap-method.c | 42 ++++++++
panels/network/wireless-security/eap-method.h | 18 ++++
.../network/wireless-security/wireless-security.c | 106 +--------------------
.../network/wireless-security/wireless-security.h | 16 ----
panels/network/wireless-security/ws-dynamic-wep.c | 60 +++++-------
panels/network/wireless-security/ws-wpa-eap.c | 63 ++++++------
17 files changed, 466 insertions(+), 345 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-fast.c
b/panels/network/wireless-security/eap-method-fast.c
index 28b42b639..b3573b760 100644
--- a/panels/network/wireless-security/eap-method-fast.c
+++ b/panels/network/wireless-security/eap-method-fast.c
@@ -27,7 +27,6 @@
#include "eap-method-simple.h"
#include "helpers.h"
#include "ui-helpers.h"
-#include "wireless-security.h"
#define I_NAME_COLUMN 0
#define I_ID_COLUMN 1
@@ -161,13 +160,20 @@ static void
inner_auth_combo_changed_cb (EAPMethodFAST *self)
{
EAPMethod *inner_method;
- GList *elt, *children;
+ GList *children;
+ inner_method = get_inner_method (self);
+
+ /* Remove the previous method and migrate username/password across */
children = gtk_container_get_children (GTK_CONTAINER (self->inner_auth_box));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (elt->data));
+ if (children != NULL) {
+ EAPMethod *old_eap = g_list_nth_data (children, 0);
+ eap_method_set_username (inner_method, eap_method_get_username (old_eap));
+ eap_method_set_password (inner_method, eap_method_get_password (old_eap));
+ eap_method_set_show_password (inner_method, eap_method_get_show_password (old_eap));
+ gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (old_eap));
+ }
- inner_method = get_inner_method (self);
gtk_container_add (GTK_CONTAINER (self->inner_auth_box), g_object_ref (GTK_WIDGET (inner_method)));
eap_method_emit_changed (EAP_METHOD (self));
@@ -195,6 +201,48 @@ get_password_flags_name (EAPMethod *parent)
return NM_SETTING_802_1X_PASSWORD;
}
+static const gchar *
+get_username (EAPMethod *method)
+{
+ EAPMethodFAST *self = EAP_METHOD_FAST (method);
+ return eap_method_get_username (get_inner_method (self));
+}
+
+static void
+set_username (EAPMethod *method, const gchar *username)
+{
+ EAPMethodFAST *self = EAP_METHOD_FAST (method);
+ return eap_method_set_username (get_inner_method (self), username);
+}
+
+static const gchar *
+get_password (EAPMethod *method)
+{
+ EAPMethodFAST *self = EAP_METHOD_FAST (method);
+ return eap_method_get_password (get_inner_method (self));
+}
+
+static void
+set_password (EAPMethod *method, const gchar *password)
+{
+ EAPMethodFAST *self = EAP_METHOD_FAST (method);
+ return eap_method_set_password (get_inner_method (self), password);
+}
+
+static gboolean
+get_show_password (EAPMethod *method)
+{
+ EAPMethodFAST *self = EAP_METHOD_FAST (method);
+ return eap_method_get_show_password (get_inner_method (self));
+}
+
+static void
+set_show_password (EAPMethod *method, gboolean show_password)
+{
+ EAPMethodFAST *self = EAP_METHOD_FAST (method);
+ return eap_method_set_show_password (get_inner_method (self), show_password);
+}
+
static void
pac_toggled_cb (EAPMethodFAST *self)
{
@@ -246,11 +294,16 @@ eap_method_iface_init (EAPMethodInterface *iface)
iface->update_secrets = update_secrets;
iface->get_default_field = get_default_field;
iface->get_password_flags_name = get_password_flags_name;
+ iface->get_username = get_username;
+ iface->set_username = set_username;
+ iface->get_password = get_password;
+ iface->set_password = set_password;
+ iface->get_show_password = get_show_password;
+ iface->set_show_password = set_show_password;
}
EAPMethodFAST *
-eap_method_fast_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+eap_method_fast_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
@@ -321,15 +374,13 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
if (secrets_only)
simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY;
- self->em_gtc = eap_method_simple_new (ws_parent,
- connection,
+ self->em_gtc = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_GTC,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_mschap_v2 = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
simple_flags);
gtk_widget_show (GTK_WIDGET (self->em_mschap_v2));
diff --git a/panels/network/wireless-security/eap-method-fast.h
b/panels/network/wireless-security/eap-method-fast.h
index 474571d57..713d4b635 100644
--- a/panels/network/wireless-security/eap-method-fast.h
+++ b/panels/network/wireless-security/eap-method-fast.h
@@ -25,14 +25,11 @@
#include <gtk/gtk.h>
#include <NetworkManager.h>
-#include "wireless-security.h"
-
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EAPMethodFAST, eap_method_fast, EAP, METHOD_FAST, GtkGrid)
-EAPMethodFAST *eap_method_fast_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+EAPMethodFAST *eap_method_fast_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
diff --git a/panels/network/wireless-security/eap-method-leap.c
b/panels/network/wireless-security/eap-method-leap.c
index ed799b3cd..d43d446b3 100644
--- a/panels/network/wireless-security/eap-method-leap.c
+++ b/panels/network/wireless-security/eap-method-leap.c
@@ -27,7 +27,6 @@
#include "helpers.h"
#include "nma-ui-utils.h"
#include "ui-helpers.h"
-#include "wireless-security.h"
struct _EAPMethodLEAP {
GtkGrid parent;
@@ -38,8 +37,6 @@ struct _EAPMethodLEAP {
GtkEntry *username_entry;
GtkLabel *username_label;
- WirelessSecurity *ws_parent;
-
gboolean editing_connection;
};
@@ -141,36 +138,46 @@ get_password_flags_name (EAPMethod *parent)
return NM_SETTING_802_1X_PASSWORD;
}
-/* Set the UI fields for user, password and show_password to the
- * values as provided by self->ws_parent. */
-static void
-set_userpass_ui (EAPMethodLEAP *self)
+static const gchar *
+get_username (EAPMethod *method)
{
- if (wireless_security_get_username (self->ws_parent))
- gtk_entry_set_text (self->username_entry, wireless_security_get_username (self->ws_parent));
- else
- gtk_entry_set_text (self->username_entry, "");
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (method);
+ return gtk_entry_get_text (self->username_entry);
+}
- if (wireless_security_get_password (self->ws_parent) && !wireless_security_get_always_ask
(self->ws_parent))
- gtk_entry_set_text (self->password_entry, wireless_security_get_password (self->ws_parent));
- else
- gtk_entry_set_text (self->password_entry, "");
+static void
+set_username (EAPMethod *method, const gchar *username)
+{
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (method);
+ gtk_entry_set_text (self->username_entry, username);
+}
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->show_password_check),
wireless_security_get_show_password (self->ws_parent));
+static const gchar *
+get_password (EAPMethod *method)
+{
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (method);
+ return gtk_entry_get_text (self->password_entry);
}
static void
-widgets_realized (EAPMethodLEAP *self)
+set_password (EAPMethod *method, const gchar *password)
{
- set_userpass_ui (self);
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (method);
+ gtk_entry_set_text (self->password_entry, password);
+}
+
+static gboolean
+get_show_password (EAPMethod *method)
+{
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (method);
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_password_check));
}
static void
-widgets_unrealized (EAPMethodLEAP *self)
+set_show_password (EAPMethod *method, gboolean show_password)
{
- wireless_security_set_username (self->ws_parent, gtk_entry_get_text (self->username_entry));
- wireless_security_set_password (self->ws_parent, gtk_entry_get_text (self->password_entry));
- wireless_security_set_show_password (self->ws_parent, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(self->show_password_check)));
+ EAPMethodLEAP *self = EAP_METHOD_LEAP (method);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->show_password_check), show_password);
}
static void
@@ -179,8 +186,6 @@ eap_method_leap_dispose (GObject *object)
EAPMethodLEAP *self = EAP_METHOD_LEAP (object);
g_signal_handlers_disconnect_by_data (self, self);
- g_signal_handlers_disconnect_by_data (self->username_entry, self->ws_parent);
- g_signal_handlers_disconnect_by_data (self->password_entry, self->ws_parent);
g_signal_handlers_disconnect_by_data (self->show_password_check, self);
G_OBJECT_CLASS (eap_method_leap_parent_class)->dispose (object);
@@ -224,11 +229,16 @@ eap_method_iface_init (EAPMethodInterface *iface)
iface->update_secrets = update_secrets;
iface->get_default_field = get_default_field;
iface->get_password_flags_name = get_password_flags_name;
+ iface->get_username = get_username;
+ iface->set_username = set_username;
+ iface->get_password = get_password;
+ iface->set_password = set_password;
+ iface->get_show_password = get_show_password;
+ iface->set_show_password = set_show_password;
}
EAPMethodLEAP *
-eap_method_leap_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+eap_method_leap_new (NMConnection *connection,
gboolean secrets_only)
{
EAPMethodLEAP *self;
@@ -236,10 +246,6 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
self = g_object_new (eap_method_leap_get_type (), NULL);
self->editing_connection = secrets_only ? FALSE : TRUE;
- self->ws_parent = ws_parent;
-
- g_signal_connect_swapped (self, "realize", G_CALLBACK (widgets_realized), self);
- g_signal_connect_swapped (self, "unrealize", G_CALLBACK (widgets_unrealized), self);
g_signal_connect_swapped (self->username_entry, "changed", G_CALLBACK (changed_cb), self);
@@ -256,14 +262,6 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
g_signal_connect_swapped (self->show_password_check, "toggled", G_CALLBACK (show_toggled_cb), self);
- /* Initialize the UI fields with the security settings from self->ws_parent.
- * This will be done again when the widget gets realized. It must be done here as well,
- * because the outer dialog will ask to 'validate' the connection before the security tab
- * is shown/realized (to enable the 'Apply' button).
- * As 'validate' accesses the contents of the UI fields, they must be initialized now, even
- * if the widgets are not yet visible. */
- set_userpass_ui (self);
-
return self;
}
diff --git a/panels/network/wireless-security/eap-method-leap.h
b/panels/network/wireless-security/eap-method-leap.h
index 5b3491643..0973812f1 100644
--- a/panels/network/wireless-security/eap-method-leap.h
+++ b/panels/network/wireless-security/eap-method-leap.h
@@ -25,14 +25,11 @@
#include <gtk/gtk.h>
#include <NetworkManager.h>
-#include "wireless-security.h"
-
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EAPMethodLEAP, eap_method_leap, EAP, METHOD_LEAP, GtkGrid)
-EAPMethodLEAP *eap_method_leap_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+EAPMethodLEAP *eap_method_leap_new (NMConnection *connection,
gboolean secrets_only);
G_END_DECLS
diff --git a/panels/network/wireless-security/eap-method-peap.c
b/panels/network/wireless-security/eap-method-peap.c
index 5487a5e51..361e9581d 100644
--- a/panels/network/wireless-security/eap-method-peap.c
+++ b/panels/network/wireless-security/eap-method-peap.c
@@ -27,7 +27,6 @@
#include "eap-method-simple.h"
#include "helpers.h"
#include "ui-helpers.h"
-#include "wireless-security.h"
#define I_NAME_COLUMN 0
#define I_ID_COLUMN 1
@@ -176,13 +175,20 @@ static void
inner_auth_combo_changed_cb (EAPMethodPEAP *self)
{
EAPMethod *inner_method;
- GList *elt, *children;
+ GList *children;
+ inner_method = get_inner_method (self);
+
+ /* Remove the previous method and migrate username/password across */
children = gtk_container_get_children (GTK_CONTAINER (self->inner_auth_box));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (elt->data));
+ if (children != NULL) {
+ EAPMethod *old_eap = g_list_nth_data (children, 0);
+ eap_method_set_username (inner_method, eap_method_get_username (old_eap));
+ eap_method_set_password (inner_method, eap_method_get_password (old_eap));
+ eap_method_set_show_password (inner_method, eap_method_get_show_password (old_eap));
+ gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (old_eap));
+ }
- inner_method = get_inner_method (self);
gtk_container_add (GTK_CONTAINER (self->inner_auth_box), g_object_ref (GTK_WIDGET (inner_method)));
eap_method_emit_changed (EAP_METHOD (self));
@@ -211,6 +217,48 @@ get_password_flags_name (EAPMethod *method)
return NM_SETTING_802_1X_PASSWORD;
}
+static const gchar *
+get_username (EAPMethod *method)
+{
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ return eap_method_get_username (get_inner_method (self));
+}
+
+static void
+set_username (EAPMethod *method, const gchar *username)
+{
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ return eap_method_set_username (get_inner_method (self), username);
+}
+
+static const gchar *
+get_password (EAPMethod *method)
+{
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ return eap_method_get_password (get_inner_method (self));
+}
+
+static void
+set_password (EAPMethod *method, const gchar *password)
+{
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ return eap_method_set_password (get_inner_method (self), password);
+}
+
+static gboolean
+get_show_password (EAPMethod *method)
+{
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ return eap_method_get_show_password (get_inner_method (self));
+}
+
+static void
+set_show_password (EAPMethod *method, gboolean show_password)
+{
+ EAPMethodPEAP *self = EAP_METHOD_PEAP (method);
+ return eap_method_set_show_password (get_inner_method (self), show_password);
+}
+
static void
changed_cb (EAPMethodPEAP *self)
{
@@ -252,11 +300,16 @@ eap_method_iface_init (EAPMethodInterface *iface)
iface->update_secrets = update_secrets;
iface->get_default_field = get_default_field;
iface->get_password_flags_name = get_password_flags_name;
+ iface->get_username = get_username;
+ iface->set_username = set_username;
+ iface->get_password = get_password;
+ iface->set_password = set_password;
+ iface->get_show_password = get_show_password;
+ iface->set_show_password = set_show_password;
}
EAPMethodPEAP *
-eap_method_peap_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+eap_method_peap_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
@@ -299,22 +352,19 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
if (secrets_only)
simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY;
- self->em_mschap_v2 = eap_method_simple_new (ws_parent,
- connection,
+ self->em_mschap_v2 = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_md5 = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_MD5,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_gtc = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_GTC,
simple_flags);
gtk_widget_show (GTK_WIDGET (self->em_gtc));
diff --git a/panels/network/wireless-security/eap-method-peap.h
b/panels/network/wireless-security/eap-method-peap.h
index b79641799..11122d3ff 100644
--- a/panels/network/wireless-security/eap-method-peap.h
+++ b/panels/network/wireless-security/eap-method-peap.h
@@ -25,14 +25,11 @@
#include <gtk/gtk.h>
#include <NetworkManager.h>
-#include "wireless-security.h"
-
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EAPMethodPEAP, eap_method_peap, EAP, METHOD_PEAP, GtkGrid)
-EAPMethodPEAP *eap_method_peap_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+EAPMethodPEAP *eap_method_peap_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
diff --git a/panels/network/wireless-security/eap-method-simple.c
b/panels/network/wireless-security/eap-method-simple.c
index f4324e92d..8909a9b10 100644
--- a/panels/network/wireless-security/eap-method-simple.c
+++ b/panels/network/wireless-security/eap-method-simple.c
@@ -27,7 +27,6 @@
#include "helpers.h"
#include "nma-ui-utils.h"
#include "ui-helpers.h"
-#include "wireless-security.h"
struct _EAPMethodSimple {
GtkGrid parent;
@@ -38,8 +37,6 @@ struct _EAPMethodSimple {
GtkEntry *username_entry;
GtkLabel *username_label;
- WirelessSecurity *ws_parent;
-
EAPMethodSimpleType type;
EAPMethodSimpleFlags flags;
@@ -212,6 +209,48 @@ get_phase2 (EAPMethod *method)
return self->flags & EAP_METHOD_SIMPLE_FLAG_PHASE2;
}
+static const gchar *
+get_username (EAPMethod *method)
+{
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
+ return gtk_entry_get_text (self->username_entry);
+}
+
+static void
+set_username (EAPMethod *method, const gchar *username)
+{
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
+ gtk_entry_set_text (self->username_entry, username);
+}
+
+static const gchar *
+get_password (EAPMethod *method)
+{
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
+ return gtk_entry_get_text (self->password_entry);
+}
+
+static void
+set_password (EAPMethod *method, const gchar *password)
+{
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
+ gtk_entry_set_text (self->password_entry, password);
+}
+
+static gboolean
+get_show_password (EAPMethod *method)
+{
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_password_check));
+}
+
+static void
+set_show_password (EAPMethod *method, gboolean show_password)
+{
+ EAPMethodSimple *self = EAP_METHOD_SIMPLE (method);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->show_password_check), show_password);
+}
+
static gboolean
stuff_changed (EAPMethodSimple *self)
{
@@ -241,47 +280,12 @@ password_storage_changed (EAPMethodSimple *self)
self->idle_func_id = g_idle_add ((GSourceFunc) stuff_changed, self);
}
-/* Set the UI fields for user, password, always_ask and show_password to the
- * values as provided by self->ws_parent. */
-static void
-set_userpass_ui (EAPMethodSimple *self)
-{
- if (wireless_security_get_username (self->ws_parent))
- gtk_entry_set_text (self->username_entry, wireless_security_get_username (self->ws_parent));
- else
- gtk_entry_set_text (self->username_entry, "");
-
- if (wireless_security_get_password (self->ws_parent) && !wireless_security_get_always_ask
(self->ws_parent))
- gtk_entry_set_text (self->password_entry, wireless_security_get_password (self->ws_parent));
- else
- gtk_entry_set_text (self->password_entry, "");
-
- gtk_toggle_button_set_active (self->show_password_check, wireless_security_get_show_password
(self->ws_parent));
-}
-
-static void
-widgets_realized (EAPMethodSimple *self)
-{
- set_userpass_ui (self);
-}
-
-static void
-widgets_unrealized (EAPMethodSimple *self)
-{
- wireless_security_set_username (self->ws_parent, gtk_entry_get_text (self->username_entry));
- wireless_security_set_password (self->ws_parent, gtk_entry_get_text (self->password_entry));
- wireless_security_set_always_ask (self->ws_parent, always_ask_selected (self->password_entry));
- wireless_security_set_show_password (self->ws_parent, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(self->show_password_check)));
-}
-
static void
eap_method_simple_dispose (GObject *object)
{
EAPMethodSimple *self = EAP_METHOD_SIMPLE (object);
g_signal_handlers_disconnect_by_data (self, self);
- g_signal_handlers_disconnect_by_data (self->username_entry, self->ws_parent);
- g_signal_handlers_disconnect_by_data (self->password_entry, self->ws_parent);
g_signal_handlers_disconnect_by_data (self->password_entry, self);
g_signal_handlers_disconnect_by_data (self->show_password_check, self);
@@ -332,11 +336,16 @@ eap_method_iface_init (EAPMethodInterface *iface)
iface->get_default_field = get_default_field;
iface->get_password_flags_name = get_password_flags_name;
iface->get_phase2 = get_phase2;
+ iface->get_username = get_username;
+ iface->set_username = set_username;
+ iface->get_password = get_password;
+ iface->set_password = set_password;
+ iface->get_show_password = get_show_password;
+ iface->set_show_password = set_show_password;
}
EAPMethodSimple *
-eap_method_simple_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+eap_method_simple_new (NMConnection *connection,
EAPMethodSimpleType type,
EAPMethodSimpleFlags flags)
{
@@ -344,14 +353,10 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
NMSetting8021x *s_8021x = NULL;
self = g_object_new (eap_method_simple_get_type (), NULL);
- self->ws_parent = ws_parent;
self->flags = flags;
self->type = type;
g_assert (type < EAP_METHOD_SIMPLE_TYPE_LAST);
- g_signal_connect_swapped (self, "realize", G_CALLBACK (widgets_realized), self);
- g_signal_connect_swapped (self, "unrealize", G_CALLBACK (widgets_unrealized), self);
-
g_signal_connect_swapped (self->username_entry, "changed", G_CALLBACK (changed_cb), self);
if (self->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY)
@@ -369,14 +374,6 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
g_signal_connect_swapped (self->show_password_check, "toggled", G_CALLBACK (show_toggled_cb), self);
- /* Initialize the UI fields with the security settings from self->ws_parent.
- * This will be done again when the widget gets realized. It must be done here as well,
- * because the outer dialog will ask to 'validate' the connection before the security tab
- * is shown/realized (to enable the 'Apply' button).
- * As 'validate' accesses the contents of the UI fields, they must be initialized now, even
- * if the widgets are not yet visible. */
- set_userpass_ui (self);
-
return self;
}
diff --git a/panels/network/wireless-security/eap-method-simple.h
b/panels/network/wireless-security/eap-method-simple.h
index 527b7dbc4..a06f72806 100644
--- a/panels/network/wireless-security/eap-method-simple.h
+++ b/panels/network/wireless-security/eap-method-simple.h
@@ -25,8 +25,6 @@
#include <gtk/gtk.h>
#include <NetworkManager.h>
-#include "wireless-security.h"
-
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EAPMethodSimple, eap_method_simple, EAP, METHOD_SIMPLE, GtkGrid)
@@ -58,8 +56,7 @@ typedef enum {
EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY = 0x08
} EAPMethodSimpleFlags;
-EAPMethodSimple *eap_method_simple_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+EAPMethodSimple *eap_method_simple_new (NMConnection *connection,
EAPMethodSimpleType type,
EAPMethodSimpleFlags flags);
diff --git a/panels/network/wireless-security/eap-method-tls.c
b/panels/network/wireless-security/eap-method-tls.c
index 96083d632..cb0678bcf 100644
--- a/panels/network/wireless-security/eap-method-tls.c
+++ b/panels/network/wireless-security/eap-method-tls.c
@@ -47,6 +47,9 @@ struct _EAPMethodTLS {
gboolean phase2;
const gchar *password_flags_name;
gboolean editing_connection;
+ gchar *username;
+ gchar *password;
+ gboolean show_password;
};
static void eap_method_iface_init (EAPMethodInterface *);
@@ -54,6 +57,17 @@ static void eap_method_iface_init (EAPMethodInterface *);
G_DEFINE_TYPE_WITH_CODE (EAPMethodTLS, eap_method_tls, GTK_TYPE_GRID,
G_IMPLEMENT_INTERFACE (eap_method_get_type (), eap_method_iface_init))
+static void
+eap_method_tls_dispose (GObject *object)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (object);
+
+ g_clear_pointer (&self->username, g_free);
+ g_clear_pointer (&self->password, g_free);
+
+ G_OBJECT_CLASS (eap_method_tls_parent_class)->dispose (object);
+}
+
static void
show_toggled_cb (EAPMethodTLS *self)
{
@@ -417,17 +431,66 @@ get_phase2 (EAPMethod *method)
return self->phase2;
}
+static const gchar *
+get_username (EAPMethod *method)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
+ return self->username;
+}
+
+static void
+set_username (EAPMethod *method, const gchar *username)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
+ g_free (self->username);
+ self->username = g_strdup (username);
+}
+
+static const gchar *
+get_password (EAPMethod *method)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
+ return self->password;
+}
+
+static void
+set_password (EAPMethod *method, const gchar *password)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
+ g_free (self->password);
+ self->password = g_strdup (password);
+}
+
+static const gboolean
+get_show_password (EAPMethod *method)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
+ return self->show_password;
+}
+
+static void
+set_show_password (EAPMethod *method, gboolean show_password)
+{
+ EAPMethodTLS *self = EAP_METHOD_TLS (method);
+ self->show_password = show_password;
+}
+
static void
eap_method_tls_init (EAPMethodTLS *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+ self->username = g_strdup ("");
+ self->password = g_strdup ("");
}
static void
eap_method_tls_class_init (EAPMethodTLSClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->dispose = eap_method_tls_dispose;
+
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/ControlCenter/network/eap-method-tls.ui");
gtk_widget_class_bind_template_child (widget_class, EAPMethodTLS, ca_cert_button);
@@ -454,6 +517,12 @@ eap_method_iface_init (EAPMethodInterface *iface)
iface->get_default_field = get_default_field;
iface->get_password_flags_name = get_password_flags_name;
iface->get_phase2 = get_phase2;
+ iface->get_username = get_username;
+ iface->set_username = set_username;
+ iface->get_password = get_password;
+ iface->set_password = set_password;
+ iface->get_show_password = get_show_password;
+ iface->set_show_password = set_show_password;
}
EAPMethodTLS *
diff --git a/panels/network/wireless-security/eap-method-ttls.c
b/panels/network/wireless-security/eap-method-ttls.c
index 198b08a18..a3cd130b5 100644
--- a/panels/network/wireless-security/eap-method-ttls.c
+++ b/panels/network/wireless-security/eap-method-ttls.c
@@ -26,7 +26,6 @@
#include "eap-method-simple.h"
#include "eap-method-ttls.h"
#include "helpers.h"
-#include "wireless-security.h"
#define I_NAME_COLUMN 0
#define I_ID_COLUMN 1
@@ -180,13 +179,20 @@ static void
inner_auth_combo_changed_cb (EAPMethodTTLS *self)
{
EAPMethod *inner_method;
- GList *elt, *children;
+ GList *children;
+ inner_method = get_inner_method (self);
+
+ /* Remove the previous method and migrate username/password across */
children = gtk_container_get_children (GTK_CONTAINER (self->inner_auth_box));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (elt->data));
+ if (children != NULL) {
+ EAPMethod *old_eap = g_list_nth_data (children, 0);
+ eap_method_set_username (inner_method, eap_method_get_username (old_eap));
+ eap_method_set_password (inner_method, eap_method_get_password (old_eap));
+ eap_method_set_show_password (inner_method, eap_method_get_show_password (old_eap));
+ gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (old_eap));
+ }
- inner_method = get_inner_method (self);
gtk_container_add (GTK_CONTAINER (self->inner_auth_box), g_object_ref (GTK_WIDGET (inner_method)));
eap_method_emit_changed (EAP_METHOD (self));
@@ -219,6 +225,48 @@ get_password_flags_name (EAPMethod *method)
return NM_SETTING_802_1X_PASSWORD;
}
+static const gchar *
+get_username (EAPMethod *method)
+{
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ return eap_method_get_username (get_inner_method (self));
+}
+
+static void
+set_username (EAPMethod *method, const gchar *username)
+{
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ return eap_method_set_username (get_inner_method (self), username);
+}
+
+static const gchar *
+get_password (EAPMethod *method)
+{
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ return eap_method_get_password (get_inner_method (self));
+}
+
+static void
+set_password (EAPMethod *method, const gchar *password)
+{
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ return eap_method_set_password (get_inner_method (self), password);
+}
+
+static gboolean
+get_show_password (EAPMethod *method)
+{
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ return eap_method_get_show_password (get_inner_method (self));
+}
+
+static void
+set_show_password (EAPMethod *method, gboolean show_password)
+{
+ EAPMethodTTLS *self = EAP_METHOD_TTLS (method);
+ return eap_method_set_show_password (get_inner_method (self), show_password);
+}
+
static void
changed_cb (EAPMethodTTLS *self)
{
@@ -260,11 +308,16 @@ eap_method_iface_init (EAPMethodInterface *iface)
iface->update_secrets = update_secrets;
iface->get_default_field = get_default_field;
iface->get_password_flags_name = get_password_flags_name;
+ iface->get_username = get_username;
+ iface->set_username = set_username;
+ iface->get_password = get_password;
+ iface->set_password = set_password;
+ iface->get_show_password = get_show_password;
+ iface->set_show_password = set_show_password;
}
EAPMethodTTLS *
-eap_method_ttls_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+eap_method_ttls_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
{
@@ -314,50 +367,43 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
if (secrets_only)
simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY;
- self->em_pap = eap_method_simple_new (ws_parent,
- connection,
+ self->em_pap = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_PAP,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_mschap = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_MSCHAP,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_mschap_v2 = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_plain_mschap_v2 = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_PLAIN_MSCHAP_V2,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_chap = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_CHAP,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_md5 = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_MD5,
simple_flags);
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 (ws_parent,
- connection,
+ self->em_gtc = eap_method_simple_new (connection,
EAP_METHOD_SIMPLE_TYPE_GTC,
simple_flags);
gtk_widget_show (GTK_WIDGET (self->em_gtc));
diff --git a/panels/network/wireless-security/eap-method-ttls.h
b/panels/network/wireless-security/eap-method-ttls.h
index 9a0be55ef..50fc9a0ab 100644
--- a/panels/network/wireless-security/eap-method-ttls.h
+++ b/panels/network/wireless-security/eap-method-ttls.h
@@ -25,14 +25,11 @@
#include <gtk/gtk.h>
#include <NetworkManager.h>
-#include "wireless-security.h"
-
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EAPMethodTTLS, eap_method_ttls, EAP, METHOD_TTLS, GtkGrid)
-EAPMethodTTLS *eap_method_ttls_new (WirelessSecurity *ws_parent,
- NMConnection *connection,
+EAPMethodTTLS *eap_method_ttls_new (NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
diff --git a/panels/network/wireless-security/eap-method.c b/panels/network/wireless-security/eap-method.c
index c392da8f5..fdda35b56 100644
--- a/panels/network/wireless-security/eap-method.c
+++ b/panels/network/wireless-security/eap-method.c
@@ -130,6 +130,48 @@ eap_method_emit_changed (EAPMethod *self)
g_signal_emit (self, signals[CHANGED], 0);
}
+const gchar *
+eap_method_get_username (EAPMethod *self)
+{
+ g_return_val_if_fail (EAP_IS_METHOD (self), NULL);
+ return EAP_METHOD_GET_IFACE (self)->get_username (self);
+}
+
+void
+eap_method_set_username (EAPMethod *self, const gchar *username)
+{
+ g_return_if_fail (EAP_IS_METHOD (self));
+ EAP_METHOD_GET_IFACE (self)->set_username (self, username);
+}
+
+const gchar *
+eap_method_get_password (EAPMethod *self)
+{
+ g_return_val_if_fail (EAP_IS_METHOD (self), NULL);
+ return EAP_METHOD_GET_IFACE (self)->get_password (self);
+}
+
+void
+eap_method_set_password (EAPMethod *self, const gchar *password)
+{
+ g_return_if_fail (EAP_IS_METHOD (self));
+ EAP_METHOD_GET_IFACE (self)->set_password (self, password);
+}
+
+gboolean
+eap_method_get_show_password (EAPMethod *self)
+{
+ g_return_val_if_fail (EAP_IS_METHOD (self), FALSE);
+ return EAP_METHOD_GET_IFACE (self)->get_show_password (self);
+}
+
+void
+eap_method_set_show_password (EAPMethod *self, gboolean show_password)
+{
+ g_return_if_fail (EAP_IS_METHOD (self));
+ EAP_METHOD_GET_IFACE (self)->set_show_password (self, show_password);
+}
+
gboolean
eap_method_validate_filepicker (GtkFileChooser *chooser,
guint32 item_type,
diff --git a/panels/network/wireless-security/eap-method.h b/panels/network/wireless-security/eap-method.h
index d5531e2aa..34b4144ac 100644
--- a/panels/network/wireless-security/eap-method.h
+++ b/panels/network/wireless-security/eap-method.h
@@ -39,6 +39,12 @@ struct _EAPMethodInterface {
GtkWidget* (*get_default_field) (EAPMethod *method);
const gchar* (*get_password_flags_name) (EAPMethod *method);
gboolean (*get_phase2) (EAPMethod *method);
+ const gchar* (*get_username) (EAPMethod *method);
+ void (*set_username) (EAPMethod *method, const gchar *username);
+ const gchar* (*get_password) (EAPMethod *method);
+ void (*set_password) (EAPMethod *method, const gchar *password);
+ gboolean (*get_show_password) (EAPMethod *method);
+ void (*set_show_password) (EAPMethod *method, gboolean show_password);
};
GtkWidget *eap_method_get_default_field (EAPMethod *method);
@@ -59,6 +65,18 @@ void eap_method_fill_connection (EAPMethod *method,
void eap_method_emit_changed (EAPMethod *method);
+const gchar *eap_method_get_username (EAPMethod *method);
+
+void eap_method_set_username (EAPMethod *method, const gchar *username);
+
+const gchar *eap_method_get_password (EAPMethod *method);
+
+void eap_method_set_password (EAPMethod *method, const gchar *password);
+
+gboolean eap_method_get_show_password (EAPMethod *method);
+
+void eap_method_set_show_password (EAPMethod *method, gboolean show_password);
+
/* Below for internal use only */
GtkFileFilter * eap_method_default_file_chooser_filter_new (gboolean privkey);
diff --git a/panels/network/wireless-security/wireless-security.c
b/panels/network/wireless-security/wireless-security.c
index 2759b80b9..5de1b049c 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -26,9 +26,7 @@
#include "wireless-security.h"
#include "wireless-security-resources.h"
-typedef struct {
- char *username, *password;
- gboolean always_ask, show_password;
+typedef struct {
} WirelessSecurityPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (WirelessSecurity, wireless_security, G_TYPE_OBJECT)
@@ -40,21 +38,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-static void
-wireless_security_dispose (GObject *object)
-{
- WirelessSecurity *self = WIRELESS_SECURITY (object);
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- if (priv->password)
- memset (priv->password, 0, strlen (priv->password));
-
- g_clear_pointer (&priv->username, g_free);
- g_clear_pointer (&priv->password, g_free);
-
- G_OBJECT_CLASS (wireless_security_parent_class)->dispose (object);
-}
-
void
wireless_security_init (WirelessSecurity *self)
{
@@ -66,8 +49,6 @@ wireless_security_class_init (WirelessSecurityClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = wireless_security_dispose;
-
signals[CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class),
@@ -135,88 +116,3 @@ wireless_security_adhoc_compatible (WirelessSecurity *self)
else
return TRUE;
}
-
-void
-wireless_security_set_username (WirelessSecurity *self, const gchar *username)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_if_fail (WIRELESS_IS_SECURITY (self));
-
- g_clear_pointer (&priv->username, g_free);
- priv->username = g_strdup (username);
-}
-
-const gchar *
-wireless_security_get_username (WirelessSecurity *self)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL);
-
- return priv->username;
-}
-
-void
-wireless_security_set_password (WirelessSecurity *self, const gchar *password)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_if_fail (WIRELESS_IS_SECURITY (self));
-
- if (priv->password)
- memset (priv->password, 0, strlen (priv->password));
-
- g_clear_pointer (&priv->password, g_free);
- priv->password = g_strdup (password);
-}
-
-const gchar *
-wireless_security_get_password (WirelessSecurity *self)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL);
-
- return priv->password;
-}
-
-void
-wireless_security_set_always_ask (WirelessSecurity *self, gboolean always_ask)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_if_fail (WIRELESS_IS_SECURITY (self));
-
- priv->always_ask = always_ask;
-}
-
-gboolean
-wireless_security_get_always_ask (WirelessSecurity *self)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
-
- return priv->always_ask;
-}
-
-void
-wireless_security_set_show_password (WirelessSecurity *self, gboolean show_password)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_if_fail (WIRELESS_IS_SECURITY (self));
-
- priv->show_password = show_password;
-}
-
-gboolean
-wireless_security_get_show_password (WirelessSecurity *self)
-{
- WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
-
- g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
-
- return priv->show_password;
-}
diff --git a/panels/network/wireless-security/wireless-security.h
b/panels/network/wireless-security/wireless-security.h
index 00ded70a4..a0c6b0184 100644
--- a/panels/network/wireless-security/wireless-security.h
+++ b/panels/network/wireless-security/wireless-security.h
@@ -51,22 +51,6 @@ void wireless_security_fill_connection (WirelessSecurity *sec,
gboolean wireless_security_adhoc_compatible (WirelessSecurity *sec);
-void wireless_security_set_username (WirelessSecurity *sec, const gchar *username);
-
-const gchar *wireless_security_get_username (WirelessSecurity *sec);
-
-void wireless_security_set_password (WirelessSecurity *sec, const gchar *password);
-
-const gchar *wireless_security_get_password (WirelessSecurity *sec);
-
-void wireless_security_set_always_ask (WirelessSecurity *sec, gboolean always_ask);
-
-gboolean wireless_security_get_always_ask (WirelessSecurity *sec);
-
-void wireless_security_set_show_password (WirelessSecurity *sec, gboolean show_password);
-
-gboolean wireless_security_get_show_password (WirelessSecurity *sec);
-
void wireless_security_notify_changed (WirelessSecurity *sec);
G_END_DECLS
diff --git a/panels/network/wireless-security/ws-dynamic-wep.c
b/panels/network/wireless-security/ws-dynamic-wep.c
index b78da7e5f..9b98542d1 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.c
+++ b/panels/network/wireless-security/ws-dynamic-wep.c
@@ -161,18 +161,22 @@ static void
auth_combo_changed_cb (WirelessSecurityDynamicWEP *self)
{
EAPMethod *eap;
- GList *elt, *children;
+ GList *children;
GtkWidget *eap_default_field;
- /* Remove any previous wireless security widgets */
+ eap = get_eap (self);
+
+ /* Remove the previous method and migrate username/password across */
children = gtk_container_get_children (GTK_CONTAINER (self->method_box));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (self->method_box), GTK_WIDGET (elt->data));
+ if (children != NULL) {
+ EAPMethod *old_eap = g_list_nth_data (children, 0);
+ eap_method_set_username (eap, eap_method_get_username (old_eap));
+ eap_method_set_password (eap, eap_method_get_password (old_eap));
+ eap_method_set_show_password (eap, eap_method_get_show_password (old_eap));
+ gtk_container_remove (GTK_CONTAINER (self->method_box), GTK_WIDGET (old_eap));
+ }
- eap = get_eap (self);
gtk_container_add (GTK_CONTAINER (self->method_box), g_object_ref (GTK_WIDGET (eap)));
-
- /* Refocus the EAP method's default widget */
eap_default_field = eap_method_get_default_field (eap);
if (eap_default_field)
gtk_widget_grab_focus (eap_default_field);
@@ -205,8 +209,6 @@ ws_dynamic_wep_new (NMConnection *connection,
gboolean secrets_only)
{
WirelessSecurityDynamicWEP *self;
- const gchar *user = NULL, *password = NULL;
- gboolean always_ask = FALSE;
const gchar *default_method = NULL;
EAPMethodSimpleFlags simple_flags = EAP_METHOD_SIMPLE_FLAG_NONE;
GtkTreeIter iter;
@@ -237,26 +239,6 @@ ws_dynamic_wep_new (NMConnection *connection,
if (default_method == NULL)
default_method = "tls";
- /* initialize WirelessSecurity userpass from connection (clear if no connection) */
- if (connection) {
- NMSetting8021x *setting;
-
- setting = nm_connection_get_setting_802_1x (connection);
- if (setting) {
- NMSettingSecretFlags flags;
-
- user = nm_setting_802_1x_get_identity (setting);
- password = nm_setting_802_1x_get_password (setting);
-
- if (nm_setting_get_secret_flags (NM_SETTING (setting), NM_SETTING_802_1X_PASSWORD,
&flags, NULL))
- always_ask = !!(flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
- }
- }
- wireless_security_set_username (WIRELESS_SECURITY (self), user);
- wireless_security_set_password (WIRELESS_SECURITY (self), password);
- wireless_security_set_always_ask (WIRELESS_SECURITY (self), always_ask);
- wireless_security_set_show_password (WIRELESS_SECURITY (self), FALSE);
-
if (is_editor)
simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR;
if (secrets_only)
@@ -265,19 +247,19 @@ ws_dynamic_wep_new (NMConnection *connection,
self->em_tls = eap_method_tls_new (connection, FALSE, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_tls));
g_signal_connect_object (self->em_tls, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
- self->em_leap = eap_method_leap_new (WIRELESS_SECURITY (self), connection, secrets_only);
+ self->em_leap = eap_method_leap_new (connection, secrets_only);
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 (WIRELESS_SECURITY (self), connection,
EAP_METHOD_SIMPLE_TYPE_PWD, simple_flags);
+ self->em_pwd = eap_method_simple_new (connection, EAP_METHOD_SIMPLE_TYPE_PWD, simple_flags);
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 (WIRELESS_SECURITY (self), connection, is_editor, secrets_only);
+ self->em_fast = eap_method_fast_new (connection, is_editor, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_fast));
g_signal_connect_object (self->em_fast, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
- self->em_ttls = eap_method_ttls_new (WIRELESS_SECURITY (self), connection, is_editor, secrets_only);
+ self->em_ttls = eap_method_ttls_new (connection, is_editor, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_ttls));
g_signal_connect_object (self->em_ttls, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
- self->em_peap = eap_method_peap_new (WIRELESS_SECURITY (self), connection, is_editor, secrets_only);
+ self->em_peap = eap_method_peap_new (connection, is_editor, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_peap));
g_signal_connect_object (self->em_peap, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
@@ -295,6 +277,16 @@ ws_dynamic_wep_new (NMConnection *connection,
gtk_widget_hide (GTK_WIDGET (self->auth_label));
}
+ if (connection) {
+ NMSetting8021x *setting;
+
+ setting = nm_connection_get_setting_802_1x (connection);
+ if (setting) {
+ eap_method_set_username (get_eap (self), nm_setting_802_1x_get_identity (setting));
+ eap_method_set_password (get_eap (self), nm_setting_802_1x_get_password (setting));
+ }
+ }
+
g_signal_connect_object (G_OBJECT (self->auth_combo), "changed", G_CALLBACK (auth_combo_changed_cb),
self, G_CONNECT_SWAPPED);
auth_combo_changed_cb (self);
diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c
index b8a9f0356..e2da862ab 100644
--- a/panels/network/wireless-security/ws-wpa-eap.c
+++ b/panels/network/wireless-security/ws-wpa-eap.c
@@ -176,18 +176,22 @@ static void
auth_combo_changed_cb (WirelessSecurityWPAEAP *self)
{
EAPMethod *eap;
- GList *elt, *children;
+ GList *children;
GtkWidget *eap_default_field;
- /* Remove any previous wireless security widgets */
+ eap = get_eap (self);
+
+ /* Remove the previous method and migrate username/password across */
children = gtk_container_get_children (GTK_CONTAINER (self->method_box));
- for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (self->method_box), GTK_WIDGET (elt->data));
+ if (children != NULL) {
+ EAPMethod *old_eap = g_list_nth_data (children, 0);
+ eap_method_set_username (eap, eap_method_get_username (old_eap));
+ eap_method_set_password (eap, eap_method_get_password (old_eap));
+ eap_method_set_show_password (eap, eap_method_get_show_password (old_eap));
+ gtk_container_remove (GTK_CONTAINER (self->method_box), GTK_WIDGET (old_eap));
+ }
- eap = get_eap (self);
gtk_container_add (GTK_CONTAINER (self->method_box), g_object_ref (GTK_WIDGET (eap)));
-
- /* Refocus the EAP method's default widget */
eap_default_field = eap_method_get_default_field (eap);
if (eap_default_field)
gtk_widget_grab_focus (eap_default_field);
@@ -220,8 +224,6 @@ ws_wpa_eap_new (NMConnection *connection,
gboolean secrets_only)
{
WirelessSecurityWPAEAP *self;
- const gchar *user = NULL, *password = NULL;
- gboolean always_ask = FALSE;
const gchar *remove_method, *default_method = NULL;
gboolean wired = FALSE;
EAPMethodSimpleFlags simple_flags = EAP_METHOD_SIMPLE_FLAG_NONE;
@@ -270,50 +272,30 @@ ws_wpa_eap_new (NMConnection *connection,
default_method = "tls";
}
- /* initialize WirelessSecurity userpass from connection (clear if no connection) */
- if (connection) {
- NMSetting8021x *setting;
-
- setting = nm_connection_get_setting_802_1x (connection);
- if (setting) {
- NMSettingSecretFlags flags;
-
- user = nm_setting_802_1x_get_identity (setting);
- password = nm_setting_802_1x_get_password (setting);
-
- if (nm_setting_get_secret_flags (NM_SETTING (setting), NM_SETTING_802_1X_PASSWORD,
&flags, NULL))
- always_ask = !!(flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
- }
- }
- wireless_security_set_username (WIRELESS_SECURITY (self), user);
- wireless_security_set_password (WIRELESS_SECURITY (self), password);
- wireless_security_set_always_ask (WIRELESS_SECURITY (self), always_ask);
- wireless_security_set_show_password (WIRELESS_SECURITY (self), FALSE);
-
if (is_editor)
simple_flags |= EAP_METHOD_SIMPLE_FLAG_IS_EDITOR;
if (secrets_only)
simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY;
- self->em_md5 = eap_method_simple_new (WIRELESS_SECURITY (self), connection,
EAP_METHOD_SIMPLE_TYPE_MD5, simple_flags);
+ self->em_md5 = eap_method_simple_new (connection, EAP_METHOD_SIMPLE_TYPE_MD5, simple_flags);
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, FALSE, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_tls));
g_signal_connect_object (self->em_tls, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
- self->em_leap = eap_method_leap_new (WIRELESS_SECURITY (self), connection, secrets_only);
+ self->em_leap = eap_method_leap_new (connection, secrets_only);
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 (WIRELESS_SECURITY (self), connection,
EAP_METHOD_SIMPLE_TYPE_PWD, simple_flags);
+ self->em_pwd = eap_method_simple_new (connection, EAP_METHOD_SIMPLE_TYPE_PWD, simple_flags);
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 (WIRELESS_SECURITY (self), connection, is_editor, secrets_only);
+ self->em_fast = eap_method_fast_new (connection, is_editor, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_fast));
g_signal_connect_object (self->em_fast, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
- self->em_ttls = eap_method_ttls_new (WIRELESS_SECURITY (self), connection, is_editor, secrets_only);
+ self->em_ttls = eap_method_ttls_new (connection, is_editor, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_ttls));
g_signal_connect_object (self->em_ttls, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
- self->em_peap = eap_method_peap_new (WIRELESS_SECURITY (self), connection, is_editor, secrets_only);
+ self->em_peap = eap_method_peap_new (connection, is_editor, secrets_only);
gtk_widget_show (GTK_WIDGET (self->em_peap));
g_signal_connect_object (self->em_peap, "changed", G_CALLBACK (wireless_security_notify_changed),
self, G_CONNECT_SWAPPED);
@@ -341,6 +323,17 @@ ws_wpa_eap_new (NMConnection *connection,
gtk_widget_hide (GTK_WIDGET (self->auth_label));
}
+
+ if (connection) {
+ NMSetting8021x *setting;
+
+ setting = nm_connection_get_setting_802_1x (connection);
+ if (setting) {
+ eap_method_set_username (get_eap (self), nm_setting_802_1x_get_identity (setting));
+ eap_method_set_password (get_eap (self), nm_setting_802_1x_get_password (setting));
+ }
+ }
+
g_signal_connect_object (G_OBJECT (self->auth_combo), "changed", G_CALLBACK (auth_combo_changed_cb),
self, G_CONNECT_SWAPPED);
auth_combo_changed_cb (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]