[network-manager-applet/thaller/rh1000564_wifi_security_userpass: 1/2] editor: fix missing user/password when loading wifi connection to edit



commit e4610f91e7cc736c2308a731d60aba4d25e4eb8d
Author: Thomas Haller <thaller redhat com>
Date:   Fri Aug 23 20:41:06 2013 +0200

    editor: fix missing user/password when loading wifi connection to edit
    
    When you opened an existing wifi in nm-connection-editor, the username
    and password field were unset for WPA & WPA2 Enterprise.
    
    (This regression was introduced by commit c9476e9c07839e71aed49e820e364ad0b9f47039)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1000564
    
    Signed-off-by: Thomas Haller <thaller redhat com>

 src/wireless-security/eap-method-leap.c   |   11 -----------
 src/wireless-security/eap-method-simple.c |   20 --------------------
 src/wireless-security/wireless-security.c |   29 +++++++++++++++++++++++++++++
 src/wireless-security/wireless-security.h |    2 ++
 4 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c
index 281ff2b..f220179 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -180,13 +180,6 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
        g_signal_connect (G_OBJECT (widget), "changed",
                          (GCallback) wireless_security_changed_cb,
                          ws_parent);
-       if (connection) {
-               NMSetting8021x *s_8021x;
-
-               s_8021x = nm_connection_get_setting_802_1x (connection);
-               if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
-                       gtk_entry_set_text (method->username_entry, nm_setting_802_1x_get_identity (s_8021x));
-       }
 
        if (secrets_only)
                gtk_widget_set_sensitive (widget, FALSE);
@@ -198,10 +191,6 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
                          (GCallback) wireless_security_changed_cb,
                          ws_parent);
 
-       /* Fill secrets, if any */
-       if (connection)
-               update_secrets (parent, connection);
-
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapleap"));
        g_assert (widget);
        method->show_password = GTK_TOGGLE_BUTTON (widget);
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c
index 02bff33..b5ffa70 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -228,8 +228,6 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
        EAPMethod *parent;
        EAPMethodSimple *method;
        GtkWidget *widget;
-       gboolean not_saved = FALSE;
-       NMSetting8021x *s_8021x = NULL;
 
        parent = eap_method_init (sizeof (EAPMethodSimple),
                                  validate,
@@ -265,11 +263,6 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
        g_signal_connect (G_OBJECT (widget), "changed",
                          (GCallback) wireless_security_changed_cb,
                          ws_parent);
-       if (connection) {
-               s_8021x = nm_connection_get_setting_802_1x (connection);
-               if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
-                       gtk_entry_set_text (method->username_entry, nm_setting_802_1x_get_identity (s_8021x));
-       }
 
        if (secrets_only)
                gtk_widget_set_sensitive (widget, FALSE);
@@ -302,19 +295,6 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
        if (secrets_only)
                gtk_widget_hide (widget);
 
-       if (s_8021x) {
-               NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
-
-               nm_setting_get_secret_flags (NM_SETTING (s_8021x), NM_SETTING_802_1X_PASSWORD, &flags, NULL);
-               not_saved = (flags & NM_SETTING_SECRET_FLAG_NOT_SAVED);
-       }
-
-       gtk_toggle_button_set_active (method->always_ask, not_saved);
-
-       /* Fill secrets if there's a static (ie, not OTP) password */
-       if (connection && (not_saved == FALSE))
-               update_secrets (EAP_METHOD (method), connection);
-
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapsimple"));
        g_assert (widget);
        method->show_password = GTK_TOGGLE_BUTTON (widget);
diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c
index 82de85b..97dc6e0 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -248,6 +248,32 @@ wireless_security_set_userpass (WirelessSecurity *sec,
 }
 
 void
+wireless_security_set_userpass_802_1x (WirelessSecurity *sec,
+                                       NMConnection *connection)
+{
+       const char *user = NULL, *password = NULL;
+       gboolean always_ask = FALSE, show_password = FALSE;
+       NMSetting8021x  *setting;
+       NMSettingSecretFlags flags;
+
+       if (!connection)
+               goto set;
+
+       setting = nm_connection_get_setting_802_1x (connection);
+       if (!setting)
+               goto set;
+
+       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;
+
+set:
+       wireless_security_set_userpass (sec, user, password, always_ask, show_password);
+}
+
+void
 wireless_security_clear_ciphers (NMConnection *connection)
 {
        NMSettingWirelessSecurity *s_wireless_sec;
@@ -395,6 +421,9 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
                        default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
        }
 
+       /* initialize WirelessSecurity userpass from connection (clear if no connection) */
+       wireless_security_set_userpass_802_1x (sec, connection);
+
        auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ());
 
        if (wired) {
diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h
index 78f4124..992d89d 100644
--- a/src/wireless-security/wireless-security.h
+++ b/src/wireless-security/wireless-security.h
@@ -89,6 +89,8 @@ void wireless_security_set_userpass (WirelessSecurity *sec,
                                      const char *password,
                                      gboolean always_ask,
                                      gboolean show_password);
+void wireless_security_set_userpass_802_1x (WirelessSecurity *sec,
+                                            NMConnection *connection);
 
 WirelessSecurity *wireless_security_ref (WirelessSecurity *sec);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]