diff options
author | Not Zed <NotZed@Ximian.com> | 2004-05-21 11:14:16 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-05-21 11:14:16 +0800 |
commit | e660ab7c524cf5e753b3a867f04f3a0ea383517e (patch) | |
tree | dae5b3f8d624382acc038d0dc0b86ff04de4c4f6 /mail | |
parent | ddbf9a489f03a5981e724009bae547c7da9c5447 (diff) | |
download | gsoc2013-evolution-e660ab7c524cf5e753b3a867f04f3a0ea383517e.tar.gz gsoc2013-evolution-e660ab7c524cf5e753b3a867f04f3a0ea383517e.tar.zst gsoc2013-evolution-e660ab7c524cf5e753b3a867f04f3a0ea383517e.zip |
finally put the 1.2 password upgrade patch in. Untested. #42721.
2004-05-21 Not Zed <NotZed@Ximian.com>
* em-migrate.c (update_passwords_1_2): finally put the 1.2
password upgrade patch in. Untested. #42721.
svn path=/trunk/; revision=26027
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 5 | ||||
-rw-r--r-- | mail/em-migrate.c | 98 |
2 files changed, 102 insertions, 1 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 4c4658659d..1f6dc71bc1 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2004-05-21 Not Zed <NotZed@Ximian.com> + + * em-migrate.c (update_passwords_1_2): finally put the 1.2 + password upgrade patch in. Untested. #42721. + 2004-05-20 Jeffrey Stedfast <fejj@novell.com> Fixes for bug #57305. diff --git a/mail/em-migrate.c b/mail/em-migrate.c index 303be22a6d..40dcea652d 100644 --- a/mail/em-migrate.c +++ b/mail/em-migrate.c @@ -39,6 +39,7 @@ #include <gtk/gtk.h> #include <gconf/gconf-client.h> +#include <libgnome/gnome-config.h> #include <camel/camel.h> #include <camel/camel-session.h> @@ -691,6 +692,100 @@ em_upgrade_xml_1_2 (xmlDocPtr doc) return upgrade_xml_1_2_rec (root); } +/* converts passwords from ~/evolution/private/config.xmldb to gnome_private() */ +static int +upgrade_passwords_1_2(void) +{ + xmlNodePtr root, entry; + char *filename; + xmlDocPtr priv_doc; + struct stat st; + int work = 0, res = -1; + + filename = g_build_filename(g_get_home_dir(), "evolution/private/config.xmldb", NULL); + if (lstat(filename, &st) == 0 && S_ISREG(st.st_mode)) + priv_doc = xmlParseFile(filename); + g_free(filename); + + if (priv_doc == NULL) + return 0; + + root = priv_doc->children; + if (strcmp(root->name, "bonobo-config") != 0) { + xmlFreeDoc(priv_doc); + return 0; + } + + root = root->children; + while (root) { + if (!strcmp(root->name, "section")) { + char *path = xmlGetProp(root, "path"); + + /* All sections of form + <section path="/Passwords/COMPONENT"> + <entry name="base64name" value="hexvalue"> + Are converted to: + /Evolution/Passwords-COMPONENT/name = value + */ + + if (path && !strncmp(path, "/Passwords/", 11)) { + entry = root->children; + while (entry) { + if (!strcmp(entry->name, "entry")) { + char *namep = xmlGetProp(entry, "name"), *valuep = xmlGetProp(entry, "value"); + + if (namep && valuep) { + char *value = e_bconf_hex_decode(valuep); + char *p, *new; + size_t len; + + len = camel_base64_decode_simple(namep, strlen(namep)); + namep[len] = 0; + p = namep; + + d(printf("Found password entry '%s' = '%s'\n", namep, value)); + + while (*p) { + if (*p == '/' || *p == '=') + *p = '_'; + p++; + } + + p = g_strdup_printf("/Evolution/Passwords-%s/%s", path+11, namep); + new = gnome_config_private_get_string_with_default(p, NULL); + if (new == NULL) { + d(printf("password not there, setting '%s' = '%s'\n", p, value)); + gnome_config_private_set_string(p, value); + work = TRUE; + } else { + d(printf("password already there, leaving\n")); + } + g_free(p); + g_free(value); + } + xmlFree(namep); + xmlFree(valuep); + } + entry = entry->next; + } + } + xmlFree(path); + } + root = root->next; + } + + xmlFreeDoc(priv_doc); + + if (work) { + if (gnome_config_private_sync_file("/Evolution")) + res = 0; + } else { + res = 0; + } + + return res; +} + /* ********************************************************************** */ /* Tables for converting flat bonobo conf -> gconf xml blob */ /* ********************************************************************** */ @@ -986,7 +1081,8 @@ em_migrate_1_2(const char *evolution_dir, xmlDocPtr config_xmldb, xmlDocPtr filt em_upgrade_xml_1_2(filters); em_upgrade_xml_1_2(vfolders); - + upgrade_passwords_1_2(); + return 0; } |