From 5cac86fdd2cbe6839aeba9b31bdc5d1e95d3ad14 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 9 Jan 2006 05:11:29 +0000 Subject: [PATCH] 2006-01-09 Dan Williams * src/NetworkManagerPolicy.c - (nm_policy_device_change_check): don't autoswitch away from Ad-Hoc networks, since there's really no concept of "link" * src/nm-dbus-nm.c - (nm_dbus_nm_create_wireless_network): mark created networks as Ad-Hoc networks * src/nm-device-802-11-wireless.c - (real_activation_success_handler): add user-created Ad-Hoc networks to the device's scan list git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1300 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 14 ++++++++++++++ src/NetworkManagerPolicy.c | 17 +++++++++++------ src/nm-dbus-nm.c | 1 + src/nm-device-802-11-wireless.c | 8 ++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b82ac3c91a..8087f4e092 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-01-09 Dan Williams + + * src/NetworkManagerPolicy.c + - (nm_policy_device_change_check): don't autoswitch away from + Ad-Hoc networks, since there's really no concept of "link" + + * src/nm-dbus-nm.c + - (nm_dbus_nm_create_wireless_network): mark created networks + as Ad-Hoc networks + + * src/nm-device-802-11-wireless.c + - (real_activation_success_handler): add user-created Ad-Hoc + networks to the device's scan list + 2006-01-08 Dan Williams We now require a patch for wpa_supplicant to support Ad-Hoc diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index 75834f1850..66ea45c40c 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -371,19 +371,24 @@ static gboolean nm_policy_device_change_check (NMData *data) { NMAccessPoint *old_ap = nm_act_request_get_ap (old_act_req); const char * old_essid = nm_ap_get_essid (old_ap); + int old_mode = nm_ap_get_mode (old_ap); const char * new_essid = nm_ap_get_essid (ap); - /* Schedule new activation if the currently associated access point is not the "best" one - * or we've lost the link to the old access point. + /* Schedule new activation if the currently associated + * access point is not the "best" one or we've lost the + * link to the old access point. We don't switch away + * from Ad-Hoc APs either. */ - gboolean es = (strcmp (old_essid, new_essid) != 0); + gboolean same_essid = (strcmp (old_essid, new_essid) == 0); gboolean link = nm_device_has_active_link (old_dev); - if (es || !link) + if ((!same_essid || !link) && (old_mode != IW_MODE_ADHOC)) { - nm_info ("SWITCH: found better connection '%s/%s' than current connection '%s/%s'. different_ssids=%d, have_link=%d", + nm_info ("SWITCH: found better connection '%s/%s'" + " than current connection '%s/%s'. " + "same_ssid=%d, have_link=%d", nm_device_get_iface (new_dev), new_essid, nm_device_get_iface (old_dev), old_essid, - es, link); + same_essid, link); do_switch = TRUE; } } /* Always prefer Ethernet over wireless, unless the user explicitly switched away. */ diff --git a/src/nm-dbus-nm.c b/src/nm-dbus-nm.c index 0355a6c8ea..e6e79a7de3 100644 --- a/src/nm-dbus-nm.c +++ b/src/nm-dbus-nm.c @@ -386,6 +386,7 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti new_ap = nm_ap_new (); nm_ap_set_essid (new_ap, essid); + nm_ap_set_mode (new_ap, IW_MODE_ADHOC); nm_ap_set_security (new_ap, security); g_object_unref (G_OBJECT (security)); nm_ap_set_user_created (new_ap, TRUE); diff --git a/src/nm-device-802-11-wireless.c b/src/nm-device-802-11-wireless.c index 409aba0a2d..ce0a60365b 100644 --- a/src/nm-device-802-11-wireless.c +++ b/src/nm-device-802-11-wireless.c @@ -2712,6 +2712,14 @@ real_activation_success_handler (NMDevice *dev, /* Cache details in the info-daemon since the connect was successful */ automatic = !nm_act_request_get_user_requested (req); + /* If it's a user-created ad-hoc network, add it to the device's scan list */ + if (!automatic && (nm_ap_get_mode (ap) == IW_MODE_ADHOC) && nm_ap_get_user_created (ap)) + { + NMAccessPointList *ap_list = nm_device_802_11_wireless_ap_list_get (self); + if (!nm_ap_list_get_ap_by_essid (ap_list, nm_ap_get_essid (ap))) + nm_ap_list_append_ap (ap_list, ap); + } + nm_device_802_11_wireless_get_bssid (self, &addr); if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap))) nm_ap_set_address (ap, &addr);