aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-11-24 04:24:31 +0800
committerMilan Crha <mcrha@redhat.com>2009-11-24 04:24:31 +0800
commit93c4c2cffcab53eb987b44fcafc77341f53f1f9a (patch)
tree4e3e664c05038f802f5d989d95797840f6f429a6
parente14ec8882808dd938a1edbfcadd399a4f20e1569 (diff)
downloadgsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.tar
gsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.tar.gz
gsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.tar.bz2
gsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.tar.lz
gsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.tar.xz
gsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.tar.zst
gsoc2013-evolution-93c4c2cffcab53eb987b44fcafc77341f53f1f9a.zip
Bug #474502 - Don't check for contacts in broken address books
more than once
-rw-r--r--mail/em-utils.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 4bb6ef4290..6a5bd37af1 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -2093,6 +2093,7 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error)
G_LOCK_DEFINE_STATIC (contact_cache);
static GHashTable *contact_cache = NULL; /* key is lowercased contact email; value is EBook pointer (just for comparison) where it comes from */
static GHashTable *emu_books_hash = NULL; /* key is source ID; value is pointer to EBook */
+static GHashTable *emu_broken_books_hash = NULL; /* key is source ID; value is same pointer as key; this is hash of broken books, which failed to open for some reason */
static ESourceList *emu_books_source_list = NULL;
static gboolean
@@ -2112,6 +2113,7 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool
if (!emu_books_source_list) {
mail_call_main (MAIL_CALL_p_p, (MailMainFunc)emu_addr_setup, &emu_books_source_list);
emu_books_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ emu_broken_books_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
contact_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
}
@@ -2157,6 +2159,12 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool
gboolean cached_book = FALSE;
GError *err = NULL;
+ /* failed to load this book last time, skip it now */
+ if (g_hash_table_lookup (emu_broken_books_hash, e_source_peek_uid (source)) != NULL) {
+ d(printf ("%s: skipping broken book '%s'\n", G_STRFUNC, e_source_peek_name (source)));
+ continue;
+ }
+
d(printf(" checking '%s'\n", e_source_get_uri(source)));
hook_book = mail_cancel_hook_add (emu_addr_cancel_book, book);
@@ -2170,7 +2178,11 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool
if (err && g_error_matches (err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
stop = TRUE;
} else if (err) {
- g_warning ("%s: Unable to create addressbook: %s", G_STRFUNC, err->message);
+ gchar *source_uid = g_strdup (e_source_peek_uid (source));
+
+ g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid);
+
+ g_warning ("%s: Unable to create addressbook '%s': %s", G_STRFUNC, e_source_peek_name (source), err->message);
}
g_clear_error (&err);
} else if (!stop && !try_open_e_book (book, TRUE, &err)) {
@@ -2180,7 +2192,11 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool
if (err && g_error_matches (err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
stop = TRUE;
} else if (err) {
- g_warning ("%s: Unable to open addressbook: %s", G_STRFUNC, err->message);
+ gchar *source_uid = g_strdup (e_source_peek_uid (source));
+
+ g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid);
+
+ g_warning ("%s: Unable to open addressbook '%s': %s", G_STRFUNC, e_source_peek_name (source), err->message);
}
g_clear_error (&err);
}
@@ -2212,8 +2228,13 @@ search_address_in_addressbooks (const gchar *address, gboolean local_only, gbool
}
} else if (book) {
stop = stop || (err && g_error_matches (err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED));
- if (err && !stop)
- g_warning ("%s: Can't get contacts: %s", G_STRFUNC, err->message);
+ if (err && !stop) {
+ gchar *source_uid = g_strdup (e_source_peek_uid (source));
+
+ g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid);
+
+ g_warning ("%s: Can't get contacts from '%s': %s", G_STRFUNC, e_source_peek_name (source), err->message);
+ }
g_clear_error (&err);
}
@@ -2437,6 +2458,11 @@ emu_free_mail_cache (void)
emu_books_hash = NULL;
}
+ if (emu_broken_books_hash) {
+ g_hash_table_destroy (emu_broken_books_hash);
+ emu_broken_books_hash = NULL;
+ }
+
if (emu_books_source_list) {
g_object_unref (emu_books_source_list);
emu_books_source_list = NULL;