diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-02-27 21:03:22 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-02-27 23:59:55 +0800 |
commit | 0b2607486ee7207d524ba6edc3dc375e518ef427 (patch) | |
tree | 63fe21da5e0cfee40588963817bda177cc2974d6 | |
parent | ef355cd5c3380b057d69bd839f67dc82a666ad9a (diff) | |
download | gsoc2013-evolution-0b2607486ee7207d524ba6edc3dc375e518ef427.tar.gz gsoc2013-evolution-0b2607486ee7207d524ba6edc3dc375e518ef427.tar.zst gsoc2013-evolution-0b2607486ee7207d524ba6edc3dc375e518ef427.zip |
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().
-rw-r--r-- | libemail-engine/e-mail-session.c | 23 | ||||
-rw-r--r-- | 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; |