network-manager-applet r794 - in trunk: . src/gconf-helpers



Author: dcbw
Date: Mon Jul 21 04:08:17 2008
New Revision: 794
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=794&view=rev

Log:
2008-07-21  Dan Williams  <dcbw redhat com>

	* src/gconf-helpers/gconf-upgrade.c
	  src/gconf-helpers/gconf-upgrade.h
	  src/gconf-helpers/gconf-helpers.c
		- (nm_gconf_migrate_0_7_netmask_to_prefix, nm_gconf_get_all_connections):
			convert netmasks to prefixes



Modified:
   trunk/ChangeLog
   trunk/src/gconf-helpers/gconf-helpers.c
   trunk/src/gconf-helpers/gconf-upgrade.c
   trunk/src/gconf-helpers/gconf-upgrade.h

Modified: trunk/src/gconf-helpers/gconf-helpers.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-helpers.c	(original)
+++ trunk/src/gconf-helpers/gconf-helpers.c	Mon Jul 21 04:08:17 2008
@@ -751,6 +751,7 @@
 	nm_gconf_migrate_0_7_connection_names (client);
 	nm_gconf_migrate_0_7_vpn_connections (client);
 	nm_gconf_migrate_0_7_wireless_security (client);
+	nm_gconf_migrate_0_7_netmask_to_prefix (client);
 
 	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
 	if (!connections) {

Modified: trunk/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.c	(original)
+++ trunk/src/gconf-helpers/gconf-upgrade.c	Mon Jul 21 04:08:17 2008
@@ -35,6 +35,9 @@
 #include <nm-setting-8021x.h>
 #include <nm-setting-vpn.h>
 #include <nm-setting-vpn-properties.h>
+#include <nm-setting-ip4-config.h>
+#include <nm-utils.h>
+
 #include "gconf-upgrade.h"
 #include "gconf-helpers.h"
 
@@ -1002,3 +1005,61 @@
 
 }
 
+void
+nm_gconf_migrate_0_7_netmask_to_prefix (GConfClient *client)
+{
+	GSList *connections, *iter;
+
+	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
+	for (iter = connections; iter; iter = iter->next) {
+		char *id = g_path_get_basename ((const char *) iter->data);
+		GArray *array, *new;
+		int i;
+		gboolean need_update = FALSE;
+
+		if (!nm_gconf_get_uint_array_helper (client, iter->data,
+		                                     NM_SETTING_IP4_CONFIG_ADDRESSES,
+		                                     NM_SETTING_IP4_CONFIG_SETTING_NAME,
+		                                     &array))
+			goto next;
+
+		new = g_array_sized_new (FALSE, TRUE, sizeof (guint32), array->len);
+		for (i = 0; i < array->len; i+=3) {
+			guint32 addr, netmask, prefix, gateway;
+
+			addr = g_array_index (array, guint32, i);
+			g_array_append_val (new, addr);
+
+			/* get the second element of the 3-number IP address tuple */
+			netmask = g_array_index (array, guint32, i + 1);
+			if (netmask > 32) {
+				/* convert it */
+				prefix = nm_utils_ip4_netmask_to_prefix (netmask);
+				g_array_append_val (new, prefix);
+				need_update = TRUE;
+			} else {
+				/* Probably already a prefix */
+				g_array_append_val (new, netmask);
+			}
+
+			gateway = g_array_index (array, guint32, i + 2);
+			g_array_append_val (new, gateway);
+		}
+
+		/* Update GConf */
+		if (need_update) {
+			nm_gconf_set_uint_array_helper (client, iter->data,
+			                                NM_SETTING_IP4_CONFIG_ADDRESSES,
+			                                NM_SETTING_IP4_CONFIG_SETTING_NAME,
+			                                new);
+		}
+		g_array_free (new, TRUE);
+
+next:
+		g_free (id);
+	}
+	free_slist (connections);
+
+	gconf_client_suggest_sync (client, NULL);
+}
+

Modified: trunk/src/gconf-helpers/gconf-upgrade.h
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.h	(original)
+++ trunk/src/gconf-helpers/gconf-upgrade.h	Mon Jul 21 04:08:17 2008
@@ -34,5 +34,7 @@
 
 void nm_gconf_migrate_0_7_keyring_items (GConfClient *client);
 
+void nm_gconf_migrate_0_7_netmask_to_prefix (GConfClient *client);
+
 #endif	/* GCONF_UPGRADE_H */
 



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