Commit 96174e04 authored by Chris Aillon's avatar Chris Aillon Committed by Chris Aillon
Browse files

2005-09-10 Christopher Aillon <caillon@redhat.com>

	* NetworkManager.h:
	* gnome/applet/applet-dbus-info.c:
	* gnome/applet/applet-dbus-info.h:
	* gnome/applet/applet.c:
	* gnome/applet/applet.h:
	* src/NetworkManager.c:
	* src/NetworkManagerDbus.c:
	* src/NetworkManagerDbus.h:
	* src/NetworkManagerDevice.c:
	* src/NetworkManagerDevice.h:
	* src/NetworkManagerMain.h:
	* src/NetworkManagerWireless.c:
	* src/NetworkManagerWireless.h:
	* src/nm-dbus-nm.c:
	Make NetworkManager be smart about how frequently to scan
	based on its current state.  Remove the UI for choosing when
	to scan.  Scanning still may disabled completely by the user
	via the "Wireless Enabled" menu item.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@958 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent b755c028
2005-09-10 Christopher Aillon <caillon@redhat.com>
* NetworkManager.h:
* gnome/applet/applet-dbus-info.c:
* gnome/applet/applet-dbus-info.h:
* gnome/applet/applet.c:
* gnome/applet/applet.h:
* src/NetworkManager.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDbus.h:
* src/NetworkManagerDevice.c:
* src/NetworkManagerDevice.h:
* src/NetworkManagerMain.h:
* src/NetworkManagerWireless.c:
* src/NetworkManagerWireless.h:
* src/nm-dbus-nm.c:
Make NetworkManager be smart about how frequently to scan
based on its current state. Remove the UI for choosing when
to scan. Scanning still may disabled completely by the user
via the "Wireless Enabled" menu item.
2005-09-09 Christopher Aillon <caillon@redhat.com>
* gnome/applet/applet.c:
......
......@@ -225,17 +225,4 @@ typedef enum NMActStage
NM_ACT_STAGE_CANCELLED
} NMActStage;
/*
* Wireless scanning methods
*
*/
typedef enum NMWirelessScanMethod
{
NM_SCAN_METHOD_UNKNOWN = 0,
NM_SCAN_METHOD_ALWAYS,
NM_SCAN_METHOD_WHEN_UNASSOCIATED,
NM_SCAN_METHOD_NEVER
} NMWirelessScanMethod;
#endif
......@@ -213,55 +213,6 @@ void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message,
}
/*
* nmi_dbus_signal_update_scan_method
*
* Signal NetworkManager that it needs to update its wireless scanning method
*
*/
void nmi_dbus_signal_update_scan_method (DBusConnection *connection)
{
DBusMessage *message;
g_return_if_fail (connection != NULL);
message = dbus_message_new_signal (NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "WirelessScanMethodUpdate");
if (!message)
{
nm_warning ("nmi_dbus_signal_update_scan_method(): Not enough memory for new dbus message!");
return;
}
if (!dbus_connection_send (connection, message, NULL))
nm_warning ("nmi_dbus_signal_update_scan_method(): Could not raise the 'WirelessScanMethodUpdate' signal!");
dbus_message_unref (message);
}
/*
* nmi_dbus_get_wireless_scan_method
*
* Tell NetworkManager what wireless scanning method it should use
*
*/
static DBusMessage *nmi_dbus_get_wireless_scan_method (NMWirelessApplet *applet, DBusMessage *message)
{
DBusMessage * reply = NULL;
NMWirelessScanMethod method = NM_SCAN_METHOD_ALWAYS;
GConfEntry * entry;
g_return_val_if_fail (applet != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
method = nmwa_gconf_get_wireless_scan_method (applet);
reply = dbus_message_new_method_return (message);
dbus_message_append_args (reply, DBUS_TYPE_UINT32, &method, DBUS_TYPE_INVALID);
return (reply);
}
/*
* nmi_dbus_signal_update_network
*
......@@ -1143,8 +1094,6 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBu
}
}
#endif
else if (strcmp ("getWirelessScanMethod", method) == 0)
reply = nmi_dbus_get_wireless_scan_method (applet, message);
else if (strcmp ("getNetworks", method) == 0)
reply = nmi_dbus_get_networks (applet, message);
else if (strcmp ("getNetworkProperties", method) == 0)
......@@ -1171,3 +1120,21 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBu
return (DBUS_HANDLER_RESULT_HANDLED);
}
void nmi_dbus_signal_user_interface_activated (DBusConnection *connection)
{
DBusMessage *message;
g_return_if_fail (connection != NULL);
message = dbus_message_new_signal (NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "UserInterfaceActivated");
if (!message)
{
nm_warning ("nmi_dbus_signal_user_interface_activated(): Not enough memory for new dbus message!");
return;
}
if (!dbus_connection_send (connection, message, NULL))
nm_warning ("nmi_dbus_signal_user_interface_activated(): Could not raise the 'UserInterfaceActivated' signal!");
dbus_message_unref (message);
}
......@@ -32,10 +32,10 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, D
void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const NMEncKeyType key_type);
void nmi_dbus_signal_update_scan_method (DBusConnection *connection);
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMNetworkType type);
void nmi_dbus_signal_update_vpn_connection (DBusConnection *connection, const char *name);
void nmi_dbus_signal_user_interface_activated (DBusConnection *connection);
#endif
......@@ -1355,6 +1355,8 @@ static void nmwa_menu_item_activate (GtkMenuItem *item, gpointer user_data)
nmwa_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, -1, NULL);
network_device_unref (dev);
nmi_dbus_signal_user_interface_activated (applet->connection);
}
......@@ -1406,6 +1408,8 @@ static void nmwa_menu_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
}
}
}
nmi_dbus_signal_user_interface_activated (applet->connection);
}
......@@ -1428,6 +1432,8 @@ static void nmwa_menu_dialup_item_activate (GtkMenuItem *item, gpointer user_dat
return;
nmwa_dbus_dialup_activate_connection (applet, dialup);
nmi_dbus_signal_user_interface_activated (applet->connection);
}
......@@ -1446,6 +1452,8 @@ static void nmwa_menu_configure_vpn_item_activate (GtkMenuItem *item, gpointer u
g_return_if_fail (applet != NULL);
g_spawn_async (NULL, (gchar **) argv, NULL, 0, NULL, NULL, NULL, NULL);
nmi_dbus_signal_user_interface_activated (applet->connection);
}
/*
......@@ -1462,51 +1470,8 @@ static void nmwa_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer
g_return_if_fail (applet != NULL);
nmwa_dbus_vpn_deactivate_connection (applet->connection);
}
static void scanning_menu_update (GtkWidget *menu_item, GtkCheckMenuItem *active_item)
{
g_return_if_fail (active_item != NULL);
g_object_set_data (G_OBJECT (menu_item), "block-activate", GINT_TO_POINTER(1));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), (GTK_CHECK_MENU_ITEM (menu_item) == active_item) ? TRUE : FALSE);
g_object_set_data (G_OBJECT (menu_item), "block-activate", GINT_TO_POINTER(0));
}
/*
* nmwa_menu_scanning_item_activate
*
* Handle a request to change scanning behavior
*
*/
static void nmwa_menu_scanning_item_activate (GtkMenuItem *item, gpointer user_data)
{
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
char * tag;
g_return_if_fail (item != NULL);
g_return_if_fail (applet != NULL);
if ((tag = g_object_get_data (G_OBJECT (item), "block-activate")))
if (GPOINTER_TO_INT(tag) == 1)
return;
if ((tag = g_object_get_data (G_OBJECT (item), "scan_method")))
{
NMWirelessScanMethod method = GPOINTER_TO_UINT (tag);
if ((method == NM_SCAN_METHOD_ALWAYS) || (method == NM_SCAN_METHOD_NEVER)
|| (method == NM_SCAN_METHOD_WHEN_UNASSOCIATED))
gconf_client_set_int (applet->gconf_client, GCONF_PATH_WIRELESS "/scan_method", method, NULL);
}
/* Check only this menu item */
if (!applet->scanning_menu)
return;
gtk_container_foreach (GTK_CONTAINER (applet->scanning_menu), (GtkCallback) scanning_menu_update, (gpointer) item);
nmi_dbus_signal_user_interface_activated (applet->connection);
}
......@@ -2056,6 +2021,8 @@ static void nmwa_dropdown_menu_show_cb (GtkWidget *menu, NMWirelessApplet *apple
nmwa_dropdown_menu_populate (applet->dropdown_menu, applet);
gtk_widget_show_all (applet->dropdown_menu);
}
nmi_dbus_signal_user_interface_activated (applet->connection);
}
/*
......@@ -2107,15 +2074,9 @@ static void nmwa_context_menu_update (NMWirelessApplet *applet)
}
if (have_wireless)
{
gtk_widget_show_all (applet->scanning_item);
gtk_widget_show_all (applet->stop_wireless_item);
}
else
{
gtk_widget_hide (applet->scanning_item);
gtk_widget_hide (applet->stop_wireless_item);
}
}
......@@ -2130,44 +2091,11 @@ static GtkWidget *nmwa_context_menu_create (NMWirelessApplet *applet)
GtkWidget *menu;
GtkWidget *menu_item;
GtkWidget *image;
GtkWidget *scanning_subitem;
g_return_val_if_fail (applet != NULL, NULL);
menu = gtk_menu_new ();
/* Construct the wireless scanning submenu */
applet->scan_method = nmwa_gconf_get_wireless_scan_method (applet);
applet->scanning_item = gtk_menu_item_new_with_mnemonic (_("Wireless Network _Discovery"));
applet->scanning_menu = gtk_menu_new ();
scanning_subitem = GTK_WIDGET (gtk_check_menu_item_new_with_label (_("Always Search")));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_object_set_data (G_OBJECT (scanning_subitem), "scan_method", GUINT_TO_POINTER (NM_SCAN_METHOD_ALWAYS));
if (applet->scan_method == NM_SCAN_METHOD_ALWAYS)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_signal_connect (G_OBJECT (scanning_subitem), "activate", G_CALLBACK (nmwa_menu_scanning_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (applet->scanning_menu), GTK_WIDGET (scanning_subitem));
scanning_subitem = GTK_WIDGET (gtk_check_menu_item_new_with_label (_("Search Only When Disconnected")));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_object_set_data (G_OBJECT (scanning_subitem), "scan_method", GINT_TO_POINTER (NM_SCAN_METHOD_WHEN_UNASSOCIATED));
if (applet->scan_method == NM_SCAN_METHOD_WHEN_UNASSOCIATED)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_signal_connect (G_OBJECT (scanning_subitem), "activate", G_CALLBACK (nmwa_menu_scanning_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (applet->scanning_menu), GTK_WIDGET (scanning_subitem));
scanning_subitem = GTK_WIDGET (gtk_check_menu_item_new_with_label (_("Never Search")));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_object_set_data (G_OBJECT (scanning_subitem), "scan_method", GINT_TO_POINTER (NM_SCAN_METHOD_NEVER));
if (applet->scan_method == NM_SCAN_METHOD_NEVER)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (scanning_subitem), TRUE);
g_signal_connect (G_OBJECT (scanning_subitem), "activate", G_CALLBACK (nmwa_menu_scanning_item_activate), applet);
gtk_menu_shell_append (GTK_MENU_SHELL (applet->scanning_menu), GTK_WIDGET (scanning_subitem));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (applet->scanning_item), applet->scanning_menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), applet->scanning_item);
/* Wireless Enabled item */
applet->stop_wireless_item = gtk_check_menu_item_new_with_mnemonic (_("_Wireless Enabled"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->stop_wireless_item), TRUE);
......@@ -2296,38 +2224,6 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
}
/*
* nmwa_gconf_get_wireless_scan_method
*
* Grab the wireless scan method from GConf
*
*/
NMWirelessScanMethod nmwa_gconf_get_wireless_scan_method (NMWirelessApplet *applet)
{
NMWirelessScanMethod method = NM_SCAN_METHOD_ALWAYS;
GConfEntry * entry;
g_return_val_if_fail (applet, NM_SCAN_METHOD_ALWAYS);
g_return_val_if_fail (applet->gconf_client, NM_SCAN_METHOD_ALWAYS);
if ((entry = gconf_client_get_entry (applet->gconf_client, GCONF_PATH_WIRELESS "/scan_method", NULL, TRUE, NULL)))
{
GConfValue * value = gconf_entry_get_value (entry);
if (value && (value->type == GCONF_VALUE_INT))
{
NMWirelessScanMethod temp_method = gconf_value_get_int (value);
if ((method == NM_SCAN_METHOD_ALWAYS) || (method == NM_SCAN_METHOD_NEVER)
|| (method == NM_SCAN_METHOD_WHEN_UNASSOCIATED))
method = temp_method;
}
}
return method;
}
/*
* nmwa_gconf_info_notify_callback
*
......@@ -2347,19 +2243,6 @@ static void nmwa_gconf_info_notify_callback (GConfClient *client, guint connecti
{
int net_path_len = strlen (GCONF_PATH_WIRELESS_NETWORKS) + 1;
if (strcmp (GCONF_PATH_WIRELESS "/scan_method", key) == 0)
{
GConfValue * value = gconf_entry_get_value (entry);
if (value && (value->type == GCONF_VALUE_INT))
{
NMWirelessScanMethod method = gconf_value_get_int (value);
if ((method == NM_SCAN_METHOD_ALWAYS) || (method == NM_SCAN_METHOD_NEVER)
|| (method == NM_SCAN_METHOD_WHEN_UNASSOCIATED))
nmi_dbus_signal_update_scan_method (applet->connection);
}
}
if (strncmp (GCONF_PATH_WIRELESS_NETWORKS"/", key, net_path_len) == 0)
{
char *network = g_strdup ((key + net_path_len));
......@@ -2495,8 +2378,6 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
applet->dialup_list = NULL;
applet->nm_state = NM_STATE_DISCONNECTED;
applet->tooltips = NULL;
applet->scanning_menu = NULL;
applet->scanning_item = 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))
......
......@@ -82,7 +82,6 @@ typedef struct
/* Data model elements */
gboolean is_adhoc;
NMWirelessScanMethod scan_method;
gboolean wireless_enabled;
gboolean nm_running;
......@@ -125,8 +124,6 @@ typedef struct
GtkTooltips * tooltips;
GtkWidget * context_menu;
GtkWidget * scanning_item;
GtkWidget * scanning_menu;
GtkWidget * stop_wireless_item;
GtkWidget * passphrase_dialog;
......@@ -150,8 +147,6 @@ void nmwa_schedule_vpn_login_banner_dialog (NMWirelessApplet *applet, const c
NetworkDevice * nmwa_get_first_active_device (GSList *dev_list);
VPNConnection * nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet);
NMWirelessScanMethod nmwa_gconf_get_wireless_scan_method (NMWirelessApplet *applet);
int nm_null_safe_strcmp (const char *s1, const char *s2);
#endif
......@@ -428,8 +428,6 @@ static NMData *nm_data_new (gboolean enable_test_devices)
}
data->enable_test_devices = enable_test_devices;
data->scanning_method = NM_SCAN_METHOD_ALWAYS;
data->wireless_enabled = TRUE;
nm_policy_schedule_device_change_check (data);
......@@ -931,7 +929,6 @@ int main( int argc, char *argv[] )
{
nm_policy_schedule_allowed_ap_list_update (nm_data);
nm_dbus_vpn_schedule_vpn_connections_update (nm_data);
nm_dbus_update_wireless_scan_method (nm_data->dbus_connection, nm_data);
}
/* Right before we init hal, we have to make sure our mainloop
......
......@@ -36,6 +36,7 @@
#include "NetworkManagerAP.h"
#include "NetworkManagerAPList.h"
#include "NetworkManagerPolicy.h"
#include "NetworkManagerWireless.h"
#include "nm-dbus-nm.h"
#include "nm-dbus-device.h"
#include "nm-dbus-net.h"
......@@ -598,74 +599,6 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection, NMActR
}
/*
* nm_dbus_update_wireless_scan_method_cb
*
* Callback from nm_dbus_update_wireless_scan_method
*
*/
static void nm_dbus_update_wireless_scan_method_cb (DBusPendingCall *pcall, NMData *data)
{
DBusMessage * reply;
NMWirelessScanMethod method = NM_SCAN_METHOD_UNKNOWN;
g_return_if_fail (pcall != NULL);
g_return_if_fail (data != NULL);
if (!dbus_pending_call_get_completed (pcall))
goto out;
if (!(reply = dbus_pending_call_steal_reply (pcall)))
goto out;
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
{
dbus_message_unref (reply);
goto out;
}
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &method, DBUS_TYPE_INVALID))
{
if ((method == NM_SCAN_METHOD_ALWAYS) || (method == NM_SCAN_METHOD_NEVER)
|| (method == NM_SCAN_METHOD_WHEN_UNASSOCIATED))
data->scanning_method = method;
}
dbus_message_unref (reply);
out:
dbus_pending_call_unref (pcall);
}
/*
* nm_dbus_update_wireless_scan_method
*
* Get the wireless scan method from NetworkManagerInfo
*
*/
void nm_dbus_update_wireless_scan_method (DBusConnection *connection, NMData *data)
{
DBusMessage * message = NULL;
DBusPendingCall * pcall = NULL;
g_return_if_fail (connection != NULL);
g_return_if_fail (data != NULL);
if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getWirelessScanMethod")))
{
nm_warning ("nm_dbus_update_wireless_scan_method(): Couldn't allocate the dbus message");
return;
}
if (dbus_connection_send_with_reply (connection, message, &pcall, INT_MAX) && pcall)
dbus_pending_call_set_notify (pcall, (DBusPendingCallNotifyFunction) nm_dbus_update_wireless_scan_method_cb, data, NULL);
else
nm_warning ("nm_dbus_update_wireless_scan_method(): could not send dbus message");
dbus_message_unref (message);
}
/*
* nm_dbus_update_network_info
*
......@@ -1097,8 +1030,11 @@ static DBusHandlerResult nm_dbus_signal_filter (DBusConnection *connection, DBus
handled = TRUE;
}
}
else if (dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "WirelessScanMethodUpdate"))
nm_dbus_update_wireless_scan_method (data->dbus_connection, data);
else if (dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "UserInterfaceActivated"))
{
nm_wireless_set_scan_interval (data, NULL, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
handled = TRUE;
}
}
else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "Disconnected"))
{
......@@ -1126,7 +1062,6 @@ static DBusHandlerResult nm_dbus_signal_filter (DBusConnection *connection, DBus
dbus_bus_add_match (connection, match, NULL);
nm_policy_schedule_allowed_ap_list_update (data);
nm_dbus_vpn_schedule_vpn_connections_update (data);
nm_dbus_update_wireless_scan_method (data->dbus_connection, data);
g_free (match);
handled = TRUE;
}
......
......@@ -71,8 +71,6 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActReque
void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection, NMActRequest *req);
void nm_dbus_update_wireless_scan_method (DBusConnection *connection, NMData *data);
NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetworkType type, const char *network);
gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkType type, const char *network, struct ether_addr *addr);
......
......@@ -325,7 +325,7 @@ NMDevice *nm_device_new (const char *iface, const char *udi, gboolean test_dev,
nm_device_set_mode (dev, NETWORK_MODE_INFRA);
opts->scan_interval = 20;
nm_wireless_set_scan_interval (dev->app_data, dev, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
opts->scan_mutex = g_mutex_new ();
opts->ap_list = nm_ap_list_new (NETWORK_TYPE_DEVICE);
......@@ -3221,7 +3221,7 @@ gboolean nm_device_deactivate (NMDevice *dev)
nm_device_set_essid (dev, "");
nm_device_set_enc_key (dev, NULL, NM_DEVICE_AUTH_METHOD_NONE);
nm_device_set_mode (dev, NETWORK_MODE_INFRA);
dev->options.wireless.scan_interval = 20;
nm_wireless_set_scan_interval (dev->app_data, dev, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
}
return TRUE;
......@@ -3870,12 +3870,6 @@ static gboolean nm_device_wireless_process_scan_results (gpointer user_data)
g_slist_free (outdated_list);
}
/* If the list changed or we are unassociated, decrease our wireless scanning interval */
if (list_changed || !nm_device_is_activated (dev))
dev->options.wireless.scan_interval = 20;
else
dev->options.wireless.scan_interval = MIN (60, dev->options.wireless.scan_interval + 10);
nm_policy_schedule_device_change_check (dev->app_data);
return FALSE;
......@@ -3953,18 +3947,6 @@ static gboolean nm_device_wireless_scan (gpointer user_data)
return FALSE;
}
/* Reschedule if scanning is off, or if scanning is AUTO and we are
* associated to an access point.
*/
if ( ((dev->app_data->scanning_method == NM_SCAN_METHOD_NEVER)
|| ( (dev->app_data->scanning_method == NM_SCAN_METHOD_WHEN_UNASSOCIATED)
&& nm_device_is_activated (dev)))
&& !scan_cb->force)
{
dev->options.wireless.scan_interval = 10;
goto reschedule;
}
/* Reschedule ourselves if all wireless is disabled, we're asleep,
* or we are currently activating.
*/
......@@ -3972,7 +3954,18 @@ static gboolean nm_device_wireless_scan (gpointer user_data)
|| (dev->app_data->asleep == TRUE)
|| (nm_device_is_activating (dev) == TRUE))
{
dev->options.wireless.scan_interval = 10;
nm_wireless_set_scan_interval (dev->app_data, dev, NM_WIRELESS_SCAN_INTERVAL_INIT);
goto reschedule;
}
/*
* A/B/G cards should only scan if they are disconnected. Set the timeout to active
* for the case we lose this connection shortly, it will reach this point and then
* nm_device_is_activated will return FALSE, letting the scan proceed.
*/
if (dev->options.wireless.num_freqs > 14 && nm_device_is_activated (dev) == TRUE)
{
nm_wireless_set_scan_interval (dev->app_data, dev, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
goto reschedule;
}
......@@ -3980,7 +3973,7 @@ static gboolean nm_device_wireless_scan (gpointer user_data)
if (dev->test_device)
{
nm_device_fake_ap_list (dev);
dev->options.wireless.scan_interval = 20;
nm_wireless_set_scan_interval (dev->app_data, dev, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
goto reschedule;
}
......@@ -4118,6 +4111,31 @@ void nm_device_set_ip4_config (NMDevice *dev, NMIP4Config *config)
nm_ip4_config_unref (old_config);
}
void nm_device_set_wireless_scan_interval (NMDevice *dev, NMWirelessScanInterval interval)
{
guint seconds;
g_return_if_fail (dev != NULL);
switch (interval)
{
case NM_WIRELESS_SCAN_INTERVAL_INIT:
seconds = 10;
break;
case NM_WIRELESS_SCAN_INTERVAL_INACTIVE: