[Patch] Don't activate networking on wake if it was disabled

2006-10-04 Thread Tambet Ingo
Hey,

Here's a hack^W patch to keep the enabled/disabled state after waking up
from sleep. Currently, sleep is used for both sleep and disabling
networking so disable networking - suspend - resume results in enabled
networking. As Robert pointed out, it's especially bad when resuming on
an airplane since resume always enables networking.

To work around this problem without changing the public dbus api, I
added an optional boolean argument to sleep and wake methods to make
distinction between the two. For 0.7 branch we should probably do
something cleaner.

Tambet
Index: gnome/applet/applet-dbus-devices.c
===
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-devices.c,v
retrieving revision 1.51.2.4
diff -u -r1.51.2.4 applet-dbus-devices.c
--- gnome/applet/applet-dbus-devices.c	17 May 2006 20:03:56 -	1.51.2.4
+++ gnome/applet/applet-dbus-devices.c	4 Oct 2006 12:21:39 -
@@ -1373,6 +1373,9 @@
 
 	if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, method)))
 	{
+		gboolean true = TRUE; /* Eek... */
+
+		dbus_message_append_args (message, DBUS_TYPE_BOOLEAN, true, DBUS_TYPE_INVALID);
 		dbus_connection_send (applet-connection, message, NULL);
 		dbus_message_unref (message);
 	}
Index: src/NetworkManagerMain.h
===
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerMain.h,v
retrieving revision 1.25.2.1
diff -u -r1.25.2.1 NetworkManagerMain.h
--- src/NetworkManagerMain.h	6 Apr 2006 14:12:23 -	1.25.2.1
+++ src/NetworkManagerMain.h	4 Oct 2006 12:21:39 -
@@ -85,6 +85,7 @@
 	gbooleanwireless_enabled;
 	gbooleanmodem_active;
 	gbooleanasleep;
+	gbooleandisconnected;
 
 	GSList *dialup_list;
 	GMutex *dialup_list_mutex;
Index: src/nm-dbus-nm.c
===
RCS file: /cvs/gnome/NetworkManager/src/nm-dbus-nm.c,v
retrieving revision 1.39.2.2
diff -u -r1.39.2.2 nm-dbus-nm.c
--- src/nm-dbus-nm.c	21 May 2006 17:28:02 -	1.39.2.2
+++ src/nm-dbus-nm.c	4 Oct 2006 12:21:39 -
@@ -532,8 +532,28 @@
 	if (app_data-asleep == FALSE)
 	{
 		GSList *elt;
+		DBusMessageIter iter;
 
-		nm_info (Going to sleep.);
+		dbus_message_iter_init (message, iter);
+
+		switch (dbus_message_iter_get_arg_type (iter)) {
+		case DBUS_TYPE_INVALID:
+			/* The boolean argument to differentiate between sleep and disabling networking
+			   is optional and defaults to sleep */
+			app_data-disconnected = FALSE;
+			break;
+		case DBUS_TYPE_BOOLEAN:
+			dbus_message_iter_get_basic (iter, app_data-disconnected);
+			break;
+		default:
+			//bitch();	
+			break;
+		}
+
+		if (app_data-disconnected)
+			nm_info (Disconnected.);
+		else
+			nm_info (Going to sleep.);
 
 		app_data-asleep = TRUE;
 		/* Not using nm_schedule_state_change_signal_broadcast() here
@@ -564,14 +584,36 @@
 static DBusMessage *nm_dbus_nm_wake (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
 {
 	NMData	*app_data;
+	DBusMessageIter iter;
+	gboolean enable_networking = FALSE;
 
 	g_return_val_if_fail (data  data-data  connection  message, NULL);
 
+	dbus_message_iter_init (message, iter);
+
+	switch (dbus_message_iter_get_arg_type (iter)) {
+	case DBUS_TYPE_INVALID:
+		/* The boolean argument to differentiate between wake up from sleep and
+		   enabling networking is optional and defaults to wake up. */
+		break;
+	case DBUS_TYPE_BOOLEAN:
+		dbus_message_iter_get_basic (iter, enable_networking);
+		break;
+	default:
+		//bitch();
+		break;
+	}
+
 	app_data = data-data;
-	if (app_data-asleep == TRUE)
-	{
-		nm_info  (Waking up from sleep.);
-		app_data-asleep = FALSE;
+	/* Restore networking only if we're not disconnected or
+	   enable_networking argument is passed. */
+	if (app_data-asleep  (!app_data-disconnected || enable_networking)) {
+		if (enable_networking)
+			nm_info (Enabling networking.);
+		else
+			nm_info (Waking up from sleep.);
+
+		app_data-asleep = app_data-disconnected = FALSE;
 
 		/* Remove all devices from the device list */
 		nm_lock_mutex (app_data-dev_list_mutex, __FUNCTION__);
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: NM doesn't recognize my connection!

2006-10-04 Thread Jeff Schallenberg
OK, I can edit the /etc/network/interfaces file.It now contains only the lines:auto loiface lo inet loopbackBut this results in wlan0 and eth0 not being configured in Network Settings. So I can't connect to anything, either wired (eth0) or wireless (wlan0).
And the NM icon still proclaims (rightly) No Network Connection and displays the little red exclamation point.(If I enable the interfaces in Network Settings, that creates new entries in the /etc/network/interfaces file for eth0 and wlan0).
Please help me get Network Manager working with my D-Link DWL-650+ and Ubuntu 6.06!- JeffOn 10/2/06, Dan Williams 
[EMAIL PROTECTED] wrote:On Sun, 2006-10-01 at 23:06 -0400, Jeff Schallenberg wrote:
 Network Manager doesn't recognize my wireless connections. I am using a D-Link DWL-650+ (Texas Instruments ACX-100).What version of this driver, where did you get it from, and does itactually work with Wireless Extensions?Is it the old acx driver or the
new softmac acx driver?Is it from John Linville's wireless-2.6 gittree?Just to warn you that out-of-kernel drivers are usually dicey, and theydon't usually support Linux Wireless Extensions correctly.But if the
device  driver work with wpa_supplicant, they should work withNetworkManager.But first, lets see the answer to Darren's question.Dan There is an icon, OK, but it thinks I have no connection (little red
 exclamation point). Clicking on it does nothing. Double-clicking on it does nothing. Right-clicking on it offers to disable networking or to remove it from the panel. How do I get Network Manager to recognize my wireless connections? Is
 there a config file to edit, or something? -- - Jeff ___ NetworkManager-list mailing list 
NetworkManager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
-- - Jeff
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list