[1/3] Do something with trusted networks



Currently we have the concept of trusted versus preferred networks, but
we do not act on the trusted attribute.  We have some minimal support in
the daemon for marking a network as trusted, but we do nothing with that
information and the applet is totally trusted-unaware.  Also, most of
the DBUS API's are not trusted-aware.

The following three patches do the following three things:

	- This one, the first, starts using the trusted bit everywhere,
	  saving it in gconf, passing it around, adding it to the
	  missing DBUS APIs, and so on.  The net effect on behavior is
	  zero because still nothing sets it.  Since this is basically
	  a clean up to support an existing feature, with no behavioral
	  changes, we can commit this regardless of the direction we
	  go with the next two patches.

	- The second adds UI for setting networks trusted.

	- The third adds behavioral and policy changes for trusted
	  networks.  This is an open item of discussion.

So here is the first one.  This patch makes both the applet and daemon
respect and preserve the trusted attribute on networks.  Right now that
support is only half there.  Since nothing actually sets the trusted bit
true, this is merely a cleanup, the net effect is null.

All of these are against the STABLE 0.6 branch but also apply to HEAD.
You will want to `cvs up` as of now, because I just committed some bug
fixes.

	Robert Love

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 -0000	1.51.2.4
+++ gnome/applet/applet-dbus-devices.c	7 Jun 2006 17:08:53 -0000
@@ -1253,7 +1253,7 @@
  *
  */
 void nma_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const char *essid,
-						WirelessSecurityOption * opt)
+					 gboolean trusted, WirelessSecurityOption * opt)
 {
 	DBusMessage *	message;
 	gboolean		success = TRUE;
@@ -1272,6 +1272,7 @@
 			/* Build up the required args */
 			dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path,
 										DBUS_TYPE_STRING, &essid,
+										DBUS_TYPE_BOOLEAN, &trusted,
 										DBUS_TYPE_INVALID);
 
 			/* If we have specific wireless security options, add them */
Index: gnome/applet/applet-dbus-devices.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-devices.h,v
retrieving revision 1.11
diff -u -r1.11 applet-dbus-devices.h
--- gnome/applet/applet-dbus-devices.h	27 Feb 2006 06:26:31 -0000	1.11
+++ gnome/applet/applet-dbus-devices.h	7 Jun 2006 17:08:53 -0000
@@ -49,7 +49,7 @@
 void			nma_dbus_device_update_one_network		(NMApplet *applet, const char *dev_path, const char *net_path, const char *active_net_path);
 void			nma_dbus_device_remove_one_network		(NMApplet *applet, const char *dev_path, const char *net_path);
 void			nma_dbus_update_strength				(NMApplet *applet, const char *dev_path, const char *net_path, int strength);
-void			nma_dbus_set_device					(DBusConnection *connection, NetworkDevice *dev, const char *essid, WirelessSecurityOption *opt);
+void			nma_dbus_set_device					(DBusConnection *connection, NetworkDevice *dev, const char *essid, gboolean trusted, WirelessSecurityOption *opt);
 void			nma_dbus_create_network					(DBusConnection *connection, NetworkDevice *dev, const char *essid, WirelessSecurityOption *opt);
 
 void			nma_free_data_model					(NMApplet *applet);
Index: gnome/applet/applet-dbus-info.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-info.c,v
retrieving revision 1.45.2.3
diff -u -r1.45.2.3 applet-dbus-info.c
--- gnome/applet/applet-dbus-info.c	17 May 2006 14:57:04 -0000	1.45.2.3
+++ gnome/applet/applet-dbus-info.c	7 Jun 2006 17:08:54 -0000
@@ -822,6 +822,7 @@
 nmi_save_network_info (NMApplet *applet,
                        const char *essid,
                        gboolean automatic,
+                       gboolean trusted,
                        const char *bssid,
                        NMGConfWSO * gconf_wso)
 {
@@ -860,6 +861,10 @@
 		g_free (key);
 	}
 
+	key = g_strdup_printf ("%s/%s/trusted", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
+	gconf_client_set_bool (applet->gconf_client, key, trusted, NULL);
+	g_free (key);
+
 	if (bssid && (strlen (bssid) >= 11))
 	{
 		GConfValue *	value;
@@ -958,6 +963,7 @@
 	NMApplet *		applet = (NMApplet *) user_data;
 	char *			essid = NULL;
 	gboolean			automatic;
+	gboolean			trusted;
 	NMGConfWSO *		gconf_wso = NULL;
 	DBusMessageIter	iter;
 	char *			bssid;
@@ -988,7 +994,15 @@
 	}
 	dbus_message_iter_get_basic (&iter, &automatic);
 
-	/* Third argument: Access point's BSSID */
+	/* Third argument: Trusted (BOOLEAN) */
+	if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN))
+	{
+		nm_warning ("%s:%d - message argument 'trusted' was invalid.", __FILE__, __LINE__);
+		goto out;
+	}
+	dbus_message_iter_get_basic (&iter, &trusted);
+
+	/* Fourth argument: Access point's BSSID */
 	if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING))
 	{
 		nm_warning ("%s:%d - message argument 'bssid' was invalid.", __FILE__, __LINE__);
@@ -1006,7 +1020,7 @@
 		goto out;
 	}
 
-	nmi_save_network_info (applet, essid, automatic, bssid, gconf_wso);
+	nmi_save_network_info (applet, essid, automatic, trusted, bssid, gconf_wso);
 	g_object_unref (G_OBJECT (gconf_wso));
 
 out:
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.112.2.8
diff -u -r1.112.2.8 applet.c
--- gnome/applet/applet.c	2 Jun 2006 14:11:09 -0000	1.112.2.8
+++ gnome/applet/applet.c	7 Jun 2006 17:08:54 -0000
@@ -1287,7 +1287,7 @@
 	if ((tag = g_object_get_data (G_OBJECT (item), "network")))
 		net = network_device_get_wireless_network_by_essid (dev, tag);
 
-	nma_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, NULL);
+	nma_dbus_set_device (applet->connection, dev, net ? wireless_network_get_essid (net) : NULL, FALSE, NULL);
 	network_device_unref (dev);
 
 	nmi_dbus_signal_user_interface_activated (applet->connection);
Index: gnome/applet/other-network-dialog.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/other-network-dialog.c,v
retrieving revision 1.29.2.1
diff -u -r1.29.2.1 other-network-dialog.c
--- gnome/applet/other-network-dialog.c	27 Mar 2006 16:02:10 -0000	1.29.2.1
+++ gnome/applet/other-network-dialog.c	7 Jun 2006 17:08:55 -0000
@@ -422,7 +422,7 @@
 			if (create_network)
 				nma_dbus_create_network (applet->connection, dev, essid, opt);
 			else
-				nma_dbus_set_device (applet->connection, dev, essid, opt);
+				nma_dbus_set_device (applet->connection, dev, essid, FALSE, opt);
 		}
 	}
 
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 -0000	1.39.2.2
+++ src/nm-dbus-nm.c	7 Jun 2006 17:09:04 -0000
@@ -261,6 +261,7 @@
 	{
 		NMAPSecurity * 	security = NULL;
 		char *			essid = NULL;
+		gboolean			trusted = FALSE;
 
 		if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING))
 		{
@@ -276,6 +277,15 @@
 			goto out;
 		}
 
+		if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BOOLEAN))
+		{
+			nm_warning ("Invalid argument type (trusted");
+			goto out;
+		}
+
+		/* grab the trusted bit */
+		dbus_message_iter_get_basic (&iter, &trusted);
+
 		/* If there's security information, we use that.  If not, we
 		 * make some up from the scan list.
 		 */
@@ -292,6 +302,7 @@
 
 		/* Set up the wireless-specific activation request properties */
 		ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (dev), essid, security);
+		nm_ap_set_trusted (ap, trusted);
 		if (security)
 	 		g_object_unref (G_OBJECT (security));
 
Index: src/nm-dbus-nmi.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-dbus-nmi.c,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 nm-dbus-nmi.c
--- src/nm-dbus-nmi.c	17 May 2006 14:57:05 -0000	1.12.2.2
+++ src/nm-dbus-nmi.c	7 Jun 2006 17:09:04 -0000
@@ -224,6 +224,7 @@
 {
 	DBusMessage *		message;
 	gboolean			success = FALSE;
+	gboolean			trusted;
 	const char *		essid;
 	gchar *			char_bssid;
 	NMAPSecurity *		security;
@@ -246,10 +247,14 @@
 	/* First argument: ESSID (STRING) */
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &essid);
 
-	/* Second argument: Automatic (BOOLEAN) */
+	/* Second argument: Automatic or user-driven connection? (BOOLEAN) */
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &automatic);
 
-	/* Third argument: Access point's BSSID */
+	/* Third argument: Trusted? (BOOLEAN) */
+	trusted = nm_ap_get_trusted (ap);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &trusted);
+
+	/* Fourth argument: Access point's BSSID */
 	addr = nm_ap_get_address (ap);
 	if ((nm_ap_get_mode (ap) == IW_MODE_INFRA) && nm_ethernet_address_is_valid (addr))
 	{


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]