network-manager-applet r1175 - in branches/NETWORKMANAGER_APPLET_0_7: . src src/wireless-security



Author: dcbw
Date: Tue Feb 17 21:54:50 2009
New Revision: 1175
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=1175&view=rev

Log:
2009-02-17  Dan Williams  <dcbw redhat com>

	* src/wireless-security/eap-method.c
	  src/wireless-security/eap-method.h
		- Consolidate CA certificate nag dialog handling in the EAP method
			to get correct dialog destruction and reduce code.  Fixes crash
			when nag dialog would come up the second time.

	* src/wireless-security/eap-method-peap.c
	  src/wireless-security/eap-method-peap.h
	  src/wireless-security/eap-method-tls.c
	  src/wireless-security/eap-method-tls.h
	  src/wireless-security/eap-method-ttls.c
	  src/wireless-security/eap-method-ttls.h
		- Move CA certificate nag dialog handling to EAPMethod class

	* src/applet-device-wifi.c
		- (wireless_dialog_response_cb, get_secrets_dialog_response_cb):
			don't destroy nag dialog with parent; the EAP method object
			takes care of destruction for us



Modified:
   branches/NETWORKMANAGER_APPLET_0_7/ChangeLog
   branches/NETWORKMANAGER_APPLET_0_7/src/applet-device-wifi.c
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.c
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.h
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.c
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.h
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.c
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.h
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.c
   branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.h

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/applet-device-wifi.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/applet-device-wifi.c	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/applet-device-wifi.c	Tue Feb 17 21:54:50 2009
@@ -1319,7 +1319,6 @@
 		nag_dialog = nma_wireless_dialog_nag_user (dialog);
 		if (nag_dialog) {
 			gtk_window_set_transient_for (GTK_WINDOW (nag_dialog), GTK_WINDOW (dialog));
-			gtk_window_set_destroy_with_parent (GTK_WINDOW (nag_dialog), TRUE);
 			g_signal_connect (nag_dialog, "response",
 			                  G_CALLBACK (nag_dialog_response_cb),
 			                  dialog);
@@ -1522,7 +1521,6 @@
 		widget = nma_wireless_dialog_nag_user (dialog);
 		if (widget) {
 			gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (dialog));
-			gtk_window_set_destroy_with_parent (GTK_WINDOW (widget), TRUE);
 			g_signal_connect (widget, "response",
 			                  G_CALLBACK (nag_dialog_response_cb),
 			                  dialog);

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.c	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.c	Tue Feb 17 21:54:50 2009
@@ -37,7 +37,6 @@
 {
 	EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
 
-	g_object_unref (method->nag_dialog_xml);
 	if (method->size_group)
 		g_object_unref (method->size_group);
 	g_slice_free (EAPMethodPEAP, method);
@@ -110,7 +109,6 @@
 static void
 fill_connection (EAPMethod *parent, NMConnection *connection)
 {
-	EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
 	NMSetting8021x *s_8021x;
 	GtkWidget *widget;
 	const char *text;
@@ -144,7 +142,7 @@
 		g_object_set_data (G_OBJECT (connection), NMA_PATH_CA_CERT_TAG, NULL);
 	}
 
-	if (method->ignore_ca_cert)
+	if (eap_method_get_ignore_ca_cert (parent))
 		g_object_set_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG, GUINT_TO_POINTER (TRUE));
 	else
 		g_object_set_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG, NULL);
@@ -165,85 +163,6 @@
 	eap_method_fill_connection (eap, connection);
 	eap_method_unref (eap);
 }
-
-static gboolean
-nag_dialog_destroy (gpointer user_data)
-{
-	GtkWidget *nag_dialog = GTK_WIDGET (user_data);
-
-	gtk_widget_destroy (nag_dialog);
-	return FALSE;
-}
-
-static void
-nag_dialog_response_cb (GtkDialog *nag_dialog,
-                        gint response,
-                        gpointer user_data)
-{
-	EAPMethodPEAP *method = (EAPMethodPEAP *) user_data;
-	GtkWidget *widget;
-
-	if (response != GTK_RESPONSE_NO)
-		goto out;
-
-	/* Grab the value of the "don't bother me" checkbox */
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_checkbox");
-	g_assert (widget);
-
-	method->ignore_ca_cert = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
-out:
-	gtk_widget_hide (GTK_WIDGET (nag_dialog));
-	g_idle_add (nag_dialog_destroy, nag_dialog);
-}
-
-static GtkWidget *
-nag_user (EAPMethod *parent)
-{
-	GtkWidget *dialog;
-	GtkWidget *widget;
-	EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
-	char *filename = NULL;
-	char *text;
-
-	if (method->ignore_ca_cert)
-		return NULL;
-
-	/* Nag the user if the CA Cert is blank, since it's a security risk. */
-	widget = glade_xml_get_widget (parent->xml, "eap_peap_ca_cert_button");
-	g_assert (widget);
-	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
-	if (filename != NULL) {
-		g_free (filename);
-		return NULL;
-	}
-
-	dialog = glade_xml_get_widget (method->nag_dialog_xml, "nag_user_dialog");
-	g_assert (dialog);
-	g_signal_connect (dialog, "response", G_CALLBACK (nag_dialog_response_cb), method);
-	
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "content_label");
-	g_assert (widget);
-
-	text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
-	                        _("No Certificate Authority certificate chosen"),
-	                        _("Not using a Certificate Authority (CA) certificate can result in connections to insecure, rogue wireless networks.  Would you like to choose a Certificate Authority certificate?"));
-	gtk_label_set_markup (GTK_LABEL (widget), text);
-	g_free (text);
-
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_button");
-	gtk_button_set_label (GTK_BUTTON (widget), _("Ignore"));
-	g_assert (widget);
-
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "change_button");
-	gtk_button_set_label (GTK_BUTTON (widget), _("Choose CA Certificate"));
-	g_assert (widget);
-
-	gtk_widget_realize (dialog);
-	gtk_window_present (GTK_WINDOW (dialog));
-	return dialog;
-}
-
 static void
 inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 {
@@ -338,7 +257,6 @@
 	EAPMethodPEAP *method;
 	GtkWidget *widget;
 	GladeXML *xml;
-	GladeXML *nag_dialog_xml;
 	GtkFileFilter *filter;
 	NMSetting8021x *s_8021x = NULL;
 	const char *filename;
@@ -351,20 +269,12 @@
 		return NULL;
 	}
 
-	nag_dialog_xml = glade_xml_new (glade_file, "nag_user_dialog", NULL);
-	if (nag_dialog_xml == NULL) {
-		g_warning ("Couldn't get nag_user_dialog from glade xml");
-		g_object_unref (xml);
-		return NULL;
-	}
-
 	widget = glade_xml_get_widget (xml, "eap_peap_notebook");
 	g_assert (widget);
 	g_object_ref_sink (widget);
 
 	method = g_slice_new0 (EAPMethodPEAP);
 	if (!method) {
-		g_object_unref (nag_dialog_xml);
 		g_object_unref (xml);
 		g_object_unref (widget);
 		return NULL;
@@ -378,14 +288,15 @@
 	                 xml,
 	                 widget);
 
-	EAP_METHOD (method)->nag_user = nag_user;
-	method->nag_dialog_xml = nag_dialog_xml;
+	eap_method_nag_init (EAP_METHOD (method),
+	                     glade_file,
+	                     "eap_peap_ca_cert_button",
+	                     connection);
+
 	method->sec_parent = parent;
 
-	if (connection) {
-		method->ignore_ca_cert = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG));
+	if (connection)
 		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
-	}
 
 	widget = glade_xml_get_widget (xml, "eap_peap_ca_cert_button");
 	g_assert (widget);

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.h
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.h	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-peap.h	Tue Feb 17 21:54:50 2009
@@ -29,8 +29,6 @@
 
 	GtkSizeGroup *size_group;
 	WirelessSecurity *sec_parent;
-	GladeXML *nag_dialog_xml;
-	gboolean ignore_ca_cert;
 } EAPMethodPEAP;
 
 EAPMethodPEAP * eap_method_peap_new (const char *glade_file,

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.c	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.c	Tue Feb 17 21:54:50 2009
@@ -50,7 +50,6 @@
 {
 	EAPMethodTLS *method = (EAPMethodTLS *) parent;
 
-	g_object_unref (method->nag_dialog_xml);
 	g_slice_free (EAPMethodTLS, method);
 }
 
@@ -220,7 +219,7 @@
 		                   NULL);
 	}
 
-	if (method->ignore_ca_cert) {
+	if (eap_method_get_ignore_ca_cert (parent)) {
 		g_object_set_data (G_OBJECT (connection),
 		                   method->phase2 ? NMA_PHASE2_CA_CERT_IGNORE_TAG : NMA_CA_CERT_IGNORE_TAG,
 		                   GUINT_TO_POINTER (TRUE));
@@ -231,84 +230,6 @@
 	}
 }
 
-static gboolean
-nag_dialog_destroy (gpointer user_data)
-{
-	GtkWidget *nag_dialog = GTK_WIDGET (user_data);
-
-	gtk_widget_destroy (nag_dialog);
-	return FALSE;
-}
-
-static void
-nag_dialog_response_cb (GtkDialog *nag_dialog,
-                        gint response,
-                        gpointer user_data)
-{
-	EAPMethodTLS *method = (EAPMethodTLS *) user_data;
-	GtkWidget *widget;
-
-	if (response != GTK_RESPONSE_NO)
-		goto out;
-
-	/* Grab the value of the "don't bother me" checkbox */
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_checkbox");
-	g_assert (widget);
-
-	method->ignore_ca_cert = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
-out:
-	gtk_widget_hide (GTK_WIDGET (nag_dialog));
-	g_idle_add (nag_dialog_destroy, nag_dialog);
-}
-
-static GtkWidget *
-nag_user (EAPMethod *parent)
-{
-	GtkWidget *dialog;
-	GtkWidget *widget;
-	EAPMethodTLS *method = (EAPMethodTLS *) parent;
-	char *filename = NULL;
-	char *text;
-
-	if (method->ignore_ca_cert)
-		return NULL;
-
-	/* Nag the user if the CA Cert is blank, since it's a security risk. */
-	widget = glade_xml_get_widget (parent->xml, "eap_tls_ca_cert_button");
-	g_assert (widget);
-	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
-	if (filename != NULL) {
-		g_free (filename);
-		return NULL;
-	}
-
-	dialog = glade_xml_get_widget (method->nag_dialog_xml, "nag_user_dialog");
-	g_assert (dialog);
-	g_signal_connect (dialog, "response", G_CALLBACK (nag_dialog_response_cb), method);
-	
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "content_label");
-	g_assert (widget);
-
-	text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
-	                        _("No Certificate Authority certificate chosen"),
-	                        _("Not using a Certificate Authority (CA) certificate can result in connections to insecure, rogue wireless networks.  Would you like to choose a Certificate Authority certificate?"));
-	gtk_label_set_markup (GTK_LABEL (widget), text);
-	g_free (text);
-
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_button");
-	gtk_button_set_label (GTK_BUTTON (widget), _("Ignore"));
-	g_assert (widget);
-
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "change_button");
-	gtk_button_set_label (GTK_BUTTON (widget), _("Choose CA Certificate"));
-	g_assert (widget);
-
-	gtk_widget_realize (dialog);
-	gtk_window_present (GTK_WINDOW (dialog));
-	return dialog;
-}
-
 static void
 private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean changed)
 {
@@ -421,7 +342,6 @@
 	EAPMethodTLS *method;
 	GtkWidget *widget;
 	GladeXML *xml;
-	GladeXML *nag_dialog_xml;
 	NMSetting8021x *s_8021x = NULL;
 
 	g_return_val_if_fail (glade_file != NULL, NULL);
@@ -432,13 +352,6 @@
 		return NULL;
 	}
 
-	nag_dialog_xml = glade_xml_new (glade_file, "nag_user_dialog", NULL);
-	if (nag_dialog_xml == NULL) {
-		g_warning ("Couldn't get nag_user_dialog from glade xml");
-		g_object_unref (xml);
-		return NULL;
-	}
-
 	widget = glade_xml_get_widget (xml, "eap_tls_notebook");
 	g_assert (widget);
 	g_object_ref_sink (widget);
@@ -446,7 +359,6 @@
 	method = g_slice_new0 (EAPMethodTLS);
 	if (!method) {
 		g_object_unref (xml);
-		g_object_unref (nag_dialog_xml);
 		g_object_unref (widget);
 		return NULL;
 	}
@@ -459,15 +371,15 @@
 	                 xml,
 	                 widget);
 
-	EAP_METHOD (method)->nag_user = nag_user;
-	method->nag_dialog_xml = nag_dialog_xml;
+	eap_method_nag_init (EAP_METHOD (method),
+	                     glade_file,
+	                     "eap_tls_ca_cert_button",
+	                     connection);
 
 	method->phase2 = phase2;
 
-	if (connection) {
-		method->ignore_ca_cert = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG));
+	if (connection)
 		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
-	}
 
 	widget = glade_xml_get_widget (xml, "eap_tls_identity_entry");
 	g_assert (widget);

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.h
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.h	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-tls.h	Tue Feb 17 21:54:50 2009
@@ -27,8 +27,6 @@
 typedef struct {
 	struct _EAPMethod parent;
 
-	GladeXML *nag_dialog_xml;
-	gboolean ignore_ca_cert;
 	gboolean phase2;
 } EAPMethodTLS;
 

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.c	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.c	Tue Feb 17 21:54:50 2009
@@ -37,7 +37,6 @@
 {
 	EAPMethodTTLS *method = (EAPMethodTTLS *) parent;
 
-	g_object_unref (method->nag_dialog_xml);
 	if (method->size_group)
 		g_object_unref (method->size_group);
 	g_slice_free (EAPMethodTTLS, method);
@@ -106,7 +105,6 @@
 static void
 fill_connection (EAPMethod *parent, NMConnection *connection)
 {
-	EAPMethodTTLS *method = (EAPMethodTTLS *) parent;
 	NMSetting8021x *s_8021x;
 	GtkWidget *widget;
 	const char *text;
@@ -138,7 +136,7 @@
 		g_object_set_data (G_OBJECT (connection), NMA_PATH_CA_CERT_TAG, NULL);
 	}
 
-	if (method->ignore_ca_cert)
+	if (eap_method_get_ignore_ca_cert (parent))
 		g_object_set_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG, GUINT_TO_POINTER (TRUE));
 	else
 		g_object_set_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG, NULL);
@@ -153,84 +151,6 @@
 	eap_method_unref (eap);
 }
 
-static gboolean
-nag_dialog_destroy (gpointer user_data)
-{
-	GtkWidget *nag_dialog = GTK_WIDGET (user_data);
-
-	gtk_widget_destroy (nag_dialog);
-	return FALSE;
-}
-
-static void
-nag_dialog_response_cb (GtkDialog *nag_dialog,
-                        gint response,
-                        gpointer user_data)
-{
-	EAPMethodTTLS *method = (EAPMethodTTLS *) user_data;
-	GtkWidget *widget;
-
-	if (response != GTK_RESPONSE_NO)
-		goto out;
-
-	/* Grab the value of the "don't bother me" checkbox */
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_checkbox");
-	g_assert (widget);
-
-	method->ignore_ca_cert = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
-out:
-	gtk_widget_hide (GTK_WIDGET (nag_dialog));
-	g_idle_add (nag_dialog_destroy, nag_dialog);
-}
-
-static GtkWidget *
-nag_user (EAPMethod *parent)
-{
-	GtkWidget *dialog;
-	GtkWidget *widget;
-	EAPMethodTTLS *method = (EAPMethodTTLS *) parent;
-	char *filename = NULL;
-	char *text;
-
-	if (method->ignore_ca_cert)
-		return NULL;
-
-	/* Nag the user if the CA Cert is blank, since it's a security risk. */
-	widget = glade_xml_get_widget (parent->xml, "eap_ttls_ca_cert_button");
-	g_assert (widget);
-	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
-	if (filename != NULL) {
-		g_free (filename);
-		return NULL;
-	}
-
-	dialog = glade_xml_get_widget (method->nag_dialog_xml, "nag_user_dialog");
-	g_assert (dialog);
-	g_signal_connect (dialog, "response", G_CALLBACK (nag_dialog_response_cb), method);
-	
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "content_label");
-	g_assert (widget);
-
-	text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
-	                        _("No Certificate Authority certificate chosen"),
-	                        _("Not using a Certificate Authority (CA) certificate can result in connections to insecure, rogue wireless networks.  Would you like to choose a Certificate Authority certificate?"));
-	gtk_label_set_markup (GTK_LABEL (widget), text);
-	g_free (text);
-
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_button");
-	gtk_button_set_label (GTK_BUTTON (widget), _("Ignore"));
-	g_assert (widget);
-
-	widget = glade_xml_get_widget (method->nag_dialog_xml, "change_button");
-	gtk_button_set_label (GTK_BUTTON (widget), _("Choose CA Certificate"));
-	g_assert (widget);
-
-	gtk_widget_realize (dialog);
-	gtk_window_present (GTK_WINDOW (dialog));
-	return dialog;
-}
-
 static void
 inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
 {
@@ -375,7 +295,6 @@
 	EAPMethodTTLS *method;
 	GtkWidget *widget;
 	GladeXML *xml;
-	GladeXML *nag_dialog_xml;
 	GtkFileFilter *filter;
 	NMSetting8021x *s_8021x = NULL;
 	const char *filename;
@@ -388,20 +307,12 @@
 		return NULL;
 	}
 
-	nag_dialog_xml = glade_xml_new (glade_file, "nag_user_dialog", NULL);
-	if (nag_dialog_xml == NULL) {
-		g_warning ("Couldn't get nag_user_dialog from glade xml");
-		g_object_unref (xml);
-		return NULL;
-	}
-
 	widget = glade_xml_get_widget (xml, "eap_ttls_notebook");
 	g_assert (widget);
 	g_object_ref_sink (widget);
 
 	method = g_slice_new0 (EAPMethodTTLS);
 	if (!method) {
-		g_object_unref (nag_dialog_xml);
 		g_object_unref (xml);
 		g_object_unref (widget);
 		return NULL;
@@ -415,14 +326,15 @@
 	                 xml,
 	                 widget);
 
-	EAP_METHOD (method)->nag_user = nag_user;
-	method->nag_dialog_xml = nag_dialog_xml;
+	eap_method_nag_init (EAP_METHOD (method),
+	                     glade_file,
+	                     "eap_ttls_ca_cert_button",
+	                     connection);
+
 	method->sec_parent = parent;
 
-	if (connection) {
-		method->ignore_ca_cert = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG));
+	if (connection)
 		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
-	}
 
 	widget = glade_xml_get_widget (xml, "eap_ttls_ca_cert_button");
 	g_assert (widget);

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.h
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.h	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method-ttls.h	Tue Feb 17 21:54:50 2009
@@ -29,8 +29,6 @@
 
 	GtkSizeGroup *size_group;
 	WirelessSecurity *sec_parent;
-	GladeXML *nag_dialog_xml;
-	gboolean ignore_ca_cert;
 } EAPMethodTTLS;
 
 EAPMethodTTLS * eap_method_ttls_new (const char *glade_file,

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.c	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.c	Tue Feb 17 21:54:50 2009
@@ -33,6 +33,7 @@
 
 #include <nm-setting-8021x.h>
 #include "eap-method.h"
+#include "gconf-helpers.h"
 
 
 GType
@@ -86,14 +87,108 @@
 	return (*(method->fill_connection)) (method, connection);
 }
 
+static void
+nag_dialog_response_cb (GtkDialog *nag_dialog,
+                        gint response,
+                        gpointer user_data)
+{
+	EAPMethod *method = (EAPMethod *) user_data;
+	GtkWidget *widget;
+
+	if (response == GTK_RESPONSE_NO) {
+		/* Grab the value of the "don't bother me" checkbox */
+		widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_checkbox");
+		g_assert (widget);
+
+		method->ignore_ca_cert = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	}
+
+	gtk_widget_hide (GTK_WIDGET (nag_dialog));
+}
+
 GtkWidget *
 eap_method_nag_user (EAPMethod *method)
 {
+	GtkWidget *widget;
+	char *filename = NULL;
+
 	g_return_val_if_fail (method != NULL, NULL);
 
-	if (method->nag_user)
-		return (*(method->nag_user)) (method);
-	return NULL;
+	if (!method->nag_dialog || method->ignore_ca_cert)
+		return NULL;
+
+	/* Checkbox should be unchecked each time dialog comes up */
+	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_checkbox");
+	g_assert (widget);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+
+	/* Nag the user if the CA Cert is blank, since it's a security risk. */
+	widget = glade_xml_get_widget (method->xml, method->ca_cert_chooser);
+	g_assert (widget);
+	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+	if (filename != NULL) {
+		g_free (filename);
+		return NULL;
+	}
+
+	gtk_window_present (GTK_WINDOW (method->nag_dialog));
+	return method->nag_dialog;
+}
+
+gboolean
+eap_method_nag_init (EAPMethod *method,
+                     const char *glade_file,
+                     const char *ca_cert_chooser,
+                     NMConnection *connection)
+{
+	GtkWidget *dialog, *widget;
+	char *text;
+
+	g_return_val_if_fail (method != NULL, FALSE);
+	g_return_val_if_fail (glade_file != NULL, FALSE);
+	g_return_val_if_fail (ca_cert_chooser != NULL, FALSE);
+
+	method->nag_dialog_xml = glade_xml_new (glade_file, "nag_user_dialog", NULL);
+	if (method->nag_dialog_xml == NULL) {
+		g_warning ("Couldn't get nag_user_dialog from glade xml");
+		return FALSE;
+	}
+
+	method->ca_cert_chooser = g_strdup (ca_cert_chooser);
+	if (connection)
+		method->ignore_ca_cert = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NMA_CA_CERT_IGNORE_TAG));
+
+	dialog = glade_xml_get_widget (method->nag_dialog_xml, "nag_user_dialog");
+	g_assert (dialog);
+	g_signal_connect (dialog, "response", G_CALLBACK (nag_dialog_response_cb), method);
+
+	widget = glade_xml_get_widget (method->nag_dialog_xml, "content_label");
+	g_assert (widget);
+
+	text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
+	                        _("No Certificate Authority certificate chosen"),
+	                        _("Not using a Certificate Authority (CA) certificate can result in connections to insecure, rogue wireless networks.  Would you like to choose a Certificate Authority certificate?"));
+	gtk_label_set_markup (GTK_LABEL (widget), text);
+	g_free (text);
+
+	widget = glade_xml_get_widget (method->nag_dialog_xml, "ignore_button");
+	gtk_button_set_label (GTK_BUTTON (widget), _("Ignore"));
+	g_assert (widget);
+
+	widget = glade_xml_get_widget (method->nag_dialog_xml, "change_button");
+	gtk_button_set_label (GTK_BUTTON (widget), _("Choose CA Certificate"));
+	g_assert (widget);
+
+	method->nag_dialog = dialog;
+	return TRUE;
+}
+
+gboolean
+eap_method_get_ignore_ca_cert (EAPMethod *method)
+{
+	g_return_val_if_fail (method != NULL, FALSE);
+
+	return method->ignore_ca_cert;
 }
 
 void
@@ -137,6 +232,11 @@
 
 	method->refcount--;
 	if (method->refcount == 0) {
+		if (method->nag_dialog)
+			gtk_widget_destroy (method->nag_dialog);
+		if (method->nag_dialog_xml)
+			g_object_unref (method->nag_dialog_xml);
+		g_free (method->ca_cert_chooser);
 		g_object_unref (method->xml);
 		g_object_unref (method->ui_widget);
 		(*(method->destroy)) (method);

Modified: branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.h
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.h	(original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/wireless-security/eap-method.h	Tue Feb 17 21:54:50 2009
@@ -33,7 +33,6 @@
 
 typedef void        (*EMAddToSizeGroupFunc) (EAPMethod *method, GtkSizeGroup *group);
 typedef void        (*EMFillConnectionFunc) (EAPMethod *method, NMConnection *connection);
-typedef GtkWidget * (*EMNagUserFunc)        (EAPMethod *method);
 typedef void        (*EMDestroyFunc)        (EAPMethod *method);
 typedef gboolean    (*EMValidateFunc)       (EAPMethod *method);
 
@@ -42,9 +41,14 @@
 	GladeXML *xml;
 	GtkWidget *ui_widget;
 
+	GladeXML *nag_dialog_xml;
+	char *ca_cert_chooser;
+	GtkWidget *nag_dialog;
+
+	gboolean ignore_ca_cert;
+
 	EMAddToSizeGroupFunc add_to_size_group;
 	EMFillConnectionFunc fill_connection;
-	EMNagUserFunc nag_user;
 	EMValidateFunc validate;
 	EMDestroyFunc destroy;
 };
@@ -96,5 +100,12 @@
                                          const char *password,
                                          NMSetting8021xCKType *out_ck_type);
 
+gboolean eap_method_nag_init (EAPMethod *method,
+                              const char *glade_file,
+                              const char *ca_cert_chooser,
+                              NMConnection *connection);
+
+gboolean eap_method_get_ignore_ca_cert (EAPMethod *method);
+
 #endif /* EAP_METHOD_H */
 



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