diff --git a/ChangeLog b/ChangeLog index f4e65194d7..4092af556d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-01-27 Robert Love + + * gnome/applet/passphrase-dialog.c: If wsm_set_capabilities() returns + FALSE, we have no security options for this dialog, so we throw up + an error dialog instead of a broken passphrase dialog. Fixes + Novell #138404. + * gnome/applet/wireless-security-manager.c, + gnome/applet/wireless-security-manager.h: If wsm_set_capabilities() + does not add any security options, not even none, print a warning + and return FALSE. This let's functions constructed a dialog bail + out if the device's capabilities and the network's requirements have + zero overlap. + 2006-01-27 Robert Love * configure.in: Require wpa_supplicant. Detect location of binary and diff --git a/gnome/applet/passphrase-dialog.c b/gnome/applet/passphrase-dialog.c index 382e4e34d1..a2c16e9759 100644 --- a/gnome/applet/passphrase-dialog.c +++ b/gnome/applet/passphrase-dialog.c @@ -201,15 +201,38 @@ nmi_passphrase_dialog_new (NMWirelessApplet *applet, g_return_val_if_fail (net != NULL, NULL); g_return_val_if_fail (message != NULL, NULL); + wsm = wsm_new (applet->glade_file); + + caps = network_device_get_type_capabilities (dev); + caps &= wireless_network_get_capabilities (net); + if (!wsm_set_capabilities (wsm, caps)) + { + GtkWidget *error_dialog; + + error_dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "%s\n\n%s", + _("Error connecting to wireless network"), + _("The requested wireless network requires security capabilities unsupported by your hardware.")); + gtk_window_present (GTK_WINDOW (error_dialog)); + g_signal_connect_swapped (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), error_dialog); + + wsm_free (wsm); + + return NULL; + } + + if (!(xml = glade_xml_new (applet->glade_file, "passphrase_dialog", NULL))) { nmwa_schedule_warning_dialog (applet, _("The NetworkManager Applet could not find some required resources (the glade file was not found).")); + wsm_free (wsm); return NULL; } dialog = glade_xml_get_widget (xml, "passphrase_dialog"); gtk_widget_hide (dialog); + g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", (gpointer) wsm); g_object_set_data (G_OBJECT (dialog), "glade-xml", xml); g_object_set_data (G_OBJECT (dialog), "applet", applet); g_object_set_data (G_OBJECT (dialog), "uid", GINT_TO_POINTER (uid)); @@ -233,13 +256,6 @@ nmi_passphrase_dialog_new (NMWirelessApplet *applet, gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE); - wsm = wsm_new (applet->glade_file); - g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", (gpointer) wsm); - - caps = network_device_get_type_capabilities (dev); - caps &= wireless_network_get_capabilities (net); - wsm_set_capabilities (wsm, caps); - security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo")); wsm_update_combo (wsm, security_combo); diff --git a/gnome/applet/wireless-security-manager.c b/gnome/applet/wireless-security-manager.c index e6f655216e..e06d5fa046 100644 --- a/gnome/applet/wireless-security-manager.c +++ b/gnome/applet/wireless-security-manager.c @@ -27,6 +27,7 @@ #include "NetworkManager.h" #include "wireless-security-manager.h" #include "wireless-security-option.h" +#include "nm-utils.h" #include "wso-none.h" #include "wso-private.h" @@ -55,11 +56,12 @@ WirelessSecurityManager * wsm_new (const char * glade_file) } -void wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities) +gboolean wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities) { WirelessSecurityOption * opt; + gboolean ret = TRUE; - g_return_if_fail (wsm != NULL); + g_return_val_if_fail (wsm != NULL, FALSE); /* Free previous options */ g_slist_foreach (wsm->options, (GFunc) wso_free, NULL); @@ -96,6 +98,14 @@ void wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities) if ((opt = wso_wpa_psk_new (wsm->glade_file, capabilities, TRUE))) wsm->options = g_slist_append (wsm->options, opt); } + + if (!wsm->options) + { + nm_warning ("capabilities='%x' and did not match any protocals, not even none!", capabilities); + ret = FALSE; + } + + return ret; } #define NAME_COLUMN 0 diff --git a/gnome/applet/wireless-security-manager.h b/gnome/applet/wireless-security-manager.h index eef1c2e198..ecc21f1abd 100644 --- a/gnome/applet/wireless-security-manager.h +++ b/gnome/applet/wireless-security-manager.h @@ -33,7 +33,7 @@ WirelessSecurityManager * wsm_new (const char * glade_file); void wsm_free (WirelessSecurityManager *wsm); -void wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities); +gboolean wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities); void wsm_update_combo (WirelessSecurityManager *wsm, GtkComboBox *combo);