aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-03-12 20:32:13 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-03-12 22:10:09 +0800
commitb1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555 (patch)
tree5a344f9ac5466795f4ef0ef525249faf3514ad7f
parent3e8e8cb946d4597134c7d98a178c17ef5e835dc6 (diff)
downloadgsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.gz
gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.tar.zst
gsoc2013-evolution-b1b884763ee8bc7ce42f44d5a4f7f9ee1fec0555.zip
Bug 695693 - Handle <authentication> tags during auto-configuration
-rw-r--r--mail/e-mail-autoconfig.c44
-rw-r--r--modules/mail-config/e-mail-config-smtp-backend.c31
2 files changed, 71 insertions, 4 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);
diff --git a/modules/mail-config/e-mail-config-smtp-backend.c b/modules/mail-config/e-mail-config-smtp-backend.c
index ac54cd4148..c78c0176d9 100644
--- a/modules/mail-config/e-mail-config-smtp-backend.c
+++ b/modules/mail-config/e-mail-config-smtp-backend.c
@@ -289,11 +289,40 @@ static gboolean
mail_config_smtp_backend_auto_configure (EMailConfigServiceBackend *backend,
EMailAutoconfig *autoconfig)
{
+ EMailConfigSmtpBackendPrivate *priv;
ESource *source;
+ CamelSettings *settings;
+ const gchar *mechanism;
source = e_mail_config_service_backend_get_source (backend);
- return e_mail_autoconfig_set_smtp_details (autoconfig, source);
+ if (!e_mail_autoconfig_set_smtp_details (autoconfig, source))
+ return FALSE;
+
+ /* XXX Need to set the authentication widgets to match the
+ * auto-configured settings or else the auto-configured
+ * settings will be overwritten in commit_changes().
+ *
+ * It's not good enough to just set an auto-configured
+ * flag and skip the widget checks in commit_changes()
+ * if the flag is TRUE, since the user may revise the
+ * SMTP settings before committing. */
+
+ priv = E_MAIL_CONFIG_SMTP_BACKEND_GET_PRIVATE (backend);
+
+ settings = e_mail_config_service_backend_get_settings (backend);
+
+ mechanism = camel_network_settings_get_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (settings));
+
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (priv->auth_required_toggle),
+ (mechanism != NULL));
+
+ if (mechanism != NULL)
+ e_mail_config_auth_check_set_active_mechanism (
+ E_MAIL_CONFIG_AUTH_CHECK (priv->auth_check),
+ mechanism);
}
static gboolean