[network-manager-applet/jk/password-icon-1-0: 17/17] libnm-gtk: allow sensitive "always-ask" entry



commit ffc8707e43605e15c952106a53585d540d929a2c
Author: Jiří Klimeš <jklimes redhat com>
Date:   Fri Apr 24 13:38:25 2015 +0200

    libnm-gtk: allow sensitive "always-ask" entry
    
    and use the parameter properly when nm-applet asks for a password.

 src/libnm-gtk/nm-ui-utils.c               |   21 ++++++++++++++++-----
 src/libnm-gtk/nm-ui-utils.h               |    3 ++-
 src/wireless-security/eap-method-leap.c   |    3 ++-
 src/wireless-security/eap-method-simple.c |    3 ++-
 src/wireless-security/eap-method-tls.c    |    3 ++-
 src/wireless-security/ws-leap.c           |    3 ++-
 src/wireless-security/ws-wep-key.c        |    3 ++-
 src/wireless-security/ws-wpa-psk.c        |    3 ++-
 8 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/src/libnm-gtk/nm-ui-utils.c b/src/libnm-gtk/nm-ui-utils.c
index 63e1569..8b6f50c 100644
--- a/src/libnm-gtk/nm-ui-utils.c
+++ b/src/libnm-gtk/nm-ui-utils.c
@@ -597,6 +597,10 @@ nma_utils_get_connection_device_name (NMConnection *connection)
 /*---------------------------------------------------------------------------*/
 /* Password storage icon */
 
+#define PASSWORD_STORAGE_MENU_TAG  "password-storage-menu"
+#define MENU_WITH_NOT_REQUIRED_TAG "menu-with-not-required"
+#define SENSITIVE_ASK_ENTRY        "sensitive-aski-entry"
+
 typedef enum {
        ITEM_STORAGE_USER    = 0,
        ITEM_STORAGE_SYSTEM  = 1,
@@ -634,6 +638,8 @@ static void
 change_password_storage_icon (GtkWidget *passwd_entry, MenuItem item)
 {
        const char *old_pwd;
+       gboolean sensitive_ask;
+
        g_return_if_fail (item >= 0 && item <= ITEM_STORAGE_MAX);
 
        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (passwd_entry),
@@ -649,7 +655,9 @@ change_password_storage_icon (GtkWidget *passwd_entry, MenuItem item)
         * Let's workaround that by disabling focus for entry instead of
         * sensitivity change.
        */
-       if (item == ITEM_STORAGE_ASK || item == ITEM_STORAGE_UNUSED) {
+       sensitive_ask = !!g_object_get_data (G_OBJECT (passwd_entry), SENSITIVE_ASK_ENTRY);
+       if (   (item == ITEM_STORAGE_ASK && !sensitive_ask)
+           || item == ITEM_STORAGE_UNUSED) {
                /* Store the old password */
                old_pwd = gtk_entry_get_text (GTK_ENTRY (passwd_entry));
                if (old_pwd && *old_pwd)
@@ -765,9 +773,6 @@ icon_release_cb (GtkEntry *entry,
        }
 }
 
-#define PASSWORD_STORAGE_MENU_TAG  "password-storage-menu"
-#define MENU_WITH_NOT_REQUIRED_TAG "menu-with-not-required"
-
 /**
  * nma_utils_setup_password_storage:
  * @passwd_entry: password #GtkEntry which the icon is attached to
@@ -775,6 +780,8 @@ icon_release_cb (GtkEntry *entry,
  * @setting: #NMSetting containing the password, or NULL
  * @password_flags_name: name of the secret flags (like psk-flags), or NULL
  * @with_not_required: whether to include "Not required" menu item
+ * @sensitive_ask: %TRUE if entry should be sensivive on selected "always-ask"
+ *   icon (this is e.f. for nm-applet asking for password)
  *
  * Adds a secondary icon and creates a popup menu for password entry.
  * The active menu item is set up according to initial_flags, or
@@ -787,7 +794,8 @@ nma_utils_setup_password_storage (GtkWidget *passwd_entry,
                                   NMSettingSecretFlags initial_flags,
                                   NMSetting *setting,
                                   const char *password_flags_name,
-                                  gboolean with_not_required)
+                                  gboolean with_not_required,
+                                  gboolean sensitive_ask)
 {
        GtkWidget *popup_menu;
        GtkWidget *item[4];
@@ -796,6 +804,9 @@ nma_utils_setup_password_storage (GtkWidget *passwd_entry,
        PopupMenuItemInfo *info;
        NMSettingSecretFlags secret_flags;
 
+       /* Whether entry should be sensitive if "always-ask" is active " */
+       g_object_set_data (G_OBJECT (passwd_entry), SENSITIVE_ASK_ENTRY, GUINT_TO_POINTER (sensitive_ask));
+
        popup_menu = gtk_menu_new ();
        g_object_set_data (G_OBJECT (popup_menu), PASSWORD_STORAGE_MENU_TAG, GUINT_TO_POINTER (TRUE));
        g_object_set_data (G_OBJECT (popup_menu), MENU_WITH_NOT_REQUIRED_TAG, GUINT_TO_POINTER 
(with_not_required));
diff --git a/src/libnm-gtk/nm-ui-utils.h b/src/libnm-gtk/nm-ui-utils.h
index 9db1795..d821d98 100644
--- a/src/libnm-gtk/nm-ui-utils.h
+++ b/src/libnm-gtk/nm-ui-utils.h
@@ -45,7 +45,8 @@ void nma_utils_setup_password_storage (GtkWidget *passwd_entry,
                                        NMSettingSecretFlags initial_flags,
                                        NMSetting *setting,
                                        const char *password_flags_name,
-                                       gboolean with_not_required);
+                                       gboolean with_not_required,
+                                       gboolean sensitive_ask);
 NMSettingSecretFlags nma_utils_menu_to_secret_flags (GtkWidget *passwd_entry);
 void nma_utils_update_password_storage (GtkWidget *passwd_entry,
                                         NMSettingSecretFlags secret_flags,
diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c
index b224fdb..461ced4 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -231,7 +231,8 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
        /* Create password-storage popup menu for password entry under entry's secondary icon */
        if (connection)
                s_8021x = nm_connection_get_setting_802_1x (connection);
-       nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name, 
FALSE);
+       nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
+                                         FALSE, secrets_only);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapleap"));
        g_assert (widget);
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c
index 9402254..fe7680d 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -335,7 +335,8 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
        /* Create password-storage popup menu for password entry under entry's secondary icon */
        if (connection)
                s_8021x = nm_connection_get_setting_802_1x (connection);
-       nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name, 
FALSE);
+       nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
+                                         FALSE, flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY);
 
        g_signal_connect (method->password_entry, "notify::secondary-icon-name",
                          G_CALLBACK (password_storage_changed),
diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c
index ba294e9..ff8cfdb 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -495,7 +495,8 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
                          ws_parent);
 
        /* Create password-storage popup menu for password entry under entry's secondary icon */
-       nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name, 
FALSE);
+       nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
+                                         FALSE, secrets_only);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eaptls"));
        g_assert (widget);
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index 1fd7eb4..34e6257 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -171,7 +171,8 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
                          sec);
 
        /* Create password-storage popup menu for password entry under entry's secondary icon */
-       nma_utils_setup_password_storage (widget, 0, (NMSetting *) wsec, sec->password_flags_name, FALSE);
+       nma_utils_setup_password_storage (widget, 0, (NMSetting *) wsec, sec->password_flags_name,
+                                         FALSE, secrets_only);
 
        if (wsec)
                update_secrets (WIRELESS_SECURITY (sec), connection);
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index 3e08ac9..2399ace 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -265,7 +265,8 @@ ws_wep_key_new (NMConnection *connection,
        /* Create password-storage popup menu for password entry under entry's secondary icon */
        if (connection)
                setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
-       nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name, FALSE);
+       nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
+                                         FALSE, secrets_only);
 
        if (connection) {
                NMSettingWireless *s_wireless;
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index a4a036f..5cd658a 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -194,7 +194,8 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
        /* Create password-storage popup menu for password entry under entry's secondary icon */
        if (connection)
                setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
-       nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name, FALSE);
+       nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
+                                         FALSE, secrets_only);
 
        /* Fill secrets, if any */
        if (connection)


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