2005-12-11 Dan Williams <dcbw@redhat.com>

* 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


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1165 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2005-12-12 04:28:26 +00:00
parent 9bd797e508
commit 0ac916c977
17 changed files with 1017 additions and 274 deletions

View file

@ -1,3 +1,12 @@
2005-12-11 Dan Williams <dcbw@redhat.com>
* 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 <dcbw@redhat.com>
* Make validation of the key work correctly

View file

@ -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 = \

View file

@ -425,7 +425,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">12</property>
@ -486,7 +486,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -526,78 +526,73 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="wireless_security_vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkHBox" id="hbox4">
<widget class="GtkLabel" id="security_combo_label">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="security_combo_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Wireless Security:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="security_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">None
WEP Passphrase
WEP 40/128-bit hex
WEP 40/128-bit ASCII
</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<property name="label" translatable="yes">_Wireless Security:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<placeholder/>
<widget class="GtkComboBox" id="security_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">None
WEP Passphrase
WEP 40/128-bit hex
WEP 40/128-bit ASCII
</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="wireless_security_vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
</packing>
</child>
</widget>
<packing>
@ -1625,11 +1620,14 @@ WEP 40/128-bit ASCII
<property name="enable_popup">False</property>
<child>
<widget class="GtkHBox" id="hbox5">
<widget class="GtkTable" id="table6">
<property name="border_width">8</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkLabel" id="wep_key_label">
@ -1637,10 +1635,10 @@ WEP 40/128-bit ASCII
<property name="label" translatable="yes">Key:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -1650,9 +1648,12 @@ WEP 40/128-bit ASCII
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">6</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
@ -1669,9 +1670,57 @@ WEP 40/128-bit ASCII
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="auth_method_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Authentication:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="auth_method_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">Open System
Shared Key</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
@ -2087,22 +2136,25 @@ WEP 40/128-bit ASCII
<property name="enable_popup">False</property>
<child>
<widget class="GtkHBox" id="hbox8">
<widget class="GtkTable" id="table7">
<property name="border_width">8</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkLabel" id="wep_passphrase_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Key:</property>
<property name="label" translatable="yes">Passphrase:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -2112,9 +2164,12 @@ WEP 40/128-bit ASCII
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">6</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
@ -2131,9 +2186,57 @@ WEP 40/128-bit ASCII
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="auth_method_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Authentication:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="auth_method_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">Open System
Shared Key</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>

View file

@ -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
{

View file

@ -24,38 +24,11 @@
#include <gtk/gtk.h>
#include <string.h>
#include <glade/glade.h>
#include <iwlib.h>
#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));
}

View file

@ -22,13 +22,9 @@
#ifndef WIRELESS_SECURITY_OPTION_H
#define WIRELESS_SECURITY_OPTION_H
typedef struct WirelessSecurityOption WirelessSecurityOption;
#include <gtk/gtk.h>
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 */

47
gnome/applet/wso-none.c Normal file
View file

@ -0,0 +1,47 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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;
}

28
gnome/applet/wso-none.h Normal file
View file

@ -0,0 +1,28 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 */

View file

@ -0,0 +1,64 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#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 */

View file

@ -0,0 +1,118 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#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;
}

View file

@ -0,0 +1,28 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 */

118
gnome/applet/wso-wep-hex.c Normal file
View file

@ -0,0 +1,118 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#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;
}

View file

@ -0,0 +1,28 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 */

View file

@ -0,0 +1,117 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#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;
}

View file

@ -0,0 +1,28 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 */

View file

@ -0,0 +1,105 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#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;
}

View file

@ -0,0 +1,28 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* 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 */