diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-07-04 06:23:20 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-07-04 06:23:20 +0800 |
commit | 9ce710a34e75735b1ec22204869e344d4ee07be1 (patch) | |
tree | 042daf350e1e18a5fbab6fae8c0264343997fc9c /mail/mail-config.c | |
parent | 014e0bf46b33bd11cc6fd22c63df6ff62a52dbce (diff) | |
download | gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.tar gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.tar.gz gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.tar.bz2 gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.tar.lz gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.tar.xz gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.tar.zst gsoc2013-evolution-9ce710a34e75735b1ec22204869e344d4ee07be1.zip |
Use a better GHashTable technique that will hopefully solve some bugs and
2001-07-03 Jeffrey Stedfast <fejj@ximian.com>
* mail-config.c (mail_config_get_show_preview): Use a better
GHashTable technique that will hopefully solve some bugs and also
use _with_default bonobo-config call.
(mail_config_set_show_preview): No sense in removing the entry
from the hash table and then re-inserting it. Just reset the
value.
(mail_config_get_thread_list): Use the same logic.
(mail_config_set_thread_list): And again here.
svn path=/trunk/; revision=10770
Diffstat (limited to 'mail/mail-config.c')
-rw-r--r-- | mail/mail-config.c | 107 |
1 files changed, 42 insertions, 65 deletions
diff --git a/mail/mail-config.c b/mail/mail-config.c index 913c4ca940..6a60a4855e 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -287,13 +287,12 @@ config_read (void) account = g_new0 (MailConfigAccount, 1); path = g_strdup_printf ("/Mail/Accounts/account_name_%d", i); - account->name = bonobo_config_get_string (config->db, path, - NULL); + account->name = bonobo_config_get_string (config->db, path, NULL); g_free (path); path = g_strdup_printf ("/Mail/Accounts/account_is_default_%d", i); account->default_account = bonobo_config_get_boolean (config->db, path, NULL) && !have_default; - + if (account->default_account) have_default = TRUE; g_free (path); @@ -435,8 +434,7 @@ config_read (void) g_free (val); path = g_strdup_printf ("/Mail/Accounts/transport_save_passwd_%d", i); - transport->save_passwd = bonobo_config_get_boolean - (config->db, path, NULL); + transport->save_passwd = bonobo_config_get_boolean (config->db, path, NULL); g_free (path); account->id = id; @@ -881,40 +879,32 @@ mail_config_set_empty_trash_on_exit (gboolean value) config->empty_trash_on_exit = value; } +gboolean mail_config_get_show_preview (const char *uri) { if (uri) { - char *key; - gboolean value = FALSE; + gpointer key, val; + char *dbkey; + + dbkey = uri_to_key (uri); - key = uri_to_key (uri); - if (!config->preview_hash) config->preview_hash = g_hash_table_new (g_str_hash, g_str_equal); - else - value = GPOINTER_TO_INT (g_hash_table_lookup (config->preview_hash, key)); - if (!value) { - CORBA_Environment ev; + if (!g_hash_table_lookup_extended (config->preview_hash, dbkey, &key, &val)) { + gboolean value; char *str; - CORBA_exception_init (&ev); - str = g_strdup_printf ("/Mail/Preview/%s", key); - value = bonobo_config_get_boolean - (config->db, str, &ev); + str = g_strdup_printf ("/Mail/Preview/%s", dbkey); + value = bonobo_config_get_boolean_with_default (config->db, str, TRUE, NULL); g_free (str); - if (!BONOBO_EX (&ev)) { - g_hash_table_insert (config->preview_hash, - g_strdup (key), - GINT_TO_POINTER (value)); - } - - CORBA_exception_free (&ev); - g_free (key); + g_hash_table_insert (config->preview_hash, dbkey, + GINT_TO_POINTER (value)); + return value; } else - return value; + return GPOINTER_TO_INT (val); } /* return the default value */ @@ -930,17 +920,15 @@ mail_config_set_show_preview (const char *uri, gboolean value) gpointer key, val; if (!config->preview_hash) - config->preview_hash = g_hash_table_new (g_str_hash, - g_str_equal); + config->preview_hash = g_hash_table_new (g_str_hash, g_str_equal); - if (g_hash_table_lookup_extended (config->preview_hash, dbkey, - &key, &val)) { - g_hash_table_remove (config->preview_hash, dbkey); - g_free (key); + if (g_hash_table_lookup_extended (config->preview_hash, dbkey, &key, &val)) { + val = GINT_TO_POINTER (value); + g_free (dbkey); + } else { + g_hash_table_insert (config->preview_hash, dbkey, + GINT_TO_POINTER (value)); } - - g_hash_table_insert (config->preview_hash, dbkey, - GINT_TO_POINTER (value)); } else config->show_preview = value; } @@ -949,37 +937,28 @@ gboolean mail_config_get_thread_list (const char *uri) { if (uri) { - char *key; - gboolean value = FALSE; + gpointer key, val; + char *dbkey; + + dbkey = uri_to_key (uri); - key = uri_to_key (uri); - if (!config->threaded_hash) config->threaded_hash = g_hash_table_new (g_str_hash, g_str_equal); - else - value = GPOINTER_TO_INT (g_hash_table_lookup (config->threaded_hash, key)); - if (!value) { - CORBA_Environment ev; + if (!g_hash_table_lookup_extended (config->threaded_hash, dbkey, &key, &val)) { + gboolean value; char *str; - CORBA_exception_init (&ev); - str = g_strdup_printf ("/Mail/Threads/%s", key); - value = bonobo_config_get_boolean (config->db , str, - &ev); + str = g_strdup_printf ("/Mail/Threads/%s", dbkey); + value = bonobo_config_get_boolean_with_default (config->db, str, FALSE, NULL); g_free (str); - if (!BONOBO_EX (&ev)) { - g_hash_table_insert (config->threaded_hash, - g_strdup (key), - GINT_TO_POINTER (value)); - } - - CORBA_exception_free (&ev); - g_free (key); + g_hash_table_insert (config->threaded_hash, dbkey, + GINT_TO_POINTER (value)); + return value; } else - return value; + return GPOINTER_TO_INT (val); } /* return the default value */ @@ -995,17 +974,15 @@ mail_config_set_thread_list (const char *uri, gboolean value) gpointer key, val; if (!config->threaded_hash) - config->threaded_hash = g_hash_table_new (g_str_hash, - g_str_equal); + config->threaded_hash = g_hash_table_new (g_str_hash, g_str_equal); - if (g_hash_table_lookup_extended (config->threaded_hash, dbkey, - &key, &val)) { - g_hash_table_remove (config->threaded_hash, dbkey); - g_free (key); + if (g_hash_table_lookup_extended (config->threaded_hash, dbkey, &key, &val)) { + val = GINT_TO_POINTER (value); + g_free (dbkey); + } else { + g_hash_table_insert (config->threaded_hash, dbkey, + GINT_TO_POINTER (value)); } - - g_hash_table_insert (config->threaded_hash, dbkey, - GINT_TO_POINTER (value)); } else config->thread_list = value; } |