diff --git a/ChangeLog b/ChangeLog index 9fe139c3d0..f5bfa9c66a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-12-11 Dan Williams + + * gnome/applet/wso-* + gnome/applet/wireless-security-option.* + gnome/applet/Makefile.am + - split each security option out so we can eventually + have each one build up their own dbus message + arguments to send to NM + 2005-12-11 Dan Williams * Make validation of the key work correctly diff --git a/gnome/applet/Makefile.am b/gnome/applet/Makefile.am index c3c7f9b9a1..56aa99a759 100644 --- a/gnome/applet/Makefile.am +++ b/gnome/applet/Makefile.am @@ -62,6 +62,17 @@ nm_applet_SOURCES = \ wireless-security-manager.h \ wireless-security-option.c \ wireless-security-option.h \ + wso-none.c \ + wso-none.h \ + wso-private.h \ + wso-wep-ascii.c \ + wso-wep-ascii.h \ + wso-wep-hex.c \ + wso-wep-hex.h \ + wso-wep-passphrase.c \ + wso-wep-passphrase.h \ + wso-wpa-psk-passphrase.c \ + wso-wpa-psk-passphrase.h \ $(NULL) nm_applet_LDADD = \ diff --git a/gnome/applet/wireless-applet.glade b/gnome/applet/wireless-applet.glade index eefc96d142..55898f6b36 100644 --- a/gnome/applet/wireless-applet.glade +++ b/gnome/applet/wireless-applet.glade @@ -425,7 +425,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th True - 2 + 4 2 False 12 @@ -486,7 +486,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th GTK_JUSTIFY_LEFT False False - 0 + 1 0.5 0 0 @@ -526,78 +526,73 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th - - - 0 - True - True - - - - - - True - False - 6 - + True - False - 6 - - - - True - _Wireless Security: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - None -WEP Passphrase -WEP 40/128-bit hex -WEP 40/128-bit ASCII - - False - True - - - 0 - True - True - - + _Wireless Security: + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 - 0 - False - False + 0 + 1 + 2 + 3 + fill + - + + True + None +WEP Passphrase +WEP 40/128-bit hex +WEP 40/128-bit ASCII + + False + True + + + 1 + 2 + 2 + 3 + fill + fill + + + + + + True + False + 0 + + + + + + + 0 + 2 + 3 + 4 + fill + @@ -1625,11 +1620,14 @@ WEP 40/128-bit ASCII False - + 8 True + 2 + 2 False - 0 + 6 + 6 @@ -1637,10 +1635,10 @@ WEP 40/128-bit ASCII Key: False False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_RIGHT False False - 0.5 + 1 0.5 0 0 @@ -1650,9 +1648,12 @@ WEP 40/128-bit ASCII 0 - 6 - False - False + 0 + 1 + 0 + 1 + fill + @@ -1669,9 +1670,57 @@ WEP 40/128-bit ASCII False - 0 - True - True + 1 + 2 + 0 + 1 + + + + + + + True + Authentication: + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Open System +Shared Key + False + True + + + 1 + 2 + 1 + 2 + fill + fill @@ -2087,22 +2136,25 @@ WEP 40/128-bit ASCII False - + 8 True + 2 + 2 False - 0 + 6 + 6 True - Key: + Passphrase: False False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_RIGHT False False - 0.5 + 1 0.5 0 0 @@ -2112,9 +2164,12 @@ WEP 40/128-bit ASCII 0 - 6 - False - False + 0 + 1 + 0 + 1 + fill + @@ -2131,9 +2186,57 @@ WEP 40/128-bit ASCII False - 0 - True - True + 1 + 2 + 0 + 1 + + + + + + + True + Authentication: + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Open System +Shared Key + False + True + + + 1 + 2 + 1 + 2 + fill + fill diff --git a/gnome/applet/wireless-security-manager.c b/gnome/applet/wireless-security-manager.c index 61f4d5ee14..dc3f2b7884 100644 --- a/gnome/applet/wireless-security-manager.c +++ b/gnome/applet/wireless-security-manager.c @@ -27,6 +27,12 @@ #include "wireless-security-manager.h" #include "wireless-security-option.h" +#include "wso-none.h" +#include "wso-private.h" +#include "wso-wep-ascii.h" +#include "wso-wep-hex.h" +#include "wso-wep-passphrase.h" +#include "wso-wpa-psk-passphrase.h" struct WirelessSecurityManager { diff --git a/gnome/applet/wireless-security-option.c b/gnome/applet/wireless-security-option.c index 743c861c93..4271841cf3 100644 --- a/gnome/applet/wireless-security-option.c +++ b/gnome/applet/wireless-security-option.c @@ -24,38 +24,11 @@ #include #include #include +#include #include "wireless-security-option.h" - #include "cipher.h" -#include "cipher-wep-passphrase.h" -#include "cipher-wep-hex.h" -#include "cipher-wep-ascii.h" -#include "cipher-wpa-psk-passphrase.h" - -#define WS_TAG_MAGIC 0xa7f4 -#define WS_TAG_NAME "ws-tag" - -struct WirelessSecurityOption -{ - /* Human readable name for the option */ - char * name; - - /* Corresponding IEEE_802_11_Cipher objects */ - GSList * ciphers; - - /* Name of the widget for this item */ - const char * widget_name; - - /* Notebook widget (once created) for this option */ - GtkWidget * widget; - - /* The Glade UI for this option */ - GladeXML * uixml; - - /* Glade object names for sub-widgets */ - GSList * subwidget_names; -}; +#include "wso-private.h" gboolean wso_is_wso_widget (GtkWidget * widget) { @@ -69,109 +42,6 @@ gboolean wso_is_wso_widget (GtkWidget * widget) return FALSE; } - -WirelessSecurityOption * wso_none_new (const char *glade_file) -{ - WirelessSecurityOption * opt = NULL; - - g_return_val_if_fail (glade_file != NULL, NULL); - - opt = g_malloc0 (sizeof (WirelessSecurityOption)); - opt->name = g_strdup (_("None")); - return opt; -} - - -WirelessSecurityOption * wso_wep_passphrase_new (const char *glade_file) -{ - WirelessSecurityOption * opt = NULL; - GladeXML * xml = NULL; - - g_return_val_if_fail (glade_file != NULL, NULL); - - opt = g_malloc0 (sizeof (WirelessSecurityOption)); - opt->name = g_strdup (_("WEP Passphrase")); - opt->widget_name = "wep_passphrase_notebook"; - opt->subwidget_names = g_slist_append (opt->subwidget_names, "wep_passphrase_entry"); - - if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) - { - wso_free (opt); - return NULL; - } - opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_passphrase_new ()); - return opt; -} - - -WirelessSecurityOption * wso_wep_hex_new (const char *glade_file) -{ - WirelessSecurityOption * opt = NULL; - GladeXML * xml = NULL; - - g_return_val_if_fail (glade_file != NULL, NULL); - - opt = g_malloc0 (sizeof (WirelessSecurityOption)); - opt->name = g_strdup (_("WEP 40/128-bit hex")); - opt->widget_name = "wep_key_notebook"; - opt->subwidget_names = g_slist_append (opt->subwidget_names, "wep_key_entry"); - - if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) - { - wso_free (opt); - return NULL; - } - opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_hex_new ()); - opt->ciphers = g_slist_append (opt->ciphers, cipher_wep64_hex_new ()); - return opt; -} - - -WirelessSecurityOption * wso_wep_ascii_new (const char *glade_file) -{ - WirelessSecurityOption * opt = NULL; - GladeXML * xml = NULL; - - g_return_val_if_fail (glade_file != NULL, NULL); - - opt = g_malloc0 (sizeof (WirelessSecurityOption)); - opt->name = g_strdup (_("WEP 40/128-bit ASCII")); - opt->widget_name = "wep_key_notebook"; - opt->subwidget_names = g_slist_append (opt->subwidget_names, "wep_key_entry"); - - if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) - { - wso_free (opt); - return NULL; - } - opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_ascii_new ()); - opt->ciphers = g_slist_append (opt->ciphers, cipher_wep64_ascii_new ()); - return opt; -} - - -WirelessSecurityOption * wso_wpa_psk_passphrase_new (const char *glade_file) -{ - WirelessSecurityOption * opt = NULL; - GladeXML * xml = NULL; - - g_return_val_if_fail (glade_file != NULL, NULL); - - opt = g_malloc0 (sizeof (WirelessSecurityOption)); - opt->name = g_strdup (_("WPA Personal Passphrase")); - opt->widget_name = "wpa_psk_notebook"; - opt->subwidget_names = g_slist_append (opt->subwidget_names, "wpa_psk_entry"); - - if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) - { - wso_free (opt); - return NULL; - } - opt->ciphers = g_slist_append (opt->ciphers, cipher_wpa_psk_passphrase_new ()); - return opt; -} - - const char * wso_get_name (WirelessSecurityOption * opt) { g_return_val_if_fail (opt != NULL, NULL); @@ -179,72 +49,32 @@ const char * wso_get_name (WirelessSecurityOption * opt) return opt->name; } - GtkWidget * wso_get_widget (WirelessSecurityOption * opt, GtkSignalFunc validate_cb, gpointer user_data) { g_return_val_if_fail (opt != NULL, NULL); + g_return_val_if_fail (validate_cb != NULL, NULL); - /* Some options may not have any UI */ - if (!opt->widget && opt->uixml) - { - GSList * elt; - - /* Grab our UI widget and tag it as a WSO widget */ - opt->widget = glade_xml_get_widget (opt->uixml, opt->widget_name); - g_object_ref (G_OBJECT (opt->widget)); - g_object_set_data (G_OBJECT (opt->widget), WS_TAG_NAME, GINT_TO_POINTER (WS_TAG_MAGIC)); - - /* Set the caller's validate callback on any sub-widgets we care about */ - for (elt = opt->subwidget_names; elt; elt = g_slist_next (elt)) - { - const char * widget_name = (const char *) (elt->data); - GtkWidget * widget; - - if ((widget = glade_xml_get_widget (opt->uixml, widget_name))) - g_signal_connect (G_OBJECT (widget), "changed", validate_cb, user_data); - } - } - + if (!opt->widget && opt->widget_create_func) + opt->widget = (*(opt->widget_create_func))(opt, validate_cb, user_data); return opt->widget; } - -gboolean wso_validate_input (WirelessSecurityOption * opt, const char *ssid) +gboolean wso_validate_input (WirelessSecurityOption * opt, const char * ssid) { - GSList * elt; - g_return_val_if_fail (opt != NULL, FALSE); g_return_val_if_fail (ssid != NULL, FALSE); - if (!opt->subwidget_names) - return TRUE; - - for (elt = opt->subwidget_names; elt; elt = g_slist_next (elt)) - { - const char * widget_name = (const char *) (elt->data); - GtkWidget * widget; - - if ((widget = glade_xml_get_widget (opt->uixml, widget_name))) - { - const char * input = gtk_entry_get_text (GTK_ENTRY (widget)); - GSList * cipher_elt; - - /* Try each of our ciphers in turn, if one validates that's enough */ - for (cipher_elt = opt->ciphers; cipher_elt; cipher_elt = g_slist_next (cipher_elt)) - { - IEEE_802_11_Cipher * cipher = (IEEE_802_11_Cipher *) (cipher_elt->data); - if (ieee_802_11_cipher_validate (cipher, ssid, input) == 0) - return TRUE; - } - } - } - + if (opt->validate_input_func) + return (*(opt->validate_input_func))(opt, ssid); return FALSE; } - void wso_free (WirelessSecurityOption * opt) { + /* Free the option-specific data first */ + if (opt->data_free_func) + (*(opt->data_free_func))(opt); + g_free (opt->name); if (opt->uixml) g_object_unref (opt->uixml); @@ -252,7 +82,80 @@ void wso_free (WirelessSecurityOption * opt) g_object_unref (opt->widget); g_slist_foreach (opt->ciphers, (GFunc) ieee_802_11_cipher_unref, NULL); g_slist_free (opt->ciphers); + memset (opt, 0, sizeof (WirelessSecurityOption)); g_free (opt); } + +/**********************************************/ + +gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, const char *input) +{ + GSList * elt; + + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (input != NULL, FALSE); + g_return_val_if_fail (ssid != NULL, FALSE); + + /* Try each of our ciphers in turn, if one validates that's enough */ + for (elt = opt->ciphers; elt; elt = g_slist_next (elt)) + { + IEEE_802_11_Cipher * cipher = (IEEE_802_11_Cipher *) (elt->data); + if (ieee_802_11_cipher_validate (cipher, ssid, input) == 0) + return TRUE; + } + return FALSE; +} + + +GtkWidget * wso_widget_helper (WirelessSecurityOption *opt) +{ + GtkWidget * widget; + + g_return_val_if_fail (opt != NULL, NULL); + + widget = glade_xml_get_widget (opt->uixml, opt->widget_name); + g_object_ref (G_OBJECT (widget)); + g_object_set_data (G_OBJECT (widget), WS_TAG_NAME, GINT_TO_POINTER (WS_TAG_MAGIC)); + return widget; +} + + +#define NAME_COLUMN 0 +#define AUTH_ALG_COLUMN 1 +void wso_wep_auth_combo_setup (WirelessSecurityOption *opt, GtkComboBox * combo) +{ + GtkListStore * model; + GtkTreeIter iter; + char * label; + + g_return_if_fail (opt != NULL); + g_return_if_fail (combo != NULL); + + model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); + + gtk_list_store_append (model, &iter); + gtk_list_store_set (model, &iter, NAME_COLUMN, _("Open System"), AUTH_ALG_COLUMN, IW_AUTH_ALG_OPEN_SYSTEM, -1); + + gtk_list_store_append (model, &iter); + gtk_list_store_set (model, &iter, NAME_COLUMN, _("Shared Key"), AUTH_ALG_COLUMN, IW_AUTH_ALG_SHARED_KEY, -1); + + g_object_ref (G_OBJECT (model)); + + gtk_combo_box_set_model (combo, GTK_TREE_MODEL (model)); + gtk_combo_box_set_active (combo, 0); +} + +void wso_wep_auth_combo_cleanup (WirelessSecurityOption *opt, GtkComboBox * combo) +{ + GtkListStore * model; + char * label; + + g_return_if_fail (opt != NULL); + g_return_if_fail (combo != NULL); + + model = GTK_LIST_STORE (gtk_combo_box_get_model (combo)); + g_object_unref (G_OBJECT (model)); +} + diff --git a/gnome/applet/wireless-security-option.h b/gnome/applet/wireless-security-option.h index 3ee3c06303..16ea2caeff 100644 --- a/gnome/applet/wireless-security-option.h +++ b/gnome/applet/wireless-security-option.h @@ -22,13 +22,9 @@ #ifndef WIRELESS_SECURITY_OPTION_H #define WIRELESS_SECURITY_OPTION_H -typedef struct WirelessSecurityOption WirelessSecurityOption; +#include -WirelessSecurityOption * wso_none_new (const char *glade_file); -WirelessSecurityOption * wso_wep_passphrase_new (const char *glade_file); -WirelessSecurityOption * wso_wep_hex_new (const char *glade_file); -WirelessSecurityOption * wso_wep_ascii_new (const char *glade_file); -WirelessSecurityOption * wso_wpa_psk_passphrase_new (const char *glade_file); +typedef struct WirelessSecurityOption WirelessSecurityOption; const char * wso_get_name (WirelessSecurityOption * opt); GtkWidget * wso_get_widget (WirelessSecurityOption * opt, GtkSignalFunc validate_cb, gpointer user_data); @@ -36,6 +32,12 @@ gboolean wso_is_wso_widget (GtkWidget * widget); gboolean wso_validate_input (WirelessSecurityOption * opt, const char * ssid); void wso_free (WirelessSecurityOption * opt); +/* For use by the options themselves */ +gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, const char *input); +GtkWidget * wso_widget_helper (WirelessSecurityOption *opt); + +void wso_wep_auth_combo_setup (WirelessSecurityOption *opt, GtkComboBox * combo); +void wso_wep_auth_combo_cleanup (WirelessSecurityOption *opt, GtkComboBox * combo); #endif /* WIRELESS_SECURITY_OPTION_H */ diff --git a/gnome/applet/wso-none.c b/gnome/applet/wso-none.c new file mode 100644 index 0000000000..7b8fcb296a --- /dev/null +++ b/gnome/applet/wso-none.c @@ -0,0 +1,47 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + + +#include "wireless-security-option.h" +#include "wso-none.h" +#include "wso-private.h" + + +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +{ + g_return_val_if_fail (opt != NULL, FALSE); + + return TRUE; +} + +WirelessSecurityOption * wso_none_new (const char *glade_file) +{ + WirelessSecurityOption * opt = NULL; + + g_return_val_if_fail (glade_file != NULL, NULL); + + opt = g_malloc0 (sizeof (WirelessSecurityOption)); + opt->name = g_strdup (_("None")); + opt->validate_input_func = validate_input_func; + return opt; +} + + diff --git a/gnome/applet/wso-none.h b/gnome/applet/wso-none.h new file mode 100644 index 0000000000..e12137a4a5 --- /dev/null +++ b/gnome/applet/wso-none.h @@ -0,0 +1,28 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#ifndef WSO_NONE_H +#define WSO_NONE_H + +WirelessSecurityOption * wso_none_new (const char *glade_file); + + +#endif /* WSO_NONE_H */ diff --git a/gnome/applet/wso-private.h b/gnome/applet/wso-private.h new file mode 100644 index 0000000000..ab2037746c --- /dev/null +++ b/gnome/applet/wso-private.h @@ -0,0 +1,64 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#ifndef WIRELESS_SECURITY_OPTION_PRIVATE_H +#define WIRELESS_SECURITY_OPTION_PRIVATE_H + +#include +#include +#include +#include + +#define WS_TAG_MAGIC 0xa7f4 +#define WS_TAG_NAME "ws-tag" + +typedef struct OptData OptData; + +struct WirelessSecurityOption +{ + /* Human readable name for the option */ + char * name; + + /* Corresponding IEEE_802_11_Cipher objects */ + GSList * ciphers; + + /* Notebook widget for this option */ + const char * widget_name; + GtkWidget * widget; + + /* The Glade UI for this option */ + GladeXML * uixml; + + /* Option-specific data */ + OptData * data; + + /* Option-specific data free function */ + void (*data_free_func)(WirelessSecurityOption *opt); + + /* Validate the option's input */ + gboolean (*validate_input_func)(WirelessSecurityOption *opt, const char *ssid); + + /* Widget creation function */ + GtkWidget * (*widget_create_func)(WirelessSecurityOption *opt, GtkSignalFunc validate_cb, gpointer user_data); +}; + + +#endif /* WIRELESS_SECURITY_OPTION_PRIVATE_H */ diff --git a/gnome/applet/wso-wep-ascii.c b/gnome/applet/wso-wep-ascii.c new file mode 100644 index 0000000000..dbe308fe83 --- /dev/null +++ b/gnome/applet/wso-wep-ascii.c @@ -0,0 +1,118 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#include +#include +#include +#include + +#include "wireless-security-option.h" +#include "wso-wep-ascii.h" +#include "wso-private.h" +#include "cipher.h" +#include "cipher-wep-ascii.h" + + +struct OptData +{ + const char * entry_name; + const char * auth_combo_name; +}; + +static void data_free_func (WirelessSecurityOption *opt) +{ + GtkWidget * combo; + + g_return_if_fail (opt != NULL); + g_return_if_fail (opt->data != NULL); + + combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + wso_wep_auth_combo_cleanup (opt, GTK_COMBO_BOX (combo)); + + g_free (opt->data); +} + + +static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFunc validate_cb, gpointer user_data) +{ + GtkWidget * entry; + GtkWidget * combo; + GtkWidget * widget; + + g_return_val_if_fail (opt != NULL, NULL); + g_return_val_if_fail (opt->data != NULL, NULL); + g_return_val_if_fail (validate_cb != NULL, NULL); + + widget = wso_widget_helper (opt); + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data); + + combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + wso_wep_auth_combo_setup (opt, GTK_COMBO_BOX (combo)); + + return widget; +} + + +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +{ + GtkWidget * entry; + const char * input; + + g_return_val_if_fail (opt != NULL, FALSE); + + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + input = gtk_entry_get_text (GTK_ENTRY (entry)); + return wso_validate_helper (opt, ssid, input); +} + + +WirelessSecurityOption * wso_wep_ascii_new (const char *glade_file) +{ + WirelessSecurityOption * opt = NULL; + GladeXML * xml = NULL; + OptData * data = NULL; + + g_return_val_if_fail (glade_file != NULL, NULL); + + opt = g_malloc0 (sizeof (WirelessSecurityOption)); + opt->name = g_strdup (_("WEP 40/128-bit ASCII")); + opt->widget_name = "wep_key_notebook"; + opt->data_free_func = data_free_func; + opt->validate_input_func = validate_input_func; + opt->widget_create_func = widget_create_func; + + if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) + { + wso_free (opt); + return NULL; + } + opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_ascii_new ()); + opt->ciphers = g_slist_append (opt->ciphers, cipher_wep64_ascii_new ()); + + /* Option-specific data */ + opt->data = data = g_malloc0 (sizeof (OptData)); + data->entry_name = "wep_key_entry"; + data->auth_combo_name = "auth_method_combo"; + + return opt; +} + diff --git a/gnome/applet/wso-wep-ascii.h b/gnome/applet/wso-wep-ascii.h new file mode 100644 index 0000000000..38ad71b0b3 --- /dev/null +++ b/gnome/applet/wso-wep-ascii.h @@ -0,0 +1,28 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#ifndef WSO_WEP_ASCII_H +#define WSO_WEP_ASCII_H + +WirelessSecurityOption * wso_wep_ascii_new (const char *glade_file); + + +#endif /* WSO_WEP_ASCII_H */ diff --git a/gnome/applet/wso-wep-hex.c b/gnome/applet/wso-wep-hex.c new file mode 100644 index 0000000000..62eefd3d83 --- /dev/null +++ b/gnome/applet/wso-wep-hex.c @@ -0,0 +1,118 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#include +#include +#include +#include + +#include "wireless-security-option.h" +#include "wso-wep-hex.h" +#include "wso-private.h" +#include "cipher.h" +#include "cipher-wep-hex.h" + + +struct OptData +{ + const char * entry_name; + const char * auth_combo_name; +}; + +static void data_free_func (WirelessSecurityOption *opt) +{ + GtkWidget * combo; + + g_return_if_fail (opt != NULL); + g_return_if_fail (opt->data != NULL); + + combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + wso_wep_auth_combo_cleanup (opt, GTK_COMBO_BOX (combo)); + + g_free (opt->data); +} + + +static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFunc validate_cb, gpointer user_data) +{ + GtkWidget * entry; + GtkWidget * combo; + GtkWidget * widget; + + g_return_val_if_fail (opt != NULL, NULL); + g_return_val_if_fail (opt->data != NULL, NULL); + g_return_val_if_fail (validate_cb != NULL, NULL); + + widget = wso_widget_helper (opt); + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data); + + combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + wso_wep_auth_combo_setup (opt, GTK_COMBO_BOX (combo)); + + return widget; +} + + +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +{ + GtkWidget * entry; + const char * input; + + g_return_val_if_fail (opt != NULL, FALSE); + + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + input = gtk_entry_get_text (GTK_ENTRY (entry)); + return wso_validate_helper (opt, ssid, input); +} + + +WirelessSecurityOption * wso_wep_hex_new (const char *glade_file) +{ + WirelessSecurityOption * opt = NULL; + GladeXML * xml = NULL; + OptData * data = NULL; + + g_return_val_if_fail (glade_file != NULL, NULL); + + opt = g_malloc0 (sizeof (WirelessSecurityOption)); + opt->name = g_strdup (_("WEP 40/128-bit hex")); + opt->widget_name = "wep_key_notebook"; + opt->data_free_func = data_free_func; + opt->validate_input_func = validate_input_func; + opt->widget_create_func = widget_create_func; + + if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) + { + wso_free (opt); + return NULL; + } + opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_hex_new ()); + opt->ciphers = g_slist_append (opt->ciphers, cipher_wep64_hex_new ()); + + /* Option-specific data */ + opt->data = data = g_malloc0 (sizeof (OptData)); + data->entry_name = "wep_key_entry"; + data->auth_combo_name = "auth_method_combo"; + + return opt; +} + diff --git a/gnome/applet/wso-wep-hex.h b/gnome/applet/wso-wep-hex.h new file mode 100644 index 0000000000..c68d0a7115 --- /dev/null +++ b/gnome/applet/wso-wep-hex.h @@ -0,0 +1,28 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#ifndef WSO_WEP_HEX_H +#define WSO_WEP_HEX_H + +WirelessSecurityOption * wso_wep_hex_new (const char *glade_file); + + +#endif /* WSO_WEP_HEX_H */ diff --git a/gnome/applet/wso-wep-passphrase.c b/gnome/applet/wso-wep-passphrase.c new file mode 100644 index 0000000000..3bcb6e4902 --- /dev/null +++ b/gnome/applet/wso-wep-passphrase.c @@ -0,0 +1,117 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#include +#include +#include +#include + +#include "wireless-security-option.h" +#include "wso-wep-passphrase.h" +#include "wso-private.h" +#include "cipher.h" +#include "cipher-wep-passphrase.h" + + +struct OptData +{ + const char * entry_name; + const char * auth_combo_name; +}; + +static void data_free_func (WirelessSecurityOption *opt) +{ + GtkWidget * combo; + + g_return_if_fail (opt != NULL); + g_return_if_fail (opt->data != NULL); + + combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + wso_wep_auth_combo_cleanup (opt, GTK_COMBO_BOX (combo)); + + g_free (opt->data); +} + + +static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFunc validate_cb, gpointer user_data) +{ + GtkWidget * entry; + GtkWidget * combo; + GtkWidget * widget; + + g_return_val_if_fail (opt != NULL, NULL); + g_return_val_if_fail (opt->data != NULL, NULL); + g_return_val_if_fail (validate_cb != NULL, NULL); + + widget = wso_widget_helper (opt); + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data); + + combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + wso_wep_auth_combo_setup (opt, GTK_COMBO_BOX (combo)); + + return widget; +} + + +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +{ + GtkWidget * entry; + const char * input; + + g_return_val_if_fail (opt != NULL, FALSE); + + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + input = gtk_entry_get_text (GTK_ENTRY (entry)); + return wso_validate_helper (opt, ssid, input); +} + + +WirelessSecurityOption * wso_wep_passphrase_new (const char *glade_file) +{ + WirelessSecurityOption * opt = NULL; + GladeXML * xml = NULL; + OptData * data = NULL; + + g_return_val_if_fail (glade_file != NULL, NULL); + + opt = g_malloc0 (sizeof (WirelessSecurityOption)); + opt->name = g_strdup (_("WEP Passphrase")); + opt->widget_name = "wep_passphrase_notebook"; + opt->data_free_func = data_free_func; + opt->validate_input_func = validate_input_func; + opt->widget_create_func = widget_create_func; + + if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) + { + wso_free (opt); + return NULL; + } + opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_passphrase_new ()); + + /* Option-specific data */ + opt->data = data = g_malloc0 (sizeof (OptData)); + data->entry_name = "wep_passphrase_entry"; + data->auth_combo_name = "auth_method_combo"; + + return opt; +} + diff --git a/gnome/applet/wso-wep-passphrase.h b/gnome/applet/wso-wep-passphrase.h new file mode 100644 index 0000000000..90d2d141e4 --- /dev/null +++ b/gnome/applet/wso-wep-passphrase.h @@ -0,0 +1,28 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#ifndef WSO_WEP_PASSPHRASE_H +#define WSO_WEP_PASSPHRASE_H + +WirelessSecurityOption * wso_wep_passphrase_new (const char *glade_file); + + +#endif /* WSO_WEP_PASSPHRASE_H */ diff --git a/gnome/applet/wso-wpa-psk-passphrase.c b/gnome/applet/wso-wpa-psk-passphrase.c new file mode 100644 index 0000000000..535b1c1bf5 --- /dev/null +++ b/gnome/applet/wso-wpa-psk-passphrase.c @@ -0,0 +1,105 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#include +#include +#include +#include + +#include "wireless-security-option.h" +#include "wso-wpa-psk-passphrase.h" +#include "wso-private.h" +#include "cipher.h" +#include "cipher-wpa-psk-passphrase.h" + + +struct OptData +{ + const char * entry_name; +}; + +static void data_free_func (WirelessSecurityOption *opt) +{ + g_return_if_fail (opt != NULL); + g_return_if_fail (opt->data != NULL); + + g_free (opt->data); +} + + +static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFunc validate_cb, gpointer user_data) +{ + GtkWidget * entry; + GtkWidget * widget; + + g_return_val_if_fail (opt != NULL, NULL); + g_return_val_if_fail (opt->data != NULL, NULL); + g_return_val_if_fail (validate_cb != NULL, NULL); + + widget = wso_widget_helper (opt); + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data); + return widget; +} + + +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +{ + GtkWidget * entry; + const char * input; + + g_return_val_if_fail (opt != NULL, FALSE); + + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + input = gtk_entry_get_text (GTK_ENTRY (entry)); + return wso_validate_helper (opt, ssid, input); +} + + +WirelessSecurityOption * wso_wpa_psk_passphrase_new (const char *glade_file) +{ + WirelessSecurityOption * opt = NULL; + GladeXML * xml = NULL; + OptData * data = NULL; + + g_return_val_if_fail (glade_file != NULL, NULL); + + opt = g_malloc0 (sizeof (WirelessSecurityOption)); + opt->name = g_strdup (_("WPA Personal Passphrase")); + opt->widget_name = "wpa_psk_notebook"; + opt->data_free_func = data_free_func; + opt->validate_input_func = validate_input_func; + opt->widget_create_func = widget_create_func; + + if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) + { + wso_free (opt); + return NULL; + } + opt->ciphers = g_slist_append (opt->ciphers, cipher_wpa_psk_passphrase_new ()); + + /* Option-specific data */ + opt->data = data = g_malloc0 (sizeof (OptData)); + data->entry_name = "wpa_psk_entry"; + + return opt; +} + diff --git a/gnome/applet/wso-wpa-psk-passphrase.h b/gnome/applet/wso-wpa-psk-passphrase.h new file mode 100644 index 0000000000..39f03afdfe --- /dev/null +++ b/gnome/applet/wso-wpa-psk-passphrase.h @@ -0,0 +1,28 @@ +/* NetworkManager Wireless Applet -- Display wireless access points and allow user control + * + * Dan Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * (C) Copyright 2005 Red Hat, Inc. + */ + +#ifndef WSO_WPA_PSK_PASSPHRASE_H +#define WSO_WPA_PSK_PASSPHRASE_H + +WirelessSecurityOption * wso_wpa_psk_passphrase_new (const char *glade_file); + + +#endif /* WSO_WPA_PSK_PASSPHRASE_H */