mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 16:00:34 +01:00
2005-12-29 Dan Williams <dcbw@redhat.com>
* gnome/applet/applet-dbus-devices.c - Replace 'enc' parameter with 'capabilities' for wireless networks in dbus calls to NM - Set capabilities on WirelessNetwork objects - Receive and save type-specific device capabilities too * gnome/applet/applet-dbus-info.c gnome/applet/applet-dbus.c - Passphrase dialog no longer a singleton; new instance gets created on each request. Updates to deal with that. * gnome/applet/applet.c - (nmwa_has_encrypted_networks_helper): use AP capabilities rather than single 'encrypted' flag - (nmwa_menu_add_vpn_menu): if NM isn't connected, disable any VPN menu items - Passphrase dialog updates per above * gnome/applet/menu-items.c - (network_menu_item_update): use AP capabilities to determine encryption * gnome/applet/nm-device.[ch] - Add accessors for type-specific device capabilities * gnome/applet/other-network-dialog.c - Rework to respect device capabilities. i.e., if the device doesn't support WPA, remove that option from the security dropdown * gnome/applet/passphrase-dialog.c - Massive rework so that a new instance is created each time it's used, to support wireless network capabilities * gnome/applet/wireless-network.[ch] - Add accessors and members for wireless network capabilities * gnome/applet/wireless-security-manager.[ch] - (wsm_set_capabilities): called after creation to set which security options get shown to the user git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1238 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
2cc6237c02
commit
c957948a82
15 changed files with 377 additions and 293 deletions
42
ChangeLog
42
ChangeLog
|
|
@ -1,3 +1,45 @@
|
|||
2005-12-29 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* gnome/applet/applet-dbus-devices.c
|
||||
- Replace 'enc' parameter with 'capabilities' for wireless networks
|
||||
in dbus calls to NM
|
||||
- Set capabilities on WirelessNetwork objects
|
||||
- Receive and save type-specific device capabilities too
|
||||
|
||||
* gnome/applet/applet-dbus-info.c
|
||||
gnome/applet/applet-dbus.c
|
||||
- Passphrase dialog no longer a singleton; new instance gets created
|
||||
on each request. Updates to deal with that.
|
||||
|
||||
* gnome/applet/applet.c
|
||||
- (nmwa_has_encrypted_networks_helper): use AP capabilities rather
|
||||
than single 'encrypted' flag
|
||||
- (nmwa_menu_add_vpn_menu): if NM isn't connected, disable any VPN
|
||||
menu items
|
||||
- Passphrase dialog updates per above
|
||||
|
||||
* gnome/applet/menu-items.c
|
||||
- (network_menu_item_update): use AP capabilities to determine
|
||||
encryption
|
||||
|
||||
* gnome/applet/nm-device.[ch]
|
||||
- Add accessors for type-specific device capabilities
|
||||
|
||||
* gnome/applet/other-network-dialog.c
|
||||
- Rework to respect device capabilities. i.e., if the device doesn't
|
||||
support WPA, remove that option from the security dropdown
|
||||
|
||||
* gnome/applet/passphrase-dialog.c
|
||||
- Massive rework so that a new instance is created each time
|
||||
it's used, to support wireless network capabilities
|
||||
|
||||
* gnome/applet/wireless-network.[ch]
|
||||
- Add accessors and members for wireless network capabilities
|
||||
|
||||
* gnome/applet/wireless-security-manager.[ch]
|
||||
- (wsm_set_capabilities): called after creation to set which
|
||||
security options get shown to the user
|
||||
|
||||
2005-12-29 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/cipher-wpa-psk-passphrase.c
|
||||
|
|
|
|||
|
|
@ -515,8 +515,8 @@ static void nmwa_dbus_net_properties_cb (DBusPendingCall *pcall, void *user_data
|
|||
dbus_int32_t strength = -1;
|
||||
double freq = 0;
|
||||
dbus_int32_t rate = 0;
|
||||
dbus_bool_t enc = FALSE;
|
||||
dbus_int32_t mode = -1;
|
||||
dbus_int32_t capabilities = NM_802_11_CAP_NONE;
|
||||
|
||||
g_return_if_fail (pcall != NULL);
|
||||
g_return_if_fail (cb_data != NULL);
|
||||
|
|
@ -552,8 +552,8 @@ static void nmwa_dbus_net_properties_cb (DBusPendingCall *pcall, void *user_data
|
|||
DBUS_TYPE_INT32, &strength,
|
||||
DBUS_TYPE_DOUBLE, &freq,
|
||||
DBUS_TYPE_INT32, &rate,
|
||||
DBUS_TYPE_BOOLEAN,&enc,
|
||||
DBUS_TYPE_INT32, &mode,
|
||||
DBUS_TYPE_INT32, &capabilities,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
NetworkDevice * dev;
|
||||
|
|
@ -572,7 +572,7 @@ static void nmwa_dbus_net_properties_cb (DBusPendingCall *pcall, void *user_data
|
|||
network_device_remove_wireless_network (dev, tmp_net);
|
||||
}
|
||||
|
||||
wireless_network_set_encrypted (net, enc);
|
||||
wireless_network_set_capabilities (net, capabilities);
|
||||
wireless_network_set_strength (net, strength);
|
||||
if (act_net && strlen (act_net) && (strcmp (act_net, op) == 0))
|
||||
wireless_network_set_active (net, TRUE);
|
||||
|
|
@ -718,6 +718,7 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d
|
|||
char * active_network_path = NULL;
|
||||
dbus_bool_t link_active = FALSE;
|
||||
dbus_uint32_t caps = NM_DEVICE_CAP_NONE;
|
||||
dbus_uint32_t type_caps = NM_DEVICE_CAP_NONE;
|
||||
char ** networks = NULL;
|
||||
int num_networks = 0;
|
||||
NMActStage act_stage = NM_ACT_STAGE_UNKNOWN;
|
||||
|
|
@ -757,6 +758,7 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d
|
|||
DBUS_TYPE_INT32, &strength,
|
||||
DBUS_TYPE_BOOLEAN,&link_active,
|
||||
DBUS_TYPE_UINT32, &caps,
|
||||
DBUS_TYPE_UINT32, &type_caps,
|
||||
DBUS_TYPE_STRING, &active_network_path,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &networks, &num_networks,
|
||||
DBUS_TYPE_INVALID))
|
||||
|
|
@ -769,6 +771,7 @@ static void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_d
|
|||
network_device_set_active (dev, active);
|
||||
network_device_set_link (dev, link_active);
|
||||
network_device_set_capabilities (dev, caps);
|
||||
network_device_set_type_capabilities (dev, type_caps);
|
||||
network_device_set_act_stage (dev, act_stage);
|
||||
network_device_set_ip4_address (dev, ip4_address);
|
||||
network_device_set_broadcast (dev, broadcast);
|
||||
|
|
|
|||
|
|
@ -124,8 +124,10 @@ static void nmi_dbus_get_network_key_callback (GnomeKeyringResult result,
|
|||
else
|
||||
{
|
||||
WirelessNetwork *net;
|
||||
|
||||
nmi_passphrase_dialog_destroy (applet);
|
||||
if ((net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||
nmi_passphrase_dialog_schedule_show (dev, net, message, applet);
|
||||
applet->passphrase_dialog = nmi_passphrase_dialog_new (applet, 0, dev, net, message);
|
||||
}
|
||||
|
||||
free_network_key_cb_data (cb_data);
|
||||
|
|
@ -222,15 +224,8 @@ nmi_dbus_get_key_for_network (DBusConnection *connection,
|
|||
*/
|
||||
if (new_key && (net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||
{
|
||||
gboolean success;
|
||||
if (!(success = nmi_passphrase_dialog_schedule_show (dev, net, message, applet)))
|
||||
{
|
||||
return nmu_create_dbus_error_message (message,
|
||||
NMI_DBUS_INTERFACE,
|
||||
"GetKeyError",
|
||||
"Could not get user key for network '%s'.",
|
||||
essid);
|
||||
}
|
||||
nmi_passphrase_dialog_destroy (applet);
|
||||
applet->passphrase_dialog = nmi_passphrase_dialog_new (applet, 0, dev, net, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,6 +261,21 @@ nmi_dbus_return_user_key (DBusConnection *connection,
|
|||
}
|
||||
|
||||
|
||||
static DBusMessage *
|
||||
nmi_dbus_cancel_get_key_for_network (DBusConnection *connection,
|
||||
DBusMessage *message,
|
||||
void *user_data)
|
||||
{
|
||||
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
|
||||
nmi_passphrase_dialog_destroy (applet);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_dbus_signal_update_network
|
||||
*
|
||||
|
|
@ -1077,7 +1087,7 @@ DBusMethodDispatcher *nmi_dbus_nmi_methods_setup (void)
|
|||
DBusMethodDispatcher * dispatcher = dbus_method_dispatcher_new (NULL);
|
||||
|
||||
dbus_method_dispatcher_register_method (dispatcher, "getKeyForNetwork", nmi_dbus_get_key_for_network);
|
||||
dbus_method_dispatcher_register_method (dispatcher, "cancelGetKeyForNetwork", nmi_passphrase_dialog_cancel);
|
||||
dbus_method_dispatcher_register_method (dispatcher, "cancelGetKeyForNetwork", nmi_dbus_cancel_get_key_for_network);
|
||||
dbus_method_dispatcher_register_method (dispatcher, "getNetworks", nmi_dbus_get_networks);
|
||||
dbus_method_dispatcher_register_method (dispatcher, "getNetworkProperties", nmi_dbus_get_network_properties);
|
||||
dbus_method_dispatcher_register_method (dispatcher, "updateNetworkInfo", nmi_dbus_update_network_info);
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
|||
{
|
||||
applet->nm_running = FALSE;
|
||||
applet->nm_state = NM_STATE_DISCONNECTED;
|
||||
nmi_passphrase_dialog_cancel (NULL, NULL, applet);
|
||||
nmi_passphrase_dialog_destroy (applet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1603,13 +1603,17 @@ static void nmwa_add_networks_helper (NetworkDevice *dev, WirelessNetwork *net,
|
|||
*/
|
||||
static void nmwa_has_encrypted_networks_helper (NetworkDevice *dev, WirelessNetwork *net, gpointer user_data)
|
||||
{
|
||||
gboolean * has_encrypted = user_data;
|
||||
gboolean *has_encrypted = user_data;
|
||||
int capabilities;
|
||||
|
||||
g_return_if_fail (dev != NULL);
|
||||
g_return_if_fail (net != NULL);
|
||||
g_return_if_fail (has_encrypted != NULL);
|
||||
|
||||
if (wireless_network_get_encrypted (net))
|
||||
capabilities = wireless_network_get_capabilities (net);
|
||||
if ( (capabilities & NM_802_11_CAP_PROTO_WEP)
|
||||
|| (capabilities & NM_802_11_CAP_PROTO_WPA)
|
||||
|| (capabilities & NM_802_11_CAP_PROTO_WPA2))
|
||||
*has_encrypted = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1681,6 +1685,9 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
|
|||
if (active_vpn && active_vpn == vpn)
|
||||
gtk_check_menu_item_set_active (vpn_item, TRUE);
|
||||
|
||||
if (applet->nm_state != NM_STATE_CONNECTED)
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (vpn_item), FALSE);
|
||||
|
||||
g_signal_connect (G_OBJECT (vpn_item), "activate", G_CALLBACK (nmwa_menu_vpn_item_activate), applet);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (vpn_item));
|
||||
}
|
||||
|
|
@ -2315,7 +2322,7 @@ static void nmwa_destroy (NMWirelessApplet *applet, gpointer user_data)
|
|||
|
||||
nmwa_icons_free (applet);
|
||||
|
||||
nmi_passphrase_dialog_destroy (applet->passphrase_dialog);
|
||||
nmi_passphrase_dialog_destroy (applet);
|
||||
|
||||
if (applet->redraw_timeout_id > 0)
|
||||
{
|
||||
|
|
@ -2356,6 +2363,7 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
|
|||
applet->dialup_list = NULL;
|
||||
applet->nm_state = NM_STATE_DISCONNECTED;
|
||||
applet->tooltips = NULL;
|
||||
applet->passphrase_dialog = NULL;
|
||||
|
||||
applet->glade_file = g_build_filename (GLADEDIR, "wireless-applet.glade", NULL);
|
||||
if (!applet->glade_file || !g_file_test (applet->glade_file, G_FILE_TEST_IS_REGULAR))
|
||||
|
|
@ -2367,7 +2375,6 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
|
|||
}
|
||||
|
||||
applet->info_dialog_xml = glade_xml_new (applet->glade_file, "info_dialog", NULL);
|
||||
applet->passphrase_dialog = nmi_passphrase_dialog_init (applet);
|
||||
|
||||
applet->gconf_client = gconf_client_get_default ();
|
||||
if (!applet->gconf_client)
|
||||
|
|
|
|||
|
|
@ -239,8 +239,9 @@ GtkCheckMenuItem *network_menu_item_get_check_item (NMNetworkMenuItem *item)
|
|||
*/
|
||||
void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted)
|
||||
{
|
||||
char *display_essid;
|
||||
gdouble percent;
|
||||
char * display_essid;
|
||||
gdouble percent;
|
||||
int capabilities;
|
||||
|
||||
g_return_if_fail (item != NULL);
|
||||
g_return_if_fail (network != NULL);
|
||||
|
|
@ -255,7 +256,10 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||
/* Deal with the encrypted icon */
|
||||
g_object_set (item->security_image, "visible", is_encrypted, NULL);
|
||||
|
||||
if (wireless_network_get_encrypted (network))
|
||||
capabilities = wireless_network_get_capabilities (network);
|
||||
if ( (capabilities & NM_802_11_CAP_PROTO_WEP)
|
||||
|| (capabilities & NM_802_11_CAP_PROTO_WPA)
|
||||
|| (capabilities & NM_802_11_CAP_PROTO_WPA2))
|
||||
{
|
||||
/*
|
||||
* We want to use "network-wireless-encrypted," which was recently added to the icon spec,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ struct NetworkDevice
|
|||
gboolean active;
|
||||
gboolean link;
|
||||
guint32 caps;
|
||||
guint32 type_caps;
|
||||
char * addr;
|
||||
char * ip4addr;
|
||||
char * broadcast;
|
||||
|
|
@ -549,6 +550,23 @@ void network_device_set_capabilities (NetworkDevice *dev, guint32 caps)
|
|||
dev->caps = caps;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accessors for type-specific device capabilities
|
||||
*/
|
||||
guint32 network_device_get_type_capabilities (NetworkDevice *dev)
|
||||
{
|
||||
g_return_val_if_fail (dev != NULL, NM_DEVICE_CAP_NONE);
|
||||
|
||||
return dev->type_caps;
|
||||
}
|
||||
|
||||
void network_device_set_type_capabilities (NetworkDevice *dev, guint32 type_caps)
|
||||
{
|
||||
g_return_if_fail (dev != NULL);
|
||||
|
||||
dev->type_caps = type_caps;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accessors for NM object path
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ void network_device_set_secondary_dns (NetworkDevice *dev, const char *dns
|
|||
guint32 network_device_get_capabilities (NetworkDevice *dev);
|
||||
void network_device_set_capabilities (NetworkDevice *dev, guint32 caps);
|
||||
|
||||
guint32 network_device_get_type_capabilities (NetworkDevice *dev);
|
||||
void network_device_set_type_capabilities (NetworkDevice *dev, guint32 type_caps);
|
||||
|
||||
const char * network_device_get_iface (NetworkDevice *dev);
|
||||
|
||||
const char * network_device_get_nm_path (NetworkDevice *dev);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@
|
|||
#include "wireless-security-manager.h"
|
||||
#include "wireless-security-option.h"
|
||||
|
||||
#define NAME_COLUMN 0
|
||||
#define DEV_COLUMN 1
|
||||
|
||||
|
||||
static void update_button_cb (GtkWidget *unused, GtkDialog *dialog)
|
||||
{
|
||||
|
|
@ -57,6 +60,7 @@ static void update_button_cb (GtkWidget *unused, GtkDialog *dialog)
|
|||
xml = (GladeXML *) g_object_get_data (G_OBJECT (dialog), "glade-xml");
|
||||
g_return_if_fail (xml != NULL);
|
||||
wsm = (WirelessSecurityManager *) g_object_get_data (G_OBJECT (dialog), "wireless-security-manager");
|
||||
g_assert (wsm);
|
||||
g_return_if_fail (wsm != NULL);
|
||||
|
||||
/* An SSID is required */
|
||||
|
|
@ -79,13 +83,72 @@ static void update_button_cb (GtkWidget *unused, GtkDialog *dialog)
|
|||
}
|
||||
|
||||
/*
|
||||
* nmwa_other_network_dialog_security_combo_changed
|
||||
* nmwa_ond_device_combo_changed
|
||||
*
|
||||
* Replace current wireless security information with options
|
||||
* suitable for the current network device.
|
||||
*
|
||||
*/
|
||||
static void nmwa_ond_device_combo_changed (GtkWidget *dev_combo, gpointer user_data)
|
||||
{
|
||||
int choice;
|
||||
GtkDialog * dialog = (GtkDialog *) user_data;
|
||||
WirelessSecurityManager * wsm;
|
||||
GtkWidget * wso_widget;
|
||||
GladeXML * xml;
|
||||
GtkWidget * vbox;
|
||||
GtkWidget * security_combo;
|
||||
GList * elt;
|
||||
NetworkDevice *dev;
|
||||
char * str;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (dialog != NULL);
|
||||
xml = (GladeXML *) g_object_get_data (G_OBJECT (dialog), "glade-xml");
|
||||
g_return_if_fail (xml != NULL);
|
||||
|
||||
wsm = g_object_get_data (G_OBJECT (dialog), "wireless-security-manager");
|
||||
g_return_if_fail (wsm != NULL);
|
||||
|
||||
vbox = glade_xml_get_widget (xml, "wireless_security_vbox");
|
||||
|
||||
/* Remove any previous wireless security widgets */
|
||||
for (elt = gtk_container_get_children (GTK_CONTAINER (vbox)); elt; elt = g_list_next (elt))
|
||||
{
|
||||
GtkWidget * child = GTK_WIDGET (elt->data);
|
||||
|
||||
if (wso_is_wso_widget (child))
|
||||
gtk_container_remove (GTK_CONTAINER (vbox), child);
|
||||
}
|
||||
|
||||
/* Update WirelessSecurityManager with the new device's capabilities */
|
||||
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dev_combo), &iter);
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (dev_combo));
|
||||
gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, DEV_COLUMN, &dev, -1);
|
||||
g_assert (dev);
|
||||
|
||||
wsm_set_capabilities (wsm, network_device_get_type_capabilities (dev));
|
||||
security_combo = glade_xml_get_widget (xml, "security_combo");
|
||||
wsm_update_combo (wsm, GTK_COMBO_BOX (security_combo));
|
||||
|
||||
/* Determine and add the correct wireless security widget to the dialog */
|
||||
wso_widget = wsm_get_widget_for_active (wsm, GTK_COMBO_BOX (security_combo), GTK_SIGNAL_FUNC (update_button_cb), dialog);
|
||||
if (wso_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), wso_widget);
|
||||
|
||||
update_button_cb (NULL, dialog);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_ond_security_combo_changed
|
||||
*
|
||||
* Replace the current wireless security widgets with new ones
|
||||
* according to what the user chose.
|
||||
*
|
||||
*/
|
||||
static void nmwa_other_network_dialog_security_combo_changed (GtkWidget *security_combo, gpointer user_data)
|
||||
static void nmwa_ond_security_combo_changed (GtkWidget *combo, gpointer user_data)
|
||||
{
|
||||
int choice;
|
||||
GtkDialog * dialog = (GtkDialog *) user_data;
|
||||
|
|
@ -114,16 +177,13 @@ static void nmwa_other_network_dialog_security_combo_changed (GtkWidget *securit
|
|||
}
|
||||
|
||||
/* Determine and add the correct wireless security widget to the dialog */
|
||||
wso_widget = wsm_get_widget_for_active (wsm, GTK_COMBO_BOX (security_combo), GTK_SIGNAL_FUNC (update_button_cb), dialog);
|
||||
wso_widget = wsm_get_widget_for_active (wsm, GTK_COMBO_BOX (combo), GTK_SIGNAL_FUNC (update_button_cb), dialog);
|
||||
if (wso_widget)
|
||||
gtk_container_add (GTK_CONTAINER (vbox), wso_widget);
|
||||
|
||||
update_button_cb (NULL, dialog);
|
||||
}
|
||||
|
||||
|
||||
#define NAME_COLUMN 0
|
||||
#define DEV_COLUMN 1
|
||||
static GtkTreeModel * create_wireless_adapter_model (NMWirelessApplet *applet)
|
||||
{
|
||||
GtkListStore * model;
|
||||
|
|
@ -198,7 +258,7 @@ static const char * get_host_name (void)
|
|||
|
||||
|
||||
|
||||
static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApplet *applet, gboolean create_network)
|
||||
static GtkDialog *nmwa_ond_init (GladeXML *xml, NMWirelessApplet *applet, gboolean create_network)
|
||||
{
|
||||
GtkDialog * dialog = NULL;
|
||||
GtkWidget * network_name_entry;
|
||||
|
|
@ -211,6 +271,8 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
|
|||
gboolean valid;
|
||||
GtkWidget * combo;
|
||||
GtkTreeIter iter;
|
||||
NetworkDevice * dev;
|
||||
char * str;
|
||||
|
||||
g_return_val_if_fail (xml != NULL, NULL);
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
|
|
@ -237,6 +299,43 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
|
|||
gtk_widget_set_sensitive (button, FALSE);
|
||||
g_signal_connect (network_name_entry, "changed", G_CALLBACK (update_button_cb), dialog);
|
||||
|
||||
model = create_wireless_adapter_model (applet);
|
||||
|
||||
valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
while (valid)
|
||||
{
|
||||
n_wireless_interfaces++;
|
||||
valid = gtk_tree_model_iter_next (model, &iter);
|
||||
}
|
||||
|
||||
/* Can connect to a wireless network if there aren't any wireless devices */
|
||||
if (n_wireless_interfaces < 1)
|
||||
return NULL;
|
||||
|
||||
combo = glade_xml_get_widget (xml, "wireless_adapter_combo");
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
g_signal_connect (G_OBJECT (combo), "changed", GTK_SIGNAL_FUNC (nmwa_ond_device_combo_changed), dialog);
|
||||
|
||||
if (n_wireless_interfaces == 1)
|
||||
{
|
||||
gtk_widget_hide (glade_xml_get_widget (xml, "wireless_adapter_label"));
|
||||
gtk_widget_hide (combo);
|
||||
}
|
||||
|
||||
wsm = wsm_new (applet->glade_file);
|
||||
g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", (gpointer) wsm);
|
||||
|
||||
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
|
||||
gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, DEV_COLUMN, &dev, -1);
|
||||
g_assert (dev);
|
||||
wsm_set_capabilities (wsm, network_device_get_type_capabilities (dev));
|
||||
|
||||
security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo"));
|
||||
wsm_update_combo (wsm, security_combo);
|
||||
g_signal_connect (G_OBJECT (security_combo), "changed", GTK_SIGNAL_FUNC (nmwa_ond_security_combo_changed), dialog);
|
||||
nmwa_ond_security_combo_changed (GTK_WIDGET (security_combo), dialog);
|
||||
|
||||
if (create_network)
|
||||
{
|
||||
gchar * default_essid_text;
|
||||
|
|
@ -268,42 +367,11 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
|
|||
gtk_label_set_markup (GTK_LABEL (glade_xml_get_widget (xml, "caption_label")), label);
|
||||
g_free (label);
|
||||
|
||||
model = create_wireless_adapter_model (applet);
|
||||
|
||||
valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
while (valid)
|
||||
{
|
||||
n_wireless_interfaces++;
|
||||
valid = gtk_tree_model_iter_next (model, &iter);
|
||||
}
|
||||
|
||||
/* Can connect to a wireless network if there aren't any wireless devices */
|
||||
if (n_wireless_interfaces < 1)
|
||||
return NULL;
|
||||
|
||||
combo = glade_xml_get_widget (xml, "wireless_adapter_combo");
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
|
||||
if (n_wireless_interfaces == 1)
|
||||
{
|
||||
gtk_widget_hide (glade_xml_get_widget (xml, "wireless_adapter_label"));
|
||||
gtk_widget_hide (combo);
|
||||
}
|
||||
|
||||
wsm = wsm_new (applet->glade_file);
|
||||
g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", (gpointer) wsm);
|
||||
|
||||
security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo"));
|
||||
wsm_populate_combo (wsm, security_combo);
|
||||
g_signal_connect (G_OBJECT (security_combo), "changed", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_security_combo_changed), dialog);
|
||||
nmwa_other_network_dialog_security_combo_changed (GTK_WIDGET (security_combo), dialog);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
static void nmwa_other_network_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
static void nmwa_ond_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
{
|
||||
GladeXML * xml;
|
||||
NMWirelessApplet * applet;
|
||||
|
|
@ -380,9 +448,9 @@ void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_ne
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(dialog = nmwa_other_network_dialog_init (xml, applet, create_network)))
|
||||
if (!(dialog = nmwa_ond_init (xml, applet, create_network)))
|
||||
return;
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (nmwa_other_network_dialog_response_cb), NULL);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (nmwa_ond_response_cb), NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,48 +71,6 @@ static void update_button_cb (GtkWidget *unused, GtkDialog *dialog)
|
|||
gtk_widget_set_sensitive (button, enable);
|
||||
}
|
||||
|
||||
/*
|
||||
* nmi_passphrase_dialog_clear
|
||||
*
|
||||
* Return dialog to its original state; clear out any network or device qdatas,
|
||||
* clear the passphrase entry, and hide the dialog.
|
||||
*
|
||||
*/
|
||||
static void nmi_passphrase_dialog_clear (GtkWidget *dialog)
|
||||
{
|
||||
char * data;
|
||||
GtkWidget * entry = NULL;
|
||||
GladeXML * xml = NULL;
|
||||
|
||||
g_return_if_fail (dialog != NULL);
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "device")))
|
||||
{
|
||||
network_device_unref ((NetworkDevice *)data);
|
||||
g_object_set_data (G_OBJECT (dialog), "device", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "network")))
|
||||
{
|
||||
wireless_network_unref ((WirelessNetwork *)data);
|
||||
g_object_set_data (G_OBJECT (dialog), "network", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "dbus-message")))
|
||||
{
|
||||
dbus_message_unref ((DBusMessage *) data);
|
||||
g_object_set_data (G_OBJECT (dialog), "dbus-message", NULL);
|
||||
}
|
||||
|
||||
if ((xml = (GladeXML *)g_object_get_data (G_OBJECT (dialog), "glade-xml")))
|
||||
{
|
||||
/* FIXME: clear WSO widgets here */
|
||||
}
|
||||
|
||||
gtk_widget_hide (dialog);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_passphrase_dialog_security_combo_changed
|
||||
*
|
||||
|
|
@ -165,10 +123,12 @@ static void nmi_passphrase_dialog_security_combo_changed (GtkWidget *security_co
|
|||
* a cancellation message to NetworkManager.
|
||||
* Either way, get rid of the dialog.
|
||||
*/
|
||||
static void nmi_passphrase_dialog_response_received (GtkWidget *dialog, gint response, gpointer user_data)
|
||||
static void
|
||||
nmi_passphrase_dialog_response_received (GtkWidget *dialog,
|
||||
gint response,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
|
||||
|
||||
NMWirelessApplet * applet;
|
||||
GladeXML * xml;
|
||||
GtkEntry * entry;
|
||||
GtkComboBox * security_combo;
|
||||
|
|
@ -178,11 +138,12 @@ static void nmi_passphrase_dialog_response_received (GtkWidget *dialog, gint res
|
|||
WirelessNetwork * net;
|
||||
NMGConfWSO * gconf_wso;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
message = g_object_get_data (G_OBJECT (dialog), "dbus-message");
|
||||
message = (DBusMessage *) g_object_get_data (G_OBJECT (dialog), "dbus-message");
|
||||
g_assert (message);
|
||||
|
||||
applet = (NMWirelessApplet *) g_object_get_data (G_OBJECT (dialog), "applet");
|
||||
g_assert (applet);
|
||||
|
||||
if (response != GTK_RESPONSE_OK)
|
||||
{
|
||||
DBusMessage * reply;
|
||||
|
|
@ -210,141 +171,39 @@ static void nmi_passphrase_dialog_response_received (GtkWidget *dialog, gint res
|
|||
g_object_unref (G_OBJECT (gconf_wso));
|
||||
|
||||
out:
|
||||
nmi_passphrase_dialog_clear (dialog);
|
||||
}
|
||||
|
||||
|
||||
typedef struct PPDialogCBData
|
||||
{
|
||||
NMWirelessApplet * applet;
|
||||
NetworkDevice * dev;
|
||||
WirelessNetwork * net;
|
||||
DBusMessage * message;
|
||||
} PPDialogCBData;
|
||||
|
||||
/*
|
||||
* nmi_passphrase_dialog_show
|
||||
*
|
||||
* Pop up the user key dialog in response to a dbus message
|
||||
*
|
||||
*/
|
||||
static gboolean nmi_passphrase_dialog_show (PPDialogCBData *cb_data)
|
||||
{
|
||||
GtkWidget * dialog;
|
||||
GladeXML * dialog_xml;
|
||||
const char * orig_label_text;
|
||||
guint32 timestamp;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->applet != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->dev != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->net != NULL, FALSE);
|
||||
|
||||
dialog = cb_data->applet->passphrase_dialog;
|
||||
g_return_val_if_fail ((dialog_xml = get_dialog_xml (dialog)) != NULL, FALSE);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (dialog))
|
||||
return FALSE;
|
||||
|
||||
if (!(orig_label_text = g_object_get_data (G_OBJECT (dialog), "orig-label-text")))
|
||||
return FALSE;
|
||||
|
||||
nmi_passphrase_dialog_clear (dialog);
|
||||
|
||||
/* Insert the Network name into the dialog text */
|
||||
if (orig_label_text)
|
||||
{
|
||||
GtkWidget * label = glade_xml_get_widget (dialog_xml, "label1");
|
||||
char * new_label_text = g_strdup_printf (orig_label_text, wireless_network_get_essid (cb_data->net));
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), new_label_text);
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (dialog), "device", cb_data->dev);
|
||||
g_object_set_data (G_OBJECT (dialog), "network", cb_data->net);
|
||||
g_object_set_data (G_OBJECT (dialog), "dbus-message", cb_data->message);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
/* Bash focus-stealing prevention in the face */
|
||||
timestamp = gdk_x11_get_server_time (dialog->window);
|
||||
gdk_x11_window_set_user_time (dialog->window, timestamp);
|
||||
|
||||
return FALSE;
|
||||
nmi_passphrase_dialog_destroy (applet);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_passphrase_dialog_schedule_show
|
||||
*
|
||||
* Schedule the passphrase dialog to show
|
||||
* nmi_passphrase_dialog_new
|
||||
*
|
||||
* Create a new passphrase dialog instance and tie it
|
||||
* to the given UID.
|
||||
*/
|
||||
gboolean nmi_passphrase_dialog_schedule_show (NetworkDevice *dev, WirelessNetwork *net, DBusMessage *message, NMWirelessApplet *applet)
|
||||
{
|
||||
PPDialogCBData * cb_data;
|
||||
|
||||
g_return_val_if_fail (dev != NULL, FALSE);
|
||||
g_return_val_if_fail (net != NULL, FALSE);
|
||||
g_return_val_if_fail (message != NULL, FALSE);
|
||||
g_return_val_if_fail (applet != NULL, FALSE);
|
||||
|
||||
cb_data = g_malloc0 (sizeof (PPDialogCBData));
|
||||
network_device_ref (dev);
|
||||
cb_data->dev = dev;
|
||||
wireless_network_ref (net);
|
||||
cb_data->net = net;
|
||||
cb_data->applet = applet;
|
||||
dbus_message_ref (message);
|
||||
cb_data->message = message;
|
||||
|
||||
g_idle_add ((GSourceFunc) nmi_passphrase_dialog_show, cb_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_passphrase_dialog_cancel
|
||||
*
|
||||
* Cancel and hide any user key dialog that might be up
|
||||
*
|
||||
*/
|
||||
DBusMessage *
|
||||
nmi_passphrase_dialog_cancel (DBusConnection *connection,
|
||||
DBusMessage *message,
|
||||
void *user_data)
|
||||
{
|
||||
NMWirelessApplet *applet = (NMWirelessApplet *) user_data;
|
||||
GtkWidget *dialog;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
dialog = applet->passphrase_dialog;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (dialog))
|
||||
nmi_passphrase_dialog_clear (dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_passphrase_dialog_init
|
||||
*
|
||||
* Initialize the passphrase dialog
|
||||
*
|
||||
* Returns: TRUE on success
|
||||
* FALSE on failure
|
||||
*/
|
||||
GtkWidget *nmi_passphrase_dialog_init (NMWirelessApplet *applet)
|
||||
GtkWidget *
|
||||
nmi_passphrase_dialog_new (NMWirelessApplet *applet,
|
||||
guint32 uid,
|
||||
NetworkDevice *dev,
|
||||
WirelessNetwork *net,
|
||||
DBusMessage *message)
|
||||
{
|
||||
GtkWidget * dialog;
|
||||
GtkButton * ok_button;
|
||||
GtkEntry * entry;
|
||||
GtkLabel * label;
|
||||
GtkWidget * label;
|
||||
GladeXML * xml;
|
||||
char * orig_label_text;
|
||||
WirelessSecurityManager * wsm;
|
||||
GtkComboBox * security_combo;
|
||||
const char * orig_label_text;
|
||||
char * new_label_text;
|
||||
guint32 timestamp;
|
||||
guint32 caps;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
g_return_val_if_fail (dev != NULL, NULL);
|
||||
g_return_val_if_fail (net != NULL, NULL);
|
||||
g_return_val_if_fail (message != NULL, NULL);
|
||||
|
||||
if (!(xml = glade_xml_new (applet->glade_file, "passphrase_dialog", NULL)))
|
||||
{
|
||||
|
|
@ -356,31 +215,48 @@ GtkWidget *nmi_passphrase_dialog_init (NMWirelessApplet *applet)
|
|||
gtk_widget_hide (dialog);
|
||||
|
||||
g_object_set_data (G_OBJECT (dialog), "glade-xml", xml);
|
||||
|
||||
/* Save original label text to preserve the '%s' and other formatting that gets overwritten
|
||||
* when the dialog is first shown.
|
||||
*/
|
||||
label = GTK_LABEL (glade_xml_get_widget (xml, "label1"));
|
||||
orig_label_text = g_strdup (gtk_label_get_label (label));
|
||||
|
||||
g_object_set_data (G_OBJECT (dialog), "orig-label-text", orig_label_text);
|
||||
|
||||
g_signal_connect (G_OBJECT (dialog), "response", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_response_received), applet);
|
||||
g_object_set_data (G_OBJECT (dialog), "applet", applet);
|
||||
g_object_set_data (G_OBJECT (dialog), "uid", GINT_TO_POINTER (uid));
|
||||
|
||||
ok_button = GTK_BUTTON (glade_xml_get_widget (xml, "login_button"));
|
||||
gtk_widget_grab_default (GTK_WIDGET (ok_button));
|
||||
|
||||
nmi_passphrase_dialog_clear (dialog);
|
||||
/* Insert the Network name into the dialog text */
|
||||
label = glade_xml_get_widget (xml, "label1");
|
||||
orig_label_text = gtk_label_get_label (GTK_LABEL (label));
|
||||
new_label_text = g_strdup_printf (orig_label_text, wireless_network_get_essid (net));
|
||||
gtk_label_set_label (GTK_LABEL (label), new_label_text);
|
||||
g_free (new_label_text);
|
||||
|
||||
network_device_ref (dev);
|
||||
g_object_set_data (G_OBJECT (dialog), "device", dev);
|
||||
wireless_network_ref (net);
|
||||
g_object_set_data (G_OBJECT (dialog), "network", net);
|
||||
dbus_message_ref (message);
|
||||
g_object_set_data (G_OBJECT (dialog), "dbus-message", message);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
|
||||
|
||||
wsm = wsm_new (applet->glade_file);
|
||||
g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", (gpointer) wsm);
|
||||
|
||||
caps = network_device_get_type_capabilities (dev);
|
||||
caps &= wireless_network_get_capabilities (net);
|
||||
wsm_set_capabilities (wsm, caps);
|
||||
|
||||
security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo"));
|
||||
wsm_populate_combo (wsm, security_combo);
|
||||
wsm_update_combo (wsm, security_combo);
|
||||
|
||||
g_signal_connect (G_OBJECT (security_combo), "changed", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_security_combo_changed), dialog);
|
||||
nmi_passphrase_dialog_security_combo_changed (GTK_WIDGET (security_combo), dialog);
|
||||
|
||||
g_signal_connect (G_OBJECT (dialog), "response", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_response_received), dialog);
|
||||
|
||||
/* Bash focus-stealing prevention in the face */
|
||||
timestamp = gdk_x11_get_server_time (dialog->window);
|
||||
gdk_x11_window_set_user_time (dialog->window, timestamp);
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
|
@ -391,13 +267,42 @@ GtkWidget *nmi_passphrase_dialog_init (NMWirelessApplet *applet)
|
|||
* Dispose of the passphrase dialog and its data
|
||||
*
|
||||
*/
|
||||
void nmi_passphrase_dialog_destroy (GtkWidget *dialog)
|
||||
void nmi_passphrase_dialog_destroy (NMWirelessApplet *applet)
|
||||
{
|
||||
char * data;
|
||||
char * data;
|
||||
GtkWidget * dialog;
|
||||
|
||||
g_return_if_fail (dialog != NULL);
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
nmi_passphrase_dialog_clear (dialog);
|
||||
if (!applet->passphrase_dialog)
|
||||
return;
|
||||
|
||||
dialog = applet->passphrase_dialog;
|
||||
gtk_widget_hide (dialog);
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "device")))
|
||||
{
|
||||
network_device_unref ((NetworkDevice *) data);
|
||||
g_object_set_data (G_OBJECT (dialog), "device", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "network")))
|
||||
{
|
||||
wireless_network_unref ((WirelessNetwork *) data);
|
||||
g_object_set_data (G_OBJECT (dialog), "network", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "dbus-message")))
|
||||
{
|
||||
dbus_message_unref ((DBusMessage *) data);
|
||||
g_object_set_data (G_OBJECT (dialog), "dbus-message", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "wireless-security-manager")))
|
||||
{
|
||||
wsm_free ((WirelessSecurityManager *) data);
|
||||
g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "glade-xml")))
|
||||
{
|
||||
|
|
@ -405,11 +310,6 @@ void nmi_passphrase_dialog_destroy (GtkWidget *dialog)
|
|||
g_object_set_data (G_OBJECT (dialog), "glade-xml", NULL);
|
||||
}
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "orig-label-text")))
|
||||
{
|
||||
g_free (data);
|
||||
g_object_set_data (G_OBJECT (dialog), "orig-label-text", NULL);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
applet->passphrase_dialog = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,13 @@
|
|||
#include "nm-device.h"
|
||||
#include "wireless-network.h"
|
||||
|
||||
GtkWidget * nmi_passphrase_dialog_init (NMWirelessApplet *applet);
|
||||
|
||||
void nmi_passphrase_dialog_destroy (GtkWidget *dialog);
|
||||
|
||||
gboolean nmi_passphrase_dialog_schedule_show (NetworkDevice *dev, WirelessNetwork *net, DBusMessage *message, NMWirelessApplet *applet);
|
||||
|
||||
DBusMessage * nmi_passphrase_dialog_cancel (DBusConnection *connection, DBusMessage *message, void *user_data);
|
||||
GtkWidget * nmi_passphrase_dialog_new (NMWirelessApplet *applet,
|
||||
guint32 uid,
|
||||
NetworkDevice *dev,
|
||||
WirelessNetwork *net,
|
||||
DBusMessage *message);
|
||||
|
||||
void nmi_passphrase_dialog_destroy (NMWirelessApplet *applet);
|
||||
|
||||
#endif /* PASSPHRASE_DIALOG_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ struct WirelessNetwork
|
|||
int refcount;
|
||||
char * nm_path;
|
||||
char * essid;
|
||||
gboolean encrypted;
|
||||
gboolean active;
|
||||
gint8 strength;
|
||||
int capabilities;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ WirelessNetwork *wireless_network_copy (WirelessNetwork *src)
|
|||
net->nm_path = g_strdup (src->nm_path);
|
||||
net->essid = g_strdup (src->essid);
|
||||
net->active = src->active;
|
||||
net->encrypted = src->encrypted;
|
||||
net->capabilities = src->capabilities;
|
||||
net->strength = src->strength;
|
||||
|
||||
return net;
|
||||
|
|
@ -156,20 +156,20 @@ const char *wireless_network_get_nm_path (WirelessNetwork *net)
|
|||
}
|
||||
|
||||
/*
|
||||
* Accessors for encrypted
|
||||
* Accessors for capabilities
|
||||
*/
|
||||
gboolean wireless_network_get_encrypted (WirelessNetwork *net)
|
||||
int wireless_network_get_capabilities (WirelessNetwork *net)
|
||||
{
|
||||
g_return_val_if_fail (net != NULL, FALSE);
|
||||
|
||||
return net->encrypted;
|
||||
return net->capabilities;
|
||||
}
|
||||
|
||||
void wireless_network_set_encrypted (WirelessNetwork *net, gboolean encrypted)
|
||||
void wireless_network_set_capabilities (WirelessNetwork *net, int capabilities)
|
||||
{
|
||||
g_return_if_fail (net != NULL);
|
||||
|
||||
net->encrypted = encrypted;
|
||||
net->capabilities = capabilities;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ const char * wireless_network_get_essid (WirelessNetwork *net);
|
|||
|
||||
const char * wireless_network_get_nm_path (WirelessNetwork *net);
|
||||
|
||||
gboolean wireless_network_get_encrypted (WirelessNetwork *net);
|
||||
void wireless_network_set_encrypted (WirelessNetwork *net, gboolean encrypted);
|
||||
int wireless_network_get_capabilities (WirelessNetwork *net);
|
||||
void wireless_network_set_capabilities (WirelessNetwork *net, int capabilities);
|
||||
|
||||
gint8 wireless_network_get_strength (WirelessNetwork *net);
|
||||
void wireless_network_set_strength (WirelessNetwork *net, gint8 strength);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "wireless-security-manager.h"
|
||||
#include "wireless-security-option.h"
|
||||
|
||||
|
|
@ -40,40 +41,66 @@ struct WirelessSecurityManager
|
|||
GSList * options;
|
||||
};
|
||||
|
||||
|
||||
WirelessSecurityManager * wsm_new (const char * glade_file)
|
||||
{
|
||||
WirelessSecurityManager * wsm = NULL;
|
||||
WirelessSecurityOption * opt;
|
||||
|
||||
g_return_val_if_fail (glade_file, NULL);
|
||||
|
||||
wsm = g_malloc0 (sizeof (WirelessSecurityManager));
|
||||
wsm->glade_file = g_strdup (glade_file);
|
||||
|
||||
/* Add the items */
|
||||
if ((opt = wso_none_new (glade_file)))
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
|
||||
if ((opt = wso_wep_passphrase_new (glade_file)))
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
|
||||
if ((opt = wso_wep_hex_new (glade_file)))
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
|
||||
if ((opt = wso_wep_ascii_new (glade_file)))
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
|
||||
/*
|
||||
if ((opt = wso_wpa_psk_passphrase_new (glade_file)))
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
*/
|
||||
|
||||
return wsm;
|
||||
}
|
||||
|
||||
|
||||
void wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities)
|
||||
{
|
||||
WirelessSecurityOption * opt;
|
||||
|
||||
g_return_if_fail (wsm != NULL);
|
||||
|
||||
/* Free previous options */
|
||||
g_slist_foreach (wsm->options, (GFunc) wso_free, NULL);
|
||||
g_slist_free (wsm->options);
|
||||
wsm->options = NULL;
|
||||
|
||||
if (capabilities & NM_802_11_CAP_PROTO_NONE)
|
||||
{
|
||||
opt = wso_none_new (wsm->glade_file);
|
||||
g_assert (opt);
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
}
|
||||
|
||||
if (capabilities & NM_802_11_CAP_PROTO_WEP)
|
||||
{
|
||||
opt = wso_wep_passphrase_new (wsm->glade_file);
|
||||
g_assert (opt);
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
|
||||
opt = wso_wep_hex_new (wsm->glade_file);
|
||||
g_assert (opt);
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
|
||||
opt = wso_wep_ascii_new (wsm->glade_file);
|
||||
g_assert (opt);
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
}
|
||||
|
||||
#if 0 /* NOT YET */
|
||||
if (capabilities & NM_802_11_CAP_PROTO_WPA)
|
||||
{
|
||||
opt = wso_wpa_psk_passphrase_new (glade_file);
|
||||
g_assert (opt);
|
||||
wsm->options = g_slist_append (wsm->options, opt);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#define NAME_COLUMN 0
|
||||
#define OPT_COLUMN 1
|
||||
void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo)
|
||||
#define OPT_COLUMN 1
|
||||
void wsm_update_combo (WirelessSecurityManager *wsm, GtkComboBox *combo)
|
||||
{
|
||||
GtkListStore * model;
|
||||
GSList * elt;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
#include "wireless-security-option.h"
|
||||
#include "wireless-network.h"
|
||||
|
||||
typedef struct WirelessSecurityManager WirelessSecurityManager;
|
||||
|
||||
|
|
@ -32,7 +33,9 @@ WirelessSecurityManager * wsm_new (const char * glade_file);
|
|||
|
||||
void wsm_free (WirelessSecurityManager *wsm);
|
||||
|
||||
void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo);
|
||||
void wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilities);
|
||||
|
||||
void wsm_update_combo (WirelessSecurityManager *wsm, GtkComboBox *combo);
|
||||
|
||||
GtkWidget * wsm_get_widget_for_active (WirelessSecurityManager *wsm, GtkComboBox *combo,
|
||||
GtkSignalFunc validate_cb, gpointer user_data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue