Commit 976302b3 authored by Dan Williams's avatar Dan Williams
Browse files

2005-09-01 Dan Williams <dcbw@redhat.com>

	* src/NetworkManager.c
		- (nm_remove_device_from_list): rename to nm_remove_device
		- (nm_hal_device_removed): call nm_remove_device()

	* src/NetworkManagerDevice.c
		- Change the NMWirelessScanCB member 'reschedule' which
			wasn't used to 'force' to indicate that we need to
			force a scan when adding a device

	* src/nm-dbus-nm.c
		- (nm_dbus_nm_sleep): Deactivate all devices and remove them
			from the device list
		- (nm_dbus_nm_wake): Re-add all devices to the device list


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@926 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 714254d7
2005-09-01 Dan Williams <dcbw@redhat.com>
* src/NetworkManager.c
- (nm_remove_device_from_list): rename to nm_remove_device
- (nm_hal_device_removed): call nm_remove_device()
* src/NetworkManagerDevice.c
- Change the NMWirelessScanCB member 'reschedule' which
wasn't used to 'force' to indicate that we need to
force a scan when adding a device
* src/nm-dbus-nm.c
- (nm_dbus_nm_sleep): Deactivate all devices and remove them
from the device list
- (nm_dbus_nm_wake): Re-add all devices to the device list
2005-09-01 Robert Love <rml@novell.com>
* gnome/applet/applet.c: nmwa_update_info: iface is used uninitialized
......
......@@ -152,45 +152,25 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
/*
* nm_remove_device_from_list
* nm_remove_device
*
* Searches for a device entry in the NLM device list by udi,
* and if found, removes that element from the list and frees
* its data.
* Removes a particular device from the device list. Requires that
* the device list is locked, if needed.
*/
void nm_remove_device_from_list (NMData *data, const char *udi)
void nm_remove_device (NMData *data, NMDevice *dev)
{
g_return_if_fail (data != NULL);
g_return_if_fail (udi != NULL);
/* Attempt to acquire mutex for device list deletion. If acquire fails,
* just ignore the device deletion entirely.
*/
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
{
GSList *elt;
for (elt = data->dev_list; elt; elt = g_slist_next (elt))
{
NMDevice *dev = (NMDevice *)(elt->data);
g_return_if_fail (dev != NULL);
if (dev && (nm_null_safe_strcmp (nm_device_get_udi (dev), udi) == 0))
{
nm_device_set_removed (dev, TRUE);
nm_device_deactivate (dev);
nm_device_worker_thread_stop (dev);
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_REMOVED);
nm_device_set_removed (dev, TRUE);
nm_device_deactivate (dev);
nm_device_worker_thread_stop (dev);
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_REMOVED);
nm_device_unref (dev);
nm_device_unref (dev);
/* Remove the device entry from the device list and free its data */
data->dev_list = g_slist_remove_link (data->dev_list, elt);
g_slist_free (elt);
nm_policy_schedule_device_change_check (data);
break;
}
}
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
} else nm_warning ("could not acquire device list mutex." );
/* Remove the device entry from the device list and free its data */
data->dev_list = g_slist_remove (data->dev_list, dev);
}
......@@ -267,12 +247,22 @@ static void nm_hal_device_added (LibHalContext *ctx, const char *udi)
static void nm_hal_device_removed (LibHalContext *ctx, const char *udi)
{
NMData *data = (NMData *)libhal_ctx_get_user_data (ctx);
NMDevice *dev;
g_return_if_fail (data != NULL);
nm_debug ("Device removed (hal udi is '%s').", udi );
nm_remove_device_from_list (data, udi);
if (!nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
return;
if ((dev = nm_get_device_by_udi (data, udi)))
{
nm_remove_device (data, dev);
nm_policy_schedule_device_change_check (data);
}
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
}
......@@ -307,7 +297,7 @@ static void nm_hal_device_new_capability (LibHalContext *ctx, const char *udi, c
* Add all devices that hal knows about right now (ie not hotplug devices)
*
*/
static void nm_add_initial_devices (NMData *data)
void nm_add_initial_devices (NMData *data)
{
char ** net_devices;
int num_net_devices;
......
......@@ -65,8 +65,8 @@ typedef struct
typedef struct
{
NMDevice *dev;
gboolean reschedule;
NMDevice * dev;
gboolean force;
} NMWirelessScanCB;
/******************************************************/
......@@ -498,7 +498,7 @@ static gpointer nm_device_worker (gpointer user_data)
scan_cb = g_malloc0 (sizeof (NMWirelessScanCB));
scan_cb->dev = dev;
scan_cb->reschedule = TRUE;
scan_cb->force = TRUE;
g_source_set_callback (source, nm_device_wireless_scan, scan_cb, NULL);
source_id = g_source_attach (source, dev->context);
......@@ -3688,7 +3688,7 @@ static void nm_device_wireless_schedule_scan (NMDevice *dev)
scan_cb = g_malloc0 (sizeof (NMWirelessScanCB));
scan_cb->dev = dev;
scan_cb->reschedule = TRUE;
scan_cb->force = FALSE;
wscan_source = g_timeout_source_new (dev->options.wireless.scan_interval * 1000);
g_source_set_callback (wscan_source, nm_device_wireless_scan, scan_cb, NULL);
......@@ -3952,9 +3952,10 @@ static gboolean nm_device_wireless_scan (gpointer user_data)
/* 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)
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;
......@@ -4067,8 +4068,7 @@ static gboolean nm_device_wireless_scan (gpointer user_data)
reschedule:
/* Make sure we reschedule ourselves so we keep scanning */
if (scan_cb->reschedule)
nm_device_wireless_schedule_scan (dev);
nm_device_wireless_schedule_scan (dev);
g_free (scan_cb);
return FALSE;
......
......@@ -97,7 +97,9 @@ struct NMDevice * nm_get_active_device (NMData *data);
struct NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, const char *iface,
gboolean test_device, NMDeviceType test_device_type);
void nm_remove_device_from_list (NMData *data, const char *udi);
void nm_add_initial_devices (NMData *data);
void nm_remove_device (NMData *data, struct NMDevice *dev);
void nm_schedule_state_change_signal_broadcast (NMData *data);
......
......@@ -386,7 +386,7 @@ static DBusMessage *nm_dbus_nm_remove_test_device (DBusConnection *connection, D
if ((dev = nm_dbus_get_device_from_object_path (data->data, dev_path)))
{
if (nm_device_is_test_device (dev))
nm_remove_device_from_list (data->data, nm_device_get_udi (dev));
nm_remove_device (data->data, dev);
else
reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "NotTestDevice",
"Only test devices can be removed via dbus calls.");
......@@ -488,14 +488,14 @@ static DBusMessage *nm_dbus_nm_sleep (DBusConnection *connection, DBusMessage *m
app_data->asleep = TRUE;
/* Physically down all devices */
/* Remove all devices from the device list */
nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
for (elt = app_data->dev_list; elt; elt = g_slist_next (elt))
while (g_slist_length (app_data->dev_list))
{
NMDevice *dev = (NMDevice *)(elt->data);
NMDevice *dev = (NMDevice *)(app_data->dev_list->data);
nm_device_deactivate (dev);
nm_device_bring_down (dev);
fprintf (stderr, "dev %p\n", dev);
nm_remove_device (app_data, dev);
}
nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
......@@ -523,15 +523,7 @@ static DBusMessage *nm_dbus_nm_wake (DBusConnection *connection, DBusMessage *me
nm_info ("Waking up from sleep.");
app_data->asleep = FALSE;
/* Physically up all devices */
nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
for (elt = app_data->dev_list; elt; elt = g_slist_next (elt))
{
NMDevice *dev = (NMDevice *)(elt->data);
nm_device_bring_up (dev);
}
nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
nm_add_initial_devices (app_data);
nm_schedule_state_change_signal_broadcast (app_data);
nm_policy_schedule_device_change_check (data->data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment