[network-manager-applet/nma-1-0: 16/18] editor: save secrets flags according to the storage icon



commit 6b0cb989da05d945be96beea588674303fd0fefc
Author: Jiří Klimeš <jklimes redhat com>
Date:   Wed Apr 22 15:25:02 2015 +0200

    editor: save secrets flags according to the storage icon

 src/wireless-security/eap-method-leap.c |   18 ++++++++++++------
 src/wireless-security/eap-method-tls.c  |    8 +++++++-
 src/wireless-security/ws-leap.c         |   14 +++++---------
 src/wireless-security/ws-wep-key.c      |   13 ++++---------
 src/wireless-security/ws-wpa-psk.c      |   14 +++++---------
 5 files changed, 33 insertions(+), 34 deletions(-)
---
diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c
index b9186c8..b224fdb 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -86,6 +86,8 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
 {
        EAPMethodLEAP *method = (EAPMethodLEAP *) parent;
        NMSetting8021x *s_8021x;
+       NMSettingSecretFlags secret_flags;
+       GtkWidget *passwd_entry;
 
        s_8021x = nm_connection_get_setting_802_1x (connection);
        g_assert (s_8021x);
@@ -95,14 +97,18 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
        g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (method->username_entry), NULL);
        g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (method->password_entry), NULL);
 
-       /* Update secret flags and popup when editing the connection */
-       if (method->editing_connection) {
-               GtkWidget *passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_leap_password_entry"));
-               g_assert (passwd_entry);
+       passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_password_entry"));
+       g_assert (passwd_entry);
+
+       /* Save 802.1X password flags to the connection */
+       secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+       nm_setting_set_secret_flags (NM_SETTING (s_8021x), parent->password_flags_name,
+                                    secret_flags, NULL);
 
-               nma_utils_update_password_storage (passwd_entry, flags,
+       /* Update secret flags and popup when editing the connection */
+       if (method->editing_connection)
+               nma_utils_update_password_storage (passwd_entry, secret_flags,
                                                   NM_SETTING (s_8021x), parent->password_flags_name);
-       }
 }
 
 static void
diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c
index a368dfc..ba294e9 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -138,6 +138,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
        EAPMethodTLS *method = (EAPMethodTLS *) parent;
        NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
        NMSetting8021x *s_8021x;
+       NMSettingSecretFlags secret_flags;
        GtkWidget *widget, *passwd_entry;
        char *ca_filename, *pk_filename, *cc_filename;
        const char *password = NULL;
@@ -181,9 +182,14 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
        }
        g_free (pk_filename);
 
+       /* Save 802.1X password flags to the connection */
+       secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+       nm_setting_set_secret_flags (NM_SETTING (s_8021x), parent->password_flags_name,
+                                    secret_flags, NULL);
+
        /* Update secret flags and popup when editing the connection */
        if (method->editing_connection) {
-               nma_utils_update_password_storage (passwd_entry, flags,
+               nma_utils_update_password_storage (passwd_entry, secret_flags,
                                                   NM_SETTING (s_8021x), parent->password_flags_name);
        }
 
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index 6a53592..1fd7eb4 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -88,15 +88,6 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
        GtkWidget *widget, *passwd_entry;
        const char *leap_password = NULL, *leap_username = NULL;
 
-       /* Get LEAP_PASSWORD_FLAGS from the old security setting, if any, or
-        * set the flags to NM_SETTING_SECRET_FLAG_AGENT_OWNED by default.
-        */
-       s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
-       if (s_wireless_sec)
-               secret_flags = nm_setting_wireless_security_get_leap_password_flags (s_wireless_sec);
-       else
-               secret_flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
        /* Blow away the old security setting by adding a clear one */
        s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
        nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
@@ -115,6 +106,11 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
                      NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, leap_password,
                      NULL);
 
+       /* Save LEAP_PASSWORD_FLAGS to the connection */
+       secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+       nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), sec->password_flags_name,
+                                    secret_flags, NULL);
+
        /* Update secret flags and popup when editing the connection */
        if (sec->editing_connection)
                nma_utils_update_password_storage (passwd_entry, secret_flags,
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index cc31173..3e08ac9 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -162,15 +162,6 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
        key = gtk_entry_get_text (GTK_ENTRY (widget));
        strcpy (sec->keys[sec->cur_index], key);
 
-       /* Get WEP_KEY_FLAGS from the old security setting, if any. Else
-        * initialize the flags to NM_SETTING_SECRET_FLAG_AGENT_OWNED.
-        */
-       s_wsec = nm_connection_get_setting_wireless_security (connection);
-       if (s_wsec)
-               secret_flags = nm_setting_wireless_security_get_wep_key_flags (s_wsec);
-       else
-               secret_flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
        /* Blow away the old security setting by adding a clear one */
        s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
        nm_connection_add_setting (connection, (NMSetting *) s_wsec);
@@ -187,6 +178,10 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
                        nm_setting_wireless_security_set_wep_key (s_wsec, i, sec->keys[i]);
        }
 
+       /* Save WEP_KEY_FLAGS to the connection */
+       secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+       g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, secret_flags, NULL);
+
        /* Update secret flags and popup when editing the connection */
        if (sec->editing_connection)
                nma_utils_update_password_storage (passwd_entry, secret_flags,
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index 251b24c..a4a036f 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -110,15 +110,6 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
        if (mode && !strcmp (mode, "adhoc"))
                is_adhoc = TRUE;
 
-       /* Get PSK_FLAGS from the old security setting, if any. Else
-        * initialize the flags to NM_SETTING_SECRET_FLAG_AGENT_OWNED.
-        */
-       s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
-       if (s_wireless_sec)
-               secret_flags = nm_setting_wireless_security_get_psk_flags (s_wireless_sec);
-       else
-               secret_flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
        /* Blow away the old security setting by adding a clear one */
        s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
        nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
@@ -128,6 +119,11 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
        key = gtk_entry_get_text (GTK_ENTRY (widget));
        g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
 
+       /* Save PSK_FLAGS to the connection */
+       secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+       nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK,
+                                    secret_flags, NULL);
+
        /* Update secret flags and popup when editing the connection */
        if (wpa_psk->editing_connection)
                nma_utils_update_password_storage (passwd_entry, secret_flags,


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