mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 20:40:34 +01:00
2005-12-11 Dan Williams <dcbw@redhat.com>
* 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
This commit is contained in:
parent
e6c5848a13
commit
7713d13397
15 changed files with 202 additions and 72 deletions
10
ChangeLog
10
ChangeLog
|
|
@ -1,3 +1,13 @@
|
|||
2005-12-11 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* 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 <rml@novell.com>
|
||||
|
||||
* src/dhcp-manager/nm-dhcp-manager.c: Do not fail if DHCP does not
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,15 +23,23 @@
|
|||
#define WIRELESS_SECURITY_MANAGER_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#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 */
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
#include <iwlib.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -22,22 +22,32 @@
|
|||
#ifndef WIRELESS_SECURITY_OPTION_H
|
||||
#define WIRELESS_SECURITY_OPTION_H
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#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 */
|
||||
|
|
|
|||
|
|
@ -19,13 +19,22 @@
|
|||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#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)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue