mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-24 20:50:43 +02:00
2006-01-22 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerAP.[ch] - (nm_ap_get_matched, nm_ap_set_matched): remove * src/NetworkManagerAPList.[ch] - (nm_ap_list_diff): removed - (nm_ap_list_merge_scanned_ap): move AP dbus signal logic here, deal with access points changing essids on us * src/nm-device-802-11-wireless.c - (add_new_ap_to_device_list): move AP dbus signal logic to src/NetworkManagerAPList.c - (real_can_interrupt_activation): new function; allow interruption of device activation if we are waiting for a network key * src/NetworkManagerPolicy.c - (nm_policy_device_change_check): allow interruption of currently activating devices if the device allows it. Previous behavior would refuse to activate a just-plugged wired device if a wireless device was waiting for a key. * src/nm-device.[ch] - (nm_device_can_interrupt_activation): new function; ask devices whether their activation can be interrupted git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1375 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
d2c3bd2701
commit
2864ede525
9 changed files with 122 additions and 127 deletions
26
ChangeLog
26
ChangeLog
|
|
@ -1,3 +1,29 @@
|
|||
2006-01-22 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/NetworkManagerAP.[ch]
|
||||
- (nm_ap_get_matched, nm_ap_set_matched): remove
|
||||
|
||||
* src/NetworkManagerAPList.[ch]
|
||||
- (nm_ap_list_diff): removed
|
||||
- (nm_ap_list_merge_scanned_ap): move AP dbus signal logic here,
|
||||
deal with access points changing essids on us
|
||||
|
||||
* src/nm-device-802-11-wireless.c
|
||||
- (add_new_ap_to_device_list): move AP dbus signal logic to
|
||||
src/NetworkManagerAPList.c
|
||||
- (real_can_interrupt_activation): new function; allow interruption
|
||||
of device activation if we are waiting for a network key
|
||||
|
||||
* src/NetworkManagerPolicy.c
|
||||
- (nm_policy_device_change_check): allow interruption of currently
|
||||
activating devices if the device allows it. Previous behavior
|
||||
would refuse to activate a just-plugged wired device if a
|
||||
wireless device was waiting for a key.
|
||||
|
||||
* src/nm-device.[ch]
|
||||
- (nm_device_can_interrupt_activation): new function; ask devices
|
||||
whether their activation can be interrupted
|
||||
|
||||
2006-01-20 Robert Love <rml@novell.com>
|
||||
|
||||
* Makefile.am, configure.in: Add new man subdirectory.
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ struct NMAccessPoint
|
|||
|
||||
/* Non-scanned attributes */
|
||||
gboolean invalid;
|
||||
gboolean matched; /* used in ap list diffing */
|
||||
gboolean artificial; /* Whether or not the AP is from a scan */
|
||||
gboolean user_created; /* Whether or not the AP was created by the user with "Create network..." */
|
||||
GTimeVal last_seen; /* Last time the AP was seen in a scan */
|
||||
|
|
@ -375,26 +374,6 @@ void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get/set functions for "matched", which is used by
|
||||
* the ap list diffing functions to speed up the diff
|
||||
*
|
||||
*/
|
||||
gboolean nm_ap_get_matched (const NMAccessPoint *ap)
|
||||
{
|
||||
g_return_val_if_fail (ap != NULL, TRUE);
|
||||
|
||||
return (ap->matched);
|
||||
}
|
||||
|
||||
void nm_ap_set_matched (NMAccessPoint *ap, gboolean matched)
|
||||
{
|
||||
g_return_if_fail (ap != NULL);
|
||||
|
||||
ap->matched = matched;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get/Set functions to indicate that an access point is
|
||||
* 'trusted'
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@ void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate);
|
|||
gboolean nm_ap_get_invalid (const NMAccessPoint *ap);
|
||||
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid);
|
||||
|
||||
gboolean nm_ap_get_matched (const NMAccessPoint *ap);
|
||||
void nm_ap_set_matched (NMAccessPoint *ap, gboolean matched);
|
||||
|
||||
gboolean nm_ap_get_trusted (const NMAccessPoint *ap);
|
||||
void nm_ap_set_trusted (NMAccessPoint *ap, gboolean trusted);
|
||||
|
||||
|
|
|
|||
|
|
@ -435,18 +435,24 @@ NMAccessPoint *nm_ap_list_get_ap_by_address (NMAccessPointList *list, const stru
|
|||
* TRUE if the ap was completely new
|
||||
*
|
||||
*/
|
||||
gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *merge_ap,
|
||||
gboolean *new, gboolean *strength_changed)
|
||||
gboolean nm_ap_list_merge_scanned_ap (NMDevice80211Wireless *dev, NMAccessPointList *list, NMAccessPoint *merge_ap)
|
||||
{
|
||||
NMAccessPoint *list_ap_addr, *list_ap_essid;
|
||||
NMAccessPoint * list_ap = NULL;
|
||||
gboolean strength_changed = FALSE;
|
||||
gboolean new = FALSE;
|
||||
NMData * app_data;
|
||||
|
||||
g_return_val_if_fail (dev != NULL, FALSE);
|
||||
g_return_val_if_fail (list != NULL, FALSE);
|
||||
g_return_val_if_fail (merge_ap != NULL, FALSE);
|
||||
g_return_val_if_fail (new != NULL, FALSE);
|
||||
g_return_val_if_fail (strength_changed != NULL, FALSE);
|
||||
|
||||
if ((list_ap_addr = nm_ap_list_get_ap_by_address (list, nm_ap_get_address (merge_ap))))
|
||||
app_data = nm_device_get_app_data (NM_DEVICE (dev));
|
||||
g_return_val_if_fail (app_data != NULL, FALSE);
|
||||
|
||||
if ((list_ap = nm_ap_list_get_ap_by_address (list, nm_ap_get_address (merge_ap))))
|
||||
{
|
||||
const char * devlist_essid = nm_ap_get_essid (list_ap);
|
||||
const char * merge_essid = nm_ap_get_essid (merge_ap);
|
||||
|
||||
/* First, we check for an address match. If the merge AP has the
|
||||
* same address as a list AP, the merge AP and the list AP
|
||||
|
|
@ -457,15 +463,28 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
|
|||
|
||||
const GTimeVal *merge_ap_seen = nm_ap_get_last_seen (merge_ap);
|
||||
|
||||
nm_ap_set_capabilities (list_ap_addr, nm_ap_get_capabilities (merge_ap));
|
||||
if (nm_ap_get_strength (merge_ap) != nm_ap_get_strength (list_ap_addr))
|
||||
/* Did the AP's name change? */
|
||||
if (!devlist_essid || !merge_essid || nm_null_safe_strcmp (devlist_essid, merge_essid))
|
||||
{
|
||||
nm_ap_set_strength (list_ap_addr, nm_ap_get_strength (merge_ap));
|
||||
*strength_changed = TRUE;
|
||||
nm_dbus_signal_wireless_network_change (app_data->dbus_connection,
|
||||
dev, list_ap, NETWORK_STATUS_DISAPPEARED, -1);
|
||||
new = TRUE;
|
||||
}
|
||||
nm_ap_set_last_seen (list_ap_addr, merge_ap_seen);
|
||||
|
||||
nm_ap_set_capabilities (list_ap, nm_ap_get_capabilities (merge_ap));
|
||||
if (nm_ap_get_strength (merge_ap) != nm_ap_get_strength (list_ap))
|
||||
{
|
||||
nm_ap_set_strength (list_ap, nm_ap_get_strength (merge_ap));
|
||||
strength_changed = TRUE;
|
||||
}
|
||||
nm_ap_set_last_seen (list_ap, merge_ap_seen);
|
||||
|
||||
/* Have to change AP's name _after_ dbus signal for old network name
|
||||
* has gone out.
|
||||
*/
|
||||
nm_ap_set_essid (list_ap, merge_essid);
|
||||
}
|
||||
else if ((list_ap_essid = nm_ap_list_get_ap_by_essid (list, nm_ap_get_essid (merge_ap))))
|
||||
else if ((list_ap = nm_ap_list_get_ap_by_essid (list, nm_ap_get_essid (merge_ap))))
|
||||
{
|
||||
|
||||
/* Second, we check for an ESSID match. In this case,
|
||||
|
|
@ -477,26 +496,41 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
|
|||
* equal, the merge AP and the list AP come from the same scan.
|
||||
* Update the time_last_seen. */
|
||||
|
||||
const GTimeVal *merge_ap_seen = nm_ap_get_last_seen (merge_ap);
|
||||
const GTimeVal *list_ap_essid_seen = nm_ap_get_last_seen (list_ap_essid);
|
||||
const GTimeVal * merge_ap_seen = nm_ap_get_last_seen (merge_ap);
|
||||
const GTimeVal * list_ap_seen = nm_ap_get_last_seen (list_ap);
|
||||
const int merge_ap_strength = nm_ap_get_strength (merge_ap);
|
||||
|
||||
nm_ap_set_capabilities (list_ap_essid, nm_ap_get_capabilities (merge_ap));
|
||||
nm_ap_set_capabilities (list_ap, nm_ap_get_capabilities (merge_ap));
|
||||
|
||||
if (!((list_ap_essid_seen->tv_sec == merge_ap_seen->tv_sec)
|
||||
&& (nm_ap_get_strength (list_ap_essid) >= nm_ap_get_strength (merge_ap))))
|
||||
if (!((list_ap_seen->tv_sec == merge_ap_seen->tv_sec)
|
||||
&& (nm_ap_get_strength (list_ap) >= merge_ap_strength)))
|
||||
{
|
||||
nm_ap_set_strength (list_ap_essid, nm_ap_get_strength (merge_ap));
|
||||
nm_ap_set_address (list_ap_essid, nm_ap_get_address (merge_ap));
|
||||
*strength_changed = TRUE;
|
||||
nm_ap_set_strength (list_ap, merge_ap_strength);
|
||||
nm_ap_set_address (list_ap, nm_ap_get_address (merge_ap));
|
||||
}
|
||||
nm_ap_set_last_seen (list_ap_essid, merge_ap_seen);
|
||||
nm_ap_set_last_seen (list_ap, merge_ap_seen);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add the merge AP to the list. */
|
||||
nm_ap_list_append_ap (list, merge_ap);
|
||||
*new = TRUE;
|
||||
list_ap = merge_ap;
|
||||
new = TRUE;
|
||||
}
|
||||
|
||||
if (list_ap && strength_changed && !new)
|
||||
{
|
||||
const int new_strength = nm_ap_get_strength (list_ap);
|
||||
nm_dbus_signal_wireless_network_change (app_data->dbus_connection,
|
||||
dev, list_ap, NETWORK_STATUS_STRENGTH_CHANGED, new_strength);
|
||||
}
|
||||
|
||||
if (list_ap && new)
|
||||
{
|
||||
nm_dbus_signal_wireless_network_change (app_data->dbus_connection,
|
||||
dev, list_ap, NETWORK_STATUS_APPEARED, -1);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -584,68 +618,6 @@ void nm_ap_list_copy_essids_by_address (NMAccessPointList *dest, NMAccessPointLi
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_ap_list_diff
|
||||
*
|
||||
* Takes two ap lists and determines the differences. For each ap that is present
|
||||
* in the original list, but not in the new list, a WirelessNetworkDisappeared signal is emitted
|
||||
* over DBus. For each ap in the new list but not in the original, a WirelessNetworkAppeared
|
||||
* signal is emitted. For each ap that is the same between the lists, the "invalid" flag is copied
|
||||
* over from the old ap to the new ap to preserve "invalid" ap status (ie, user cancelled entering
|
||||
* a WEP key so we cannot connect to it anyway, so why try).
|
||||
*
|
||||
* NOTE: it is assumed that this function is called only ONCE for each list passed into it,
|
||||
* since the "matched" value on access points in the list are never cleared after the
|
||||
* ap is initially created. Therefore, calling this function twice for any given ap list
|
||||
* may result in undesired behavior.
|
||||
*
|
||||
*/
|
||||
void nm_ap_list_diff (NMData *data, NMDevice80211Wireless *dev, NMAccessPointList *old, NMAccessPointList *new)
|
||||
{
|
||||
NMAPListIter *iter;
|
||||
NMAccessPoint *old_ap;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
g_return_if_fail (dev != NULL);
|
||||
|
||||
/* Iterate over each item in the old list and find it in the new list */
|
||||
if (old && (iter = nm_ap_list_iter_new (old)))
|
||||
{
|
||||
while ((old_ap = nm_ap_list_iter_next (iter)))
|
||||
{
|
||||
NMAccessPoint *new_ap;
|
||||
|
||||
if (nm_ap_get_essid (old_ap))
|
||||
{
|
||||
if ((new_ap = nm_ap_list_get_ap_by_essid (new, nm_ap_get_essid (old_ap))))
|
||||
{
|
||||
nm_ap_set_matched (old_ap, TRUE);
|
||||
nm_ap_set_matched (new_ap, TRUE);
|
||||
}
|
||||
else
|
||||
nm_dbus_signal_wireless_network_change (data->dbus_connection, dev, old_ap, NETWORK_STATUS_DISAPPEARED, -1);
|
||||
}
|
||||
}
|
||||
nm_ap_list_iter_free (iter);
|
||||
}
|
||||
|
||||
/* Iterate over the new list and compare to the old list. Items that aren't already
|
||||
* matched are by definition new networks.
|
||||
*/
|
||||
if (new && (iter = nm_ap_list_iter_new (new)))
|
||||
{
|
||||
NMAccessPoint *new_ap;
|
||||
|
||||
while ((new_ap = nm_ap_list_iter_next (iter)))
|
||||
{
|
||||
if (!nm_ap_get_matched (new_ap) && nm_ap_get_essid (new_ap))
|
||||
nm_dbus_signal_wireless_network_change (data->dbus_connection, dev, new_ap, NETWORK_STATUS_APPEARED, -1);
|
||||
}
|
||||
nm_ap_list_iter_free (iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_ap_list_get_type
|
||||
*
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ void nm_ap_list_copy_properties (NMAccessPointList *dest, NMAccessPointList
|
|||
void nm_ap_list_copy_essids_by_address (NMAccessPointList *dest, NMAccessPointList *source);
|
||||
void nm_ap_list_copy_one_essid_by_address (NMAccessPoint *ap, NMAccessPointList *search_list);
|
||||
|
||||
void nm_ap_list_diff (NMData *data, NMDevice80211Wireless *dev, NMAccessPointList *old, NMAccessPointList *new);
|
||||
gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *merge_ap, gboolean *new, gboolean *strength_changed);
|
||||
gboolean nm_ap_list_merge_scanned_ap (NMDevice80211Wireless *dev, NMAccessPointList *list, NMAccessPoint *merge_ap);
|
||||
|
||||
NMNetworkType nm_ap_list_get_type (NMAccessPointList *list);
|
||||
|
||||
|
|
|
|||
|
|
@ -271,7 +271,8 @@ static NMDevice * nm_policy_auto_get_best_device (NMData *data, NMAccessPoint **
|
|||
* 3) wireless network topology changes
|
||||
*
|
||||
*/
|
||||
static gboolean nm_policy_device_change_check (NMData *data)
|
||||
static gboolean
|
||||
nm_policy_device_change_check (NMData *data)
|
||||
{
|
||||
NMAccessPoint * ap = NULL;
|
||||
NMDevice * new_dev = NULL;
|
||||
|
|
@ -292,7 +293,8 @@ static gboolean nm_policy_device_change_check (NMData *data)
|
|||
guint32 caps = nm_device_get_capabilities (old_dev);
|
||||
|
||||
/* Don't interrupt a currently activating device. */
|
||||
if (nm_device_is_activating (old_dev))
|
||||
if ( nm_device_is_activating (old_dev)
|
||||
&& !nm_device_can_interrupt_activation (old_dev))
|
||||
{
|
||||
nm_info ("Old device '%s' activating, won't change.", nm_device_get_iface (old_dev));
|
||||
goto out;
|
||||
|
|
@ -359,7 +361,7 @@ static gboolean nm_policy_device_change_check (NMData *data)
|
|||
* a new device. Note that new_dev will never be wireless since automatic device picking
|
||||
* above will prefer a wired device to a wireless device.
|
||||
*/
|
||||
if ((!old_user_requested || !old_has_link) && (new_dev != old_dev))
|
||||
if ((!old_user_requested || !old_has_link) && (new_dev != old_dev))
|
||||
{
|
||||
nm_info ("SWITCH: found better connection '%s' than current connection '%s'.", nm_device_get_iface (new_dev), nm_device_get_iface (old_dev));
|
||||
do_switch = TRUE;
|
||||
|
|
|
|||
|
|
@ -2814,6 +2814,21 @@ real_activation_failure_handler (NMDevice *dev,
|
|||
ap ? nm_ap_get_essid (ap) : "(none)");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_can_interrupt_activation (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMActRequest * req;
|
||||
gboolean interrupt = FALSE;
|
||||
|
||||
if ( (req = nm_device_get_act_request (dev))
|
||||
&& (nm_act_request_get_stage (req) == NM_ACT_STAGE_NEED_USER_KEY))
|
||||
{
|
||||
interrupt = TRUE;
|
||||
}
|
||||
return interrupt;
|
||||
}
|
||||
|
||||
|
||||
static guint32
|
||||
real_get_type_capabilities (NMDevice *dev)
|
||||
|
|
@ -2889,6 +2904,7 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
|||
parent_class->act_stage4_ip_config_timeout = real_act_stage4_ip_config_timeout;
|
||||
parent_class->deactivate = real_deactivate;
|
||||
parent_class->deactivate_quickly = real_deactivate_quickly;
|
||||
parent_class->can_interrupt_activation = real_can_interrupt_activation;
|
||||
|
||||
parent_class->activation_failure_handler = real_activation_failure_handler;
|
||||
parent_class->activation_success_handler = real_activation_success_handler;
|
||||
|
|
@ -3053,10 +3069,9 @@ static void
|
|||
add_new_ap_to_device_list (NMDevice80211Wireless *dev,
|
||||
NMAccessPoint *ap)
|
||||
{
|
||||
gboolean new = FALSE;
|
||||
gboolean strength_changed = FALSE;
|
||||
GTimeVal cur_time;
|
||||
NMData * app_data;
|
||||
NMAccessPointList * ap_list;
|
||||
|
||||
g_return_if_fail (dev != NULL);
|
||||
g_return_if_fail (ap != NULL);
|
||||
|
|
@ -3072,18 +3087,8 @@ add_new_ap_to_device_list (NMDevice80211Wireless *dev,
|
|||
nm_ap_list_copy_one_essid_by_address (ap, app_data->allowed_ap_list);
|
||||
|
||||
/* Add the AP to the device's AP list */
|
||||
if (nm_ap_list_merge_scanned_ap (nm_device_802_11_wireless_ap_list_get (dev), ap, &new, &strength_changed))
|
||||
{
|
||||
DBusConnection *con = app_data->dbus_connection;
|
||||
/* Handle dbus signals that we need to broadcast when the AP is added to the list or changes strength */
|
||||
if (new)
|
||||
nm_dbus_signal_wireless_network_change (con, dev, ap, NETWORK_STATUS_APPEARED, -1);
|
||||
else if (strength_changed)
|
||||
{
|
||||
nm_dbus_signal_wireless_network_change (con, dev, ap, NETWORK_STATUS_STRENGTH_CHANGED,
|
||||
nm_ap_get_strength (ap));
|
||||
}
|
||||
}
|
||||
ap_list = nm_device_802_11_wireless_ap_list_get (dev);
|
||||
nm_ap_list_merge_scanned_ap (dev, ap_list, ap);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -1616,6 +1616,17 @@ void nm_device_activation_success_handler (NMDevice *self,
|
|||
NM_DEVICE_GET_CLASS (self)->activation_success_handler (self, req);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_device_can_interrupt_activation (NMDevice *self)
|
||||
{
|
||||
gboolean interrupt = FALSE;
|
||||
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (self)->can_interrupt_activation)
|
||||
interrupt = NM_DEVICE_GET_CLASS (self)->can_interrupt_activation (self);
|
||||
return interrupt;
|
||||
}
|
||||
|
||||
/* IP Configuration stuff */
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ struct _NMDeviceClass
|
|||
struct NMActRequest *req);
|
||||
void (* activation_success_handler) (NMDevice *self,
|
||||
struct NMActRequest *req);
|
||||
|
||||
gboolean (* can_interrupt_activation) (NMDevice *self);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -189,6 +191,8 @@ void nm_device_activation_failure_handler (NMDevice *dev,
|
|||
void nm_device_activation_success_handler (NMDevice *dev,
|
||||
struct NMActRequest *req);
|
||||
|
||||
gboolean nm_device_can_interrupt_activation (NMDevice *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_DEVICE_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue