[evolution] Remove em_utils_in_addressbook().



commit bc27cacec39ef6043b0109b8d7ba81605cea5714
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Feb 27 08:29:48 2013 -0500

    Remove em_utils_in_addressbook().
    
    No longer used.

 libemail-engine/e-mail-utils.c |  314 ----------------------------------------
 libemail-engine/e-mail-utils.h |    4 -
 2 files changed, 0 insertions(+), 318 deletions(-)
---
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index 21d53b6..cc5ef73 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -294,320 +294,6 @@ em_utils_folder_is_outbox (ESourceRegistry *registry,
        return is_outbox;
 }
 
-/* ********************************************************************** */
-
-struct TryOpenEBookStruct {
-       GError **error;
-       EFlag *flag;
-       gboolean result;
-};
-
-extern gint camel_application_is_exiting;
-
-#define NOT_FOUND_BOOK (GINT_TO_POINTER (1))
-
-/* to be able to cancel pending requests on exit; this lock
- * should not be held while contact_cache lock is held */
-G_LOCK_DEFINE_STATIC (search_addressbook_cancellables);
-static GSList *search_addressbook_cancellables = NULL;
-
-ECancellableMutex contact_cache_lock;
-
-/* key is lowercased contact email; value is EBook pointer
- * (just for comparison) where it comes from */
-static GHashTable *contact_cache = NULL;
-
-/* key is source ID; value is pointer to EBook */
-static GHashTable *emu_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 GHashTable *emu_broken_books_hash = NULL;
-
-static gboolean
-search_address_in_addressbooks (ESourceRegistry *registry,
-                                const gchar *address,
-                                gboolean local_only,
-                                gboolean (*check_contact) (EContact *contact,
-                                                           gpointer user_data),
-                                gpointer user_data,
-                                GCancellable *cancellable)
-{
-       GList *list, *link;
-       GList *addr_sources = NULL;
-       gboolean found = FALSE, stop = FALSE, found_any = FALSE;
-       gchar *lowercase_addr;
-       gpointer ptr;
-       EBookQuery *book_query;
-       gchar *query;
-       const gchar *extension_name;
-
-       if (!address || !*address || g_cancellable_is_cancelled (cancellable) || camel_application_is_exiting)
-               return FALSE;
-
-       G_LOCK (search_addressbook_cancellables);
-       if (cancellable)
-               g_object_ref (cancellable);
-       else
-               cancellable = g_cancellable_new ();
-       search_addressbook_cancellables = g_slist_prepend (search_addressbook_cancellables, cancellable);
-       G_UNLOCK (search_addressbook_cancellables);
-
-       if (!e_cancellable_mutex_lock (&contact_cache_lock, cancellable)) {
-               G_LOCK (search_addressbook_cancellables);
-               search_addressbook_cancellables = g_slist_remove (search_addressbook_cancellables, 
cancellable);
-               g_object_unref (cancellable);
-               G_UNLOCK (search_addressbook_cancellables);
-
-               return FALSE;
-       }
-
-       if (camel_application_is_exiting || g_cancellable_is_cancelled (cancellable)) {
-               e_cancellable_mutex_unlock (&contact_cache_lock);
-
-               G_LOCK (search_addressbook_cancellables);
-               search_addressbook_cancellables = g_slist_remove (search_addressbook_cancellables, 
cancellable);
-               g_object_unref (cancellable);
-               G_UNLOCK (search_addressbook_cancellables);
-
-               return FALSE;
-       }
-
-       if (emu_books_hash == NULL) {
-               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);
-       }
-
-       lowercase_addr = g_utf8_strdown (address, -1);
-       ptr = g_hash_table_lookup (contact_cache, lowercase_addr);
-       if (ptr != NULL && (check_contact == NULL || ptr == NOT_FOUND_BOOK)) {
-               g_free (lowercase_addr);
-               e_cancellable_mutex_unlock (&contact_cache_lock);
-
-               G_LOCK (search_addressbook_cancellables);
-               search_addressbook_cancellables = g_slist_remove (search_addressbook_cancellables, 
cancellable);
-               g_object_unref (cancellable);
-               G_UNLOCK (search_addressbook_cancellables);
-
-               return ptr != NOT_FOUND_BOOK;
-       }
-
-       book_query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address);
-       query = e_book_query_to_string (book_query);
-       e_book_query_unref (book_query);
-
-       extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
-       list = e_source_registry_list_sources (registry, extension_name);
-
-       for (link = list; link != NULL && !g_cancellable_is_cancelled (cancellable); link = g_list_next 
(link)) {
-               ESource *source = E_SOURCE (link->data);
-               ESourceExtension *extension;
-               const gchar *backend_name;
-               gboolean source_is_local;
-               gboolean autocomplete;
-
-               extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
-               extension = e_source_get_extension (source, extension_name);
-
-               backend_name = e_source_backend_get_backend_name (
-                       E_SOURCE_BACKEND (extension));
-
-               source_is_local = (g_strcmp0 (backend_name, "local") == 0);
-
-               if (local_only && !source_is_local)
-                       continue;
-
-               extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
-               extension = e_source_get_extension (source, extension_name);
-
-               autocomplete = e_source_autocomplete_get_include_me (
-                       E_SOURCE_AUTOCOMPLETE (extension));
-
-               if (!autocomplete)
-                       continue;
-
-               addr_sources = g_list_prepend (
-                       addr_sources, g_object_ref (source));
-       }
-
-       g_list_free_full (list, (GDestroyNotify) g_object_unref);
-
-       stop = g_cancellable_is_cancelled (cancellable);
-
-       for (link = addr_sources; !stop && !found && link != NULL
-            && !g_cancellable_is_cancelled (cancellable);
-            link = g_list_next (link)) {
-               ESource *source = E_SOURCE (link->data);
-               GSList *contacts;
-               EBookClient *book_client = NULL;
-               gboolean cached_book = FALSE;
-               const gchar *display_name;
-               const gchar *uid;
-               GError *err = NULL;
-
-               uid = e_source_get_uid (source);
-               display_name = e_source_get_display_name (source);
-
-               /* failed to load this book last time, skip it now */
-               if (g_hash_table_lookup (emu_broken_books_hash, uid) != NULL)
-                       continue;
-
-               d (printf (" checking '%s'\n", e_source_get_uri (source)));
-
-               book_client = g_hash_table_lookup (emu_books_hash, uid);
-               if (!book_client) {
-                       /* FIXME This blocks, but this entire function is
-                        *       in desperate need of a rewrite.  This is
-                        *       horribly convoluted, even for Evolution! */
-                       book_client = (EBookClient *)
-                               e_book_client_connect_sync (source, NULL, &err);
-
-                       if (book_client == NULL) {
-                               if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
-                                   g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) {
-                                       stop = TRUE;
-                               } else if (err) {
-                                       gchar *source_uid;
-
-                                       source_uid = g_strdup (uid);
-
-                                       g_hash_table_insert (
-                                               emu_broken_books_hash,
-                                               source_uid, source_uid);
-
-                                       g_warning (
-                                               "%s: Unable to create addressbook '%s': %s",
-                                               G_STRFUNC,
-                                               display_name,
-                                               err->message);
-                               }
-                               g_clear_error (&err);
-                       } else if (!stop) {
-                               g_object_unref (book_client);
-                               book_client = NULL;
-
-                               if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
-                                   g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) {
-                                       stop = TRUE;
-                               } else if (err) {
-                                       gchar *source_uid;
-
-                                       source_uid = g_strdup (uid);
-
-                                       g_hash_table_insert (
-                                               emu_broken_books_hash,
-                                               source_uid, source_uid);
-
-                                       g_warning (
-                                               "%s: Unable to open addressbook '%s': %s",
-                                               G_STRFUNC,
-                                               display_name,
-                                               err->message);
-                               }
-                               g_clear_error (&err);
-                       }
-               } else {
-                       cached_book = TRUE;
-               }
-
-               if (book_client && !stop &&
-                   e_book_client_get_contacts_sync (
-                   book_client, query, &contacts, cancellable, &err)) {
-                       if (contacts != NULL) {
-                               if (!found_any) {
-                                       g_hash_table_insert (
-                                               contact_cache,
-                                               g_strdup (lowercase_addr),
-                                               book_client);
-                               }
-                               found_any = TRUE;
-
-                               if (check_contact) {
-                                       GSList *l;
-
-                                       for (l = contacts; l && !found; l = l->next) {
-                                               EContact *contact = l->data;
-
-                                               found = check_contact (contact, user_data);
-                                       }
-                               } else {
-                                       found = TRUE;
-                               }
-
-                               g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
-                               g_slist_free (contacts);
-                       }
-               } else if (book_client) {
-                       stop = stop || (err &&
-                           (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
-                            g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)));
-                       if (err && !stop) {
-                               gchar *source_uid = g_strdup (uid);
-
-                               g_hash_table_insert (
-                                       emu_broken_books_hash,
-                                       source_uid, source_uid);
-
-                               g_warning (
-                                       "%s: Can't get contacts from '%s': %s",
-                                       G_STRFUNC,
-                                       display_name,
-                                       err->message);
-                       }
-                       g_clear_error (&err);
-               }
-
-               if (stop && !cached_book && book_client) {
-                       g_object_unref (book_client);
-               } else if (!stop && book_client && !cached_book) {
-                       g_hash_table_insert (
-                               emu_books_hash, g_strdup (uid), book_client);
-               }
-       }
-
-       g_list_free_full (addr_sources, (GDestroyNotify) g_object_unref);
-
-       g_free (query);
-
-       if (!found_any) {
-               g_hash_table_insert (contact_cache, lowercase_addr, NOT_FOUND_BOOK);
-               lowercase_addr = NULL;
-       }
-
-       e_cancellable_mutex_unlock (&contact_cache_lock);
-
-       g_free (lowercase_addr);
-
-       G_LOCK (search_addressbook_cancellables);
-       search_addressbook_cancellables = g_slist_remove (search_addressbook_cancellables, cancellable);
-       g_object_unref (cancellable);
-       G_UNLOCK (search_addressbook_cancellables);
-
-       return found_any;
-}
-
-gboolean
-em_utils_in_addressbook (ESourceRegistry *registry,
-                         CamelInternetAddress *iaddr,
-                         gboolean local_only,
-                         GCancellable *cancellable)
-{
-       const gchar *addr;
-
-       g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
-
-       /* TODO: check all addresses? */
-       if (iaddr == NULL || !camel_internet_address_get (iaddr, 0, NULL, &addr))
-               return FALSE;
-
-       return search_address_in_addressbooks (
-               registry, addr, local_only, NULL, NULL, cancellable);
-}
-
 static ESource *
 guess_mail_account_from_folder (ESourceRegistry *registry,
                                 CamelFolder *folder,
diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h
index 95a6bc6..87bf337 100644
--- a/libemail-engine/e-mail-utils.h
+++ b/libemail-engine/e-mail-utils.h
@@ -33,10 +33,6 @@ gboolean     em_utils_folder_is_sent         (ESourceRegistry *registry,
                                                 CamelFolder *folder);
 gboolean       em_utils_folder_is_outbox       (ESourceRegistry *registry,
                                                 CamelFolder *folder);
-gboolean       em_utils_in_addressbook         (ESourceRegistry *registry,
-                                                CamelInternetAddress *addr,
-                                                gboolean local_only,
-                                                GCancellable *cancellable);
 ESource *      em_utils_guess_mail_account     (ESourceRegistry *registry,
                                                 CamelMimeMessage *message,
                                                 CamelFolder *folder,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]