1
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
3
* Dan Williams <dcbw@redhat.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
* (C) Copyright 2007 Red Hat, Inc.
22
#include <glade/glade.h>
24
#include <nm-setting-wireless.h>
26
#include "wireless-security.h"
28
#include "gconf-helpers.h"
32
show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec)
37
widget = glade_xml_get_widget (sec->xml, "leap_password_entry");
40
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
41
gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
45
destroy (WirelessSecurity *parent)
47
WirelessSecurityLEAP *sec = (WirelessSecurityLEAP *) parent;
49
g_slice_free (WirelessSecurityLEAP, sec);
53
validate (WirelessSecurity *parent, const GByteArray *ssid)
58
entry = glade_xml_get_widget (parent->xml, "leap_username_entry");
60
text = gtk_entry_get_text (GTK_ENTRY (entry));
61
if (!text || !strlen (text))
64
entry = glade_xml_get_widget (parent->xml, "leap_password_entry");
66
text = gtk_entry_get_text (GTK_ENTRY (entry));
67
if (!text || !strlen (text))
74
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
78
widget = glade_xml_get_widget (parent->xml, "leap_username_label");
79
gtk_size_group_add_widget (group, widget);
81
widget = glade_xml_get_widget (parent->xml, "leap_password_label");
82
gtk_size_group_add_widget (group, widget);
86
fill_connection (WirelessSecurity *parent, NMConnection *connection)
88
NMSettingWireless *s_wireless;
89
NMSettingWirelessSecurity *s_wireless_sec;
92
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
93
g_assert (s_wireless);
95
if (s_wireless->security)
96
g_free (s_wireless->security);
97
s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
99
/* Blow away the old security setting by adding a clear one */
100
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
101
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
103
s_wireless_sec->key_mgmt = g_strdup ("ieee8021x");
104
s_wireless_sec->auth_alg = g_strdup ("leap");
106
widget = glade_xml_get_widget (parent->xml, "leap_username_entry");
107
s_wireless_sec->leap_username = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
109
widget = glade_xml_get_widget (parent->xml, "leap_password_entry");
110
s_wireless_sec->leap_password = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
113
WirelessSecurityLEAP *
114
ws_leap_new (const char *glade_file, NMConnection *connection)
116
WirelessSecurityLEAP *sec;
119
NMSettingWirelessSecurity *wsec = NULL;
121
g_return_val_if_fail (glade_file != NULL, NULL);
123
xml = glade_xml_new (glade_file, "leap_notebook", NULL);
125
g_warning ("Couldn't get leap_widget from glade xml");
129
widget = glade_xml_get_widget (xml, "leap_notebook");
131
g_object_ref_sink (widget);
133
sec = g_slice_new0 (WirelessSecurityLEAP);
135
g_object_unref (xml);
136
g_object_unref (widget);
140
wireless_security_init (WIRELESS_SECURITY (sec),
149
wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
151
/* Ignore if wireless security doesn't specify LEAP */
152
if (!wsec->auth_alg || strcmp (wsec->auth_alg, "leap"))
157
widget = glade_xml_get_widget (xml, "leap_password_entry");
159
g_signal_connect (G_OBJECT (widget), "changed",
160
(GCallback) wireless_security_changed_cb,
164
GError *error = NULL;
167
secrets = nm_gconf_get_keyring_items (connection,
168
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
172
value = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
174
gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
175
g_hash_table_destroy (secrets);
177
g_error_free (error);
180
widget = glade_xml_get_widget (xml, "leap_username_entry");
182
g_signal_connect (G_OBJECT (widget), "changed",
183
(GCallback) wireless_security_changed_cb,
186
gtk_entry_set_text (GTK_ENTRY (widget), wsec->leap_username);
188
widget = glade_xml_get_widget (xml, "show_checkbutton");
190
g_signal_connect (G_OBJECT (widget), "toggled",
191
(GCallback) show_toggled_cb,