diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-03 03:54:54 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:05 +0800 |
commit | dc1f9544c4b68f2fb40a3d1482f5295754b56e66 (patch) | |
tree | 24faa3677eb42d13d213f7eb4b5dbd55cccb9b7a /mail | |
parent | 9a149f3ab61a08a5943d57045fad59cd894ba7a5 (diff) | |
download | gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.tar gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.tar.gz gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.tar.bz2 gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.tar.lz gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.tar.xz gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.tar.zst gsoc2013-evolution-dc1f9544c4b68f2fb40a3d1482f5295754b56e66.zip |
Simplify mail_session_get_password().
Utilizes the new capability in e_get_account_by_uid() to handle both
CamelStore and CamelTransport UIDs.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-session.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index 8f76506dc8..1ceb98f9f0 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -603,24 +603,23 @@ mail_session_get_password (CamelSession *session, guint32 flags, GError **error) { - gchar *url = NULL; - gchar *ret = NULL; EAccount *account = NULL; + const gchar *uid = NULL; + gchar *ret = NULL; - if (service != NULL) { - CamelURL *service_url; - - service_url = camel_service_get_camel_url (service); - url = camel_url_to_string (service_url, CAMEL_URL_HIDE_ALL); + if (CAMEL_IS_SERVICE (service)) { + uid = camel_service_get_uid (service); + account = e_get_account_by_uid (uid); } if (!strcmp(item, "popb4smtp_uid")) { /* not 100% mt safe, but should be ok */ - if (url - && (account = e_get_account_by_transport_url (url))) + if (account != NULL) ret = g_strdup (account->source->url); - else - ret = g_strdup (url); + else if (CAMEL_IS_SERVICE (service)) { + CamelURL *url = camel_service_get_camel_url (service); + ret = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); + } } else { gchar *key = mail_session_make_key (service, item); EAccountService *config_service = NULL; @@ -635,10 +634,10 @@ mail_session_get_password (CamelSession *session, g_free (ret); ret = NULL; - if (url) { - if ((account = e_get_account_by_source_url (url))) + if (account != NULL) { + if (CAMEL_IS_STORE (service)) config_service = account->source; - else if ((account = e_get_account_by_transport_url (url))) + if (CAMEL_IS_TRANSPORT (service)) config_service = account->transport; } @@ -704,8 +703,6 @@ mail_session_get_password (CamelSession *session, g_free (key); } - g_free (url); - if (ret == NULL) g_set_error ( error, G_IO_ERROR, |