From 7713d133971add73b2707f0e4e6ab02b243d5678 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 12 Dec 2005 18:53:05 +0000 Subject: [PATCH] 2005-12-11 Dan Williams * gnome/applet/applet-dbus-devices.[ch] gnome/applet/applet.c gnome/applet/other-network-dialog.c gnome/applet/wireless-security-manager.[ch] gnome/applet/wireless-security-option.[ch] gnome/applet/wso-* - Push the wireless security options further into the applet git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1170 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 10 ++++++ gnome/applet/applet-dbus-devices.c | 36 ++++++++++----------- gnome/applet/applet-dbus-devices.h | 5 +-- gnome/applet/applet.c | 2 +- gnome/applet/other-network-dialog.c | 20 ++++++------ gnome/applet/wireless-security-manager.c | 39 +++++++++++++++------- gnome/applet/wireless-security-manager.h | 20 ++++++++---- gnome/applet/wireless-security-option.c | 39 ++++++++++++++++++++-- gnome/applet/wireless-security-option.h | 28 ++++++++++------ gnome/applet/wso-none.c | 12 ++++++- gnome/applet/wso-private.h | 10 +++++- gnome/applet/wso-wep-ascii.c | 41 ++++++++++++++++++++++-- gnome/applet/wso-wep-hex.c | 4 +-- gnome/applet/wso-wep-passphrase.c | 4 +-- gnome/applet/wso-wpa-psk-passphrase.c | 4 +-- 15 files changed, 202 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07a73a2d15..292ff7cd81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-12-11 Dan Williams + + * gnome/applet/applet-dbus-devices.[ch] + gnome/applet/applet.c + gnome/applet/other-network-dialog.c + gnome/applet/wireless-security-manager.[ch] + gnome/applet/wireless-security-option.[ch] + gnome/applet/wso-* + - Push the wireless security options further into the applet + 2005-12-12 Robert Love * src/dhcp-manager/nm-dhcp-manager.c: Do not fail if DHCP does not diff --git a/gnome/applet/applet-dbus-devices.c b/gnome/applet/applet-dbus-devices.c index 8a4150e901..823b0df75b 100644 --- a/gnome/applet/applet-dbus-devices.c +++ b/gnome/applet/applet-dbus-devices.c @@ -1069,29 +1069,29 @@ void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *d * */ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, - const NMEncKeyType key_type, const char *passphrase) + WirelessSecurityOption * opt) { DBusMessage *message; g_return_if_fail (connection != NULL); g_return_if_fail (dev != NULL); + if (network_device_is_wireless (dev)) + g_return_if_fail (essid != NULL); if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setActiveDevice"))) { const char *dev_path = network_device_get_nm_path (dev); - if (network_device_is_wireless (dev) && essid) + if (network_device_is_wireless (dev)) { - int tmp_key_type = (int)key_type; - - if (passphrase == NULL) - passphrase = ""; - + /* Build up the required args */ dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_STRING, &essid, - DBUS_TYPE_STRING, &passphrase, - DBUS_TYPE_INT32, &tmp_key_type, DBUS_TYPE_INVALID); + + /* If we've got specific wireless security options, add them */ + if (opt) + wso_append_dbus_params (opt, essid, message); } else { @@ -1113,7 +1113,7 @@ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const * */ void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, - NMEncKeyType key_type, const char *passphrase) + WirelessSecurityOption * opt) { DBusMessage *message; @@ -1121,21 +1121,19 @@ void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, c g_return_if_fail (dev != NULL); g_return_if_fail (essid != NULL); g_return_if_fail (network_device_is_wireless (dev)); + g_return_if_fail (opt != NULL); if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "createWirelessNetwork"))) { - const char *dev_path = network_device_get_nm_path (dev); + const char *dev_path; - if (dev_path) + if ((dev_path = network_device_get_nm_path (dev))) { - nm_info ("Creating network '%s' %s passphrase on device '%s'.\n", essid, passphrase ? "with" : "without", dev_path); - if (passphrase == NULL) - passphrase = ""; + nm_info ("Creating network '%s' on device '%s'.\n", essid, dev_path); dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, - DBUS_TYPE_STRING, &essid, - DBUS_TYPE_STRING, &passphrase, - DBUS_TYPE_INT32, &key_type, - DBUS_TYPE_INVALID); + DBUS_TYPE_STRING, &essid, + DBUS_TYPE_INVALID); + wso_append_dbus_params (opt, essid, message); dbus_connection_send (connection, message, NULL); } dbus_message_unref (message); diff --git a/gnome/applet/applet-dbus-devices.h b/gnome/applet/applet-dbus-devices.h index 3e09e56e90..0f14d361d3 100644 --- a/gnome/applet/applet-dbus-devices.h +++ b/gnome/applet/applet-dbus-devices.h @@ -29,6 +29,7 @@ #include "applet.h" #include "nm-device.h" #include "wireless-network.h" +#include "wireless-security-option.h" void nmwa_dbus_update_one_vpn_connection (DBusConnection *connection, const char *name, NMWirelessApplet *applet, gboolean is_active); void nmwa_dbus_update_vpn_connections (NMWirelessApplet *applet); @@ -45,8 +46,8 @@ void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const cha void nmwa_dbus_device_update_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path, const char *active_net_path); void nmwa_dbus_device_remove_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path); void nmwa_dbus_update_strength (NMWirelessApplet *applet, const char *dev_path, const char *net_path, int strength); -void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase); -void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase); +void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, WirelessSecurityOption *opt); +void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, WirelessSecurityOption *opt); void nmwa_free_data_model (NMWirelessApplet *applet); diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index 06245c62e9..dabf59a611 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -1305,7 +1305,7 @@ static void nmwa_menu_item_activate (GtkMenuItem *item, gpointer user_data) if ((tag = g_object_get_data (G_OBJECT (item), "network"))) net = network_device_get_wireless_network_by_essid (dev, tag); - nmwa_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, -1, NULL); + nmwa_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, NULL); network_device_unref (dev); nmi_dbus_signal_user_interface_activated (applet->connection); diff --git a/gnome/applet/other-network-dialog.c b/gnome/applet/other-network-dialog.c index 2246a2ba3b..70cf8a06db 100644 --- a/gnome/applet/other-network-dialog.c +++ b/gnome/applet/other-network-dialog.c @@ -325,7 +325,6 @@ static void nmwa_other_network_dialog_response_cb (GtkDialog *dialog, gint respo if (response == GTK_RESPONSE_OK) { GtkEntry * network_name_entry; - GtkComboBox * security_combo; const char * essid = NULL; const char * key = NULL; int key_type = -1; @@ -333,23 +332,24 @@ static void nmwa_other_network_dialog_response_cb (GtkDialog *dialog, gint respo network_name_entry = GTK_ENTRY (glade_xml_get_widget (xml, "network_name_entry")); essid = gtk_entry_get_text (network_name_entry); - security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo")); - if (essid[0] != '\000') { - NMEncKeyType nm_key_type = -1; - GtkTreeIter iter; - char * str; - NetworkDevice *dev; - char * passphrase = NULL; + WirelessSecurityOption * opt; + GtkComboBox * security_combo; + GtkTreeIter iter; + char * str; + NetworkDevice * dev; gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter); gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, DEV_COLUMN, &dev, -1); + security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo")); + opt = wsm_get_option_for_active (wsm, security_combo); + if (create_network) - nmwa_dbus_create_network (applet->connection, dev, essid, nm_key_type, passphrase); + nmwa_dbus_create_network (applet->connection, dev, essid, opt); else - nmwa_dbus_set_device (applet->connection, dev, essid, nm_key_type, passphrase); + nmwa_dbus_set_device (applet->connection, dev, essid, opt); } } diff --git a/gnome/applet/wireless-security-manager.c b/gnome/applet/wireless-security-manager.c index dc3f2b7884..992d371327 100644 --- a/gnome/applet/wireless-security-manager.c +++ b/gnome/applet/wireless-security-manager.c @@ -99,43 +99,58 @@ void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo) } -GtkWidget * wsm_get_widget_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo, - GtkSignalFunc validate_cb, gpointer user_data) +static WirelessSecurityOption * get_active_option_from_combo (GtkComboBox *combo) { WirelessSecurityOption * opt = NULL; GtkTreeIter iter; GtkTreeModel * model; char * str; - g_return_val_if_fail (wsm != NULL, NULL); g_return_val_if_fail (combo != NULL, NULL); model = gtk_combo_box_get_model (combo); g_assert (model); gtk_combo_box_get_active_iter (combo, &iter); gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, OPT_COLUMN, &opt, -1); - g_return_val_if_fail (opt != NULL, NULL); + return opt; +} + + +GtkWidget * wsm_get_widget_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo, + GtkSignalFunc validate_cb, gpointer user_data) +{ + WirelessSecurityOption * opt = NULL; + + g_return_val_if_fail (wsm != NULL, NULL); + g_return_val_if_fail (combo != NULL, NULL); + + opt = get_active_option_from_combo (combo); + g_return_val_if_fail (opt != NULL, NULL); return wso_get_widget (opt, validate_cb, user_data); } gboolean wsm_validate_active (WirelessSecurityManager *wsm, GtkComboBox *combo, const char *ssid) { WirelessSecurityOption * opt = NULL; - GtkTreeIter iter; - GtkTreeModel * model; - char * str; g_return_val_if_fail (wsm != NULL, FALSE); g_return_val_if_fail (combo != NULL, FALSE); - model = gtk_combo_box_get_model (combo); - g_assert (model); - gtk_combo_box_get_active_iter (combo, &iter); - gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, OPT_COLUMN, &opt, -1); + opt = get_active_option_from_combo (combo); g_return_val_if_fail (opt != NULL, FALSE); + return wso_validate_input (opt, ssid, NULL); +} - return wso_validate_input (opt, ssid); + +WirelessSecurityOption * wsm_get_option_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo) +{ + WirelessSecurityOption * opt = NULL; + + g_return_val_if_fail (wsm != NULL, NULL); + g_return_val_if_fail (combo != NULL, NULL); + + return get_active_option_from_combo (combo); } diff --git a/gnome/applet/wireless-security-manager.h b/gnome/applet/wireless-security-manager.h index 17cdc5bfaf..40fd4e6074 100644 --- a/gnome/applet/wireless-security-manager.h +++ b/gnome/applet/wireless-security-manager.h @@ -23,15 +23,23 @@ #define WIRELESS_SECURITY_MANAGER_H #include +#include "wireless-security-option.h" typedef struct WirelessSecurityManager WirelessSecurityManager; -WirelessSecurityManager * wsm_new (const char * glade_file); -void wsm_free (WirelessSecurityManager *wsm); -void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo); -GtkWidget * wsm_get_widget_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo, - GtkSignalFunc validate_cb, gpointer user_data); -gboolean wsm_validate_active (WirelessSecurityManager *wsm, GtkComboBox *combo, const char *ssid); +WirelessSecurityManager * wsm_new (const char * glade_file); + +void wsm_free (WirelessSecurityManager *wsm); + +void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo); + +GtkWidget * wsm_get_widget_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo, + GtkSignalFunc validate_cb, gpointer user_data); + +gboolean wsm_validate_active (WirelessSecurityManager *wsm, GtkComboBox *combo, + const char *ssid); + +WirelessSecurityOption * wsm_get_option_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo); #endif /* WIRELESS_SECURITY_MANAGER_H */ diff --git a/gnome/applet/wireless-security-option.c b/gnome/applet/wireless-security-option.c index 4271841cf3..e780500a1d 100644 --- a/gnome/applet/wireless-security-option.c +++ b/gnome/applet/wireless-security-option.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "wireless-security-option.h" #include "cipher.h" @@ -59,16 +60,26 @@ GtkWidget * wso_get_widget (WirelessSecurityOption * opt, GtkSignalFunc validate return opt->widget; } -gboolean wso_validate_input (WirelessSecurityOption * opt, const char * ssid) +gboolean wso_validate_input (WirelessSecurityOption * opt, const char * ssid, IEEE_802_11_Cipher ** out_cipher) { g_return_val_if_fail (opt != NULL, FALSE); g_return_val_if_fail (ssid != NULL, FALSE); if (opt->validate_input_func) - return (*(opt->validate_input_func))(opt, ssid); + return (*(opt->validate_input_func))(opt, ssid, out_cipher); return FALSE; } +gboolean wso_append_dbus_params (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message) +{ + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (ssid != NULL, FALSE); + g_return_val_if_fail (message != NULL, FALSE); + + g_assert (opt->append_dbus_params_func); + return (*(opt->append_dbus_params_func))(opt, ssid, message); +} + void wso_free (WirelessSecurityOption * opt) { /* Free the option-specific data first */ @@ -90,7 +101,7 @@ void wso_free (WirelessSecurityOption * opt) /**********************************************/ -gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, const char *input) +gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, const char *input, IEEE_802_11_Cipher ** out_cipher) { GSList * elt; @@ -98,12 +109,18 @@ gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, con g_return_val_if_fail (input != NULL, FALSE); g_return_val_if_fail (ssid != NULL, FALSE); + if (out_cipher) + g_return_val_if_fail (*out_cipher != 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) + { + *out_cipher = cipher; return TRUE; + } } return FALSE; } @@ -147,6 +164,22 @@ void wso_wep_auth_combo_setup (WirelessSecurityOption *opt, GtkComboBox * combo) gtk_combo_box_set_active (combo, 0); } +int wso_wep_auth_combo_get_auth_alg (WirelessSecurityOption *opt, GtkComboBox * combo) +{ + GtkTreeIter iter; + GtkTreeModel * model; + int auth_alg; + char * str; + + g_return_val_if_fail (opt != NULL, -1); + g_return_val_if_fail (combo != NULL, -1); + + model = gtk_combo_box_get_model (combo); + gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter); + gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, AUTH_ALG_COLUMN, &auth_alg, -1); + return auth_alg; +} + void wso_wep_auth_combo_cleanup (WirelessSecurityOption *opt, GtkComboBox * combo) { GtkListStore * model; diff --git a/gnome/applet/wireless-security-option.h b/gnome/applet/wireless-security-option.h index 16ea2caeff..510a155cc2 100644 --- a/gnome/applet/wireless-security-option.h +++ b/gnome/applet/wireless-security-option.h @@ -22,22 +22,32 @@ #ifndef WIRELESS_SECURITY_OPTION_H #define WIRELESS_SECURITY_OPTION_H +#include #include +#include "cipher.h" + typedef struct WirelessSecurityOption WirelessSecurityOption; -const char * wso_get_name (WirelessSecurityOption * opt); -GtkWidget * wso_get_widget (WirelessSecurityOption * opt, GtkSignalFunc validate_cb, gpointer user_data); -gboolean wso_is_wso_widget (GtkWidget * widget); -gboolean wso_validate_input (WirelessSecurityOption * opt, const char * ssid); -void wso_free (WirelessSecurityOption * opt); +const char * wso_get_name (WirelessSecurityOption * opt); + +GtkWidget * wso_get_widget (WirelessSecurityOption * opt, GtkSignalFunc validate_cb, gpointer user_data); + +gboolean wso_is_wso_widget (GtkWidget * widget); + +gboolean wso_validate_input (WirelessSecurityOption * opt, const char * ssid, IEEE_802_11_Cipher ** out_cipher); + +gboolean wso_append_dbus_params (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message); + +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); +gboolean wso_validate_helper (WirelessSecurityOption *opt, const char *ssid, const char *input, IEEE_802_11_Cipher ** out_cipher); +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); +void wso_wep_auth_combo_setup (WirelessSecurityOption *opt, GtkComboBox * combo); +int wso_wep_auth_combo_get_auth_alg (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 index 7b8fcb296a..083efaed18 100644 --- a/gnome/applet/wso-none.c +++ b/gnome/applet/wso-none.c @@ -19,13 +19,22 @@ * (C) Copyright 2005 Red Hat, Inc. */ +#include #include "wireless-security-option.h" #include "wso-none.h" #include "wso-private.h" +#include "cipher.h" -static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid, IEEE_802_11_Cipher ** out_cipher) +{ + g_return_val_if_fail (opt != NULL, FALSE); + + return TRUE; +} + +static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message) { g_return_val_if_fail (opt != NULL, FALSE); @@ -41,6 +50,7 @@ WirelessSecurityOption * wso_none_new (const char *glade_file) opt = g_malloc0 (sizeof (WirelessSecurityOption)); opt->name = g_strdup (_("None")); opt->validate_input_func = validate_input_func; + opt->append_dbus_params_func = append_dbus_params_func; return opt; } diff --git a/gnome/applet/wso-private.h b/gnome/applet/wso-private.h index ab2037746c..77e2c6b431 100644 --- a/gnome/applet/wso-private.h +++ b/gnome/applet/wso-private.h @@ -26,6 +26,9 @@ #include #include #include +#include + +#include "cipher.h" #define WS_TAG_MAGIC 0xa7f4 #define WS_TAG_NAME "ws-tag" @@ -54,10 +57,15 @@ struct WirelessSecurityOption void (*data_free_func)(WirelessSecurityOption *opt); /* Validate the option's input */ - gboolean (*validate_input_func)(WirelessSecurityOption *opt, const char *ssid); + gboolean (*validate_input_func)(WirelessSecurityOption *opt, const char *ssid, IEEE_802_11_Cipher ** out_cipher); /* Widget creation function */ GtkWidget * (*widget_create_func)(WirelessSecurityOption *opt, GtkSignalFunc validate_cb, gpointer user_data); + + /* DBUS params append function for building up a suitable + * dbus message describing this particular security option + */ + gboolean (*append_dbus_params_func)(WirelessSecurityOption *opt, const char *ssid, DBusMessage *message); }; diff --git a/gnome/applet/wso-wep-ascii.c b/gnome/applet/wso-wep-ascii.c index dbe308fe83..e5592b86e1 100644 --- a/gnome/applet/wso-wep-ascii.c +++ b/gnome/applet/wso-wep-ascii.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "wireless-security-option.h" #include "wso-wep-ascii.h" @@ -60,6 +61,8 @@ static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFun 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); + g_return_val_if_fail (opt->data->auth_combo_name != NULL, FALSE); + g_return_val_if_fail (opt->data->entry_name != NULL, FALSE); widget = wso_widget_helper (opt); entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); @@ -72,16 +75,49 @@ static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFun } -static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid, IEEE_802_11_Cipher ** out_cipher) { GtkWidget * entry; const char * input; g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (opt->data->entry_name != 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); + return wso_validate_helper (opt, ssid, input, out_cipher); +} + + +static gboolean append_dbus_params_func (WirelessSecurityOption *opt, const char *ssid, DBusMessage *message) +{ + IEEE_802_11_Cipher * cipher = NULL; + GtkWidget * auth_combo; + int auth_alg = -1; + int we_cipher = -1; + GtkWidget * entry; + const char * input; + char * hashed = NULL; + + g_return_val_if_fail (opt != NULL, FALSE); + g_return_val_if_fail (opt->data != NULL, FALSE); + g_return_val_if_fail (opt->data->auth_combo_name != NULL, FALSE); + g_return_val_if_fail (opt->data->entry_name != NULL, FALSE); + + entry = glade_xml_get_widget (opt->uixml, opt->data->entry_name); + input = gtk_entry_get_text (GTK_ENTRY (entry)); + if (!wso_validate_helper (opt, ssid, input, &cipher) || !cipher) + return FALSE; + + auth_combo = glade_xml_get_widget (opt->uixml, opt->data->auth_combo_name); + auth_alg = wso_wep_auth_combo_get_auth_alg (opt, GTK_COMBO_BOX (auth_combo)); + + we_cipher = ieee_802_11_cipher_get_we_cipher (cipher); + hashed = ieee_802_11_cipher_hash (cipher, ssid, input); + + g_free (hashed); + + return TRUE; } @@ -99,6 +135,7 @@ WirelessSecurityOption * wso_wep_ascii_new (const char *glade_file) opt->data_free_func = data_free_func; opt->validate_input_func = validate_input_func; opt->widget_create_func = widget_create_func; + opt->append_dbus_params_func = append_dbus_params_func; if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL))) { diff --git a/gnome/applet/wso-wep-hex.c b/gnome/applet/wso-wep-hex.c index 62eefd3d83..0ca2488fdb 100644 --- a/gnome/applet/wso-wep-hex.c +++ b/gnome/applet/wso-wep-hex.c @@ -72,7 +72,7 @@ static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFun } -static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid, IEEE_802_11_Cipher ** out_cipher) { GtkWidget * entry; const char * input; @@ -81,7 +81,7 @@ static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ss 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); + return wso_validate_helper (opt, ssid, input, out_cipher); } diff --git a/gnome/applet/wso-wep-passphrase.c b/gnome/applet/wso-wep-passphrase.c index 3bcb6e4902..a4dda7a422 100644 --- a/gnome/applet/wso-wep-passphrase.c +++ b/gnome/applet/wso-wep-passphrase.c @@ -72,7 +72,7 @@ static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFun } -static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid, IEEE_802_11_Cipher ** out_cipher) { GtkWidget * entry; const char * input; @@ -81,7 +81,7 @@ static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ss 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); + return wso_validate_helper (opt, ssid, input, out_cipher); } diff --git a/gnome/applet/wso-wpa-psk-passphrase.c b/gnome/applet/wso-wpa-psk-passphrase.c index 535b1c1bf5..9796e490a1 100644 --- a/gnome/applet/wso-wpa-psk-passphrase.c +++ b/gnome/applet/wso-wpa-psk-passphrase.c @@ -61,7 +61,7 @@ static GtkWidget * widget_create_func (WirelessSecurityOption *opt, GtkSignalFun } -static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid) +static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ssid, IEEE_802_11_Cipher ** out_cipher) { GtkWidget * entry; const char * input; @@ -70,7 +70,7 @@ static gboolean validate_input_func (WirelessSecurityOption *opt, const char *ss 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); + return wso_validate_helper (opt, ssid, input, out_cipher); }