diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-01-25 11:18:20 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-01-25 11:21:59 +0800 |
commit | d75f6c636406385abb50025b4c371dec262b1c4b (patch) | |
tree | 62a62a06cb6a6b78373dd2e13a2c198d5ef9e3a0 /libemail-engine/e-mail-session.c | |
parent | fa244511cec16843162db9896ecbb4350d827957 (diff) | |
download | gsoc2013-evolution-d75f6c636406385abb50025b4c371dec262b1c4b.tar.gz gsoc2013-evolution-d75f6c636406385abb50025b4c371dec262b1c4b.tar.zst gsoc2013-evolution-d75f6c636406385abb50025b4c371dec262b1c4b.zip |
Bug 668479: Missing transport-only accounts in Preferences
Evolution kinda sorta supports multiple identities by allowing users
to set up so-called "transport-only" accounts by choosing "None" for
the account type.
Add a CamelStore subclass for those types of accounts so they get
added to EMailAccountStore. It's just a stupid hack to keep another
stupid hack working, but this should sustain us until we can support
multiple identities FOR REAL.
Diffstat (limited to 'libemail-engine/e-mail-session.c')
-rw-r--r-- | libemail-engine/e-mail-session.c | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c index 46ed515675..f146f4510e 100644 --- a/libemail-engine/e-mail-session.c +++ b/libemail-engine/e-mail-session.c @@ -51,6 +51,9 @@ #include "libemail-utils/e-account-utils.h" #include "libemail-utils/mail-mt.h" +/* This is our hack, not part of libcamel. */ +#include "camel-null-store.h" + #include "e-mail-junk-filter.h" #include "e-mail-session.h" #include "e-mail-folder-utils.h" @@ -406,36 +409,36 @@ mail_session_add_by_account (EMailSession *session, { CamelService *service = NULL; CamelProvider *provider; - CamelURL *url; - gboolean transport_only; + CamelURL *url = NULL; + const gchar *protocol = NULL; + gboolean have_source_url; GError *error = NULL; - /* check whether it's transport-only accounts */ - transport_only = - (account->source == NULL) || - (account->source->url == NULL) || - (*account->source->url == '\0'); - if (transport_only) - goto handle_transport; + have_source_url = + (account->source != NULL) && + (account->source->url != NULL); - /* Load the service, but don't connect. Check its provider, - * and if this belongs in the folder tree model, add it. */ + if (have_source_url) + url = camel_url_new (account->source->url, NULL); + + protocol = (url != NULL) ? url->protocol : "none"; + provider = camel_provider_get (protocol, &error); - url = camel_url_new (account->source->url, NULL); - if (url != NULL) { - provider = camel_provider_get (url->protocol, NULL); + if (url != NULL) camel_url_free (url); - } else { - provider = NULL; - } - if (provider == NULL) { - /* In case we do not have a provider here, we handle - * the special case of having multiple mail identities - * eg. a dummy account having just SMTP server defined */ - goto handle_transport; + if (error != NULL) { + g_warn_if_fail (provider == NULL); + g_warning ("%s", error->message); + g_error_free (error); + return; } + g_return_if_fail (provider != NULL); + + /* Load the service, but don't connect. Check its provider, + * and if this belongs in the folder tree model, add it. */ + service = camel_session_add_service ( CAMEL_SESSION (session), account->uid, provider->protocol, @@ -451,8 +454,6 @@ mail_session_add_by_account (EMailSession *session, camel_service_set_display_name (service, account->name); -handle_transport: - /* While we're at it, add the account's transport (if it has one) * to the CamelSession. The transport's UID is a kludge for now. * We take the EAccount's UID and tack on "-transport". */ @@ -851,13 +852,9 @@ mail_session_add_service (CamelSession *session, break; } - if (url_string != NULL) { - url = camel_url_new (url_string, error); - if (url == NULL) { - g_object_unref (service); - service = NULL; - } - } + /* Be lenient about malformed URLs. */ + if (url_string != NULL) + url = camel_url_new (url_string, NULL); } if (url != NULL) { @@ -1477,6 +1474,7 @@ e_mail_session_class_init (EMailSessionClass *class) G_TYPE_NONE, 1, CAMEL_TYPE_STORE); + camel_null_store_register_provider (); } static void |