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



commit eb2828fd6338dcb3bda53e8007163edbdd392eda
Author: Dan Williams <dcbw redhat com>
Date:   Mon Jun 20 15:00:04 2011 -0500

    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.

 src/applet-device-wifi.c                       |    4 +-
 src/connection-editor/page-wired-security.c    |    2 +-
 src/connection-editor/page-wireless-security.c |   10 +++--
 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, 184 insertions(+), 69 deletions(-)
---
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 413c1d2..2045d59 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -471,7 +471,7 @@ _do_new_auto_connection (NMApplet *applet,
 		more_info->callback = callback;
 		more_info->callback_data = callback_data;
 
-		dialog = nma_wireless_dialog_new (applet, connection, device, ap);
+		dialog = nma_wireless_dialog_new (applet, connection, device, ap, FALSE);
 		if (dialog) {
 			g_signal_connect (dialog, "response",
 				              G_CALLBACK (more_info_wifi_dialog_response_cb),
@@ -1673,7 +1673,7 @@ wireless_get_secrets (SecretsRequest *req, GError **error)
 
 	applet_secrets_request_set_free_func (req, free_wifi_info);
 
-	info->dialog = nma_wireless_dialog_new (req->applet, req->connection, NULL, NULL);
+	info->dialog = nma_wireless_dialog_new (req->applet, req->connection, NULL, NULL, TRUE);
 	if (info->dialog) {
 		g_signal_connect (info->dialog, "response",
 		                  G_CALLBACK (get_secrets_dialog_response_cb),
diff --git a/src/connection-editor/page-wired-security.c b/src/connection-editor/page-wired-security.c
index 2d56785..c53b36e 100644
--- a/src/connection-editor/page-wired-security.c
+++ b/src/connection-editor/page-wired-security.c
@@ -77,7 +77,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 d7974d1..fb34d5f 100644
--- a/src/connection-editor/page-wireless-security.c
+++ b/src/connection-editor/page-wireless-security.c
@@ -279,7 +279,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"));
@@ -292,7 +292,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)"));
@@ -306,7 +306,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"));
@@ -320,8 +320,10 @@ 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);
+g_message ("%s: here!", __func__);
+		ws_wpa_eap = ws_wpa_eap_new (connection, TRUE, FALSE);
 		if (ws_wpa_eap) {
+g_message ("%s: here 22!", __func__);
 			add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model,
 			                   &iter, _("WPA & WPA2 Enterprise"));
 			if ((active < 0) && ((default_type == NMU_SEC_WPA_ENTERPRISE) || (default_type == NMU_SEC_WPA2_ENTERPRISE)))
diff --git a/src/wired-dialog.c b/src/wired-dialog.c
index 2ff7c5a..6e03fe4 100644
--- a/src/wired-dialog.c
+++ b/src/wired-dialog.c
@@ -62,7 +62,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 2e3c967..99b8aaf 100644
--- a/src/wireless-dialog.c
+++ b/src/wireless-dialog.c
@@ -73,7 +73,7 @@ typedef struct {
 	gboolean nag_ignored;
 	gboolean network_name_focus;
 
-	gboolean auth_only;
+	gboolean secrets_only;
 
 	guint revalidate_id;
 
@@ -93,7 +93,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
@@ -366,7 +366,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;
 	}
@@ -585,7 +585,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;
 	}
@@ -833,7 +833,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;
@@ -918,7 +918,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)"));
@@ -927,7 +927,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"));
@@ -944,7 +944,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"));
@@ -957,7 +957,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)"));
@@ -971,7 +971,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"));
@@ -985,7 +985,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"));
@@ -1042,7 +1042,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);
@@ -1055,8 +1055,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";
@@ -1126,7 +1126,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;
 	}
@@ -1135,6 +1135,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) {
@@ -1267,7 +1273,8 @@ GtkWidget *
 nma_wireless_dialog_new (NMApplet *applet,
                          NMConnection *connection,
                          NMDevice *device,
-                         NMAccessPoint *ap)
+                         NMAccessPoint *ap,
+                         gboolean secrets_only)
 {
 	GObject *obj;
 	NMAWirelessDialogPrivate *priv;
@@ -1294,7 +1301,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 (NMA_WIRELESS_DIALOG (obj), connection, device, TRUE, FALSE)) {
+		if (!internal_init (NMA_WIRELESS_DIALOG (obj), connection, device, secrets_only, FALSE)) {
 			g_warning ("Couldn't create wireless security dialog.");
 			g_object_unref (obj);
 			obj = 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 bc80f59..c29fd49 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -112,7 +112,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 e80cfcf..c53eb71 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -213,7 +213,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;
@@ -238,7 +239,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"),
@@ -254,7 +256,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"),
@@ -270,7 +273,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"),
@@ -307,7 +311,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;
@@ -356,7 +361,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"));
@@ -385,6 +390,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 e7fca34..08a84bf 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -205,7 +205,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;
@@ -241,6 +242,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",
@@ -264,6 +268,9 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
 		                  method);
 	}
 
+	if (secrets_only)
+		gtk_widget_hide (widget);
+
 	if (s_8021x) {
 		NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
 
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 8db91dc..ece62c1 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -373,7 +373,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;
 	GtkWidget *widget;
@@ -440,6 +441,23 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
 	                  (GCallback) show_toggled_cb,
 	                  parent);
 
+	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 (EAPMethodTLS *) parent;
 }
 
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 ca19190..1a4d6e8 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -196,7 +196,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;
@@ -222,7 +223,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"),
@@ -238,7 +240,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"),
@@ -254,7 +257,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"),
@@ -270,7 +273,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"),
@@ -307,7 +311,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;
@@ -363,9 +368,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 331ecb8..77df1eb 100644
--- a/src/wireless-security/eap-method.h
+++ b/src/wireless-security/eap-method.h
@@ -50,6 +50,7 @@ struct _EAPMethod {
 	GtkWidget *nag_dialog;
 
 	gboolean phase2;
+	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 982f17b..8144789 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -323,11 +323,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;
@@ -363,7 +365,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"),
@@ -375,7 +378,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"),
@@ -387,7 +390,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"),
@@ -399,7 +402,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"),
@@ -410,7 +413,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)"),
@@ -430,6 +433,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 742374a..acf8bbf 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -118,7 +118,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;
@@ -167,6 +167,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 72c8dc4..2b2a72b 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -241,7 +241,7 @@ WirelessSecurityWEPKey *
 ws_wep_key_new (NMConnection *connection,
                 NMWepKeyType type,
                 gboolean adhoc_create,
-                gboolean simple)
+                gboolean secrets_only)
 {
 	WirelessSecurity *parent;
 	WirelessSecurityWEPKey *sec;
@@ -309,7 +309,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);
@@ -335,7 +335,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 b69b4a4..6964338 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -145,7 +145,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;
@@ -182,6 +182,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]