Re: [evolution-patches] Fix for Evolution 1.2 shortcut migration



> On Wed, 2003-09-10 at 12:15, Frederic Crozat wrote:
> > I'll try to do a new version of my patch tomorrow.. (probably not in
> > time for 1.4.5)..
> 
> If you send it in tomorrow it can definitely go in 1.4.5.
> 
> At any rate, thanks in advance for your help with this!

Here is it.. I've kept this utf8 undecypher outside xml1_decode because
I'm not sure of its effect on other xml1 strings (ie nodes) and I don't
want to break everything before 1.4.5 :))

I didn't add ChangeLog entry yet because I usually add it just before
committing..

-- 
Frederic Crozat <fcrozat mandrakesoft com>
Mandrakesoft
--- evolution-1.4.4/shell/e-config-upgrade.c.migration	2003-06-25 19:08:01.000000000 +0200
+++ evolution-1.4.4/shell/e-config-upgrade.c	2003-09-11 15:59:53.000000000 +0200
@@ -612,17 +612,40 @@
 	return res;
 }
 
+static char *
+utf8_reencode (const char * txt) {
+	GString *out = g_string_new("");
+	const unsigned char *p;
+	char *res;
+
+	/* convert:
+        libxml1  8 bit utf8 converted to xml entities byte-by-byte chars -> utf8 */
+
+	p =  (const unsigned char *) txt;
+
+	while (*p) {
+		g_string_append_c(out,(char) g_utf8_get_char(p));
+		p = g_utf8_next_char (p);
+	}
+	res = out->str;
+	g_string_free(out, FALSE);
+}
+
+
 static int
 upgrade_xml_1_2_rec(xmlNodePtr node)
 {
 	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 +657,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 +676,19 @@
 				work = work->next;
 			}
 			break;
-		}
+		   }
+		   if (tags[i].props != NULL) {
+			for (j=0; tags[i].props[j];j++) {
+				txt = xmlGetProp (node, tags[i].props[j]);
+				d(printf("upgrading xml property %s on node %s '%s' -> '%s'\n", tags[i].props[j],tags[i].name,txt,tmp));
+				tmp = utf8_reencode(txt);
+				xmlSetProp(node, tags[i].props[j],tmp);
+				changed = 1;
+				g_free(tmp);
+				xmlFree(txt);
+			}
+		   }
+		} 
 	}
 
 	node = node->children;
@@ -1849,7 +1885,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]