fallback functionality with persistence.
- From: Robert Love <rml novell com>
- To: networkmanager-list gnome org
- Subject: fallback functionality with persistence.
- Date: Wed, 07 Jun 2006 16:00:09 -0400
So I am redoing the patches for CVS. We are ditching the trusted
network stuff -- we have no good use for it -- and renaming it to
fallback.
We will add the fallback behavior to CVS, but not the
persistence-in-the-scan-list.
The attached patch does all of this, and is ready to commit, except it
still does the persistence thing.
This is because it is EASIER to do the persistence than not (everything
is sort-of free if we just fake a scan result).
So I need to come up with an elegant way to ditch the persistence but
keep the fallback behavior.
For now, here is a reworked single patch of the previous three.
Robert Love
Index: gnome/applet/applet-dbus-devices.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-devices.c,v
retrieving revision 1.51.2.4
diff -u -r1.51.2.4 applet-dbus-devices.c
--- gnome/applet/applet-dbus-devices.c 17 May 2006 20:03:56 -0000 1.51.2.4
+++ gnome/applet/applet-dbus-devices.c 7 Jun 2006 19:53:49 -0000
@@ -1253,7 +1253,7 @@
*
*/
void nma_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid,
- WirelessSecurityOption * opt)
+ gboolean fallback, WirelessSecurityOption * opt)
{
DBusMessage * message;
gboolean success = TRUE;
@@ -1272,6 +1272,7 @@
/* Build up the required args */
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path,
DBUS_TYPE_STRING, &essid,
+ DBUS_TYPE_BOOLEAN, &fallback,
DBUS_TYPE_INVALID);
/* If we have specific wireless security options, add them */
Index: gnome/applet/applet-dbus-devices.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-devices.h,v
retrieving revision 1.11
diff -u -r1.11 applet-dbus-devices.h
--- gnome/applet/applet-dbus-devices.h 27 Feb 2006 06:26:31 -0000 1.11
+++ gnome/applet/applet-dbus-devices.h 7 Jun 2006 19:53:49 -0000
@@ -49,7 +49,7 @@
void nma_dbus_device_update_one_network (NMApplet *applet, const char *dev_path, const char *net_path, const char *active_net_path);
void nma_dbus_device_remove_one_network (NMApplet *applet, const char *dev_path, const char *net_path);
void nma_dbus_update_strength (NMApplet *applet, const char *dev_path, const char *net_path, int strength);
-void nma_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, WirelessSecurityOption *opt);
+void nma_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid, gboolean fallback, WirelessSecurityOption *opt);
void nma_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, WirelessSecurityOption *opt);
void nma_free_data_model (NMApplet *applet);
Index: gnome/applet/applet-dbus-info.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-info.c,v
retrieving revision 1.45.2.4
diff -u -r1.45.2.4 applet-dbus-info.c
--- gnome/applet/applet-dbus-info.c 7 Jun 2006 17:34:20 -0000 1.45.2.4
+++ gnome/applet/applet-dbus-info.c 7 Jun 2006 19:53:49 -0000
@@ -395,7 +395,7 @@
char * escaped_network = NULL;
char * essid = NULL;
gint timestamp = -1;
- gboolean trusted = FALSE;
+ gboolean fallback = FALSE;
DBusMessageIter iter, array_iter;
GConfClient * client;
NMGConfWSO * gconf_wso;
@@ -435,9 +435,9 @@
if (!nm_gconf_get_int_helper (client, GCONF_PATH_WIRELESS_NETWORKS, "timestamp", escaped_network, ×tamp) || (timestamp < 0))
timestamp = 0;
- /* Trusted status */
- if (!nm_gconf_get_bool_helper (client, GCONF_PATH_WIRELESS_NETWORKS, "trusted", escaped_network, &trusted))
- trusted = FALSE;
+ /* Fallback status */
+ if (!nm_gconf_get_bool_helper (client, GCONF_PATH_WIRELESS_NETWORKS, "fallback", escaped_network, &fallback))
+ fallback = FALSE;
/* Grab the list of stored access point BSSIDs */
gconf_key = g_strdup_printf ("%s/%s/bssids", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
@@ -468,8 +468,8 @@
/* Second arg: Timestamp (INT32) */
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, ×tamp);
- /* Third arg: Trusted (BOOLEAN) */
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &trusted);
+ /* Third arg: Fallback? (BOOLEAN) */
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &fallback);
/* Fourth arg: List of AP BSSIDs (ARRAY, STRING) */
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array_iter);
@@ -818,6 +818,7 @@
nmi_save_network_info (NMApplet *applet,
const char *essid,
gboolean automatic,
+ gboolean fallback,
const char *bssid,
NMGConfWSO * gconf_wso)
{
@@ -856,6 +857,10 @@
g_free (key);
}
+ key = g_strdup_printf ("%s/%s/fallback", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
+ gconf_client_set_bool (applet->gconf_client, key, fallback, NULL);
+ g_free (key);
+
if (bssid && (strlen (bssid) >= 11))
{
GConfValue * value;
@@ -954,6 +959,7 @@
NMApplet * applet = (NMApplet *) user_data;
char * essid = NULL;
gboolean automatic;
+ gboolean fallback;
NMGConfWSO * gconf_wso = NULL;
DBusMessageIter iter;
char * bssid;
@@ -984,7 +990,15 @@
}
dbus_message_iter_get_basic (&iter, &automatic);
- /* Third argument: Access point's BSSID */
+ /* Third argument: Fallback? (BOOLEAN) */
+ if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN))
+ {
+ nm_warning ("%s:%d - message argument 'fallback' was invalid.", __FILE__, __LINE__);
+ goto out;
+ }
+ dbus_message_iter_get_basic (&iter, &fallback);
+
+ /* Fourth argument: Access point's BSSID */
if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING))
{
nm_warning ("%s:%d - message argument 'bssid' was invalid.", __FILE__, __LINE__);
@@ -1002,7 +1016,7 @@
goto out;
}
- nmi_save_network_info (applet, essid, automatic, bssid, gconf_wso);
+ nmi_save_network_info (applet, essid, automatic, fallback, bssid, gconf_wso);
g_object_unref (G_OBJECT (gconf_wso));
out:
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.112.2.8
diff -u -r1.112.2.8 applet.c
--- gnome/applet/applet.c 2 Jun 2006 14:11:09 -0000 1.112.2.8
+++ gnome/applet/applet.c 7 Jun 2006 19:53:49 -0000
@@ -1287,7 +1287,7 @@
if ((tag = g_object_get_data (G_OBJECT (item), "network")))
net = network_device_get_wireless_network_by_essid (dev, tag);
- nma_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, NULL);
+ nma_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, FALSE, NULL);
network_device_unref (dev);
nmi_dbus_signal_user_interface_activated (applet->connection);
Index: gnome/applet/applet.glade
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.glade,v
retrieving revision 1.4.2.8
diff -u -r1.4.2.8 applet.glade
--- gnome/applet/applet.glade 29 May 2006 03:35:15 -0000 1.4.2.8
+++ gnome/applet/applet.glade 7 Jun 2006 19:53:49 -0000
@@ -426,7 +426,7 @@
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
@@ -548,8 +548,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -569,8 +569,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
@@ -589,9 +589,31 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="fallback_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Fallback on this Network</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="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">fill</property>
+ <property name="y_options"></property>
</packing>
</child>
</widget>
Index: gnome/applet/other-network-dialog.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/other-network-dialog.c,v
retrieving revision 1.29.2.2
diff -u -r1.29.2.2 other-network-dialog.c
--- gnome/applet/other-network-dialog.c 7 Jun 2006 17:34:20 -0000 1.29.2.2
+++ gnome/applet/other-network-dialog.c 7 Jun 2006 19:53:49 -0000
@@ -410,19 +410,24 @@
WirelessSecurityOption * opt;
GtkComboBox * security_combo;
GtkTreeIter iter;
+ GtkWidget * fallback_button;
char * str;
NetworkDevice * dev;
+ gboolean fallback;
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
gtk_tree_model_get (model, &iter, NAME_COLUMN, &str, DEV_COLUMN, &dev, -1);
+ fallback_button = glade_xml_get_widget (xml, "fallback_button");
+ fallback = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fallback_button));
+
security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo"));
opt = wsm_get_option_for_active (wsm, security_combo);
if (create_network)
nma_dbus_create_network (applet->connection, dev, essid, opt);
else
- nma_dbus_set_device (applet->connection, dev, essid, opt);
+ nma_dbus_set_device (applet->connection, dev, essid, fallback, opt);
}
}
Index: src/NetworkManagerAP.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAP.c,v
retrieving revision 1.53.2.1
diff -u -r1.53.2.1 NetworkManagerAP.c
--- src/NetworkManagerAP.c 9 Mar 2006 20:55:46 -0000 1.53.2.1
+++ src/NetworkManagerAP.c 7 Jun 2006 19:53:54 -0000
@@ -51,7 +51,7 @@
GTimeVal last_seen; /* Last time the AP was seen in a scan */
/* Things from user prefs/NetworkManagerInfo */
- gboolean trusted;
+ gboolean fallback;
NMAPSecurity * security;
GTimeVal timestamp;
GSList * user_addresses;
@@ -398,21 +398,21 @@
/*
* Get/Set functions to indicate that an access point is
- * 'trusted'
+ * 'fallback'
*
*/
-gboolean nm_ap_get_trusted (const NMAccessPoint *ap)
+gboolean nm_ap_get_fallback (const NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, FALSE);
- return (ap->trusted);
+ return (ap->fallback);
}
-void nm_ap_set_trusted (NMAccessPoint *ap, gboolean trusted)
+void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback)
{
g_return_if_fail (ap != NULL);
- ap->trusted = trusted;
+ ap->fallback = fallback;
}
Index: src/NetworkManagerAP.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAP.h,v
retrieving revision 1.37.2.1
diff -u -r1.37.2.1 NetworkManagerAP.h
--- src/NetworkManagerAP.h 9 Mar 2006 20:55:46 -0000 1.37.2.1
+++ src/NetworkManagerAP.h 7 Jun 2006 19:53:54 -0000
@@ -72,8 +72,8 @@
gboolean nm_ap_get_invalid (const NMAccessPoint *ap);
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid);
-gboolean nm_ap_get_trusted (const NMAccessPoint *ap);
-void nm_ap_set_trusted (NMAccessPoint *ap, gboolean trusted);
+gboolean nm_ap_get_fallback (const NMAccessPoint *ap);
+void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback);
gboolean nm_ap_get_artificial (const NMAccessPoint *ap);
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial);
Index: src/NetworkManagerAPList.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAPList.c,v
retrieving revision 1.51.2.3
diff -u -r1.51.2.3 NetworkManagerAPList.c
--- src/NetworkManagerAPList.c 7 Jun 2006 17:34:21 -0000 1.51.2.3
+++ src/NetworkManagerAPList.c 7 Jun 2006 19:53:54 -0000
@@ -422,6 +422,56 @@
return (found_ap);
}
+/*
+ * nm_ap_list_merge_fallback
+ *
+ * Merges the user's fallback networks, if any, into the scan list. We "fall back"
+ * on these networks and attempt a brute-force connection, given no better options.
+ */
+void nm_ap_list_merge_fallback (NMDevice80211Wireless *dev)
+{
+ NMAccessPointList * allowed_list;
+ NMAccessPointList * scan_list;
+ NMAPListIter * iter;
+ NMData * app_data;
+
+ app_data = nm_device_get_app_data (NM_DEVICE (dev));
+ allowed_list = app_data->allowed_ap_list;
+ scan_list = nm_device_802_11_wireless_ap_list_get (dev);
+
+ iter = nm_ap_list_iter_new (allowed_list);
+ if (iter)
+ {
+ NMAccessPoint * allowed_ap;
+
+ while ((allowed_ap = nm_ap_list_iter_next (iter)))
+ {
+ if (nm_ap_get_fallback (allowed_ap))
+ {
+ NMAccessPoint * ap;
+ GTimeVal cur_time;
+
+ ap = nm_ap_new ();
+ nm_ap_set_essid (ap, nm_ap_get_essid (allowed_ap));
+ nm_ap_set_timestamp_via_timestamp (ap, nm_ap_get_timestamp (allowed_ap));
+ nm_ap_set_fallback (ap, TRUE);
+ nm_ap_set_security (ap, nm_ap_get_security (allowed_ap));
+
+ /*
+ * Fake it as if we see the AP right now. We process the scan results _after_ this, thus
+ * if the AP is seen in a scan we will favor that AP when we merge.
+ */
+ g_get_current_time (&cur_time);
+ nm_ap_set_last_seen (ap, &cur_time);
+ nm_ap_set_artificial (ap, TRUE);
+
+ nm_ap_list_merge_scanned_ap (dev, scan_list, ap);
+ nm_ap_unref (ap);
+ }
+ }
+ nm_ap_list_iter_free (iter);
+ }
+}
/*
* nm_ap_list_merge_scanned_ap
Index: src/NetworkManagerAPList.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAPList.h,v
retrieving revision 1.15.2.1
diff -u -r1.15.2.1 NetworkManagerAPList.h
--- src/NetworkManagerAPList.h 20 Apr 2006 20:39:52 -0000 1.15.2.1
+++ src/NetworkManagerAPList.h 7 Jun 2006 19:53:54 -0000
@@ -51,6 +51,8 @@
void nm_ap_list_copy_essids_by_address (NMData *app_data, NMDevice80211Wireless *dev, NMAccessPointList *dest, NMAccessPointList *source);
void nm_ap_list_copy_one_essid_by_address (NMData *app_data, NMDevice80211Wireless *dev, NMAccessPoint *ap, NMAccessPointList *search_list);
+void nm_ap_list_merge_fallback (NMDevice80211Wireless *dev);
+
gboolean nm_ap_list_merge_scanned_ap (NMDevice80211Wireless *dev, NMAccessPointList *list, NMAccessPoint *merge_ap);
NMNetworkType nm_ap_list_get_type (NMAccessPointList *list);
Index: src/nm-dbus-nm.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-dbus-nm.c,v
retrieving revision 1.39.2.2
diff -u -r1.39.2.2 nm-dbus-nm.c
--- src/nm-dbus-nm.c 21 May 2006 17:28:02 -0000 1.39.2.2
+++ src/nm-dbus-nm.c 7 Jun 2006 19:53:54 -0000
@@ -261,6 +261,7 @@
{
NMAPSecurity * security = NULL;
char * essid = NULL;
+ gboolean fallback = FALSE;
if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING))
{
@@ -276,6 +277,15 @@
goto out;
}
+ if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN))
+ {
+ nm_warning ("Invalid argument type (fallback");
+ goto out;
+ }
+
+ /* grab the fallback bit */
+ dbus_message_iter_get_basic (&iter, &fallback);
+
/* If there's security information, we use that. If not, we
* make some up from the scan list.
*/
@@ -292,6 +302,7 @@
/* Set up the wireless-specific activation request properties */
ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (dev), essid, security);
+ nm_ap_set_fallback (ap, fallback);
if (security)
g_object_unref (G_OBJECT (security));
Index: src/nm-dbus-nmi.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-dbus-nmi.c,v
retrieving revision 1.12.2.3
diff -u -r1.12.2.3 nm-dbus-nmi.c
--- src/nm-dbus-nmi.c 7 Jun 2006 17:34:21 -0000 1.12.2.3
+++ src/nm-dbus-nmi.c 7 Jun 2006 19:53:54 -0000
@@ -224,6 +224,7 @@
{
DBusMessage * message;
gboolean success = FALSE;
+ gboolean fallback;
const char * essid;
gchar * char_bssid;
NMAPSecurity * security;
@@ -246,10 +247,14 @@
/* First argument: ESSID (STRING) */
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &essid);
- /* Second argument: Automatic (BOOLEAN) */
+ /* Second argument: Automatic or user-driven connection? (BOOLEAN) */
dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &automatic);
- /* Third argument: Access point's BSSID */
+ /* Third argument: Fallback? (BOOLEAN) */
+ fallback = nm_ap_get_fallback (ap);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &fallback);
+
+ /* Fourth argument: Access point's BSSID */
addr = nm_ap_get_address (ap);
if ((nm_ap_get_mode (ap) == IW_MODE_INFRA) && nm_ethernet_address_is_valid (addr))
{
@@ -340,7 +345,7 @@
DBusMessageIter subiter;
const char * essid = NULL;
gint timestamp_secs = -1;
- gboolean trusted = FALSE;
+ gboolean fallback = FALSE;
GSList * addr_list = NULL;
NMAPSecurity * security;
NMAccessPoint * ap;
@@ -393,14 +398,14 @@
}
dbus_message_iter_get_basic (&iter, ×tamp_secs);
- /* Third arg: Trusted (BOOLEAN) */
+ /* Third arg: Fallback? (BOOLEAN) */
if (!dbus_message_iter_next (&iter)
|| (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN))
{
- nm_warning ("a message argument (trusted) was invalid.");
+ nm_warning ("a message argument (fallback) was invalid.");
goto out;
}
- dbus_message_iter_get_basic (&iter, &trusted);
+ dbus_message_iter_get_basic (&iter, &fallback);
/* Fourth arg: BSSID addresses (ARRAY, STRING) */
if (!dbus_message_iter_next (&iter)
@@ -443,14 +448,14 @@
nm_ap_set_timestamp (ap, timestamp_secs, 0);
- nm_ap_set_trusted (ap, trusted);
+ nm_ap_set_fallback (ap, fallback);
nm_ap_set_user_addresses (ap, addr_list);
if ((list_ap = nm_ap_list_get_ap_by_essid (cb_data->list, essid)))
{
nm_ap_set_essid (list_ap, nm_ap_get_essid (ap));
nm_ap_set_timestamp_via_timestamp (list_ap, nm_ap_get_timestamp (ap));
- nm_ap_set_trusted (list_ap, nm_ap_get_trusted (ap));
+ nm_ap_set_fallback (list_ap, nm_ap_get_fallback (ap));
nm_ap_set_security (list_ap, nm_ap_get_security (ap));
nm_ap_set_user_addresses (list_ap, nm_ap_get_user_addresses (ap));
}
Index: src/nm-device-802-11-wireless.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-device-802-11-wireless.c,v
retrieving revision 1.60.2.12
diff -u -r1.60.2.12 nm-device-802-11-wireless.c
--- src/nm-device-802-11-wireless.c 7 Jun 2006 17:34:21 -0000 1.60.2.12
+++ src/nm-device-802-11-wireless.c 7 Jun 2006 19:53:55 -0000
@@ -671,12 +671,11 @@
NMAPListIter * iter;
NMAccessPoint * scan_ap = NULL;
NMAccessPoint * best_ap = NULL;
+ NMAccessPoint * fallback_ap = NULL;
NMAccessPoint * cur_ap = NULL;
NMActRequest * req = NULL;
- NMAccessPoint * trusted_best_ap = NULL;
- NMAccessPoint * untrusted_best_ap = NULL;
- GTimeVal trusted_latest_timestamp = {0, 0};
- GTimeVal untrusted_latest_timestamp = {0, 0};
+ GTimeVal best_timestamp = {0, 0};
+ GTimeVal fallback_timestamp = {0, 0};
NMData * app_data;
g_return_val_if_fail (self != NULL, NULL);
@@ -762,27 +761,46 @@
}
}
- g_slist_foreach (user_addrs, (GFunc)g_free, NULL);
+ g_slist_foreach (user_addrs, (GFunc) g_free, NULL);
g_slist_free (user_addrs);
}
- if (!blacklisted && nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > trusted_latest_timestamp.tv_sec))
+ if (!blacklisted)
{
- trusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap);
- trusted_best_ap = scan_ap;
- nm_ap_set_security (trusted_best_ap, nm_ap_get_security (tmp_ap));
- }
- else if (!blacklisted && !nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > untrusted_latest_timestamp.tv_sec))
- {
- untrusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap);
- untrusted_best_ap = scan_ap;
- nm_ap_set_security (untrusted_best_ap, nm_ap_get_security (tmp_ap));
+ if (!nm_ap_get_artificial (tmp_ap))
+ {
+ /*
+ * Allowed, non-blacklist, non-invalid, really-seen-in-scan network. We
+ * prefer these, and we will return the most-recently-used.
+ */
+ if (curtime->tv_sec > best_timestamp.tv_sec)
+ {
+ best_timestamp = *nm_ap_get_timestamp (tmp_ap);
+ best_ap = scan_ap;
+ nm_ap_set_security (best_ap, nm_ap_get_security (tmp_ap));
+ }
+ }
+ else
+ {
+ /*
+ * Allowed, non-blacklist, non-invalid, fallback, but not-seen-in-scan network.
+ * If we don't find any of the above networks, we will brute-force one of these
+ */
+ if (nm_ap_get_fallback (tmp_ap) && (curtime->tv_sec > fallback_timestamp.tv_sec))
+ {
+ fallback_timestamp = *nm_ap_get_timestamp (tmp_ap);
+ fallback_ap = scan_ap;
+ nm_ap_set_security (fallback_ap, nm_ap_get_security (tmp_ap));
+ }
+ }
}
}
}
- best_ap = trusted_best_ap ? trusted_best_ap : untrusted_best_ap;
nm_ap_list_iter_free (iter);
+ if (!best_ap)
+ best_ap = fallback_ap;
+
if (best_ap)
nm_ap_ref (best_ap);
@@ -1733,7 +1751,6 @@
NMDevice80211Wireless * self;
GTimeVal cur_time;
NMAPListIter * iter = NULL;
- const char * iface;
NMData * app_data;
NMAccessPointList * ap_list;
@@ -1746,12 +1763,17 @@
return FALSE;
}
- iface = nm_device_get_iface (NM_DEVICE (self));
+ nm_ap_list_merge_fallback (self);
+
app_data = nm_device_get_app_data (NM_DEVICE (self));
if (cb_data->results_len > 0)
{
if (!process_scan_results (self, cb_data->results, cb_data->results_len))
+ {
+ const char * iface;
+ iface = nm_device_get_iface (NM_DEVICE (self));
nm_warning ("process_scan_results() on device %s returned an error.", iface);
+ }
/* Once we have the list, copy in any relevant information from our Allowed list. */
nm_ap_list_copy_properties (nm_device_802_11_wireless_ap_list_get (self), app_data->allowed_ap_list);
@@ -2883,10 +2905,10 @@
if ((ap = nm_act_request_get_ap (req)))
{
- if (nm_ap_get_artificial (ap))
+ if (nm_ap_get_artificial (ap) && !nm_ap_get_fallback (ap))
{
NMAccessPointList * dev_list;
-
+
/* Artificial APs are ones that don't show up in scans,
* but which the user explicitly attempted to connect to.
* However, if we fail on one of these, remove it from the
Index: src/backends/NetworkManagerSuSE.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/backends/NetworkManagerSuSE.c,v
retrieving revision 1.32.2.17
diff -u -r1.32.2.17 NetworkManagerSuSE.c
--- src/backends/NetworkManagerSuSE.c 22 May 2006 15:23:42 -0000 1.32.2.17
+++ src/backends/NetworkManagerSuSE.c 7 Jun 2006 19:53:55 -0000
@@ -543,7 +543,7 @@
ap = nm_ap_new ();
nm_ap_set_essid (ap, buf);
nm_ap_set_timestamp (ap, time (NULL), 0);
- nm_ap_set_trusted (ap, TRUE);
+ nm_ap_set_fallback (ap, TRUE);
if ((mode = svGetValue (file, "WIRELESS_AUTH_MODE")) && !strcmp (mode, "psk"))
{
@@ -644,7 +644,7 @@
{
nm_ap_set_essid (list_ap, nm_ap_get_essid (ap));
nm_ap_set_timestamp_via_timestamp (list_ap, nm_ap_get_timestamp (ap));
- nm_ap_set_trusted (list_ap, nm_ap_get_trusted (ap));
+ nm_ap_set_fallback (list_ap, TRUE);
nm_ap_set_security (list_ap, nm_ap_get_security (ap));
}
else
Index: test/nm-set-fallback
===================================================================
RCS file: test/nm-set-fallback
diff -N test/nm-set-fallback
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/nm-set-fallback 7 Jun 2006 19:53:56 -0000
@@ -0,0 +1,27 @@
+#! /bin/sh
+#
+# nm-set-fallback - mark a network as fallback
+#
+# Robert Love
+
+BIN=`which gconftool-2`
+
+if [ "x$1" == "x" ]; then
+ echo "usage: $0 <network> <true|false>"
+ exit 1
+fi
+
+if [ "x$2" != "xtrue" -a "x$2" != "xfalse" ]; then
+ echo "usage: $0 <network> <true|false>"
+ exit 2
+fi
+
+KEY="/system/networking/wireless/networks/${1}/fallback"
+CURRENT=`$BIN --get $KEY 2>/dev/null`
+
+if [ "x$CURRENT" != "xtrue" -a "x$CURRENT" != "xfalse" ]; then
+ echo "Network '$1' is not valid"
+ exit 3
+fi
+
+$BIN --set --type=bool $KEY ${2}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]