From 018866693e09f835b137b25f255d795f69d4a50e Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 4 Mar 2004 21:07:00 +0000 Subject: If event == NULL, don't try to use event->key.time 2004-03-04 Jeffrey Stedfast * em-folder-view.c (emfv_popup): If event == NULL, don't try to use event->key.time * em-migrate.c (upgrade_vfolder_sources_1_4): New function to upgrade vfolder sources. (em_upgrade_xml_1_4): If the doc is vfolders.xml, upgrade the sources nodes. svn path=/trunk/; revision=24971 --- mail/em-migrate.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'mail/em-migrate.c') diff --git a/mail/em-migrate.c b/mail/em-migrate.c index 8096e2ef99..19d44387d7 100644 --- a/mail/em-migrate.c +++ b/mail/em-migrate.c @@ -1737,9 +1737,52 @@ upgrade_xml_uris_1_4 (const char *uri) } } +static void +upgrade_vfolder_sources_1_4 (xmlDocPtr doc) +{ + xmlNodePtr root, node; + + if (!doc || !(root = xmlDocGetRootElement (doc))) + return; + + if (!root->name || strcmp (root->name, "filteroptions") != 0) { + /* root node is not , nothing to upgrade */ + return; + } + + if (!(node = xml_find_node (root, "ruleset"))) { + /* no ruleset node, nothing to upgrade */ + return; + } + + node = node->children; + while (node != NULL) { + if (node->name && !strcmp (node->name, "rule")) { + xmlNodePtr sources; + char *src; + + if (!(src = xmlGetProp (node, "source"))) + src = xmlStrdup ("local"); /* default to all local folders? */ + + xmlSetProp (node, "source", "incoming"); + + if (!(sources = xml_find_node (node, "sources"))) + sources = xmlNewChild (node, NULL, "sources", NULL); + + xmlSetProp (sources, "with", src); + xmlFree (src); + } + + node = node->next; + } +} + static int -em_upgrade_xml_1_4 (xmlDocPtr doc) +em_upgrade_xml_1_4 (xmlDocPtr doc, gboolean vfolders_xml) { + if (vfolders_xml) + upgrade_vfolder_sources_1_4 (doc); + return upgrade_xml_uris (doc, upgrade_xml_uris_1_4); } @@ -2157,10 +2200,10 @@ em_migrate_1_4 (const char *evolution_dir, xmlDocPtr filters, xmlDocPtr vfolders if (em_upgrade_accounts_1_4 () == -1) return -1; - if (em_upgrade_xml_1_4 (filters) == -1) + if (em_upgrade_xml_1_4 (filters, FALSE) == -1) return -1; - if (em_upgrade_xml_1_4 (vfolders) == -1) + if (em_upgrade_xml_1_4 (vfolders, TRUE) == -1) return -1; path = g_build_filename (g_get_home_dir (), "evolution", "searches.xml", NULL); -- cgit