diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-12 20:32:13 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-03-12 22:10:09 +0800 |
commit | b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555 (patch) | |
tree | 5a344f9ac5466795f4ef0ef525249faf3514ad7f /mail/e-mail-autoconfig.c | |
parent | 3e8e8cb946d4597134c7d98a178c17ef5e835dc6 (diff) | |
download | gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.gz gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.bz2 gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.lz gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.xz gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.zst gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.zip |
Bug 695693 - Handle <authentication> tags during auto-configuration
Diffstat (limited to 'mail/e-mail-autoconfig.c')
-rw-r--r-- | mail/e-mail-autoconfig.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/mail/e-mail-autoconfig.c b/mail/e-mail-autoconfig.c index 69b7329b23..61fe0c6f75 100644 --- a/mail/e-mail-autoconfig.c +++ b/mail/e-mail-autoconfig.c @@ -89,6 +89,7 @@ struct _EMailAutoconfigResult { gchar *user; gchar *host; guint16 port; + gchar *auth_mechanism; CamelNetworkSecurityMethod security_method; }; @@ -281,10 +282,43 @@ mail_autoconfig_parse_text (GMarkupParseContext *context, CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT; closure->result->set = TRUE; } - } - /* FIXME Not handling <authentication> elements. - * Unclear how some map to SASL mechanisms. */ + } else if (g_str_equal (element_name, "authentication")) { + gboolean use_plain_auth = FALSE; + + /* "password-cleartext" and "plain" are synonymous. */ + + if (g_str_equal (string->str, "password-cleartext")) + use_plain_auth = TRUE; + + if (g_str_equal (string->str, "plain")) + use_plain_auth = TRUE; + + if (use_plain_auth) { + gchar *auth_mechanism = NULL; + + /* The exact auth name depends on the protocol. */ + + /* Leave this NULL for IMAP so Camel + * will issue an IMAP LOGIN command. */ + if (closure->result == &priv->imap_result) + auth_mechanism = NULL; + + /* Leave this NULL for POP3 so Camel + * will issue POP3 USER/PASS commands. */ + if (closure->result == &priv->pop3_result) + auth_mechanism = NULL; + + if (closure->result == &priv->smtp_result) + auth_mechanism = g_strdup ("LOGIN"); + + closure->result->auth_mechanism = auth_mechanism; + closure->result->set = TRUE; + } + + /* XXX Other <authentication> values not handled, + * but they are corner cases for the most part. */ + } g_string_free (string, TRUE); } @@ -429,6 +463,7 @@ mail_autoconfig_set_details (EMailAutoconfig *autoconfig, "user", result->user, "host", result->host, "port", result->port, + "auth-mechanism", result->auth_mechanism, "security-method", result->security_method, NULL); @@ -493,10 +528,13 @@ mail_autoconfig_finalize (GObject *object) g_free (priv->imap_result.user); g_free (priv->imap_result.host); + g_free (priv->imap_result.auth_mechanism); g_free (priv->pop3_result.user); g_free (priv->pop3_result.host); + g_free (priv->pop3_result.auth_mechanism); g_free (priv->smtp_result.user); g_free (priv->smtp_result.host); + g_free (priv->smtp_result.auth_mechanism); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (e_mail_autoconfig_parent_class)->finalize (object); |