network-manager-applet r835 - in trunk: . src src/connection-editor src/gconf-helpers



Author: dcbw
Date: Mon Aug 11 17:19:41 2008
New Revision: 835
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=835&view=rev

Log:
2008-08-11  Dan Williams  <dcbw redhat com>

	Update to match NM svn3924 vpn setting changes (consolidated vpn and
	vpn-properties settings; vpn-specific data now a hash of string:string
	instead of string:variant); convert old GConf entries to new format



Modified:
   trunk/ChangeLog
   trunk/src/applet.c
   trunk/src/connection-editor/nm-connection-list.c
   trunk/src/connection-editor/page-vpn.c
   trunk/src/gconf-helpers/gconf-helpers.c
   trunk/src/gconf-helpers/gconf-helpers.h
   trunk/src/gconf-helpers/gconf-upgrade.c
   trunk/src/gconf-helpers/gconf-upgrade.h

Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c	(original)
+++ trunk/src/applet.c	Mon Aug 11 17:19:41 2008
@@ -49,7 +49,6 @@
 #include <nm-vpn-connection.h>
 #include <nm-setting-connection.h>
 #include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
 #include <nm-active-connection.h>
 #include <nm-dbus-settings-system.h>
 #include <nm-setting-wireless.h>
@@ -996,9 +995,9 @@
 			/* Not a VPN connection */
 			continue;
 
-		if (!nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES)) {
+		if (!nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN)) {
 			const char *name = NM_SETTING (s_con)->name;
-			g_warning ("%s: VPN connection '%s' didn't have requires vpn-properties setting.", __func__, name);
+			g_warning ("%s: VPN connection '%s' didn't have requires vpn setting.", __func__, name);
 			continue;
 		}
 

Modified: trunk/src/connection-editor/nm-connection-list.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.c	(original)
+++ trunk/src/connection-editor/nm-connection-list.c	Mon Aug 11 17:19:41 2008
@@ -49,7 +49,6 @@
 #include <nm-setting-wired.h>
 #include <nm-setting-wireless.h>
 #include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
 #include <nm-setting-gsm.h>
 #include <nm-setting-cdma.h>
 #include <nm-setting-pppoe.h>
@@ -811,8 +810,6 @@
 			type_setting = nm_setting_vpn_new ();
 			s_vpn = NM_SETTING_VPN (type_setting);
 			s_vpn->service_type = service;
-
-			nm_connection_add_setting (connection, nm_setting_vpn_properties_new ());
 		}		
 	} else if (ctype == NM_TYPE_SETTING_PPPOE) {
 		s_con->id = get_next_available_name (list, _("DSL connection %d"));

Modified: trunk/src/connection-editor/page-vpn.c
==============================================================================
--- trunk/src/connection-editor/page-vpn.c	(original)
+++ trunk/src/connection-editor/page-vpn.c	Mon Aug 11 17:19:41 2008
@@ -27,7 +27,6 @@
 
 #include <nm-setting-connection.h>
 #include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
 
 #define NM_VPN_API_SUBJECT_TO_CHANGE
 #include <nm-vpn-plugin-ui-interface.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 Aug 11 17:19:41 2008
@@ -39,8 +39,15 @@
 #include "gconf-upgrade.h"
 #include "utils.h"
 
-#define DBUS_TYPE_G_ARRAY_OF_UINT          (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
-#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_ARRAY_OF_UINT))
+#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH    (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
+#define DBUS_TYPE_G_ARRAY_OF_STRING         (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
+#define DBUS_TYPE_G_ARRAY_OF_UINT           (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
+#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_UCHAR_ARRAY))
+#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT  (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_ARRAY_OF_UINT))
+#define DBUS_TYPE_G_MAP_OF_VARIANT          (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
+#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT   (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
+#define DBUS_TYPE_G_MAP_OF_STRING           (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
+#define DBUS_TYPE_G_LIST_OF_STRING          (dbus_g_type_get_collection ("GSList", G_TYPE_STRING))
 
 const char *applet_8021x_ignore_keys[] = {
 	"ca-cert",
@@ -383,8 +390,8 @@
 		return FALSE;
 
 	*value = g_hash_table_new_full (g_str_hash, g_str_equal,
-							  (GDestroyNotify) g_free,
-							  property_value_destroy);
+	                                (GDestroyNotify) g_free,
+	                                property_value_destroy);
 
 	for (iter = gconf_entries; iter; iter = iter->next) {
 		GConfEntry *entry = (GConfEntry *) iter->data;
@@ -397,7 +404,58 @@
 	}
 
 	g_slist_free (gconf_entries);
+	return TRUE;
+}
+
+gboolean
+nm_gconf_get_stringhash_helper (GConfClient *client,
+                                const char *path,
+                                const char *setting,
+                                GHashTable **value)
+{
+	char *gc_key;
+	GSList *gconf_entries;
+	GSList *iter;
+	int prefix_len;
+
+	g_return_val_if_fail (setting != NULL, FALSE);
+	g_return_val_if_fail (value != NULL, FALSE);
+
+	gc_key = g_strdup_printf ("%s/%s", path, setting);
+	prefix_len = strlen (gc_key);
+	gconf_entries = gconf_client_all_entries (client, gc_key, NULL);
+	g_free (gc_key);
+
+	if (!gconf_entries)
+		return FALSE;
 
+	*value = g_hash_table_new_full (g_str_hash, g_str_equal,
+	                                (GDestroyNotify) g_free,
+	                                (GDestroyNotify) g_free);
+
+	for (iter = gconf_entries; iter; iter = iter->next) {
+		GConfEntry *entry = (GConfEntry *) iter->data;
+
+		gc_key = (char *) gconf_entry_get_key (entry);
+		gc_key += prefix_len + 1; /* get rid of the full path */
+
+		if (   !strcmp (setting, NM_SETTING_VPN_SETTING_NAME)
+		    && (!strcmp (gc_key, NM_SETTING_VPN_SERVICE_TYPE) || !strcmp (gc_key, NM_SETTING_NAME))) {
+			/* Ignore; these handled elsewhere since they are not part of the
+			 * vpn service specific data
+			 */
+		} else {
+			GConfValue *gc_val = gconf_entry_get_value (entry);
+
+			if (gc_val && gconf_value_get_string (gc_val)) {
+				g_hash_table_insert (*value, gconf_unescape_key (gc_key, -1),
+				                     g_strdup (gconf_value_get_string (gc_val)));
+			}
+		}
+		gconf_entry_free (entry);
+	}
+
+	g_slist_free (gconf_entries);
 	return TRUE;
 }
 
@@ -650,7 +708,7 @@
 } WritePropertiesInfo;
 
 static void
-write_properties (gpointer key, gpointer val, gpointer user_data)
+write_properties_valuehash (gpointer key, gpointer val, gpointer user_data)
 {
 	GValue *value = (GValue *) val;
 	WritePropertiesInfo *info = (WritePropertiesInfo *) user_data;
@@ -694,7 +752,48 @@
 	info.client = client;
 	info.path = gc_key;
 
-	g_hash_table_foreach (value, write_properties, &info);
+	g_hash_table_foreach (value, write_properties_valuehash, &info);
+
+	g_free (gc_key);
+	return TRUE;
+}
+
+static void
+write_properties_stringhash (gpointer key, gpointer value, gpointer user_data)
+{
+	WritePropertiesInfo *info = (WritePropertiesInfo *) user_data;
+	char *esc_key;
+	char *full_key;
+
+	esc_key = gconf_escape_key ((char *) key, -1);
+	full_key = g_strconcat (info->path, "/", esc_key, NULL);
+	gconf_client_set_string (info->client, full_key, (char *) value, NULL);
+	g_free (esc_key);
+	g_free (full_key);
+}
+
+gboolean
+nm_gconf_set_stringhash_helper (GConfClient *client,
+                                const char *path,
+                                const char *network,
+                                GHashTable *value)
+{
+	char *gc_key;
+	WritePropertiesInfo info;
+
+	g_return_val_if_fail (network != NULL, FALSE);
+	g_return_val_if_fail (value != NULL, FALSE);
+
+	gc_key = g_strdup_printf ("%s/%s", path, network);
+	if (!gc_key) {
+		g_warning ("Not enough memory to create gconf path");
+		return FALSE;
+	}
+
+	info.client = client;
+	info.path = gc_key;
+
+	g_hash_table_foreach (value, write_properties_stringhash, &info);
 
 	g_free (gc_key);
 	return TRUE;
@@ -760,7 +859,9 @@
 	nm_gconf_migrate_0_7_netmask_to_prefix (client);
 	nm_gconf_migrate_0_7_ip4_method (client);
 	nm_gconf_migrate_0_7_ignore_dhcp_dns (client);
-	nm_gconf_migrate_0_7_vpn_routes (client);	
+	nm_gconf_migrate_0_7_vpn_routes (client);
+	nm_gconf_migrate_0_7_vpn_properties (client);
+	nm_gconf_migrate_0_7_openvpn_properties (client);
 
 	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
 	if (!connections) {
@@ -864,20 +965,27 @@
 			g_object_set (setting, key, ba_val, NULL);
 			g_byte_array_free (ba_val, TRUE);
 		}
-	} else if (type == dbus_g_type_get_collection ("GSList", G_TYPE_STRING)) {
+	} else if (type == DBUS_TYPE_G_LIST_OF_STRING) {
 		GSList *sa_val = NULL;
 
 		if (nm_gconf_get_stringlist_helper (info->client, info->dir, key, setting->name, &sa_val)) {
 			g_object_set (setting, key, sa_val, NULL);
 			// FIXME: how to free sa_val?
 		}
-	} else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) {
+	} else if (type == DBUS_TYPE_G_MAP_OF_VARIANT) {
 		GHashTable *vh_val = NULL;
 
 		if (nm_gconf_get_valuehash_helper (info->client, info->dir, setting->name, &vh_val)) {
 			g_object_set (setting, key, vh_val, NULL);
 			g_hash_table_destroy (vh_val);
 		}
+	} else if (type == DBUS_TYPE_G_MAP_OF_STRING) {
+		GHashTable *sh_val = NULL;
+
+		if (nm_gconf_get_stringhash_helper (info->client, info->dir, setting->name, &sh_val)) {
+			g_object_set (setting, key, sh_val, NULL);
+			g_hash_table_destroy (sh_val);
+		}
 	} else if (type == DBUS_TYPE_G_UINT_ARRAY) {
 		GArray *a_val = NULL;
 
@@ -1140,14 +1248,18 @@
 		nm_gconf_set_bytearray_helper (info->client, info->dir,
 								 key, setting->name,
 								 (GByteArray *) g_value_get_boxed (value));
-	} else if (type == dbus_g_type_get_collection ("GSList", G_TYPE_STRING)) {
+	} else if (type == DBUS_TYPE_G_LIST_OF_STRING) {
 		nm_gconf_set_stringlist_helper (info->client, info->dir,
 								  key, setting->name,
 								  (GSList *) g_value_get_boxed (value));
-	} else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) {
+	} else if (type == DBUS_TYPE_G_MAP_OF_VARIANT) {
 		nm_gconf_set_valuehash_helper (info->client, info->dir,
 								 setting->name,
 								 (GHashTable *) g_value_get_boxed (value));
+	} else if (type == DBUS_TYPE_G_MAP_OF_STRING) {
+		nm_gconf_set_stringhash_helper (info->client, info->dir,
+		                                setting->name,
+		                                (GHashTable *) g_value_get_boxed (value));
 	} else if (type == DBUS_TYPE_G_UINT_ARRAY) {
 		nm_gconf_set_uint_array_helper (info->client, info->dir,
 								  key, setting->name,

Modified: trunk/src/gconf-helpers/gconf-helpers.h
==============================================================================
--- trunk/src/gconf-helpers/gconf-helpers.h	(original)
+++ trunk/src/gconf-helpers/gconf-helpers.h	Mon Aug 11 17:19:41 2008
@@ -108,6 +108,12 @@
 			       GHashTable **value);
 
 gboolean
+nm_gconf_get_stringhash_helper (GConfClient *client,
+                                const char *path,
+                                const char *setting,
+                                GHashTable **value);
+
+gboolean
 nm_gconf_get_ip4_helper (GConfClient *client,
 						  const char *path,
 						  const char *key,
@@ -173,6 +179,12 @@
 			       GHashTable *value);
 
 gboolean
+nm_gconf_set_stringhash_helper (GConfClient *client,
+                                const char *path,
+                                const char *network,
+                                GHashTable *value);
+
+gboolean
 nm_gconf_set_ip4_helper (GConfClient *client,
 					  const char *path,
 					  const char *key,

Modified: trunk/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.c	(original)
+++ trunk/src/gconf-helpers/gconf-upgrade.c	Mon Aug 11 17:19:41 2008
@@ -37,7 +37,6 @@
 #include <nm-setting-wireless-security.h>
 #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>
 
@@ -430,81 +429,52 @@
 	return connection;
 }
 
-static NMSettingVPNProperties *
-nm_gconf_0_6_vpnc_settings (GSList *vpn_data)
+static void
+nm_gconf_0_6_vpnc_settings (NMSettingVPN *s_vpn, GSList *vpn_data)
 {
-	NMSettingVPNProperties *s_vpn_props;
 	GSList *iter;
-	const char *key, *value;
-	GValue *gvalue;
 
-	s_vpn_props = (NMSettingVPNProperties *)nm_setting_vpn_properties_new ();
 	for (iter = vpn_data; iter && iter->next; iter = iter->next->next) {
-		key = iter->data;
-		value = iter->next->data;
+		const char *key = iter->data;
+		const char *value = iter->next->data;
 
-		gvalue = g_slice_new0 (GValue);
 		if (*value) {
-			g_value_init (gvalue, G_TYPE_STRING);
-			g_value_set_string (gvalue, value);
+			/* A string value */
+			g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup (value));
 		} else {
-			g_value_init (gvalue, G_TYPE_BOOLEAN);
-			g_value_set_boolean (gvalue, TRUE);
+			/* A boolean; 0.6 treated key-without-value as "true" */
+			g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup ("yes"));
 		}
-		g_hash_table_insert (s_vpn_props->data, g_strdup (key), gvalue);
 	}
-
-	return s_vpn_props;
 }
 
-static const struct flagnames openvpn_contypes[] = {
-	{ "x509",       0 /* NM_OPENVPN_CONTYPE_X509 */ },
-	{ "shared-key", 1 /* NM_OPENVPN_CONTYPE_SHAREDKEY */ },
-	{ "password",   2 /* NM_OPENVPN_CONTYPE_PASSWORD */ },
-	{ NULL, 0 }
-};
-
-static NMSettingVPNProperties *
-nm_gconf_0_6_openvpn_settings (GSList *vpn_data)
+static void
+nm_gconf_0_6_openvpn_settings (NMSettingVPN *s_vpn, GSList *vpn_data)
 {
-	NMSettingVPNProperties *s_vpn_props;
 	GSList *iter;
-	const char *key, *value;
-	GValue *gvalue;
-	int i;
 
-	s_vpn_props = (NMSettingVPNProperties *)nm_setting_vpn_properties_new ();
 	for (iter = vpn_data; iter && iter->next; iter = iter->next->next) {
-		key = iter->data;
-		value = iter->next->data;
+		const char *key = iter->data;
+		const char *value = iter->next->data;
 
-		gvalue = g_slice_new0 (GValue);
-		if (!strcmp (key, "port")) {
-			g_value_init (gvalue, G_TYPE_UINT);
-			g_value_set_uint (gvalue, atoi (value));
-		} else if (!strcmp (key, "connection-type")) {
-			g_value_init (gvalue, G_TYPE_INT);
-			for (i = 0; openvpn_contypes[i].name; i++) {
-				if (!strcmp (openvpn_contypes[i].name, value))
-					g_value_set_int (gvalue, openvpn_contypes[i].value);
-			}
+		if (!strcmp (key, "connection-type")) {
+			if (!strcmp (value, "x509"))
+				g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup ("tls"));
+			else if (!strcmp (value, "shared-key"))
+				g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup ("static-key"));
+			else if (!strcmp (value, "password"))
+				g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup ("password"));
 		} else if (!strcmp (key, "comp-lzo")) {
-			g_value_init (gvalue, G_TYPE_BOOLEAN);
-			g_value_set_boolean (gvalue, !strcmp (value, "yes"));
+			g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup ("yes"));
 		} else if (!strcmp (key, "dev")) {
-			g_value_init (gvalue, G_TYPE_BOOLEAN);
-			g_value_set_boolean (gvalue, !strcmp (value, "tap")); 
+			if (!strcmp (value, "tap"))
+				g_hash_table_insert (s_vpn->data, g_strdup ("tap-dev"), g_strdup ("yes"));
 		} else if (!strcmp (key, "proto")) {
-			g_value_init (gvalue, G_TYPE_BOOLEAN);
-			g_value_set_boolean (gvalue, !strcmp (value, "tcp")); 
-		} else {
-			g_value_init (gvalue, G_TYPE_STRING);
-			g_value_set_string (gvalue, value);
-		}
-		g_hash_table_insert (s_vpn_props->data, g_strdup (key), gvalue);
+			if (!strcmp (value, "tcp"))
+				g_hash_table_insert (s_vpn->data, g_strdup ("proto-tcp"), g_strdup ("yes"));
+		} else
+			g_hash_table_insert (s_vpn->data, g_strdup (key), g_strdup (value));
 	}
-
-	return s_vpn_props;
 }
 
 static GSList *
@@ -558,7 +528,6 @@
 	NMConnection *connection;
 	NMSettingConnection *s_con;
 	NMSettingVPN *s_vpn;
-	NMSettingVPNProperties *s_vpn_props;
 	NMSettingIP4Config *s_ip4;
 	char *path, *network, *id = NULL, *service_name = NULL;
 	GSList *str_routes = NULL, *vpn_data = NULL;
@@ -591,13 +560,11 @@
 	s_vpn->service_type = service_name;
 
 	if (!strcmp (service_name, "org.freedesktop.NetworkManager.vpnc"))
-		s_vpn_props = nm_gconf_0_6_vpnc_settings (vpn_data);
+		nm_gconf_0_6_vpnc_settings (s_vpn, vpn_data);
 	else if (!strcmp (service_name, "org.freedesktop.NetworkManager.openvpn"))
-		s_vpn_props = nm_gconf_0_6_openvpn_settings (vpn_data);
-	else {
+		nm_gconf_0_6_openvpn_settings (s_vpn, vpn_data);
+	else
 		g_warning ("unmatched service name %s\n", service_name);
-		s_vpn_props = NULL;
-	}
 
 	free_slist (vpn_data);
 	g_free (path);
@@ -611,10 +578,8 @@
 	connection = nm_connection_new ();
 	nm_connection_add_setting (connection, NM_SETTING (s_con));
 	nm_connection_add_setting (connection, NM_SETTING (s_vpn));
-	if (s_vpn_props)
-		nm_connection_add_setting (connection, NM_SETTING (s_vpn_props));
 	if (s_ip4)
-		nm_connection_add_setting (connection, NM_SETTING (s_vpn_props));
+		nm_connection_add_setting (connection, NM_SETTING (s_ip4));
 
 	return connection;
 }
@@ -1321,3 +1286,150 @@
 	gconf_client_suggest_sync (client, NULL);
 }
 
+void
+nm_gconf_migrate_0_7_vpn_properties (GConfClient *client)
+{
+	GSList *connections, *iter;
+
+	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
+	for (iter = connections; iter; iter = iter->next) {
+		char *path;
+		GSList *properties, *props_iter;
+
+		path = g_strdup_printf ("%s/vpn-properties", (const char *) iter->data);
+		properties = gconf_client_all_entries (client, path, NULL);
+
+		for (props_iter = properties; props_iter; props_iter = props_iter->next) {
+			GConfEntry *entry = (GConfEntry *) props_iter->data;
+			char *tmp;
+			char *key_name = g_path_get_basename (entry->key);
+
+			/* 'service-type' is reserved */
+			if (!strcmp (key_name, NM_SETTING_VPN_SERVICE_TYPE))
+				goto next;
+
+			/* Don't convert the setting name */
+			if (!strcmp (key_name, NM_SETTING_NAME))
+				goto next;
+
+			switch (entry->value->type) {
+			case GCONF_VALUE_STRING:
+				nm_gconf_set_string_helper (client, (const char *) iter->data,
+				                            key_name,
+				                            NM_SETTING_VPN_SETTING_NAME,
+				                            gconf_value_get_string (entry->value));
+				break;
+			case GCONF_VALUE_INT:
+				tmp = g_strdup_printf ("%d", gconf_value_get_int (entry->value));
+				nm_gconf_set_string_helper (client, (const char *) iter->data,
+				                            key_name,
+				                            NM_SETTING_VPN_SETTING_NAME,
+				                            tmp);
+				g_free (tmp);
+				break;
+			case GCONF_VALUE_BOOL:
+				tmp = gconf_value_get_bool (entry->value) ? "yes" : "no";
+				nm_gconf_set_string_helper (client, (const char *) iter->data,
+				                            key_name,
+				                            NM_SETTING_VPN_SETTING_NAME,
+				                            tmp);
+				break;
+			default:
+				g_warning ("%s: don't know how to convert type %d",
+				           __func__, entry->value->type);
+				break;
+			}
+
+		next:
+			g_free (key_name);
+		}
+
+		/* delete old vpn-properties dir */
+		gconf_client_recursive_unset (client, path, 0, NULL);
+	}
+	free_slist (connections);
+
+	gconf_client_suggest_sync (client, NULL);
+}
+
+static void
+move_one_vpn_string_bool (GConfClient *client,
+                          const char *path,
+                          const char *old_key,
+                          const char *new_key)
+{
+	char *del_key;
+	char *value = NULL;
+
+	if (!nm_gconf_get_string_helper (client, path,
+	                                 old_key,
+	                                 NM_SETTING_VPN_SETTING_NAME,
+	                                 &value));
+		return;
+
+	if (value && !strcmp (value, "yes")) {
+		nm_gconf_set_string_helper (client, path,
+		                            new_key,
+		                            NM_SETTING_VPN_SETTING_NAME,
+		                            "yes");
+	}
+	g_free (value);
+
+	/* delete old key */
+	del_key = g_strdup_printf ("%s/%s/%s",
+	                           path,
+	                           NM_SETTING_VPN_SETTING_NAME,
+	                           old_key);
+	gconf_client_unset (client, del_key, NULL);
+	g_free (del_key);
+}
+
+void
+nm_gconf_migrate_0_7_openvpn_properties (GConfClient *client)
+{
+	GSList *connections, *iter;
+
+	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
+	for (iter = connections; iter; iter = iter->next) {
+		char *old_type, *new_type = NULL, *service = NULL;
+
+		if (!nm_gconf_get_string_helper (client, (const char *) iter->data,
+		                                 NM_SETTING_VPN_SERVICE_TYPE,
+		                                 NM_SETTING_VPN_SETTING_NAME,
+		                                 &service))
+			continue;
+
+		if (!service || strcmp (service, "org.freedesktop.NetworkManager.openvpn"))
+			continue;
+
+		move_one_vpn_string_bool (client, iter->data, "dev", "tap-dev");
+		move_one_vpn_string_bool (client, iter->data, "proto", "proto-tcp");
+
+		if (!nm_gconf_get_string_helper (client, (const char *) iter->data,
+		                                 "connection-type",
+		                                 NM_SETTING_VPN_SETTING_NAME,
+		                                 &old_type))
+			continue;
+
+		/* Convert connection type from old integer to new string */
+		if (!strcmp (old_type, "0"))
+			new_type = "tls";
+		else if (!strcmp (old_type, "1"))
+			new_type = "static-key";
+		else if (!strcmp (old_type, "2"))
+			new_type = "password";
+		else if (!strcmp (old_type, "3"))
+			new_type = "password-tls";
+
+		if (new_type) {
+			nm_gconf_set_string_helper (client, (const char *) iter->data,
+			                            "connection-type",
+			                            NM_SETTING_VPN_SETTING_NAME,
+			                            new_type);
+		}
+	}
+	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 Aug 11 17:19:41 2008
@@ -42,5 +42,9 @@
 
 void nm_gconf_migrate_0_7_vpn_routes (GConfClient *client);
 
+void nm_gconf_migrate_0_7_vpn_properties (GConfClient *client);
+
+void nm_gconf_migrate_0_7_openvpn_properties (GConfClient *client);
+
 #endif	/* GCONF_UPGRADE_H */
 



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