Thu Aug 26 2004 Dan Williams <dcbw@redhat.com>

* panel-applet/NMWirelessApplet.c
		- Remove debugging code
		- Enable device switching from menus

	* panel-applet/NMWirelessAppletDbus.[ch]
		- Method for asking NM to switch devices

	* src/NetworkManagerDevice.c
		- Set dev->activating earlier, avoids race between
			the dbus signal of "DeviceActivating" and setting
			dev->activating (which is what NM's "status" method call
			looks at)


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@83 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2004-08-26 21:11:27 +00:00
parent 97e86a1857
commit d52e623fde
5 changed files with 50 additions and 14 deletions

View file

@ -1,3 +1,18 @@
Thu Aug 26 2004 Dan Williams <dcbw@redhat.com>
* panel-applet/NMWirelessApplet.c
- Remove debugging code
- Enable device switching from menus
* panel-applet/NMWirelessAppletDbus.[ch]
- Method for asking NM to switch devices
* src/NetworkManagerDevice.c
- Set dev->activating earlier, avoids race between
the dbus signal of "DeviceActivating" and setting
dev->activating (which is what NM's "status" method call
looks at)
Thu Aug 26 2004 Dan Williams <dcbw@redhat.com>
* panel-applet/NMWirelessApplet.[ch]

View file

@ -126,7 +126,6 @@ static void nmwa_redraw (NMWirelessApplet *applet)
*/
static void nmwa_update_state (NMWirelessApplet *applet)
{
fprintf( stderr, "state (%d)\n", applet->applet_state);
switch (applet->applet_state)
{
case (APPLET_STATE_NO_NM):
@ -430,13 +429,15 @@ void nmwa_handle_network_choice (NMWirelessApplet *applet, char *network)
void nmwa_menu_item_activate (GtkMenuItem *item, gpointer user_data)
{
NMWirelessApplet *applet = (NMWirelessApplet *)user_data;
char *network;
char *tag;
g_return_if_fail (item != NULL);
g_return_if_fail (applet != NULL);
if ((network = g_object_get_data (G_OBJECT (item), "network")))
nmwa_handle_network_choice (applet, network);
if ((tag = g_object_get_data (G_OBJECT (item), "network")))
nmwa_handle_network_choice (applet, tag);
else if ((tag = g_object_get_data (G_OBJECT (item), "device")))
nmwa_dbus_set_device (applet->connection, tag);
}
@ -452,9 +453,7 @@ static void nmwa_toplevel_menu_activate (GtkWidget *menu, NMWirelessApplet *appl
GtkWidget *menu_item;
nmwa_dispose_menu_items (applet);
nmwa_populate_menu (applet);
gtk_widget_show (applet->menu);
}
@ -716,7 +715,6 @@ GtkWidget * nmwa_populate_menu (NMWirelessApplet *applet)
g_return_if_fail (applet != NULL);
fprintf( stderr, "populate_menu() state (%d)\n", applet->applet_state);
if (applet->applet_state == APPLET_STATE_NO_NM)
{
nmwa_menu_add_text_item (menu, _("NetworkManager is not running..."));

View file

@ -631,6 +631,30 @@ void nmwa_dbus_set_network (DBusConnection *connection, char *network)
}
/*
* nmwa_dbus_set_device
*
* Tell NetworkManager to use a specific network device that the user picked.
*
*/
void nmwa_dbus_set_device (DBusConnection *connection, char *device)
{
DBusMessage *message;
g_return_if_fail (connection != NULL);
g_return_if_fail (device != NULL);
message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setActiveDevice");
if (message)
{
dbus_message_append_args (message, DBUS_TYPE_STRING, device, DBUS_TYPE_INVALID);
dbus_connection_send (connection, message, NULL);
}
else
fprintf (stderr, "nm_dbus_set_device(): Couldn't allocate the dbus message\n");
}
/*
* wireless_network_free
*
@ -906,10 +930,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
dbus_error_init (&error);
if ( dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID)
&& (strcmp (service, NM_DBUS_SERVICE) == 0) && (applet->applet_state == APPLET_STATE_NO_NM))
{
applet->applet_state = APPLET_STATE_NO_CONNECTION;
fprintf( stderr, "ServiceCreate state = (%d)\n", applet->applet_state);
}
}
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceDeleted"))
{

View file

@ -42,8 +42,10 @@ enum
DEVICE_TYPE_WIRELESS_ETHERNET
};
gpointer nmwa_dbus_worker (gpointer user_data);
gpointer nmwa_dbus_worker (gpointer user_data);
void nmwa_dbus_set_network (DBusConnection *connection, char *network);
void nmwa_dbus_set_network (DBusConnection *connection, char *network);
void nmwa_dbus_set_device (DBusConnection *connection, char *device);
#endif

View file

@ -839,7 +839,7 @@ gboolean nm_device_activation_begin (NMDevice *dev)
nm_device_ref (dev);
/* Reset communication flags between worker and main thread */
dev->activating = FALSE;
dev->activating = TRUE;
dev->just_activated = FALSE;
dev->quit_activation = FALSE;
if (nm_device_is_wireless (dev))
@ -848,6 +848,7 @@ gboolean nm_device_activation_begin (NMDevice *dev)
if (!g_thread_create (nm_device_activation_worker, dev, FALSE, &error))
{
syslog (LOG_CRIT, "nm_device_activation_begin(): could not create activation worker thread.");
dev->activating = FALSE;
return (FALSE);
}
@ -930,7 +931,6 @@ static gpointer nm_device_activation_worker (gpointer user_data)
g_return_val_if_fail (dev->app_data != NULL, NULL);
syslog (LOG_DEBUG, "nm_device_activation_worker (%s) started...", nm_device_get_iface (dev));
dev->activating = TRUE;
/* If its a wireless device, set the ESSID and WEP key */
if (nm_device_is_wireless (dev))