aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-session.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-03 03:54:54 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-03 03:54:54 +0800
commit7c8489e9d644c5e101a5c74bbc393868d957532a (patch)
tree373b7e3df788b5e2ece8b8ed4afd297bd5474b83 /mail/e-mail-session.c
parent7b4a69edc4a67445ae11c77135772934e4d380a2 (diff)
downloadgsoc2013-evolution-7c8489e9d644c5e101a5c74bbc393868d957532a.tar.gz
gsoc2013-evolution-7c8489e9d644c5e101a5c74bbc393868d957532a.tar.zst
gsoc2013-evolution-7c8489e9d644c5e101a5c74bbc393868d957532a.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/e-mail-session.c')
-rw-r--r--mail/e-mail-session.c29
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,