diff options
author | Peter Williams <peterw@ximian.com> | 2002-08-10 00:50:07 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2002-08-10 00:50:07 +0800 |
commit | c585c8203f54c07e91104bdb6623124e5f795a2d (patch) | |
tree | 8bc54c699f5a540e5094f8af2068ed5b4f678499 /mail | |
parent | a22468499591d5279ed0cfda4455032270f0ba3d (diff) | |
download | gsoc2013-evolution-c585c8203f54c07e91104bdb6623124e5f795a2d.tar.gz gsoc2013-evolution-c585c8203f54c07e91104bdb6623124e5f795a2d.tar.zst gsoc2013-evolution-c585c8203f54c07e91104bdb6623124e5f795a2d.zip |
When a URI is changed, try to copy over threaded view settings, preview
2002-08-09 Peter Williams <peterw@ximian.com>
* mail-config.c (mail_config_uri_renamed): When a URI is changed,
try to copy over threaded view settings, preview pane shown settings,
headers, hide state, tree expansion, and GAL view files.
(uri_to_evname): New utility function.
svn path=/trunk/; revision=17751
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 7 | ||||
-rw-r--r-- | mail/mail-config.c | 64 |
2 files changed, 71 insertions, 0 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 6b1afcda89..83a94b7950 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2002-08-09 Peter Williams <peterw@ximian.com> + + * mail-config.c (mail_config_uri_renamed): When a URI is changed, + try to copy over threaded view settings, preview pane shown settings, + headers, hide state, tree expansion, and GAL view files. + (uri_to_evname): New utility function. + 2002-08-08 Jeffrey Stedfast <fejj@ximian.com> * mail-account-gui.c (mail_account_gui_save): Instead of comparing diff --git a/mail/mail-config.c b/mail/mail-config.c index 491885f32c..0db4017ad8 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -2442,12 +2442,39 @@ mail_config_get_default_transport (void) return NULL; } +static char * +uri_to_evname (const char *uri, const char *prefix) +{ + char *safe; + char *tmp; + + safe = g_strdup (uri); + e_filename_make_safe (safe); + /* blah, easiest thing to do */ + if (prefix[0] == '*') + tmp = g_strdup_printf ("%s/%s%s.xml", evolution_dir, prefix + 1, safe); + else + tmp = g_strdup_printf ("%s/%s%s", evolution_dir, prefix, safe); + g_free (safe); + return tmp; +} + void mail_config_uri_renamed(GCompareFunc uri_cmp, const char *old, const char *new) { MailConfigAccount *ac; const GSList *l; int work = 0; + gpointer oldkey, newkey, hashkey; + gpointer val; + char *oldname, *newname; + char *cachenames[] = { "config/hidestate-", + "config/et-expanded-", + "config/et-header-", + "*views/mail/current_view-", + "*views/mail/custom_view-", + NULL }; + int i; l = mail_config_get_accounts(); while (l) { @@ -2465,6 +2492,43 @@ mail_config_uri_renamed(GCompareFunc uri_cmp, const char *old, const char *new) l = l->next; } + oldkey = uri_to_key (old); + newkey = uri_to_key (new); + + /* call this to load the hash table and the key */ + mail_config_get_thread_list (old); + if (g_hash_table_lookup_extended (config->threaded_hash, oldkey, &hashkey, &val)) { + /*printf ("changing key in threaded_hash\n");*/ + g_hash_table_remove (config->threaded_hash, hashkey); + g_hash_table_insert (config->threaded_hash, newkey, val); + work = 2; + } + + /* ditto */ + mail_config_get_show_preview (old); + if (g_hash_table_lookup_extended (config->preview_hash, oldkey, &hashkey, &val)) { + /*printf ("changing key in preview_hash\n");*/ + g_hash_table_remove (config->preview_hash, hashkey); + g_hash_table_insert (config->preview_hash, newkey, val); + work = 2; + } + + g_free (oldkey); + if (work != 2) + g_free (newkey); + + /* ignore return values or if the files exist or + * not, doesn't matter */ + + for (i = 0; cachenames[i]; i++) { + oldname = uri_to_evname (old, cachenames[i]); + newname = uri_to_evname (new, cachenames[i]); + /*printf ("** renaming %s to %s\n", oldname, newname);*/ + rename (oldname, newname); + g_free (oldname); + g_free (newname); + } + /* nasty ... */ if (work) mail_config_write(); |