2004-08-11 Dan Williams <dcbw@redhat.com>

* info-daemon/NetworkManagerInfo.c:
		- (main): clean up Seth's code style

	* info-daemon/NetworkManagerInfoDbus.c:
		- Use the more aptly-named path/service/interface constants from NetworkManager
		- Don't return empty strings ("") as object paths ever, instead return errors

	* panel-applet/NMWirelessApplet.c:
		- Clean up Seth's code style

	* src/NetworkManager.[ch]
		- (nm_remove_device_from_list): remove anything having to do with pending_device
		- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon

	* src/NetworkManagerAPList.[ch]
		- Move Iter struct right above the iter functions to preserve opacity
		- (nm_ap_list_remove_ap): implement
		- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
			remove AP if NetworkManagerInfo doesn't know anything about it
		- (nm_ap_list_diff): user NMAPList iterators
		- (nm_ap_list_print_members): implement debugging function

	* src/NetworkManagerDbus.[ch]
		- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
		- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
			and move the actual key setting stuff into NetworkManagerDevice.c
		- (nm_dbus_get_network_priority): return -1 now on errors
		- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
			get lost, and force the active device to update its "best" ap when AP lists change
		- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
			method call due to pending_device member removal

	* src/NetworkManagerDevice.[ch]
		- Move NMDevice structure to the top
		- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
		- Remove Pending Action stuff from everywhere
		- (nm_device_activation_*): We now "begin" activation and start a thread to do the
			activation for us.  This thread blocks until all conditions for activation have
			been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
			then setup up the interface and runs dhclient.  We have to do this because there
			is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
			run our main loop and respond to dbus method calls or HAL device removals/inserts
		- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
			can tell nm_device_activation_worker() that we've got a key
		- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
		- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
			diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
		- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here

	* src/NetworkManagerPolicy.c
		- Remove anything to do with pending_device
		- Adjust device activation to deal with activation-in-worker-thread

	* src/NetworkManagerUtils.c
		- Clean up locking debugging a bit

	* src/NetworkManagerWireless.[ch]
		- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap().  This function
			was badly named and is better as a device function

	* panel-applet/.cvsignore: add


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2004-08-11 18:14:02 +00:00
parent 8e04fc11ff
commit d06aa3e6ff
18 changed files with 726 additions and 472 deletions

View File

@@ -163,7 +163,6 @@ gboolean nm_state_modification_monitor (gpointer user_data)
/* If the info daemon is now running, get our trusted/preferred ap lists from it */
if (data->info_daemon_avail && data->update_ap_lists)
{
fprintf( stderr, "getting lists from NetworkManagerInfo\n");
/* Query info daemon for network lists if its now running */
if (data->trusted_ap_list)
nm_ap_list_unref (data->trusted_ap_list);
@@ -198,7 +197,7 @@ fprintf( stderr, "getting lists from NetworkManagerInfo\n");
{
NMDevice *best_dev = NULL;
if ((best_dev = nm_policy_get_best_device (data)) != NULL)
if ((best_dev = nm_policy_get_best_device (data)))
nm_device_ref (best_dev);
/* Only do a switch when:
@@ -207,22 +206,10 @@ fprintf( stderr, "getting lists from NetworkManagerInfo\n");
* 3) best_dev is wireless and its access point is the best, but it doesn't have an IP address
*/
if ( best_dev != data->active_device
|| ( best_dev && nm_device_is_wireless (best_dev)
|| ( best_dev && nm_device_is_wireless (best_dev) && !nm_device_activating (best_dev)
&& (nm_device_need_ap_switch (best_dev) || (nm_device_get_ip4_address (best_dev) == 0))))
{
/* Cancel pending device actions on an existing pending device */
if (data->pending_device && (best_dev != data->pending_device))
{
nm_device_pending_action_cancel (data->pending_device);
nm_device_unref (data->pending_device);
data->pending_device = NULL;
}
NM_DEBUG_PRINT_1 ("nm_state_modification_monitor() set pending_device = %s\n", best_dev ? nm_device_get_iface (best_dev) : "(null)");
data->pending_device = best_dev;
if (data->pending_device && !nm_device_is_up (data->pending_device))
nm_device_bring_up (data->pending_device);
NM_DEBUG_PRINT_1 ("nm_state_modification_monitor(): beginning activation for device '%s'\n", best_dev ? nm_device_get_iface (best_dev) : "(null)");
/* Deactivate the old device */
if (data->active_device)
@@ -231,6 +218,11 @@ fprintf( stderr, "getting lists from NetworkManagerInfo\n");
nm_device_unref (data->active_device);
data->active_device = NULL;
}
/* Begin activation on the new device */
nm_device_ref (best_dev);
data->active_device = best_dev;
nm_device_activation_begin (data->active_device);
}
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
@@ -238,24 +230,10 @@ fprintf( stderr, "getting lists from NetworkManagerInfo\n");
else
NM_DEBUG_PRINT("nm_state_modification_monitor() could not get device list mutex\n");
}
else if (data->pending_device)
else if (data->active_device && nm_device_just_activated (data->active_device))
{
/* If there are pending device actions, don't switch to the device, but
* wait for the actions to complete.
*/
if (!nm_device_pending_action (data->pending_device))
{
/* Only move it from pending -> active if the activation was successfull,
* otherwise keep trying to activate it successfully.
*/
if (nm_device_activate (data->pending_device))
{
NM_DEBUG_PRINT_1 ("nm_state_modification_monitor() activated device %s\n", nm_device_get_iface (data->pending_device));
data->active_device = data->pending_device;
data->pending_device = NULL;
}
}
nm_dbus_signal_device_now_active (data->dbus_connection, data->active_device);
NM_DEBUG_PRINT_1 ("nm_state_modification_monitor() activated device %s\n", nm_device_get_iface (data->active_device));
}
return (TRUE);