HEAD 1.451 gconf timestamp patch



From the list discussion I have a better idea of the original design for the gconf timestamp. I believe the attached patches will almost return NM to its original design. Now timestamps are written as follows.

1. If a successful connection is made, the function NetworkManagerPolicy.c:nm_policy_activation_finish will call

A. nm_dbus_update_network_info which causes nmi_save_network_info to update essid, auth_method, key, key_type but NOT the timestamp

and

B. nm_dbus_add_network_address which causes nmi_dbus_add_network_address to add a MAC address and a timestamp to gconf BUT ONLY IF the MAC address is not already in the list for the given network. Thus NM will only initiate a timestamp write to gconf when a NEW MAC address has been found.

2. The gconf timestamp will be unchanged as long as the user does not select a wireless network from the menu. When the user selects a wireless network from the menu, the time stamp will be updated by the function applet.c: nmwa_update_network_timestamp. I have modified the behaviour (applet.patch) of this function so that it will only write the timestamp to gconf if the network already exists in gconf. The original behavior was to create a new gconf network entry containing essid and timestamp everytime a new Wireless Networks item appeared in the NM menu. Is this desireable?

Pro: You have a record in gconf of every Wireless Network menu item that ever appeared in the NM menu. You will see your home and work AP's listed in gconf along every AP that ever appeared in a scan list and then generated a NM Wireless Networks menu item. Call this wardriving with NM. If the consensus is to stick with the original behaviour, do not apply applet.patch.

Con: The list of junk APs could grow quite long over time. To see in gconf only APs for which a successful connection has been made, apply applet.patch.


--
Bill Moss
Professor, Mathematical Sciences
Clemson University

--- applet-dbus-info.c_orig	2005-08-16 08:58:45.000000000 -0400
+++ applet-dbus-info.c	2005-08-16 14:26:05.000000000 -0400
@@ -866,10 +866,6 @@
 		gconf_client_set_int (applet->gconf_client, key, (int)enc_key_type, NULL);
 		g_free (key);
 
-		key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
-		gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
-		g_free (key);
-
 		if (auth_method != NM_DEVICE_AUTH_METHOD_UNKNOWN)
 		{
 			key = g_strdup_printf ("%s/%s/auth_method", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
@@ -953,28 +949,11 @@
 		return (reply_message);
 	}
 
-	/* Force-set the essid too so that we have a semi-complete network entry */
 	escaped_network = gconf_escape_key (network, strlen (network));
-	key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
-	value = gconf_client_get (applet->gconf_client, key, NULL);
-
-	/* If the network doesn't already exist in GConf, add it and set its timestamp to now. */
-	if (!value || (!value && (value->type == GCONF_VALUE_STRING)))
-	{
-		/* Set the essid of the network. */
-		gconf_client_set_string (applet->gconf_client, key, network, NULL);
-		g_free (key);
-
-		/* Update timestamp on network */
-		key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
-		gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
-	}
-	g_free (key);
 
 	/* Get current list of access point MAC addresses for this AP from GConf */
 	key = g_strdup_printf ("%s/%s/addresses", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
 	value = gconf_client_get (applet->gconf_client, key, NULL);
-	g_free (escaped_network);
 
 	if (value && (value->type == GCONF_VALUE_LIST) && (gconf_value_get_list_type (value) == GCONF_VALUE_STRING))
 	{
@@ -1001,14 +980,19 @@
 	{
 		new_mac_list = g_slist_append (new_mac_list, g_strdup (addr));
 		gconf_client_set_list (applet->gconf_client, key, GCONF_VALUE_STRING, new_mac_list, NULL);
+		g_free (key);
+
+                /* Update timestamp on network */
+                key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
+                gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
 	}
+	g_free (key);
+	g_free (escaped_network);
 
 	/* Free the list, since gconf_client_set_list deep-copies it */
 	g_slist_foreach (new_mac_list, (GFunc)g_free, NULL);
 	g_slist_free (new_mac_list);
 
-	g_free (key);
-
 	return (NULL);
 }
 
--- applet.c_orig	2005-08-15 00:19:33.000000000 -0400
+++ applet.c	2005-08-16 14:34:46.000000000 -0400
@@ -1194,27 +1194,28 @@
 	char *		key;
 	char *		escaped_network;
 	const char *	net_essid;
+	GConfValue              *value;
 
 	g_return_if_fail (applet != NULL);
 	g_return_if_fail (network != NULL);
 
 	net_essid = wireless_network_get_essid (network);
 
-	/* Update GConf to set timestamp for this network, or add it if
-	 * it doesn't already exist.
-	 */
-
-	/* Update timestamp on network */
+	/* Update GConf to set timestamp for this network. */
 	escaped_network = gconf_escape_key (net_essid, strlen (net_essid));
-	key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
-	gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
-	g_free (key);
-
-	/* Force-set the essid too so that we have a semi-complete network entry */
 	key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
-	gconf_client_set_string (applet->gconf_client, key, net_essid, NULL);
+	value = gconf_client_get (applet->gconf_client, key, NULL);
 	g_free (key);
+
+	if (value && (value->type == GCONF_VALUE_STRING))
+	{
+		/* Update timestamp on network */
+		key = g_strdup_printf ("%s/%s/timestamp", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
+		gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
+		g_free (key);
+	}
 	g_free (escaped_network);
+	gconf_value_free (value);
 }
 
 


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