[network-manager-applet/NMA_0_8] applet: don't show irrelevant security options during secrets requests



commit 089b982f013bf6469c6b7aba8fc2515fb90edf29
Author: Dan Williams <dcbw redhat com>
Date:   Thu Jun 23 15:26:28 2011 +0200

    applet: don't show irrelevant security options during secrets requests
    
    Since secrets requests can only change secrets, don't bother showing the
    user options they can't actually change when asking for secrets during
    a connection attempt.  All the options are still shown in the editor
    and when initially connecting to a new AP.
    
    Cherry-picked from eb2828fd6338dcb3bda53e8007163edbdd392eda (master)
    and rebased to NMA_0_8 branch by jklimes.

 src/applet-device-wifi.c                       |    4 +-
 src/connection-editor/page-wired-security.c    |    2 +-
 src/connection-editor/page-wireless-security.c |    8 ++--
 src/wired-dialog.c                             |    2 +-
 src/wireless-dialog.c                          |   41 ++++++++++++++----------
 src/wireless-dialog.h                          |    3 +-
 src/wireless-security/eap-method-leap.c        |    6 +++-
 src/wireless-security/eap-method-leap.h        |    3 +-
 src/wireless-security/eap-method-peap.c        |   36 +++++++++++++++++---
 src/wireless-security/eap-method-peap.h        |    3 +-
 src/wireless-security/eap-method-simple.c      |    9 +++++-
 src/wireless-security/eap-method-simple.h      |    3 +-
 src/wireless-security/eap-method-tls.c         |   20 +++++++++++-
 src/wireless-security/eap-method-tls.h         |    3 +-
 src/wireless-security/eap-method-ttls.c        |   34 +++++++++++++++----
 src/wireless-security/eap-method-ttls.h        |    3 +-
 src/wireless-security/eap-method.h             |    1 +
 src/wireless-security/wireless-security.c      |   23 +++++++++----
 src/wireless-security/wireless-security.h      |    4 ++-
 src/wireless-security/ws-dynamic-wep.c         |    7 +++-
 src/wireless-security/ws-dynamic-wep.h         |    3 +-
 src/wireless-security/ws-leap.c                |    5 ++-
 src/wireless-security/ws-leap.h                |    2 +-
 src/wireless-security/ws-wep-key.c             |    6 ++--
 src/wireless-security/ws-wep-key.h             |    2 +-
 src/wireless-security/ws-wpa-eap.c             |    7 +++-
 src/wireless-security/ws-wpa-eap.h             |    3 +-
 src/wireless-security/ws-wpa-psk.c             |    6 +++-
 src/wireless-security/ws-wpa-psk.h             |    2 +-
 29 files changed, 182 insertions(+), 69 deletions(-)
---
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 7d41779..d331209 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1563,7 +1563,7 @@ wireless_get_more_info (NMDevice *device,
 	WirelessMenuItemInfo *info = (WirelessMenuItemInfo *) user_data;
 	GtkWidget *dialog;
 
-	dialog = nma_wireless_dialog_new (applet, connection, device, info->ap);
+	dialog = nma_wireless_dialog_new (applet, connection, device, info->ap, FALSE);
 	g_return_if_fail (dialog != NULL);
 
 	g_signal_connect (dialog, "response",
@@ -1804,7 +1804,7 @@ wireless_get_secrets (NMDevice *device,
 	info = g_malloc0 (sizeof (NMWifiInfo));
 
 	ap = nm_device_wifi_get_access_point_by_path (NM_DEVICE_WIFI (device), specific_object);
-	info->dialog = nma_wireless_dialog_new (applet, NM_CONNECTION (connection), device, ap);
+	info->dialog = nma_wireless_dialog_new (applet, NM_CONNECTION (connection), device, ap, TRUE);
 	if (!info->dialog) {
 		g_set_error (error,
 		             NM_SETTINGS_INTERFACE_ERROR,
diff --git a/src/connection-editor/page-wired-security.c b/src/connection-editor/page-wired-security.c
index e955b50..4dd2b53 100644
--- a/src/connection-editor/page-wired-security.c
+++ b/src/connection-editor/page-wired-security.c
@@ -76,7 +76,7 @@ finish_setup (CEPageWiredSecurity *self, gpointer unused, GError *error, gpointe
 	if (error)
 		return;
 
-	priv->security = (WirelessSecurity *) ws_wpa_eap_new (parent->connection, TRUE);
+	priv->security = (WirelessSecurity *) ws_wpa_eap_new (parent->connection, TRUE, FALSE);
 	if (!priv->security) {
 		g_warning ("Could not load wired 802.1x user interface.");
 		return;
diff --git a/src/connection-editor/page-wireless-security.c b/src/connection-editor/page-wireless-security.c
index f8b5821..8860263 100644
--- a/src/connection-editor/page-wireless-security.c
+++ b/src/connection-editor/page-wireless-security.c
@@ -278,7 +278,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 	if (nm_utils_security_valid (NMU_SEC_LEAP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
 		WirelessSecurityLEAP *ws_leap;
 
-		ws_leap = ws_leap_new (connection);
+		ws_leap = ws_leap_new (connection, FALSE);
 		if (ws_leap) {
 			add_security_item (self, WIRELESS_SECURITY (ws_leap), sec_model,
 			                   &iter, _("LEAP"));
@@ -291,7 +291,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 	if (nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
 		WirelessSecurityDynamicWEP *ws_dynamic_wep;
 
-		ws_dynamic_wep = ws_dynamic_wep_new (connection, TRUE);
+		ws_dynamic_wep = ws_dynamic_wep_new (connection, TRUE, FALSE);
 		if (ws_dynamic_wep) {
 			add_security_item (self, WIRELESS_SECURITY (ws_dynamic_wep), sec_model,
 			                   &iter, _("Dynamic WEP (802.1x)"));
@@ -305,7 +305,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 	    || nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
 		WirelessSecurityWPAPSK *ws_wpa_psk;
 
-		ws_wpa_psk = ws_wpa_psk_new (connection);
+		ws_wpa_psk = ws_wpa_psk_new (connection, FALSE);
 		if (ws_wpa_psk) {
 			add_security_item (self, WIRELESS_SECURITY (ws_wpa_psk), sec_model,
 			                   &iter, _("WPA & WPA2 Personal"));
@@ -319,7 +319,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 	    || nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
 		WirelessSecurityWPAEAP *ws_wpa_eap;
 
-		ws_wpa_eap = ws_wpa_eap_new (connection, TRUE);
+		ws_wpa_eap = ws_wpa_eap_new (connection, TRUE, FALSE);
 		if (ws_wpa_eap) {
 			add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model,
 			                   &iter, _("WPA & WPA2 Enterprise"));
diff --git a/src/wired-dialog.c b/src/wired-dialog.c
index 9db89db..73c96bc 100644
--- a/src/wired-dialog.c
+++ b/src/wired-dialog.c
@@ -63,7 +63,7 @@ dialog_set_security (NMConnection *connection,
 	GList *iter;
 	WirelessSecurity *security;
 
-	security = (WirelessSecurity *) ws_wpa_eap_new (connection, FALSE);
+	security = (WirelessSecurity *) ws_wpa_eap_new (connection, FALSE, TRUE);
 
 	/* Remove any previous wireless security widgets */
 	children = gtk_container_get_children (GTK_CONTAINER (box));
diff --git a/src/wireless-dialog.c b/src/wireless-dialog.c
index 16bfaff..4e33ccd 100644
--- a/src/wireless-dialog.c
+++ b/src/wireless-dialog.c
@@ -74,7 +74,7 @@ typedef struct {
 	gboolean nag_ignored;
 	gboolean network_name_focus;
 
-	gboolean auth_only;
+	gboolean secrets_only;
 
 	guint revalidate_id;
 
@@ -94,7 +94,7 @@ typedef struct {
 #define C_SEP_COLUMN		2
 #define C_NEW_COLUMN		3
 
-static gboolean security_combo_init (NMAWirelessDialog *self, gboolean auth_only);
+static gboolean security_combo_init (NMAWirelessDialog *self, gboolean secrets_only);
 static void ssid_entry_changed (GtkWidget *entry, gpointer user_data);
 
 void
@@ -384,7 +384,7 @@ connection_combo_changed (GtkWidget *combo,
 	                    C_CON_COLUMN, &priv->connection,
 	                    C_NEW_COLUMN, &is_new, -1);
 
-	if (!security_combo_init (self, priv->auth_only)) {
+	if (!security_combo_init (self, priv->secrets_only)) {
 		g_warning ("Couldn't change wireless security combo box.");
 		return;
 	}
@@ -605,7 +605,7 @@ device_combo_changed (GtkWidget *combo,
 		return;
 	}
 
-	if (!security_combo_init (self, priv->auth_only)) {
+	if (!security_combo_init (self, priv->secrets_only)) {
 		g_warning ("Couldn't change wireless security combo box.");
 		return;
 	}
@@ -853,7 +853,7 @@ out:
 }
 
 static gboolean
-security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
+security_combo_init (NMAWirelessDialog *self, gboolean secrets_only)
 {
 	NMAWirelessDialogPrivate *priv;
 	GtkListStore *sec_model;
@@ -937,7 +937,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 	    && ((!ap_wpa && !ap_rsn) || !(dev_caps & (NM_WIFI_DEVICE_CAP_WPA | NM_WIFI_DEVICE_CAP_RSN)))) {
 		WirelessSecurityWEPKey *ws_wep;
 
-		ws_wep = ws_wep_key_new (priv->connection, NM_WEP_KEY_TYPE_KEY, priv->adhoc_create, auth_only);
+		ws_wep = ws_wep_key_new (priv->connection, NM_WEP_KEY_TYPE_KEY, priv->adhoc_create, secrets_only);
 		if (ws_wep) {
 			add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
 			                   &iter, _("WEP 40/128-bit Key (Hex or ASCII)"));
@@ -946,7 +946,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 			item++;
 		}
 
-		ws_wep = ws_wep_key_new (priv->connection, NM_WEP_KEY_TYPE_PASSPHRASE, priv->adhoc_create, auth_only);
+		ws_wep = ws_wep_key_new (priv->connection, NM_WEP_KEY_TYPE_PASSPHRASE, priv->adhoc_create, secrets_only);
 		if (ws_wep) {
 			add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
 			                   &iter, _("WEP 128-bit Passphrase"));
@@ -963,7 +963,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 	    && ((!ap_wpa && !ap_rsn) || !(dev_caps & (NM_WIFI_DEVICE_CAP_WPA | NM_WIFI_DEVICE_CAP_RSN)))) {
 		WirelessSecurityLEAP *ws_leap;
 
-		ws_leap = ws_leap_new (priv->connection);
+		ws_leap = ws_leap_new (priv->connection, secrets_only);
 		if (ws_leap) {
 			add_security_item (self, WIRELESS_SECURITY (ws_leap), sec_model,
 			                   &iter, _("LEAP"));
@@ -976,7 +976,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 	if (nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)) {
 		WirelessSecurityDynamicWEP *ws_dynamic_wep;
 
-		ws_dynamic_wep = ws_dynamic_wep_new (priv->connection, FALSE);
+		ws_dynamic_wep = ws_dynamic_wep_new (priv->connection, FALSE, secrets_only);
 		if (ws_dynamic_wep) {
 			add_security_item (self, WIRELESS_SECURITY (ws_dynamic_wep), sec_model,
 			                   &iter, _("Dynamic WEP (802.1x)"));
@@ -990,7 +990,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 	    || nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)) {
 		WirelessSecurityWPAPSK *ws_wpa_psk;
 
-		ws_wpa_psk = ws_wpa_psk_new (priv->connection);
+		ws_wpa_psk = ws_wpa_psk_new (priv->connection, secrets_only);
 		if (ws_wpa_psk) {
 			add_security_item (self, WIRELESS_SECURITY (ws_wpa_psk), sec_model,
 			                   &iter, _("WPA & WPA2 Personal"));
@@ -1004,7 +1004,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 	    || nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)) {
 		WirelessSecurityWPAEAP *ws_wpa_eap;
 
-		ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE);
+		ws_wpa_eap = ws_wpa_eap_new (priv->connection, FALSE, secrets_only);
 		if (ws_wpa_eap) {
 			add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model,
 			                   &iter, _("WPA & WPA2 Enterprise"));
@@ -1064,7 +1064,7 @@ static gboolean
 internal_init (NMAWirelessDialog *self,
                NMConnection *specific_connection,
                NMDevice *specific_device,
-               gboolean auth_only,
+               gboolean secrets_only,
                gboolean create)
 {
 	NMAWirelessDialogPrivate *priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self);
@@ -1077,8 +1077,8 @@ internal_init (NMAWirelessDialog *self,
 	gtk_window_set_default_size (GTK_WINDOW (self), 488, -1);
 	gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
 
-	priv->auth_only = auth_only;
-	if (auth_only)
+	priv->secrets_only = secrets_only;
+	if (secrets_only)
 		icon_name = "dialog-password";
 	else
 		icon_name = "network-wireless";
@@ -1152,7 +1152,7 @@ internal_init (NMAWirelessDialog *self,
 		return FALSE;
 	}
 
-	if (!security_combo_init (self, priv->auth_only)) {
+	if (!security_combo_init (self, priv->secrets_only)) {
 		g_warning ("Couldn't set up wireless security combo box.");
 		return FALSE;
 	}
@@ -1161,6 +1161,12 @@ internal_init (NMAWirelessDialog *self,
 	g_signal_connect (G_OBJECT (priv->sec_combo), "changed",
 	                  G_CALLBACK (security_combo_changed_manually), self);
 
+	if (secrets_only) {
+		gtk_widget_hide (priv->sec_combo);
+		widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo_label"));
+		gtk_widget_hide (widget);
+	}
+
 	if (security_combo_focus)
 		gtk_widget_grab_focus (priv->sec_combo);
 	else if (priv->network_name_focus) {
@@ -1298,7 +1304,8 @@ GtkWidget *
 nma_wireless_dialog_new (NMApplet *applet,
                          NMConnection *connection,
                          NMDevice *device,
-                         NMAccessPoint *ap)
+                         NMAccessPoint *ap,
+                         gboolean secrets_only)
 {
 	NMAWirelessDialog *self;
 	NMAWirelessDialogPrivate *priv;
@@ -1326,7 +1333,7 @@ nma_wireless_dialog_new (NMApplet *applet,
 	priv->sec_combo = GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_combo"));
 	priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
-	if (!internal_init (self, connection, device, TRUE, FALSE)) {
+	if (!internal_init (self, connection, device, secrets_only, FALSE)) {
 		nm_warning ("Couldn't create wireless security dialog.");
 		g_object_unref (self);
 		return NULL;
diff --git a/src/wireless-dialog.h b/src/wireless-dialog.h
index 3b9ee4d..95848ff 100644
--- a/src/wireless-dialog.h
+++ b/src/wireless-dialog.h
@@ -50,7 +50,8 @@ GType nma_wireless_dialog_get_type (void);
 GtkWidget *nma_wireless_dialog_new (NMApplet *applet,
                                     NMConnection *connection,
                                     NMDevice *device,
-                                    NMAccessPoint *ap);
+                                    NMAccessPoint *ap,
+                                    gboolean secrets_only);
 
 GtkWidget *nma_wireless_dialog_new_for_other (NMApplet *applet);
 
diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c
index 513b10c..b4b92b2 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -113,7 +113,8 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
 
 EAPMethodLEAP *
 eap_method_leap_new (WirelessSecurity *ws_parent,
-                     NMConnection *connection)
+                     NMConnection *connection,
+                     gboolean secrets_only)
 {
 	EAPMethod *parent;
 	GtkWidget *widget;
@@ -143,6 +144,9 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
 			gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x));
 	}
 
+	if (secrets_only)
+		gtk_widget_set_sensitive (widget, FALSE);
+
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_password_entry"));
 	g_assert (widget);
 	g_signal_connect (G_OBJECT (widget), "changed",
diff --git a/src/wireless-security/eap-method-leap.h b/src/wireless-security/eap-method-leap.h
index ec9090f..2a95e51 100644
--- a/src/wireless-security/eap-method-leap.h
+++ b/src/wireless-security/eap-method-leap.h
@@ -28,7 +28,8 @@
 typedef struct _EAPMethodLEAP EAPMethodLEAP;
 
 EAPMethodLEAP *eap_method_leap_new (WirelessSecurity *ws_parent,
-                                    NMConnection *connection);
+                                    NMConnection *connection,
+                                    gboolean secrets_only);
 
 #endif /* EAP_METHOD_LEAP_H */
 
diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c
index 1b300b8..12c14a5 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -220,7 +220,8 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 static GtkWidget *
 inner_auth_combo_init (EAPMethodPEAP *method,
                        NMConnection *connection,
-                       NMSetting8021x *s_8021x)
+                       NMSetting8021x *s_8021x,
+                       gboolean secrets_only)
 {
 	EAPMethod *parent = (EAPMethod *) method;
 	GtkWidget *combo;
@@ -245,7 +246,8 @@ inner_auth_combo_init (EAPMethodPEAP *method,
 	                                      connection,
 	                                      EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
 	                                      TRUE,
-	                                      method->is_editor);
+	                                      method->is_editor,
+	                                      secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("MSCHAPv2"),
@@ -261,7 +263,8 @@ inner_auth_combo_init (EAPMethodPEAP *method,
 	                                connection,
 	                                EAP_METHOD_SIMPLE_TYPE_MD5,
 	                                TRUE,
-	                                method->is_editor);
+	                                method->is_editor,
+	                                secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("MD5"),
@@ -277,7 +280,8 @@ inner_auth_combo_init (EAPMethodPEAP *method,
 	                                connection,
 	                                EAP_METHOD_SIMPLE_TYPE_GTC,
 	                                TRUE,
-	                                method->is_editor);
+	                                method->is_editor,
+	                                secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("GTC"),
@@ -314,7 +318,8 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
 EAPMethodPEAP *
 eap_method_peap_new (WirelessSecurity *ws_parent,
                      NMConnection *connection,
-                     gboolean is_editor)
+                     gboolean is_editor,
+                     gboolean secrets_only)
 {
 	EAPMethod *parent;
 	EAPMethodPEAP *method;
@@ -365,7 +370,7 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
 		}
 	}
 
-	widget = inner_auth_combo_init (method, connection, s_8021x);
+	widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
 	inner_auth_combo_changed_cb (widget, (gpointer) method);
 
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo"));
@@ -394,6 +399,25 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
 	                  (GCallback) wireless_security_changed_cb,
 	                  ws_parent);
 
+	if (secrets_only) {
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_anon_identity_entry"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_button"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo"));
+		gtk_widget_hide (widget);
+	}
+
 	return method;
 }
 
diff --git a/src/wireless-security/eap-method-peap.h b/src/wireless-security/eap-method-peap.h
index 1443522..958db34 100644
--- a/src/wireless-security/eap-method-peap.h
+++ b/src/wireless-security/eap-method-peap.h
@@ -29,7 +29,8 @@ typedef struct _EAPMethodPEAP EAPMethodPEAP;
 
 EAPMethodPEAP *eap_method_peap_new (WirelessSecurity *ws_parent,
                                     NMConnection *connection,
-                                    gboolean is_editor);
+                                    gboolean is_editor,
+                                    gboolean secrets_only);
 
 #endif /* EAP_METHOD_PEAP_H */
 
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c
index 9adf3bb..7c5fb8b 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -219,7 +219,8 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
                        NMConnection *connection,
                        EAPMethodSimpleType type,
                        gboolean phase2,
-                       gboolean is_editor)
+                       gboolean is_editor,
+                       gboolean secrets_only)
 {
 	EAPMethod *parent;
 	EAPMethodSimple *method;
@@ -256,6 +257,9 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
 			gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x));
 	}
 
+	if (secrets_only)
+		gtk_widget_set_sensitive (widget, FALSE);
+
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry"));
 	g_assert (widget);
 	g_signal_connect (G_OBJECT (widget), "changed",
@@ -290,6 +294,9 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
 		always_ask = nm_gconf_get_8021x_password_always_ask (uuid);
 	}
 
+	if (secrets_only)
+		gtk_widget_hide (widget);
+
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), always_ask);
 
 	/* Fill secrets if there's a static (ie, not OTP) password */
diff --git a/src/wireless-security/eap-method-simple.h b/src/wireless-security/eap-method-simple.h
index c28a06c..480efdf 100644
--- a/src/wireless-security/eap-method-simple.h
+++ b/src/wireless-security/eap-method-simple.h
@@ -40,7 +40,8 @@ EAPMethodSimple *eap_method_simple_new (WirelessSecurity *ws_parent,
                                         NMConnection *connection,
                                         EAPMethodSimpleType type,
                                         gboolean phase2,
-                                        gboolean is_editor);
+                                        gboolean is_editor,
+                                        gboolean secrets_only);
 
 #endif /* EAP_METHOD_SIMPLE_H */
 
diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c
index 26eaafc..edf0567 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -389,7 +389,8 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
 EAPMethodTLS *
 eap_method_tls_new (WirelessSecurity *ws_parent,
                     NMConnection *connection,
-                    gboolean phase2)
+                    gboolean phase2,
+                    gboolean secrets_only)
 {
 	EAPMethod *parent;
 	EAPMethodTLS *method;
@@ -462,6 +463,23 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
 	                  (GCallback) show_toggled_cb,
 	                  method);
 
+	if (secrets_only) {
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
+		gtk_widget_set_sensitive (widget, FALSE);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_button"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_private_key_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_private_key_button"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button"));
+		gtk_widget_hide (widget);
+	}
+
 	return method;
 }
 
diff --git a/src/wireless-security/eap-method-tls.h b/src/wireless-security/eap-method-tls.h
index 8cd42c4..7b33cfb 100644
--- a/src/wireless-security/eap-method-tls.h
+++ b/src/wireless-security/eap-method-tls.h
@@ -29,7 +29,8 @@ typedef struct _EAPMethodTLS EAPMethodTLS;
 
 EAPMethodTLS *eap_method_tls_new (WirelessSecurity *ws_parent,
                                   NMConnection *connection,
-                                  gboolean phase2);
+                                  gboolean phase2,
+                                  gboolean secrets_only);
 
 #endif /* EAP_METHOD_TLS_H */
 
diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c
index d23e70c..fd157a9 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -203,7 +203,8 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 static GtkWidget *
 inner_auth_combo_init (EAPMethodTTLS *method,
                        NMConnection *connection,
-                       NMSetting8021x *s_8021x)
+                       NMSetting8021x *s_8021x,
+                       gboolean secrets_only)
 {
 	EAPMethod *parent = (EAPMethod *) method;
 	GtkWidget *combo;
@@ -229,7 +230,8 @@ inner_auth_combo_init (EAPMethodTTLS *method,
 	                                connection,
 	                                EAP_METHOD_SIMPLE_TYPE_PAP,
 	                                TRUE,
-	                                method->is_editor);
+	                                method->is_editor,
+	                                secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("PAP"),
@@ -245,7 +247,8 @@ inner_auth_combo_init (EAPMethodTTLS *method,
 	                                   connection,
 	                                   EAP_METHOD_SIMPLE_TYPE_MSCHAP,
 	                                   TRUE,
-	                                   method->is_editor);
+	                                   method->is_editor,
+	                                   secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("MSCHAP"),
@@ -261,7 +264,7 @@ inner_auth_combo_init (EAPMethodTTLS *method,
 	                                      connection,
 	                                      EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2,
 	                                      TRUE,
-	                                      method->is_editor);
+	                                      method->is_editor, secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("MSCHAPv2"),
@@ -277,7 +280,8 @@ inner_auth_combo_init (EAPMethodTTLS *method,
 	                                 connection,
 	                                 EAP_METHOD_SIMPLE_TYPE_CHAP,
 	                                 TRUE,
-	                                 method->is_editor);
+	                                 method->is_editor,
+	                                 secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    I_NAME_COLUMN, _("CHAP"),
@@ -314,7 +318,8 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
 EAPMethodTTLS *
 eap_method_ttls_new (WirelessSecurity *ws_parent,
                      NMConnection *connection,
-                     gboolean is_editor)
+                     gboolean is_editor,
+                     gboolean secrets_only)
 {
 	EAPMethod *parent;
 	EAPMethodTTLS *method;
@@ -372,9 +377,24 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
 	                  (GCallback) wireless_security_changed_cb,
 	                  ws_parent);
 
-	widget = inner_auth_combo_init (method, connection, s_8021x);
+	widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
 	inner_auth_combo_changed_cb (widget, (gpointer) method);
 
+	if (secrets_only) {
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_anon_identity_entry"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_ca_cert_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_ca_cert_button"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_label"));
+		gtk_widget_hide (widget);
+		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo"));
+		gtk_widget_hide (widget);
+	}
+
 	return method;
 }
 
diff --git a/src/wireless-security/eap-method-ttls.h b/src/wireless-security/eap-method-ttls.h
index 503b357..eaccb24 100644
--- a/src/wireless-security/eap-method-ttls.h
+++ b/src/wireless-security/eap-method-ttls.h
@@ -29,7 +29,8 @@ typedef struct _EAPMethodTTLS EAPMethodTTLS;
 
 EAPMethodTTLS *eap_method_ttls_new (WirelessSecurity *ws_parent,
                                     NMConnection *connection,
-                                    gboolean is_editor);
+                                    gboolean is_editor,
+                                    gboolean secrets_only);
 
 #endif /* EAP_METHOD_TLS_H */
 
diff --git a/src/wireless-security/eap-method.h b/src/wireless-security/eap-method.h
index 6553696..0c39948 100644
--- a/src/wireless-security/eap-method.h
+++ b/src/wireless-security/eap-method.h
@@ -49,6 +49,7 @@ struct _EAPMethod {
 	const char *default_field;
 	GtkWidget *nag_dialog;
 
+	gboolean secrets_only;
 	gboolean ignore_ca_cert;
 
 	EMAddToSizeGroupFunc add_to_size_group;
diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c
index ff117cb..91ab4c9 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -321,11 +321,13 @@ ws_802_1x_auth_combo_changed (GtkWidget *combo,
 GtkWidget *
 ws_802_1x_auth_combo_init (WirelessSecurity *sec,
                            const char *combo_name,
+                           const char *combo_label,
                            GCallback auth_combo_changed_cb,
                            NMConnection *connection,
-                           gboolean is_editor)
+                           gboolean is_editor,
+                           gboolean secrets_only)
 {
-	GtkWidget *combo;
+	GtkWidget *combo, *widget;
 	GtkListStore *auth_model;
 	GtkTreeIter iter;
 	EAPMethodSimple *em_md5;
@@ -360,7 +362,8 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 		                                connection,
 		                                EAP_METHOD_SIMPLE_TYPE_MD5,
 		                                FALSE,
-		                                is_editor);
+		                                is_editor,
+		                                secrets_only);
 		gtk_list_store_append (auth_model, &iter);
 		gtk_list_store_set (auth_model, &iter,
 			                AUTH_NAME_COLUMN, _("MD5"),
@@ -372,7 +375,7 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 		item++;
 	}
 
-	em_tls = eap_method_tls_new (sec, connection, FALSE);
+	em_tls = eap_method_tls_new (sec, connection, FALSE, secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    AUTH_NAME_COLUMN, _("TLS"),
@@ -384,7 +387,7 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 	item++;
 
 	if (!wired) {
-		em_leap = eap_method_leap_new (sec, connection);
+		em_leap = eap_method_leap_new (sec, connection, secrets_only);
 		gtk_list_store_append (auth_model, &iter);
 		gtk_list_store_set (auth_model, &iter,
 		                    AUTH_NAME_COLUMN, _("LEAP"),
@@ -396,7 +399,7 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 		item++;
 	}
 
-	em_ttls = eap_method_ttls_new (sec, connection, is_editor);
+	em_ttls = eap_method_ttls_new (sec, connection, is_editor, secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    AUTH_NAME_COLUMN, _("Tunneled TLS"),
@@ -407,7 +410,7 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 		active = item;
 	item++;
 
-	em_peap = eap_method_peap_new (sec, connection, is_editor);
+	em_peap = eap_method_peap_new (sec, connection, is_editor, secrets_only);
 	gtk_list_store_append (auth_model, &iter);
 	gtk_list_store_set (auth_model, &iter,
 	                    AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"),
@@ -427,6 +430,12 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 
 	g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec);
 
+	if (secrets_only) {
+		gtk_widget_hide (combo);
+		widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_label));
+		gtk_widget_hide (widget);
+	}
+
 	return combo;
 }
 
diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h
index fe68b84..004fd6d 100644
--- a/src/wireless-security/wireless-security.h
+++ b/src/wireless-security/wireless-security.h
@@ -111,9 +111,11 @@ void wireless_security_clear_ciphers (NMConnection *connection);
 
 GtkWidget *ws_802_1x_auth_combo_init (WirelessSecurity *sec,
                                       const char *combo_name,
+                                      const char *combo_label,
                                       GCallback auth_combo_changed_cb,
                                       NMConnection *connection,
-                                      gboolean is_editor);
+                                      gboolean is_editor,
+                                      gboolean secrets_only);
 
 void ws_802_1x_auth_combo_changed (GtkWidget *combo,
                                    WirelessSecurity *sec,
diff --git a/src/wireless-security/ws-dynamic-wep.c b/src/wireless-security/ws-dynamic-wep.c
index b8ca197..2e9c636 100644
--- a/src/wireless-security/ws-dynamic-wep.c
+++ b/src/wireless-security/ws-dynamic-wep.c
@@ -109,7 +109,8 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
 
 WirelessSecurityDynamicWEP *
 ws_dynamic_wep_new (NMConnection *connection,
-                    gboolean is_editor)
+                    gboolean is_editor,
+                    gboolean secrets_only)
 {
 	WirelessSecurity *parent;
 	GtkWidget *widget;
@@ -130,9 +131,11 @@ ws_dynamic_wep_new (NMConnection *connection,
 
 	widget = ws_802_1x_auth_combo_init (parent,
 	                                    "dynamic_wep_auth_combo",
+	                                    "dynamic_wep_auth_label",
 	                                    (GCallback) auth_combo_changed_cb,
 	                                    connection,
-	                                    is_editor);
+	                                    is_editor,
+	                                    secrets_only);
 	auth_combo_changed_cb (widget, (gpointer) parent);
 
 	return (WirelessSecurityDynamicWEP *) parent;
diff --git a/src/wireless-security/ws-dynamic-wep.h b/src/wireless-security/ws-dynamic-wep.h
index 481ec07..fe6b34c 100644
--- a/src/wireless-security/ws-dynamic-wep.h
+++ b/src/wireless-security/ws-dynamic-wep.h
@@ -28,7 +28,8 @@
 typedef struct _WirelessSecurityDynamicWEP WirelessSecurityDynamicWEP;
 
 WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection,
-                                                gboolean is_editor);
+                                                gboolean is_editor,
+                                                gboolean secrets_only);
 
 #endif /* WS_DYNAMIC_WEP_H */
 
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index cb4228d..2af4a01 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -120,7 +120,7 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
 }
 
 WirelessSecurityLEAP *
-ws_leap_new (NMConnection *connection)
+ws_leap_new (NMConnection *connection, gboolean secrets_only)
 {
 	WirelessSecurity *parent;
 	WirelessSecurityLEAP *sec;
@@ -169,6 +169,9 @@ ws_leap_new (NMConnection *connection)
 	if (wsec)
 		gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_wireless_security_get_leap_username (wsec));
 
+	if (secrets_only)
+		gtk_widget_hide (widget);
+
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_leap"));
 	g_assert (widget);
 	g_signal_connect (G_OBJECT (widget), "toggled",
diff --git a/src/wireless-security/ws-leap.h b/src/wireless-security/ws-leap.h
index 4192a09..18063f5 100644
--- a/src/wireless-security/ws-leap.h
+++ b/src/wireless-security/ws-leap.h
@@ -27,7 +27,7 @@
 
 typedef struct _WirelessSecurityLEAP WirelessSecurityLEAP;
 
-WirelessSecurityLEAP * ws_leap_new (NMConnection *connection);
+WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only);
 
 #endif /* WS_LEAP_H */
 
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index 438c81c..18c1ed3 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -243,7 +243,7 @@ WirelessSecurityWEPKey *
 ws_wep_key_new (NMConnection *connection,
                 NMWepKeyType type,
                 gboolean adhoc_create,
-                gboolean simple)
+                gboolean secrets_only)
 {
 	WirelessSecurity *parent;
 	WirelessSecurityWEPKey *sec;
@@ -311,7 +311,7 @@ ws_wep_key_new (NMConnection *connection,
 	                  sec);
 
 	/* Key index is useless with adhoc networks */
-	if (is_adhoc || simple) {
+	if (is_adhoc || secrets_only) {
 		gtk_widget_hide (widget);
 		widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label"));
 		gtk_widget_hide (widget);
@@ -337,7 +337,7 @@ ws_wep_key_new (NMConnection *connection,
 	/* Don't show auth method for adhoc (which always uses open-system) or
 	 * when in "simple" mode.
 	 */
-	if (is_adhoc || simple) {
+	if (is_adhoc || secrets_only) {
 		/* Ad-Hoc connections can't use Shared Key auth */
 		if (is_adhoc)
 			gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
diff --git a/src/wireless-security/ws-wep-key.h b/src/wireless-security/ws-wep-key.h
index 1fafd5d..d328fc7 100644
--- a/src/wireless-security/ws-wep-key.h
+++ b/src/wireless-security/ws-wep-key.h
@@ -30,7 +30,7 @@ typedef struct _WirelessSecurityWEPKey WirelessSecurityWEPKey;
 WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection,
                                         NMWepKeyType type,
                                         gboolean adhoc_create,
-                                        gboolean simple);
+                                        gboolean secrets_only);
 
 #endif /* WS_WEP_KEY_H */
 
diff --git a/src/wireless-security/ws-wpa-eap.c b/src/wireless-security/ws-wpa-eap.c
index 6a81030..68b0293 100644
--- a/src/wireless-security/ws-wpa-eap.c
+++ b/src/wireless-security/ws-wpa-eap.c
@@ -105,7 +105,8 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
 
 WirelessSecurityWPAEAP *
 ws_wpa_eap_new (NMConnection *connection,
-                gboolean is_editor)
+                gboolean is_editor,
+                gboolean secrets_only)
 {
 	WirelessSecurity *parent;
 	GtkWidget *widget;
@@ -126,9 +127,11 @@ ws_wpa_eap_new (NMConnection *connection,
 
 	widget = ws_802_1x_auth_combo_init (parent,
 	                                    "wpa_eap_auth_combo",
+	                                    "wpa_eap_auth_label",
 	                                    (GCallback) auth_combo_changed_cb,
 	                                    connection,
-	                                    is_editor);
+	                                    is_editor,
+	                                    secrets_only);
 	auth_combo_changed_cb (widget, parent);
 
 	return (WirelessSecurityWPAEAP *) parent;
diff --git a/src/wireless-security/ws-wpa-eap.h b/src/wireless-security/ws-wpa-eap.h
index 0f21b59..6c7f6ab 100644
--- a/src/wireless-security/ws-wpa-eap.h
+++ b/src/wireless-security/ws-wpa-eap.h
@@ -28,7 +28,8 @@
 typedef struct _WirelessSecurityWPAEAP WirelessSecurityWPAEAP;
 
 WirelessSecurityWPAEAP * ws_wpa_eap_new (NMConnection *connection,
-                                         gboolean is_editor);
+                                         gboolean is_editor,
+                                         gboolean secrets_only);
 
 #endif /* WS_WPA_EAP_H */
 
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index 641d1c6..6ad8d96 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -147,7 +147,7 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
 }
 
 WirelessSecurityWPAPSK *
-ws_wpa_psk_new (NMConnection *connection)
+ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
 {
 	WirelessSecurity *parent;
 	WirelessSecurityWPAPSK *sec;
@@ -184,6 +184,10 @@ ws_wpa_psk_new (NMConnection *connection)
 	                  (GCallback) show_toggled_cb,
 	                  sec);
 
+	/* Hide WPA/RSN for now since this can be autodetected by NM and the
+	 * supplicant when connecting to the AP.
+	 */
+
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wpa_psk_type_combo"));
 	g_assert (widget);
 	gtk_widget_hide (widget);
diff --git a/src/wireless-security/ws-wpa-psk.h b/src/wireless-security/ws-wpa-psk.h
index 9bad94b..2a1fd85 100644
--- a/src/wireless-security/ws-wpa-psk.h
+++ b/src/wireless-security/ws-wpa-psk.h
@@ -25,7 +25,7 @@
 
 typedef struct _WirelessSecurityWPAPSK WirelessSecurityWPAPSK;
 
-WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection);
+WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only);
 
 #endif /* WS_WEP_KEY_H */
 



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