[evolution-patches] Fix for Evolution 1.2 shortcut migration



The attach patch fixes shortcuts migration from Evolution 1.2 :
http://qa.mandrakesoft.com/show_bug.cgi?id=4927

Strangely, you need to feed libxml2 with locale-encoded strings (and not
UTF-8 ones) for shortcuts.xml migration from 1.2 (otherwise you'll end
with very ugly strings, which is quite obvious in french).

This patch is for Evo 1.4 branch and I think it should go into 1.4.5 if
possible..



-- 
Frederic Crozat <fcrozat mandrakesoft com>
Mandrakesoft
--- evolution-1.4.4/shell/e-config-upgrade.c.migrate	2003-06-25 19:08:01.000000000 +0200
+++ evolution-1.4.4/shell/e-config-upgrade.c	2003-09-09 20:33:00.000000000 +0200
@@ -617,12 +617,15 @@
 {
 	const char *value_tags[] = { "string", "address", "regex", "file", "command", NULL };
 	const char *rule_tags[] = { "title", NULL };
+	const char *item_props[] = { "name", NULL };
 	struct {
 		const char *name;
 		const char **tags;
+		const char **props;
 	} tags[] = {
-		{ "value", value_tags },
-		{ "rule", rule_tags },
+		{ "value", value_tags, NULL },
+		{ "rule", rule_tags, NULL },
+		{ "item", NULL, item_props },
 		{ 0 },
 	};
 	int changed = 0;
@@ -634,6 +637,7 @@
 
 	for (i=0;tags[i].name;i++) {
 		if (!strcmp(node->name, tags[i].name)) {
+		   if (tags[i].tags != NULL) {
 			work = node->children;
 			while (work) {
 				for (j=0;tags[i].tags[j];j++) {
@@ -652,7 +656,20 @@
 				work = work->next;
 			}
 			break;
-		}
+		   }
+		   if (tags[i].props != NULL) {
+			for (j=0; tags[i].props[j];j++) {
+				txt = xmlGetProp (node, tags[i].props[j]);
+				if (g_utf8_validate(txt,-1,NULL)) {
+					tmp = g_locale_from_utf8(txt, -1, NULL, NULL, NULL);
+					xmlSetProp(node, tags[i].props[j],tmp);
+					changed = 1;
+					g_free(tmp);
+				}
+				xmlFree(txt);
+			}
+		   }
+		} 
 	}
 
 	node = node->children;
@@ -1849,7 +1866,7 @@
 
 	if (major <=1 && minor <=3 && revision < 1) {
 		/* check for xml 1 encoding from version 1.2 upgrade or from a previous previous 1.3.0 upgrade */
-		char *xml_files[] = { "vfolders.xml", "filters.xml" };
+		char *xml_files[] = { "vfolders.xml", "filters.xml", "shortcuts.xml"};
 
 		d(printf("Checking for xml1 format xml files\n"));
 


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