From 0b2607486ee7207d524ba6edc3dc375e518ef427 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 27 Feb 2013 08:03:22 -0500 Subject: Move CamelSession.lookup_addressbook() handler to EMailUISession. Have the new handler call e_mail_ui_session_check_known_address_sync() instead of em_utils_in_addressbook(). --- libemail-engine/e-mail-session.c | 23 ----------------------- mail/e-mail-ui-session.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c index 4d34b6f922..8d852edb82 100644 --- a/libemail-engine/e-mail-session.c +++ b/libemail-engine/e-mail-session.c @@ -1515,28 +1515,6 @@ mail_session_get_filter_driver (CamelSession *session, session, type, error); } -static gboolean -mail_session_lookup_addressbook (CamelSession *session, - const gchar *name) -{ - ESourceRegistry *registry; - CamelInternetAddress *addr; - gboolean ret; - - if (!mail_config_get_lookup_book ()) - return FALSE; - - registry = e_mail_session_get_registry (E_MAIL_SESSION (session)); - - addr = camel_internet_address_new (); - camel_address_decode ((CamelAddress *) addr, name); - ret = em_utils_in_addressbook ( - registry, addr, mail_config_get_lookup_book_local_only (), NULL); - g_object_unref (addr); - - return ret; -} - static void mail_session_get_socks_proxy (CamelSession *session, const gchar *for_host, @@ -1873,7 +1851,6 @@ e_mail_session_class_init (EMailSessionClass *class) session_class->alert_user = mail_session_alert_user; session_class->trust_prompt = mail_session_trust_prompt; session_class->get_filter_driver = mail_session_get_filter_driver; - session_class->lookup_addressbook = mail_session_lookup_addressbook; session_class->get_socks_proxy = mail_session_get_socks_proxy; session_class->authenticate_sync = mail_session_authenticate_sync; session_class->forward_to_sync = mail_session_forward_to_sync; diff --git a/mail/e-mail-ui-session.c b/mail/e-mail-ui-session.c index 978e78b1bd..b9e2690744 100644 --- a/mail/e-mail-ui-session.c +++ b/mail/e-mail-ui-session.c @@ -700,6 +700,44 @@ mail_ui_session_get_filter_driver (CamelSession *session, session, type, error); } +static gboolean +mail_ui_session_lookup_addressbook (CamelSession *session, + const gchar *name) +{ + CamelInternetAddress *cia; + gboolean known_address = FALSE; + + /* FIXME CamelSession's lookup_addressbook() method needs redone. + * No GCancellable provided, no means of reporting an error. */ + + if (!mail_config_get_lookup_book ()) + return FALSE; + + cia = camel_internet_address_new (); + + if (camel_address_decode (CAMEL_ADDRESS (cia), name) > 0) { + GError *error = NULL; + + e_mail_ui_session_check_known_address_sync ( + E_MAIL_UI_SESSION (session), cia, + mail_config_get_lookup_book_local_only (), + NULL, &known_address, &error); + + if (error != NULL) { + g_warning ("%s: %s", G_STRFUNC, error->message); + g_error_free (error); + } + } else { + g_warning ( + "%s: Failed to decode internet " + "address '%s'", G_STRFUNC, name); + } + + g_object_unref (cia); + + return known_address; +} + static void mail_ui_session_refresh_service (EMailSession *session, CamelService *service) @@ -733,6 +771,7 @@ e_mail_ui_session_class_init (EMailUISessionClass *class) session_class->remove_service = mail_ui_session_remove_service; session_class->alert_user = e_mail_ui_session_alert_user; session_class->get_filter_driver = mail_ui_session_get_filter_driver; + session_class->lookup_addressbook = mail_ui_session_lookup_addressbook; mail_session_class = E_MAIL_SESSION_CLASS (class); mail_session_class->create_vfolder_context = mail_ui_session_create_vfolder_context; -- cgit v1.2.3