2004-10-29 Dan Williams <dcbw@redhat.com>
* panel-applet/NMWirelessAppletOtherNetworksDialog.[ch] - New files, implement the "Other wireless network" dialog * panel-applet/NMWirelessApplet.c - Move "other wireless network" dialog to separate file * panel-applet/NMWirelessAppletDbus.[ch] - Take key and key_type paramaters for the set_device function * panel-applet/essid.glade - Add UI bits for encryption settings * src/NetworkManagerDbus.c - Retrieve key and key_type params for "setActiveDevice" method call and pass them on - unref AP returned from nm_device_get_best_ap() when needed * src/NetworkManagerDevice.c - (nm_device_get_best_ap): ref the ap before returning it - unref AP returned from nm_device_get_best_ap() when needed - (nm_device_activate_wireless): add "ap" parameter so we don't need to call nm_device_get_best_ap() here, it was pretty much redundant anyway - (AP_NEED_KEY): break second link check condition out into separate function, and fix segfault when ap->enc_key_source was NULL - (nm_device_find_and_use_essid): take key and key_type parameters and pass them along to nm_device_wireless_network_exists(). If the network does exist, set the passed-in key+key_type on the AP * src/NetworkManagerPolicy.c - unref AP returned from nm_device_get_best_ap() when needed git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@277 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
34
ChangeLog
34
ChangeLog
@@ -1,3 +1,37 @@
|
|||||||
|
2004-10-29 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* panel-applet/NMWirelessAppletOtherNetworksDialog.[ch]
|
||||||
|
- New files, implement the "Other wireless network" dialog
|
||||||
|
|
||||||
|
* panel-applet/NMWirelessApplet.c
|
||||||
|
- Move "other wireless network" dialog to separate file
|
||||||
|
|
||||||
|
* panel-applet/NMWirelessAppletDbus.[ch]
|
||||||
|
- Take key and key_type paramaters for the set_device function
|
||||||
|
|
||||||
|
* panel-applet/essid.glade
|
||||||
|
- Add UI bits for encryption settings
|
||||||
|
|
||||||
|
* src/NetworkManagerDbus.c
|
||||||
|
- Retrieve key and key_type params for "setActiveDevice" method call
|
||||||
|
and pass them on
|
||||||
|
- unref AP returned from nm_device_get_best_ap() when needed
|
||||||
|
|
||||||
|
* src/NetworkManagerDevice.c
|
||||||
|
- (nm_device_get_best_ap): ref the ap before returning it
|
||||||
|
- unref AP returned from nm_device_get_best_ap() when needed
|
||||||
|
- (nm_device_activate_wireless): add "ap" parameter so we don't
|
||||||
|
need to call nm_device_get_best_ap() here, it was pretty much
|
||||||
|
redundant anyway
|
||||||
|
- (AP_NEED_KEY): break second link check condition out into separate
|
||||||
|
function, and fix segfault when ap->enc_key_source was NULL
|
||||||
|
- (nm_device_find_and_use_essid): take key and key_type parameters and
|
||||||
|
pass them along to nm_device_wireless_network_exists(). If the
|
||||||
|
network does exist, set the passed-in key+key_type on the AP
|
||||||
|
|
||||||
|
* src/NetworkManagerPolicy.c
|
||||||
|
- unref AP returned from nm_device_get_best_ap() when needed
|
||||||
|
|
||||||
2004-10-28 Dan Williams <dcbw@redhat.com>
|
2004-10-28 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/NetworkManagerUtils.c
|
* src/NetworkManagerUtils.c
|
||||||
|
@@ -26,6 +26,8 @@ libnm_notification_applet_la_SOURCES = \
|
|||||||
NMWirelessApplet.h \
|
NMWirelessApplet.h \
|
||||||
NMWirelessAppletDbus.c \
|
NMWirelessAppletDbus.c \
|
||||||
NMWirelessAppletDbus.h \
|
NMWirelessAppletDbus.h \
|
||||||
|
NMWirelessAppletOtherNetworkDialog.c \
|
||||||
|
NMWirelessAppletOtherNetworkDialog.h \
|
||||||
menu-info.c \
|
menu-info.c \
|
||||||
menu-info.h \
|
menu-info.h \
|
||||||
gtkcellview.c \
|
gtkcellview.c \
|
||||||
|
@@ -377,14 +377,13 @@ static void nmwa_start_redraw_timeout (NMWirelessApplet *applet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* show_warning_dialog
|
* show_warning_dialog
|
||||||
*
|
*
|
||||||
* pop up a warning or error dialog with certain text
|
* pop up a warning or error dialog with certain text
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void show_warning_dialog (gboolean error, gchar *mesg, ...)
|
void show_warning_dialog (gboolean error, gchar *mesg, ...)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@@ -555,7 +554,7 @@ static void nmwa_menu_item_activate (GtkMenuItem *item, gpointer user_data)
|
|||||||
{
|
{
|
||||||
applet->applet_state = APPLET_STATE_WIRELESS_CONNECTING;
|
applet->applet_state = APPLET_STATE_WIRELESS_CONNECTING;
|
||||||
applet->forcing_device = TRUE;
|
applet->forcing_device = TRUE;
|
||||||
nmwa_dbus_set_device (applet->connection, dev, net);
|
nmwa_dbus_set_device (applet->connection, dev, net, -1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,173 +639,13 @@ static void nmwa_menu_add_device_item (GtkWidget *menu, NetworkDevice *device, g
|
|||||||
gtk_widget_show (menu_item);
|
gtk_widget_show (menu_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
update_button_cb (GtkWidget *entry,
|
|
||||||
GtkWidget *button)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
|
|
||||||
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
||||||
if (text[0] == '\000')
|
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
|
||||||
else
|
|
||||||
gtk_widget_set_sensitive (button, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkTreeModel *
|
|
||||||
create_wireless_adaptor_model (NMWirelessApplet *applet)
|
|
||||||
{
|
|
||||||
GtkListStore *retval;
|
|
||||||
GSList *element;
|
|
||||||
|
|
||||||
retval = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
|
|
||||||
for (element = applet->device_list; element; element = element->next)
|
|
||||||
{
|
|
||||||
NetworkDevice *network = (NetworkDevice *)(element->data);
|
|
||||||
|
|
||||||
g_assert (network);
|
|
||||||
if (network->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
const char *network_name;
|
|
||||||
|
|
||||||
network_name = network->hal_name ? network->hal_name : network->nm_name;
|
|
||||||
|
|
||||||
gtk_list_store_append (retval, &iter);
|
|
||||||
gtk_list_store_set (retval, &iter,
|
|
||||||
0, network_name,
|
|
||||||
1, network,
|
|
||||||
-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GTK_TREE_MODEL (retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: We really should break this dialog into its own file. This function is too long.
|
/* FIXME: We really should break this dialog into its own file. This function is too long.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
custom_essid_item_selected (GtkWidget *menu_item, NMWirelessApplet *applet)
|
custom_essid_item_selected (GtkWidget *menu_item, NMWirelessApplet *applet)
|
||||||
{
|
{
|
||||||
gchar *glade_file;
|
nmwa_other_network_dialog_run (applet);
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkWidget *entry;
|
|
||||||
GtkWidget *button;
|
|
||||||
GladeXML *xml;
|
|
||||||
gint response;
|
|
||||||
gint n_wireless_interfaces = 0;
|
|
||||||
GSList *element;
|
|
||||||
NetworkDevice *default_dev = NULL;
|
|
||||||
char *label;
|
|
||||||
|
|
||||||
glade_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_DATADIR,
|
|
||||||
"NetworkManagerNotification/essid.glade",
|
|
||||||
FALSE, NULL);
|
|
||||||
|
|
||||||
if (!glade_file ||
|
|
||||||
!g_file_test (glade_file, G_FILE_TEST_IS_REGULAR))
|
|
||||||
{
|
|
||||||
show_warning_dialog (TRUE, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = glade_xml_new (glade_file, NULL, NULL);
|
|
||||||
g_free (glade_file);
|
|
||||||
|
|
||||||
if (xml == NULL)
|
|
||||||
{
|
|
||||||
/* Reuse the above string to make the translators less angry. */
|
|
||||||
show_warning_dialog (TRUE, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up the dialog */
|
|
||||||
dialog = glade_xml_get_widget (xml, "custom_essid_dialog");
|
|
||||||
entry = glade_xml_get_widget (xml, "essid_entry");
|
|
||||||
button = glade_xml_get_widget (xml, "ok_button");
|
|
||||||
|
|
||||||
gtk_widget_grab_focus (entry);
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
|
||||||
g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), button);
|
|
||||||
|
|
||||||
label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
|
|
||||||
_("Custom wireless network"),
|
|
||||||
_("Enter the ESSID of the wireless network to which you wish to connect."));
|
|
||||||
gtk_label_set_markup (GTK_LABEL (glade_xml_get_widget (xml, "essid_label")), label);
|
|
||||||
|
|
||||||
/* Do we have multiple Network cards? */
|
|
||||||
g_mutex_lock (applet->data_mutex);
|
|
||||||
for (element = applet->device_list; element; element = element->next)
|
|
||||||
{
|
|
||||||
NetworkDevice *dev = (NetworkDevice *)(element->data);
|
|
||||||
|
|
||||||
g_assert (dev);
|
|
||||||
if (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
|
||||||
{
|
|
||||||
if (!default_dev)
|
|
||||||
{
|
|
||||||
default_dev = dev;
|
|
||||||
network_device_ref (default_dev);
|
|
||||||
}
|
|
||||||
n_wireless_interfaces++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n_wireless_interfaces < 1)
|
|
||||||
{
|
|
||||||
g_mutex_unlock (applet->data_mutex);
|
|
||||||
/* Run away!!! */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (n_wireless_interfaces == 1)
|
|
||||||
{
|
|
||||||
gtk_widget_hide (glade_xml_get_widget (xml, "wireless_adaptor_label"));
|
|
||||||
gtk_widget_hide (glade_xml_get_widget (xml, "wireless_adaptor_combo"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GtkWidget *combo;
|
|
||||||
GtkTreeModel *model;
|
|
||||||
|
|
||||||
combo = glade_xml_get_widget (xml, "wireless_adaptor_combo");
|
|
||||||
model = create_wireless_adaptor_model (applet);
|
|
||||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model);
|
|
||||||
|
|
||||||
/* Select the first one randomly */
|
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
|
||||||
}
|
|
||||||
g_mutex_unlock (applet->data_mutex);
|
|
||||||
|
|
||||||
/* Run the dialog */
|
|
||||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
|
||||||
|
|
||||||
if (response == GTK_RESPONSE_OK)
|
|
||||||
{
|
|
||||||
const char *essid;
|
|
||||||
essid = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
||||||
if (essid[0] != '\000')
|
|
||||||
{
|
|
||||||
WirelessNetwork *net = wireless_network_new_with_essid (essid);
|
|
||||||
/* FIXME: allow picking of the wireless device, we currently just
|
|
||||||
* use the first one found in our device list.
|
|
||||||
*
|
|
||||||
* FIXME: default_dev might have gone away by the time the dialog
|
|
||||||
* gets dismissed and we get here...
|
|
||||||
*/
|
|
||||||
if (net)
|
|
||||||
{
|
|
||||||
applet->applet_state = APPLET_STATE_WIRELESS_CONNECTING;
|
|
||||||
applet->forcing_device = TRUE;
|
|
||||||
nmwa_dbus_set_device (applet->connection, default_dev, net);
|
|
||||||
network_device_unref (default_dev);
|
|
||||||
wireless_network_unref (net);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
g_object_unref (xml);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nmwa_menu_add_custom_essid_item (GtkWidget *menu, NMWirelessApplet *applet)
|
static void nmwa_menu_add_custom_essid_item (GtkWidget *menu, NMWirelessApplet *applet)
|
||||||
|
@@ -148,5 +148,6 @@ typedef struct
|
|||||||
|
|
||||||
NetworkDevice *nmwa_get_device_for_nm_device (NMWirelessApplet *applet, const char *nm_dev);
|
NetworkDevice *nmwa_get_device_for_nm_device (NMWirelessApplet *applet, const char *nm_dev);
|
||||||
NMWirelessApplet *nmwa_new (void);
|
NMWirelessApplet *nmwa_new (void);
|
||||||
|
void show_warning_dialog (gboolean error, gchar *mesg, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -514,20 +514,27 @@ static char *nmwa_dbus_get_hal_device_info (DBusConnection *connection, const ch
|
|||||||
* possibly a specific wireless network too.
|
* possibly a specific wireless network too.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void nmwa_dbus_set_device (DBusConnection *connection, const NetworkDevice *dev, const WirelessNetwork *network)
|
void nmwa_dbus_set_device (DBusConnection *connection, const NetworkDevice *dev, const WirelessNetwork *network,
|
||||||
|
NMEncKeyType key_type, const char *passphrase)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_if_fail (connection != NULL);
|
||||||
g_return_if_fail (dev != NULL);
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
if ((dev->type == DEVICE_TYPE_WIRED_ETHERNET) && !passphrase && (key_type != -1))
|
||||||
|
return;
|
||||||
|
|
||||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setActiveDevice")))
|
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setActiveDevice")))
|
||||||
{
|
{
|
||||||
if ((dev->type == DEVICE_TYPE_WIRELESS_ETHERNET) && network && network->essid)
|
if ((dev->type == DEVICE_TYPE_WIRELESS_ETHERNET) && network && network->essid)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Forcing device '%s' and network '%s'\n", dev->nm_device, network->essid);
|
fprintf (stderr, "Forcing device '%s' and network '%s' %s passphrase\n", dev->nm_device, network->essid, passphrase ? "with" : "without");
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, dev->nm_device,
|
dbus_message_append_args (message, DBUS_TYPE_STRING, dev->nm_device,
|
||||||
DBUS_TYPE_STRING, network->essid, DBUS_TYPE_INVALID);
|
DBUS_TYPE_STRING, network->essid,
|
||||||
|
DBUS_TYPE_STRING, (passphrase ? passphrase : ""),
|
||||||
|
DBUS_TYPE_INT32, key_type,
|
||||||
|
DBUS_TYPE_INVALID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,8 @@ enum
|
|||||||
gpointer nmwa_dbus_worker (gpointer user_data);
|
gpointer nmwa_dbus_worker (gpointer user_data);
|
||||||
|
|
||||||
void nmwa_dbus_set_device (DBusConnection *connection, const NetworkDevice *dev,
|
void nmwa_dbus_set_device (DBusConnection *connection, const NetworkDevice *dev,
|
||||||
const WirelessNetwork *network);
|
const WirelessNetwork *network, NMEncKeyType key_type,
|
||||||
|
const char *passphrase);
|
||||||
|
|
||||||
WirelessNetwork * wireless_network_new_with_essid (const char *essid);
|
WirelessNetwork * wireless_network_new_with_essid (const char *essid);
|
||||||
void wireless_network_unref (WirelessNetwork *net);
|
void wireless_network_unref (WirelessNetwork *net);
|
||||||
|
336
panel-applet/NMWirelessAppletOtherNetworkDialog.c
Normal file
336
panel-applet/NMWirelessAppletOtherNetworkDialog.c
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
/* 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.
|
||||||
|
*
|
||||||
|
* This applet used the GNOME Wireless Applet as a skeleton to build from.
|
||||||
|
*
|
||||||
|
* GNOME Wireless Applet Authors:
|
||||||
|
* Eskil Heyn Olsen <eskil@eskil.dk>
|
||||||
|
* Bastien Nocera <hadess@hadess.net> (Gnome2 port)
|
||||||
|
*
|
||||||
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
|
* (C) Copyright 2001, 2002 Free Software Foundation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gnome.h>
|
||||||
|
#include <libgnomeui/libgnomeui.h>
|
||||||
|
#include <glade/glade.h>
|
||||||
|
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
#include "NMWirelessApplet.h"
|
||||||
|
#include "NMWirelessAppletDbus.h"
|
||||||
|
#include "NMWirelessAppletOtherNetworkDialog.h"
|
||||||
|
|
||||||
|
enum NMWAEncryptionKeyTypes
|
||||||
|
{
|
||||||
|
KEY_TYPE_128_BIT_PASSPHRASE = 0,
|
||||||
|
KEY_TYPE_128_BIT_HEX_KEY = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void update_button_cb (GtkWidget *entry, GtkWidget *button)
|
||||||
|
{
|
||||||
|
const char *text;
|
||||||
|
|
||||||
|
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
|
if (text[0] == '\000')
|
||||||
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
|
else
|
||||||
|
gtk_widget_set_sensitive (button, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkTreeModel *create_wireless_adaptor_model (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
GtkListStore *retval;
|
||||||
|
GSList *element;
|
||||||
|
|
||||||
|
retval = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
|
||||||
|
for (element = applet->device_list; element; element = element->next)
|
||||||
|
{
|
||||||
|
NetworkDevice *network = (NetworkDevice *)(element->data);
|
||||||
|
|
||||||
|
g_assert (network);
|
||||||
|
if (network->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
const char *network_name;
|
||||||
|
|
||||||
|
network_name = network->hal_name ? network->hal_name : network->nm_name;
|
||||||
|
|
||||||
|
gtk_list_store_append (retval, &iter);
|
||||||
|
gtk_list_store_set (retval, &iter,
|
||||||
|
0, network_name,
|
||||||
|
1, network,
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GTK_TREE_MODEL (retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_other_network_dialog_key_type_combo_changed
|
||||||
|
*
|
||||||
|
* Change the text of the passphrase entry label to match the selected
|
||||||
|
* key type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_other_network_dialog_key_type_combo_changed (GtkWidget *key_type_combo, gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkLabel *entry_label;
|
||||||
|
int combo_choice;
|
||||||
|
GladeXML *xml = (GladeXML *)user_data;
|
||||||
|
|
||||||
|
g_return_if_fail (xml != NULL);
|
||||||
|
|
||||||
|
entry_label = GTK_LABEL (glade_xml_get_widget (xml, "passphrase_entry_label"));
|
||||||
|
switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo))))
|
||||||
|
{
|
||||||
|
case KEY_TYPE_128_BIT_PASSPHRASE:
|
||||||
|
gtk_label_set_label (entry_label, _("Passphrase:"));
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_128_BIT_HEX_KEY:
|
||||||
|
gtk_label_set_label (entry_label, _("Key:"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_other_network_dialog_enc_check_toggled
|
||||||
|
*
|
||||||
|
* Enable/disable the encryption-related dialog items based on the
|
||||||
|
* widget's status.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nmwa_other_network_dialog_enc_check_toggled (GtkWidget *enc_check_button, gpointer user_data)
|
||||||
|
{
|
||||||
|
GladeXML *xml = (GladeXML *)user_data;
|
||||||
|
GtkComboBox *combo;
|
||||||
|
GtkEntry *entry;
|
||||||
|
GtkLabel *combo_label;
|
||||||
|
GtkLabel *entry_label;
|
||||||
|
gboolean active;
|
||||||
|
|
||||||
|
g_return_if_fail (xml != NULL);
|
||||||
|
|
||||||
|
combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
||||||
|
combo_label = GTK_LABEL (glade_xml_get_widget (xml, "key_type_combo_label"));
|
||||||
|
entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
|
||||||
|
entry_label = GTK_LABEL (glade_xml_get_widget (xml, "passphrase_entry_label"));
|
||||||
|
|
||||||
|
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enc_check_button));
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (combo), active);
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (combo_label), active);
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (entry), active);
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (entry_label), active);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApplet *applet, NetworkDevice **def_dev)
|
||||||
|
{
|
||||||
|
GtkDialog *dialog = NULL;
|
||||||
|
GtkWidget *entry;
|
||||||
|
GtkWidget *button;
|
||||||
|
GtkComboBox *key_type_combo;
|
||||||
|
gint n_wireless_interfaces = 0;
|
||||||
|
GSList *element;
|
||||||
|
char *label;
|
||||||
|
GtkCheckButton *enc_check_button;
|
||||||
|
|
||||||
|
g_return_val_if_fail (xml != NULL, NULL);
|
||||||
|
g_return_val_if_fail (applet != NULL, NULL);
|
||||||
|
g_return_val_if_fail (def_dev != NULL, NULL);
|
||||||
|
g_return_val_if_fail (*def_dev == NULL, NULL);
|
||||||
|
|
||||||
|
/* Set up the dialog */
|
||||||
|
dialog = GTK_DIALOG (glade_xml_get_widget (xml, "custom_essid_dialog"));
|
||||||
|
entry = glade_xml_get_widget (xml, "essid_entry");
|
||||||
|
button = glade_xml_get_widget (xml, "ok_button");
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (entry);
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
||||||
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
|
g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), button);
|
||||||
|
|
||||||
|
label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
|
||||||
|
_("Custom wireless network"),
|
||||||
|
_("Enter the ESSID of the wireless network to which you wish to connect."));
|
||||||
|
gtk_label_set_markup (GTK_LABEL (glade_xml_get_widget (xml, "essid_label")), label);
|
||||||
|
|
||||||
|
/* Do we have multiple Network cards? */
|
||||||
|
g_mutex_lock (applet->data_mutex);
|
||||||
|
for (element = applet->device_list; element; element = element->next)
|
||||||
|
{
|
||||||
|
NetworkDevice *dev = (NetworkDevice *)(element->data);
|
||||||
|
|
||||||
|
g_assert (dev);
|
||||||
|
if (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
||||||
|
{
|
||||||
|
if (!*def_dev)
|
||||||
|
{
|
||||||
|
*def_dev = dev;
|
||||||
|
network_device_ref (*def_dev);
|
||||||
|
}
|
||||||
|
n_wireless_interfaces++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n_wireless_interfaces < 1)
|
||||||
|
{
|
||||||
|
g_mutex_unlock (applet->data_mutex);
|
||||||
|
/* Run away!!! */
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
else if (n_wireless_interfaces == 1)
|
||||||
|
{
|
||||||
|
gtk_widget_hide (glade_xml_get_widget (xml, "wireless_adaptor_label"));
|
||||||
|
gtk_widget_hide (glade_xml_get_widget (xml, "wireless_adaptor_combo"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GtkWidget *combo;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
|
||||||
|
combo = glade_xml_get_widget (xml, "wireless_adaptor_combo");
|
||||||
|
model = create_wireless_adaptor_model (applet);
|
||||||
|
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model);
|
||||||
|
|
||||||
|
/* Select the first one randomly */
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||||
|
}
|
||||||
|
g_mutex_unlock (applet->data_mutex);
|
||||||
|
|
||||||
|
/* Uncheck the "use encryption" checkbox and disable relevant encryption widgets */
|
||||||
|
enc_check_button = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "use_encryption_checkbox"));
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enc_check_button), 0);
|
||||||
|
g_signal_connect (G_OBJECT (enc_check_button), "toggled", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_enc_check_toggled), xml);
|
||||||
|
nmwa_other_network_dialog_enc_check_toggled (GTK_WIDGET (enc_check_button), xml);
|
||||||
|
|
||||||
|
/* Set initial passphrase entry label and key type combo box item */
|
||||||
|
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
||||||
|
gtk_combo_box_set_active (key_type_combo, 0);
|
||||||
|
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_key_type_combo_changed), xml);
|
||||||
|
nmwa_other_network_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), xml);
|
||||||
|
|
||||||
|
return (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nmwa_other_network_dialog_run (NMWirelessApplet *applet)
|
||||||
|
{
|
||||||
|
gchar *glade_file;
|
||||||
|
GtkDialog *dialog;
|
||||||
|
GladeXML *xml;
|
||||||
|
gint response;
|
||||||
|
NetworkDevice *def_dev = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (applet != NULL);
|
||||||
|
|
||||||
|
glade_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_DATADIR,
|
||||||
|
"NetworkManagerNotification/essid.glade", FALSE, NULL);
|
||||||
|
|
||||||
|
if (!glade_file || !g_file_test (glade_file, G_FILE_TEST_IS_REGULAR))
|
||||||
|
{
|
||||||
|
show_warning_dialog (TRUE, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
xml = glade_xml_new (glade_file, NULL, NULL);
|
||||||
|
g_free (glade_file);
|
||||||
|
if (xml == NULL)
|
||||||
|
{
|
||||||
|
/* Reuse the above string to make the translators less angry. */
|
||||||
|
show_warning_dialog (TRUE, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dialog = nmwa_other_network_dialog_init (xml, applet, &def_dev)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Run the dialog */
|
||||||
|
response = gtk_dialog_run (dialog);
|
||||||
|
|
||||||
|
if (response == GTK_RESPONSE_OK)
|
||||||
|
{
|
||||||
|
GtkEntry *essid_entry;
|
||||||
|
GtkCheckButton *enc_check_button;
|
||||||
|
GtkEntry *passphrase_entry;
|
||||||
|
GtkComboBox *key_type_combo;
|
||||||
|
const char *essid = NULL;
|
||||||
|
const char *passphrase = NULL;
|
||||||
|
int key_type = -1;
|
||||||
|
|
||||||
|
essid_entry = GTK_ENTRY (glade_xml_get_widget (xml, "essid_entry"));
|
||||||
|
essid = gtk_entry_get_text (essid_entry);
|
||||||
|
|
||||||
|
enc_check_button = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "use_encryption_checkbox"));
|
||||||
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enc_check_button)))
|
||||||
|
{
|
||||||
|
passphrase_entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
|
||||||
|
passphrase = gtk_entry_get_text (passphrase_entry);
|
||||||
|
|
||||||
|
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
|
||||||
|
key_type = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (essid[0] != '\000')
|
||||||
|
{
|
||||||
|
WirelessNetwork *net = wireless_network_new_with_essid (essid);
|
||||||
|
|
||||||
|
/* FIXME: allow picking of the wireless device, we currently just
|
||||||
|
* use the first one found in our device list.
|
||||||
|
*
|
||||||
|
* FIXME: default_dev might have gone away by the time the dialog
|
||||||
|
* gets dismissed and we get here...
|
||||||
|
*/
|
||||||
|
if (net)
|
||||||
|
{
|
||||||
|
NMEncKeyType nm_key_type;
|
||||||
|
|
||||||
|
switch (key_type)
|
||||||
|
{
|
||||||
|
case KEY_TYPE_128_BIT_PASSPHRASE:
|
||||||
|
nm_key_type = NM_ENC_TYPE_128_BIT_PASSPHRASE;
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_128_BIT_HEX_KEY:
|
||||||
|
nm_key_type = NM_ENC_TYPE_128_BIT_HEX_KEY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nm_key_type = NM_ENC_TYPE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
applet->applet_state = APPLET_STATE_WIRELESS_CONNECTING;
|
||||||
|
applet->forcing_device = TRUE;
|
||||||
|
nmwa_dbus_set_device (applet->connection, def_dev, net, nm_key_type, passphrase);
|
||||||
|
network_device_unref (def_dev);
|
||||||
|
wireless_network_unref (net);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
g_object_unref (xml);
|
||||||
|
}
|
31
panel-applet/NMWirelessAppletOtherNetworkDialog.h
Normal file
31
panel-applet/NMWirelessAppletOtherNetworkDialog.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/* 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 2004 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libgnomeui/libgnomeui.h>
|
||||||
|
#include "NMWirelessApplet.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NM_WIRELESS_APPLET_OTHER_NETWORK_DIALOG_H
|
||||||
|
#define NM_WIRELESS_APPLET_OTHER_NETWORK_DIALOG_H
|
||||||
|
|
||||||
|
void nmwa_other_network_dialog_run (NMWirelessApplet *applet);
|
||||||
|
|
||||||
|
#endif
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
<widget class="GtkDialog" id="custom_essid_dialog">
|
<widget class="GtkDialog" id="custom_essid_dialog">
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
|
<property name="width_request">488</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="title" translatable="yes"></property>
|
<property name="title" translatable="yes"></property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
<widget class="GtkVBox" id="dialog-vbox1">
|
<widget class="GtkVBox" id="dialog-vbox1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">4</property>
|
||||||
|
|
||||||
<child internal-child="action_area">
|
<child internal-child="action_area">
|
||||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||||
@@ -111,20 +112,60 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="table1">
|
<widget class="GtkTable" id="table1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">2</property>
|
<property name="n_rows">3</property>
|
||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="row_spacing">12</property>
|
<property name="row_spacing">12</property>
|
||||||
<property name="column_spacing">6</property>
|
<property name="column_spacing">6</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="wireless_adaptor_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Wireless _Adaptor:</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="mnemonic_widget">wireless_adaptor_combo</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkComboBox" id="wireless_adaptor_combo">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="items" translatable="yes"></property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<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="x_options">fill</property>
|
||||||
|
<property name="y_options">fill</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label2">
|
<widget class="GtkLabel" id="label2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -143,8 +184,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="right_attach">1</property>
|
<property name="right_attach">1</property>
|
||||||
<property name="top_attach">0</property>
|
<property name="top_attach">1</property>
|
||||||
<property name="bottom_attach">1</property>
|
<property name="bottom_attach">2</property>
|
||||||
<property name="x_options">fill</property>
|
<property name="x_options">fill</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@@ -165,17 +206,69 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">0</property>
|
<property name="top_attach">1</property>
|
||||||
<property name="bottom_attach">1</property>
|
<property name="bottom_attach">2</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="wireless_adaptor_label">
|
<widget class="GtkFrame" id="frame1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Wireless _Adaptor:</property>
|
<property name="label_xalign">0</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="label_yalign">0.5</property>
|
||||||
|
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkAlignment" id="alignment1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xscale">1</property>
|
||||||
|
<property name="yscale">1</property>
|
||||||
|
<property name="top_padding">3</property>
|
||||||
|
<property name="bottom_padding">6</property>
|
||||||
|
<property name="left_padding">6</property>
|
||||||
|
<property name="right_padding">6</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkTable" id="table2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="n_rows">2</property>
|
||||||
|
<property name="n_columns">3</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="row_spacing">12</property>
|
||||||
|
<property name="column_spacing">6</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="key_type_combo_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Key Type:</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">0</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="passphrase_entry_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Passphrase:</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
<property name="use_markup">False</property>
|
<property name="use_markup">False</property>
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
<property name="wrap">False</property>
|
<property name="wrap">False</property>
|
||||||
@@ -184,7 +277,6 @@
|
|||||||
<property name="yalign">0.5</property>
|
<property name="yalign">0.5</property>
|
||||||
<property name="xpad">0</property>
|
<property name="xpad">0</property>
|
||||||
<property name="ypad">0</property>
|
<property name="ypad">0</property>
|
||||||
<property name="mnemonic_widget">wireless_adaptor_combo</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
@@ -197,20 +289,72 @@
|
|||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="wireless_adaptor_combo">
|
<widget class="GtkEntry" id="passphrase_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="items" translatable="yes"></property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="editable">True</property>
|
||||||
|
<property name="visibility">True</property>
|
||||||
|
<property name="max_length">0</property>
|
||||||
|
<property name="text" translatable="yes"></property>
|
||||||
|
<property name="has_frame">True</property>
|
||||||
|
<property name="invisible_char" translatable="yes">*</property>
|
||||||
|
<property name="activates_default">False</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkComboBox" id="key_type_combo">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="items" translatable="yes">128-bit Passphrase
|
||||||
|
128-bit Raw Hex Key</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">0</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">1</property>
|
||||||
<property name="x_options">fill</property>
|
<property name="x_options">fill</property>
|
||||||
<property name="y_options">fill</property>
|
<property name="y_options">fill</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="use_encryption_checkbox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label" translatable="yes">Connect with encryption enabled</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
<property name="focus_on_click">True</property>
|
||||||
|
<property name="active">False</property>
|
||||||
|
<property name="inconsistent">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="type">label_item</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</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>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
|
@@ -238,6 +238,8 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply_message = NULL;
|
||||||
char *dev_path = NULL;
|
char *dev_path = NULL;
|
||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
|
char *key = NULL;
|
||||||
|
int key_type = -1;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
@@ -247,9 +249,12 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||||||
/* Try to grab both device _and_ network first, and if that fails then just the device. */
|
/* Try to grab both device _and_ network first, and if that fails then just the device. */
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev_path,
|
if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev_path,
|
||||||
DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID))
|
DBUS_TYPE_STRING, &network, DBUS_TYPE_STRING, &key,
|
||||||
|
DBUS_TYPE_INT32, &key_type, DBUS_TYPE_INVALID))
|
||||||
{
|
{
|
||||||
network = NULL;
|
network = NULL;
|
||||||
|
key = NULL;
|
||||||
|
key_type = -1;
|
||||||
|
|
||||||
if (dbus_error_is_set (&error))
|
if (dbus_error_is_set (&error))
|
||||||
dbus_error_free (&error);
|
dbus_error_free (&error);
|
||||||
@@ -291,7 +296,7 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* If the user specificed a wireless network too, force that as well */
|
/* If the user specificed a wireless network too, force that as well */
|
||||||
if (nm_device_is_wireless (dev) && !nm_device_find_and_use_essid (dev, network))
|
if (nm_device_is_wireless (dev) && !nm_device_find_and_use_essid (dev, network, key, key_type))
|
||||||
nm_dbus_send_network_not_found (data->dbus_connection, network);
|
nm_dbus_send_network_not_found (data->dbus_connection, network);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -446,6 +451,9 @@ void nm_dbus_signal_device_status_change (DBusConnection *connection, NMDevice *
|
|||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, dev_path, DBUS_TYPE_STRING, nm_ap_get_essid (ap), DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_STRING, dev_path, DBUS_TYPE_STRING, nm_ap_get_essid (ap), DBUS_TYPE_INVALID);
|
||||||
else
|
else
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, dev_path, DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_STRING, dev_path, DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
|
if (ap)
|
||||||
|
nm_ap_unref (ap);
|
||||||
g_free (dev_path);
|
g_free (dev_path);
|
||||||
|
|
||||||
if (!dbus_connection_send (connection, message, NULL))
|
if (!dbus_connection_send (connection, message, NULL))
|
||||||
|
@@ -135,7 +135,7 @@ struct NMDevice
|
|||||||
static gboolean nm_device_test_wireless_extensions (NMDevice *dev)
|
static gboolean nm_device_test_wireless_extensions (NMDevice *dev)
|
||||||
{
|
{
|
||||||
int sk;
|
int sk;
|
||||||
int error;
|
int err;
|
||||||
char ioctl_buf[64];
|
char ioctl_buf[64];
|
||||||
|
|
||||||
g_return_val_if_fail (dev != NULL, FALSE);
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
@@ -150,9 +150,9 @@ static gboolean nm_device_test_wireless_extensions (NMDevice *dev)
|
|||||||
strncpy(ioctl_buf, nm_device_get_iface(dev), 63);
|
strncpy(ioctl_buf, nm_device_get_iface(dev), 63);
|
||||||
|
|
||||||
sk = iw_sockets_open ();
|
sk = iw_sockets_open ();
|
||||||
error = ioctl(sk, SIOCGIWNAME, ioctl_buf);
|
err = ioctl(sk, SIOCGIWNAME, ioctl_buf);
|
||||||
close (sk);
|
close (sk);
|
||||||
return (error == 0);
|
return (err == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ static gboolean nm_device_test_wireless_extensions (NMDevice *dev)
|
|||||||
static gboolean nm_device_supports_wireless_scan (NMDevice *dev)
|
static gboolean nm_device_supports_wireless_scan (NMDevice *dev)
|
||||||
{
|
{
|
||||||
int sk;
|
int sk;
|
||||||
int error;
|
int err;
|
||||||
gboolean can_scan = TRUE;
|
gboolean can_scan = TRUE;
|
||||||
wireless_scan_head scan_data;
|
wireless_scan_head scan_data;
|
||||||
|
|
||||||
@@ -177,9 +177,9 @@ static gboolean nm_device_supports_wireless_scan (NMDevice *dev)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
sk = iw_sockets_open ();
|
sk = iw_sockets_open ();
|
||||||
error = iw_scan (sk, (char *)nm_device_get_iface (dev), WIRELESS_EXT, &scan_data);
|
err = iw_scan (sk, (char *)nm_device_get_iface (dev), WIRELESS_EXT, &scan_data);
|
||||||
nm_dispose_scan_results (scan_data.result);
|
nm_dispose_scan_results (scan_data.result);
|
||||||
if ((error == -1) && (errno == EOPNOTSUPP))
|
if ((err == -1) && (errno == EOPNOTSUPP))
|
||||||
can_scan = FALSE;
|
can_scan = FALSE;
|
||||||
close (sk);
|
close (sk);
|
||||||
return (can_scan);
|
return (can_scan);
|
||||||
@@ -535,11 +535,16 @@ static gboolean nm_device_wireless_link_active (NMDevice *dev)
|
|||||||
*/
|
*/
|
||||||
iwlib_socket = iw_sockets_open ();
|
iwlib_socket = iw_sockets_open ();
|
||||||
if (iw_get_ext (iwlib_socket, nm_device_get_iface (dev), SIOCGIWAP, &wrq) >= 0)
|
if (iw_get_ext (iwlib_socket, nm_device_get_iface (dev), SIOCGIWAP, &wrq) >= 0)
|
||||||
|
{
|
||||||
|
NMAccessPoint *best_ap;
|
||||||
|
|
||||||
|
if ((best_ap = nm_device_get_best_ap (dev)))
|
||||||
{
|
{
|
||||||
if ( nm_ethernet_address_is_valid ((struct ether_addr *)(&(wrq.u.ap_addr.sa_data)))
|
if ( nm_ethernet_address_is_valid ((struct ether_addr *)(&(wrq.u.ap_addr.sa_data)))
|
||||||
&& nm_device_get_best_ap (dev)
|
|
||||||
&& !nm_device_need_ap_switch (dev))
|
&& !nm_device_need_ap_switch (dev))
|
||||||
link = TRUE;
|
link = TRUE;
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close (iwlib_socket);
|
close (iwlib_socket);
|
||||||
|
|
||||||
@@ -638,10 +643,16 @@ char * nm_device_get_essid (NMDevice *dev)
|
|||||||
*/
|
*/
|
||||||
if (dev->test_device)
|
if (dev->test_device)
|
||||||
{
|
{
|
||||||
if (nm_device_get_best_ap (dev))
|
NMAccessPoint *best_ap = nm_device_get_best_ap (dev);
|
||||||
return (nm_ap_get_essid (nm_device_get_best_ap (dev)));
|
char *essid = dev->options.wireless.cur_essid;
|
||||||
else
|
|
||||||
return (dev->options.wireless.cur_essid);
|
/* Or, if we've got a best ap, use that ESSID instead */
|
||||||
|
if (best_ap)
|
||||||
|
{
|
||||||
|
essid = nm_ap_get_essid (best_ap);
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
|
}
|
||||||
|
return (essid);
|
||||||
}
|
}
|
||||||
|
|
||||||
iwlib_socket = iw_sockets_open ();
|
iwlib_socket = iw_sockets_open ();
|
||||||
@@ -1281,18 +1292,17 @@ static gboolean nm_device_activation_should_cancel (NMDevice *dev)
|
|||||||
* FALSE on unsuccessful activation (ie no best AP)
|
* FALSE on unsuccessful activation (ie no best AP)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static gboolean nm_device_activate_wireless (NMDevice *dev, guint *bad_crypt_packets)
|
static gboolean nm_device_activate_wireless (NMDevice *dev, NMAccessPoint *ap, guint *bad_crypt_packets)
|
||||||
{
|
{
|
||||||
NMAccessPoint *best_ap;
|
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
|
const char *essid = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (dev != NULL, FALSE);
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
g_return_val_if_fail (nm_device_is_wireless (dev), FALSE);
|
g_return_val_if_fail (nm_device_is_wireless (dev), FALSE);
|
||||||
|
g_return_val_if_fail (ap != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (nm_ap_get_essid (ap) != NULL, FALSE);
|
||||||
|
|
||||||
*bad_crypt_packets = 0;
|
*bad_crypt_packets = 0;
|
||||||
/* If there is a desired AP to connect to, use that essid and possible WEP key */
|
|
||||||
if ((best_ap = nm_device_get_best_ap (dev)) && nm_ap_get_essid (best_ap))
|
|
||||||
{
|
|
||||||
nm_device_bring_down (dev);
|
nm_device_bring_down (dev);
|
||||||
|
|
||||||
/* Force the card into Managed/Infrastructure mode */
|
/* Force the card into Managed/Infrastructure mode */
|
||||||
@@ -1301,18 +1311,19 @@ static gboolean nm_device_activate_wireless (NMDevice *dev, guint *bad_crypt_pac
|
|||||||
/* Disable encryption, then re-enable and set correct key on the card
|
/* Disable encryption, then re-enable and set correct key on the card
|
||||||
* if we are going to encrypt traffic.
|
* if we are going to encrypt traffic.
|
||||||
*/
|
*/
|
||||||
|
essid = nm_ap_get_essid (ap);
|
||||||
nm_device_set_enc_key (dev, NULL);
|
nm_device_set_enc_key (dev, NULL);
|
||||||
if (nm_ap_get_encrypted (best_ap) && nm_ap_get_enc_key_source (best_ap))
|
if (nm_ap_get_encrypted (ap) && nm_ap_get_enc_key_source (ap))
|
||||||
{
|
{
|
||||||
char *hashed_key = nm_ap_get_enc_key_hashed (best_ap);
|
char *hashed_key = nm_ap_get_enc_key_hashed (ap);
|
||||||
nm_device_set_enc_key (dev, hashed_key);
|
nm_device_set_enc_key (dev, hashed_key);
|
||||||
g_free (hashed_key);
|
g_free (hashed_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_device_set_essid (dev, nm_ap_get_essid (best_ap));
|
nm_device_set_essid (dev, essid);
|
||||||
*bad_crypt_packets = nm_device_get_bad_crypt_packets (dev);
|
*bad_crypt_packets = nm_device_get_bad_crypt_packets (dev);
|
||||||
|
|
||||||
syslog (LOG_INFO, "nm_device_wireless_activate(%s) using essid '%s'", nm_device_get_iface (dev), nm_ap_get_essid (best_ap));
|
syslog (LOG_INFO, "nm_device_wireless_activate(%s) using essid '%s'", nm_device_get_iface (dev), essid);
|
||||||
|
|
||||||
/* Bring the device up and pause to allow card to associate */
|
/* Bring the device up and pause to allow card to associate */
|
||||||
nm_device_bring_up (dev);
|
nm_device_bring_up (dev);
|
||||||
@@ -1320,13 +1331,29 @@ static gboolean nm_device_activate_wireless (NMDevice *dev, guint *bad_crypt_pac
|
|||||||
|
|
||||||
nm_device_update_link_active (dev, FALSE);
|
nm_device_update_link_active (dev, FALSE);
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
return (success);
|
return (success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline gboolean HAVE_LINK (NMDevice *dev, guint32 bad_crypt_packets)
|
gboolean AP_NEED_KEY (NMAccessPoint *ap)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
int len = 0;
|
||||||
|
g_return_val_if_fail (ap != NULL, FALSE);
|
||||||
|
|
||||||
|
if ((s = nm_ap_get_enc_key_source (ap)))
|
||||||
|
len = strlen (s);
|
||||||
|
|
||||||
|
syslog (LOG_NOTICE, "AP_NEED_KEY: is_enc=%d && (!(key_source=%d) || !(strlen=%d))\n", nm_ap_get_encrypted (ap),
|
||||||
|
!!nm_ap_get_enc_key_source (ap), len);
|
||||||
|
if (nm_ap_get_encrypted (ap) && (!nm_ap_get_enc_key_source (ap) || !len))
|
||||||
|
return (TRUE);
|
||||||
|
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean HAVE_LINK (NMDevice *dev, guint32 bad_crypt_packets)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (dev != NULL, FALSE);
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
g_return_val_if_fail (nm_device_is_wireless (dev), FALSE);
|
g_return_val_if_fail (nm_device_is_wireless (dev), FALSE);
|
||||||
@@ -1351,16 +1378,14 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
|
|||||||
g_return_if_fail (dev != NULL);
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
/* If the card is just inserted, we may not have had a chance to scan yet */
|
/* If the card is just inserted, we may not have had a chance to scan yet */
|
||||||
if (!(best_ap = nm_device_get_best_ap (dev)))
|
best_ap = nm_device_get_best_ap (dev);
|
||||||
|
if (!best_ap)
|
||||||
{
|
{
|
||||||
nm_device_do_wireless_scan (dev);
|
nm_device_do_wireless_scan (dev);
|
||||||
nm_device_update_best_ap (dev);
|
nm_device_update_best_ap (dev);
|
||||||
best_ap = nm_device_get_best_ap (dev);
|
best_ap = nm_device_get_best_ap (dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try activating the device with the key and access point we have already */
|
|
||||||
nm_device_activate_wireless (dev, &bad_crypt_packets);
|
|
||||||
|
|
||||||
/* Wait until we have a link. Some things that might block us from
|
/* Wait until we have a link. Some things that might block us from
|
||||||
* getting one:
|
* getting one:
|
||||||
* 1) Access point we want to associate with has encryption enabled and
|
* 1) Access point we want to associate with has encryption enabled and
|
||||||
@@ -1388,6 +1413,10 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
|
|||||||
* when the card cannot communicate with the access point.
|
* when the card cannot communicate with the access point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Try activating the device with the key and access point we have already */
|
||||||
|
if (best_ap)
|
||||||
|
nm_device_activate_wireless (dev, best_ap, &bad_crypt_packets);
|
||||||
|
|
||||||
/* For the link check, ensure that:
|
/* For the link check, ensure that:
|
||||||
* 1) a classic link check is good, ie does the card report a valid associated AP MAC address and is it
|
* 1) a classic link check is good, ie does the card report a valid associated AP MAC address and is it
|
||||||
* receiving WEP-enabled packets OK if WEP is on
|
* receiving WEP-enabled packets OK if WEP is on
|
||||||
@@ -1397,20 +1426,11 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
|
|||||||
* from the user.
|
* from the user.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
while ( !HAVE_LINK (dev, bad_crypt_packets)
|
while (!HAVE_LINK (dev, bad_crypt_packets) || (best_ap && AP_NEED_KEY (best_ap)))
|
||||||
|| (best_ap && (nm_ap_get_encrypted (best_ap) &&
|
|
||||||
(!nm_ap_get_enc_key_source (best_ap) || !strlen (nm_ap_get_enc_key_source (best_ap))))))
|
|
||||||
{
|
{
|
||||||
|
/* Refresh what we think is the best AP to associate with */
|
||||||
if (best_ap)
|
if (best_ap)
|
||||||
{
|
nm_ap_unref (best_ap);
|
||||||
syslog (LOG_NOTICE, "LINK: !HAVE=%d, (best_ap=0x%X && (is_enc=%d && (!source=%d || !len_source=%d)))",
|
|
||||||
!HAVE_LINK (dev, bad_crypt_packets), best_ap, nm_ap_get_encrypted (best_ap), !nm_ap_get_enc_key_source (best_ap),
|
|
||||||
nm_ap_get_enc_key_source (best_ap) ? !strlen (nm_ap_get_enc_key_source (best_ap)) : 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
syslog (LOG_NOTICE, "LINK: !HAVE=%d, (best_ap=NULL)", !HAVE_LINK (dev, bad_crypt_packets));
|
|
||||||
|
|
||||||
|
|
||||||
if ((best_ap = nm_device_get_best_ap (dev)))
|
if ((best_ap = nm_device_get_best_ap (dev)))
|
||||||
{
|
{
|
||||||
dev->options.wireless.now_scanning = FALSE;
|
dev->options.wireless.now_scanning = FALSE;
|
||||||
@@ -1432,11 +1452,11 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
|
|||||||
|
|
||||||
/* If we were told to quit activation, stop the thread and return */
|
/* If we were told to quit activation, stop the thread and return */
|
||||||
if (nm_device_activation_should_cancel (dev))
|
if (nm_device_activation_should_cancel (dev))
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try activating again with up-to-date access point and keys */
|
/* Try activating again with up-to-date access point and keys */
|
||||||
nm_device_activate_wireless (dev, &bad_crypt_packets);
|
nm_device_activate_wireless (dev, best_ap, &bad_crypt_packets);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1447,9 +1467,12 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
|
|||||||
|
|
||||||
/* If we were told to quit activation, stop the thread and return */
|
/* If we were told to quit activation, stop the thread and return */
|
||||||
if (nm_device_activation_should_cancel (dev))
|
if (nm_device_activation_should_cancel (dev))
|
||||||
break;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (best_ap)
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
dev->options.wireless.now_scanning = FALSE;
|
dev->options.wireless.now_scanning = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1509,6 +1532,7 @@ static gpointer nm_device_activation_worker (gpointer user_data)
|
|||||||
NMDevice *dev = (NMDevice *)user_data;
|
NMDevice *dev = (NMDevice *)user_data;
|
||||||
unsigned char hostname[100] = "\0";
|
unsigned char hostname[100] = "\0";
|
||||||
int host_err;
|
int host_err;
|
||||||
|
NMAccessPoint *best_ap = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (dev != NULL, NULL);
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
g_return_val_if_fail (dev->app_data != NULL, NULL);
|
g_return_val_if_fail (dev->app_data != NULL, NULL);
|
||||||
@@ -1524,8 +1548,11 @@ static gpointer nm_device_activation_worker (gpointer user_data)
|
|||||||
if (nm_device_activation_should_cancel (dev))
|
if (nm_device_activation_should_cancel (dev))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
best_ap = nm_device_get_best_ap (dev);
|
||||||
syslog (LOG_DEBUG, "nm_device_activation_worker(%s): using ESSID '%s'", nm_device_get_iface (dev),
|
syslog (LOG_DEBUG, "nm_device_activation_worker(%s): using ESSID '%s'", nm_device_get_iface (dev),
|
||||||
nm_ap_get_essid (nm_device_get_best_ap (dev)));
|
best_ap ? nm_ap_get_essid (best_ap) : "none");
|
||||||
|
if (best_ap)
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1538,7 +1565,9 @@ static gpointer nm_device_activation_worker (gpointer user_data)
|
|||||||
nm_system_device_stop_dhcp (dev);
|
nm_system_device_stop_dhcp (dev);
|
||||||
|
|
||||||
/* If we don't have a "best" ap, don't try to get a DHCP address or restart the name service cache */
|
/* If we don't have a "best" ap, don't try to get a DHCP address or restart the name service cache */
|
||||||
if (nm_device_is_wired (dev) || (nm_device_is_wireless (dev) && nm_device_get_best_ap (dev)))
|
if (nm_device_is_wireless (dev))
|
||||||
|
best_ap = nm_device_get_best_ap (dev);
|
||||||
|
if (nm_device_is_wired (dev) || best_ap)
|
||||||
{
|
{
|
||||||
gboolean success;
|
gboolean success;
|
||||||
/* Save machine host name */
|
/* Save machine host name */
|
||||||
@@ -1569,6 +1598,8 @@ static gpointer nm_device_activation_worker (gpointer user_data)
|
|||||||
/* Make system aware of any new DNS settings from resolv.conf */
|
/* Make system aware of any new DNS settings from resolv.conf */
|
||||||
nm_system_update_dns ();
|
nm_system_update_dns ();
|
||||||
}
|
}
|
||||||
|
if (best_ap)
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
|
|
||||||
/* If we were told to quit activation, stop the thread and return */
|
/* If we were told to quit activation, stop the thread and return */
|
||||||
if (nm_device_activation_should_cancel (dev))
|
if (nm_device_activation_should_cancel (dev))
|
||||||
@@ -1757,6 +1788,8 @@ void nm_device_set_user_key_for_network (NMDevice *dev, NMAccessPointList *inval
|
|||||||
*/
|
*/
|
||||||
if (nm_null_safe_strcmp (network, nm_ap_get_essid (best_ap)) == 0)
|
if (nm_null_safe_strcmp (network, nm_ap_get_essid (best_ap)) == 0)
|
||||||
nm_ap_set_enc_key_source (best_ap, key, enc_method);
|
nm_ap_set_enc_key_source (best_ap, key, enc_method);
|
||||||
|
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
}
|
}
|
||||||
dev->options.wireless.user_key_received = TRUE;
|
dev->options.wireless.user_key_received = TRUE;
|
||||||
}
|
}
|
||||||
@@ -1862,6 +1895,8 @@ NMAccessPointList *nm_device_ap_list_get (NMDevice *dev)
|
|||||||
/*
|
/*
|
||||||
* Get/Set functions for "best" access point
|
* Get/Set functions for "best" access point
|
||||||
*
|
*
|
||||||
|
* Caller MUST unref returned access point when done with it.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
NMAccessPoint *nm_device_get_best_ap (NMDevice *dev)
|
NMAccessPoint *nm_device_get_best_ap (NMDevice *dev)
|
||||||
{
|
{
|
||||||
@@ -1872,6 +1907,8 @@ NMAccessPoint *nm_device_get_best_ap (NMDevice *dev)
|
|||||||
|
|
||||||
g_mutex_lock (dev->options.wireless.best_ap_mutex);
|
g_mutex_lock (dev->options.wireless.best_ap_mutex);
|
||||||
best_ap = dev->options.wireless.best_ap;
|
best_ap = dev->options.wireless.best_ap;
|
||||||
|
/* Callers get a reffed AP */
|
||||||
|
if (best_ap) nm_ap_ref (best_ap);
|
||||||
g_mutex_unlock (dev->options.wireless.best_ap_mutex);
|
g_mutex_unlock (dev->options.wireless.best_ap_mutex);
|
||||||
|
|
||||||
return (best_ap);
|
return (best_ap);
|
||||||
@@ -1967,6 +2004,8 @@ gboolean nm_device_need_ap_switch (NMDevice *dev)
|
|||||||
if (nm_null_safe_strcmp (nm_device_get_essid (dev), (ap ? nm_ap_get_essid (ap) : NULL)) != 0)
|
if (nm_null_safe_strcmp (nm_device_get_essid (dev), (ap ? nm_ap_get_essid (ap) : NULL)) != 0)
|
||||||
need_switch = TRUE;
|
need_switch = TRUE;
|
||||||
|
|
||||||
|
if (ap) nm_ap_unref (ap);
|
||||||
|
|
||||||
return (need_switch);
|
return (need_switch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1984,7 +2023,7 @@ void nm_device_update_best_ap (NMDevice *dev)
|
|||||||
{
|
{
|
||||||
NMAccessPointList *ap_list;
|
NMAccessPointList *ap_list;
|
||||||
NMAPListIter *iter;
|
NMAPListIter *iter;
|
||||||
NMAccessPoint *ap = NULL;
|
NMAccessPoint *scan_ap = NULL;
|
||||||
NMAccessPoint *best_ap = NULL;
|
NMAccessPoint *best_ap = NULL;
|
||||||
NMAccessPoint *trusted_best_ap = NULL;
|
NMAccessPoint *trusted_best_ap = NULL;
|
||||||
NMAccessPoint *untrusted_best_ap = NULL;
|
NMAccessPoint *untrusted_best_ap = NULL;
|
||||||
@@ -2005,19 +2044,24 @@ void nm_device_update_best_ap (NMDevice *dev)
|
|||||||
*/
|
*/
|
||||||
if (nm_device_is_best_ap_frozen (dev))
|
if (nm_device_is_best_ap_frozen (dev))
|
||||||
{
|
{
|
||||||
NMAccessPoint *best_ap = nm_device_get_best_ap (dev);
|
best_ap = nm_device_get_best_ap (dev);
|
||||||
|
|
||||||
/* If its in the device's ap list still, don't change the
|
/* If its in the device's ap list still, don't change the
|
||||||
* best ap, since its frozen.
|
* best ap, since its frozen.
|
||||||
*/
|
*/
|
||||||
g_mutex_lock (dev->options.wireless.best_ap_mutex);
|
g_mutex_lock (dev->options.wireless.best_ap_mutex);
|
||||||
if ( best_ap
|
if (best_ap)
|
||||||
&& !nm_ap_list_get_ap_by_essid (dev->app_data->invalid_ap_list, nm_ap_get_essid (best_ap))
|
|
||||||
&& nm_device_ap_list_get_ap_by_essid (dev, nm_ap_get_essid (best_ap)))
|
|
||||||
{
|
{
|
||||||
|
char *essid = nm_ap_get_essid (best_ap);
|
||||||
|
if ( !nm_ap_list_get_ap_by_essid (dev->app_data->invalid_ap_list, essid)
|
||||||
|
&& nm_device_ap_list_get_ap_by_essid (dev, essid))
|
||||||
|
{
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
g_mutex_unlock (dev->options.wireless.best_ap_mutex);
|
g_mutex_unlock (dev->options.wireless.best_ap_mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
|
}
|
||||||
|
|
||||||
/* Otherwise, its gone away and we don't care about it anymore */
|
/* Otherwise, its gone away and we don't care about it anymore */
|
||||||
nm_device_unfreeze_best_ap (dev);
|
nm_device_unfreeze_best_ap (dev);
|
||||||
@@ -2026,10 +2070,10 @@ void nm_device_update_best_ap (NMDevice *dev)
|
|||||||
|
|
||||||
if (!(iter = nm_ap_list_iter_new (ap_list)))
|
if (!(iter = nm_ap_list_iter_new (ap_list)))
|
||||||
return;
|
return;
|
||||||
while ((ap = nm_ap_list_iter_next (iter)))
|
while ((scan_ap = nm_ap_list_iter_next (iter)))
|
||||||
{
|
{
|
||||||
NMAccessPoint *tmp_ap;
|
NMAccessPoint *tmp_ap;
|
||||||
char *ap_essid = nm_ap_get_essid (ap);
|
char *ap_essid = nm_ap_get_essid (scan_ap);
|
||||||
|
|
||||||
/* Access points in the "invalid" list cannot be used */
|
/* Access points in the "invalid" list cannot be used */
|
||||||
if (nm_ap_list_get_ap_by_essid (dev->app_data->invalid_ap_list, ap_essid))
|
if (nm_ap_list_get_ap_by_essid (dev->app_data->invalid_ap_list, ap_essid))
|
||||||
@@ -2042,14 +2086,14 @@ void nm_device_update_best_ap (NMDevice *dev)
|
|||||||
if (nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > trusted_latest_timestamp.tv_sec))
|
if (nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > trusted_latest_timestamp.tv_sec))
|
||||||
{
|
{
|
||||||
trusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap);
|
trusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap);
|
||||||
trusted_best_ap = ap;
|
trusted_best_ap = scan_ap;
|
||||||
/* Merge access point data (mainly to get updated WEP key) */
|
/* Merge access point data (mainly to get updated WEP key) */
|
||||||
nm_ap_set_enc_key_source (trusted_best_ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap));
|
nm_ap_set_enc_key_source (trusted_best_ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap));
|
||||||
}
|
}
|
||||||
else if (!nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > untrusted_latest_timestamp.tv_sec))
|
else if (!nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > untrusted_latest_timestamp.tv_sec))
|
||||||
{
|
{
|
||||||
untrusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap);
|
untrusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap);
|
||||||
untrusted_best_ap = ap;
|
untrusted_best_ap = scan_ap;
|
||||||
/* Merge access point data (mainly to get updated WEP key) */
|
/* Merge access point data (mainly to get updated WEP key) */
|
||||||
nm_ap_set_enc_key_source (untrusted_best_ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap));
|
nm_ap_set_enc_key_source (untrusted_best_ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap));
|
||||||
}
|
}
|
||||||
@@ -2060,7 +2104,7 @@ void nm_device_update_best_ap (NMDevice *dev)
|
|||||||
|
|
||||||
/* If the best ap is NULL, bring device down and clear out its essid and AP */
|
/* If the best ap is NULL, bring device down and clear out its essid and AP */
|
||||||
nm_device_set_best_ap (dev, best_ap);
|
nm_device_set_best_ap (dev, best_ap);
|
||||||
if (!nm_device_get_best_ap (dev))
|
if (!best_ap)
|
||||||
{
|
{
|
||||||
nm_device_bring_down (dev);
|
nm_device_bring_down (dev);
|
||||||
nm_device_set_essid (dev, "");
|
nm_device_set_essid (dev, "");
|
||||||
@@ -2081,7 +2125,8 @@ void nm_device_update_best_ap (NMDevice *dev)
|
|||||||
* WARNING: will blow away any connection the card currently has.
|
* WARNING: will blow away any connection the card currently has.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network, struct ether_addr *ap_addr, gboolean *encrypted)
|
gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network, const char *key, NMEncKeyType key_type,
|
||||||
|
struct ether_addr *ap_addr, gboolean *encrypted)
|
||||||
{
|
{
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
struct ether_addr addr;
|
struct ether_addr addr;
|
||||||
@@ -2166,7 +2211,7 @@ gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network,
|
|||||||
* Returns: TRUE on success
|
* Returns: TRUE on success
|
||||||
* FALSE on failure
|
* FALSE on failure
|
||||||
*/
|
*/
|
||||||
gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid)
|
gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid, const char *key, NMEncKeyType key_type)
|
||||||
{
|
{
|
||||||
struct ether_addr ap_addr;
|
struct ether_addr ap_addr;
|
||||||
gboolean encrypted = FALSE;
|
gboolean encrypted = FALSE;
|
||||||
@@ -2183,14 +2228,13 @@ gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid)
|
|||||||
* (it might have been a blank ESSID up to this point) and use it.
|
* (it might have been a blank ESSID up to this point) and use it.
|
||||||
*/
|
*/
|
||||||
nm_device_deactivate (dev, FALSE);
|
nm_device_deactivate (dev, FALSE);
|
||||||
if (nm_device_wireless_network_exists (dev, essid, &ap_addr, &encrypted))
|
if (nm_device_wireless_network_exists (dev, essid, key, key_type, &ap_addr, &encrypted))
|
||||||
{
|
{
|
||||||
if (!(ap = nm_ap_list_get_ap_by_essid (nm_device_ap_list_get (dev), essid)))
|
if (!(ap = nm_ap_list_get_ap_by_essid (nm_device_ap_list_get (dev), essid)))
|
||||||
{
|
{
|
||||||
NMAccessPoint *tmp_ap;
|
NMAccessPoint *tmp_ap;
|
||||||
|
|
||||||
ap = nm_device_ap_list_get_ap_by_address (dev, &ap_addr);
|
if (!(ap = nm_device_ap_list_get_ap_by_address (dev, &ap_addr)))
|
||||||
if (!ap)
|
|
||||||
{
|
{
|
||||||
/* Okay, the card didn't see it in the scan, Cisco cards sometimes do this.
|
/* Okay, the card didn't see it in the scan, Cisco cards sometimes do this.
|
||||||
* So we make a "fake" access point and add it to the scan list.
|
* So we make a "fake" access point and add it to the scan list.
|
||||||
@@ -2199,6 +2243,8 @@ gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid)
|
|||||||
nm_ap_set_encrypted (ap, encrypted);
|
nm_ap_set_encrypted (ap, encrypted);
|
||||||
nm_ap_set_artificial (ap, TRUE);
|
nm_ap_set_artificial (ap, TRUE);
|
||||||
nm_ap_set_address (ap, &ap_addr);
|
nm_ap_set_address (ap, &ap_addr);
|
||||||
|
if (key_type != NM_ENC_TYPE_UNKNOWN)
|
||||||
|
nm_ap_set_enc_key_source (ap, key, key_type);
|
||||||
nm_ap_list_append_ap (nm_device_ap_list_get (dev), ap);
|
nm_ap_list_append_ap (nm_device_ap_list_get (dev), ap);
|
||||||
nm_ap_unref (ap);
|
nm_ap_unref (ap);
|
||||||
}
|
}
|
||||||
@@ -2207,11 +2253,20 @@ gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid)
|
|||||||
nm_ap_set_essid (ap, essid);
|
nm_ap_set_essid (ap, essid);
|
||||||
if ((tmp_ap = nm_ap_list_get_ap_by_essid (dev->app_data->allowed_ap_list, essid)))
|
if ((tmp_ap = nm_ap_list_get_ap_by_essid (dev->app_data->allowed_ap_list, essid)))
|
||||||
{
|
{
|
||||||
nm_ap_set_invalid (ap, nm_ap_get_invalid (tmp_ap));
|
if (key_type != NM_ENC_TYPE_UNKNOWN)
|
||||||
|
nm_ap_set_enc_key_source (ap, key, key_type);
|
||||||
|
else
|
||||||
nm_ap_set_enc_key_source (ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap));
|
nm_ap_set_enc_key_source (ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap));
|
||||||
|
nm_ap_set_invalid (ap, nm_ap_get_invalid (tmp_ap));
|
||||||
nm_ap_set_timestamp (ap, nm_ap_get_timestamp (tmp_ap));
|
nm_ap_set_timestamp (ap, nm_ap_get_timestamp (tmp_ap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Use the encryption key and type the user sent us if its valid */
|
||||||
|
if (key_type != NM_ENC_TYPE_UNKNOWN)
|
||||||
|
nm_ap_set_enc_key_source (ap, key, key_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we found a valid access point, use it */
|
/* If we found a valid access point, use it */
|
||||||
|
@@ -62,7 +62,8 @@ void nm_device_get_ip6_address (NMDevice *dev);
|
|||||||
|
|
||||||
gboolean nm_device_get_supports_wireless_scan (NMDevice *dev);
|
gboolean nm_device_get_supports_wireless_scan (NMDevice *dev);
|
||||||
void nm_device_do_wireless_scan (NMDevice *dev);
|
void nm_device_do_wireless_scan (NMDevice *dev);
|
||||||
gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network, struct ether_addr *addr, gboolean *encrypted);
|
gboolean nm_device_wireless_network_exists (NMDevice *dev, const char *network, const char *key, NMEncKeyType key_type,
|
||||||
|
struct ether_addr *addr, gboolean *encrypted);
|
||||||
|
|
||||||
void nm_device_set_mode_managed (NMDevice *dev);
|
void nm_device_set_mode_managed (NMDevice *dev);
|
||||||
void nm_device_set_mode_adhoc (NMDevice *dev);
|
void nm_device_set_mode_adhoc (NMDevice *dev);
|
||||||
@@ -96,7 +97,7 @@ gboolean nm_device_deactivate (NMDevice *dev, gboolean just_added);
|
|||||||
|
|
||||||
gboolean nm_device_is_scanning (NMDevice *dev);
|
gboolean nm_device_is_scanning (NMDevice *dev);
|
||||||
|
|
||||||
gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid);
|
gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid, const char *key, NMEncKeyType key_type);
|
||||||
|
|
||||||
void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list,
|
void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list,
|
||||||
unsigned char *network, unsigned char *key,
|
unsigned char *network, unsigned char *key,
|
||||||
|
@@ -123,6 +123,8 @@ static NMDevice * nm_policy_auto_get_best_device (NMData *data)
|
|||||||
best_wireless_dev = dev;
|
best_wireless_dev = dev;
|
||||||
best_wireless_prio = prio;
|
best_wireless_prio = prio;
|
||||||
}
|
}
|
||||||
|
if (best_ap)
|
||||||
|
nm_ap_unref (best_ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
element = g_slist_next (element);
|
element = g_slist_next (element);
|
||||||
@@ -353,9 +355,9 @@ gboolean nm_state_modification_monitor (gpointer user_data)
|
|||||||
if (nm_device_is_wireless (data->active_device))
|
if (nm_device_is_wireless (data->active_device))
|
||||||
{
|
{
|
||||||
ap = nm_device_get_best_ap (data->active_device);
|
ap = nm_device_get_best_ap (data->active_device);
|
||||||
nm_ap_ref (ap);
|
|
||||||
/* Add the AP to the invalid list and force a best ap update */
|
/* Add the AP to the invalid list and force a best ap update */
|
||||||
nm_ap_list_append_ap (data->invalid_ap_list, ap);
|
nm_ap_list_append_ap (data->invalid_ap_list, ap);
|
||||||
|
nm_ap_unref (ap);
|
||||||
nm_device_update_best_ap (data->active_device);
|
nm_device_update_best_ap (data->active_device);
|
||||||
}
|
}
|
||||||
if (ap && nm_ap_get_essid (ap))
|
if (ap && nm_ap_get_essid (ap))
|
||||||
|
Reference in New Issue
Block a user