aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-12-13 05:47:38 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-12-13 05:58:43 +0800
commitbca0d146daf52c67c5cb8a3a9c2cbcdbf854257a (patch)
treed22e50c59ddd28839e4b7c17f6aa52176e296116 /mail
parentf3ec041c74fd35ca66e4d64a22a65649044c3e0b (diff)
downloadgsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.tar
gsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.tar.gz
gsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.tar.bz2
gsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.tar.lz
gsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.tar.xz
gsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.tar.zst
gsoc2013-evolution-bca0d146daf52c67c5cb8a3a9c2cbcdbf854257a.zip
EMAccountEditor: Fix handling of auth-mechanism.
CamelNetworkSettings:auth-mechanism defaults to NULL, so when creating a new CamelSettings instance, choose an initial value from the CamelProvider's list of available CamelServiceAuthTypes. This fixes the blank combo box issue and hopefully bug #665984.
Diffstat (limited to 'mail')
-rw-r--r--mail/em-account-editor.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 984d599c9e..4fe4a382b1 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -2094,6 +2094,36 @@ emae_file_chooser_changed (GtkFileChooser *file_chooser,
}
static void
+emae_ensure_auth_mechanism (CamelProvider *provider,
+ CamelSettings *settings)
+{
+ CamelServiceAuthType *auth_type;
+ const gchar *auth_mechanism;
+
+ auth_mechanism =
+ camel_network_settings_get_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (settings));
+
+ /* If a mechanism name is already set, we're fine. */
+ if (auth_mechanism != NULL)
+ return;
+
+ /* Check that the CamelProvider defines some auth mechanisms.
+ * If not, it's reasonable to leave the mechanism name unset. */
+ if (provider->authtypes == NULL)
+ return;
+
+ /* No authentication mechanism has been chosen, so we'll choose
+ * one from the CamelProvider's list of available mechanisms. */
+
+ auth_type = provider->authtypes->data;
+ auth_mechanism = auth_type->authproto;
+
+ camel_network_settings_set_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (settings), auth_mechanism);
+}
+
+static void
emae_setup_settings (EMAccountEditorService *service)
{
CamelServiceClass *class;
@@ -2147,14 +2177,14 @@ emae_setup_settings (EMAccountEditorService *service)
}
if (CAMEL_IS_NETWORK_SETTINGS (settings)) {
- const gchar *auth_mechanism;
- gboolean service_requires_auth;
- auth_mechanism =
- camel_network_settings_get_auth_mechanism (
- CAMEL_NETWORK_SETTINGS (settings));
-
- service_requires_auth = (auth_mechanism != NULL);
+ /* Even if the service does not need to authenticate, we
+ * still need to initialize the auth mechanism combo box.
+ * So if CamelSettings does not already have a mechanism
+ * name set, choose one from the CamelProvider's list of
+ * available auth mechanisms. Later in emae_commit(),
+ * if need be, we'll revert the setting back to NULL. */
+ emae_ensure_auth_mechanism (provider, settings);
g_object_bind_property (
settings, "auth-mechanism",
@@ -2193,21 +2223,6 @@ emae_setup_settings (EMAccountEditorService *service)
service->username, "text",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
-
- switch (service->type) {
- case CAMEL_PROVIDER_STORE:
- emae_set_store_requires_auth (
- service->emae, service_requires_auth);
- break;
-
- case CAMEL_PROVIDER_TRANSPORT:
- emae_set_transport_requires_auth (
- service->emae, service_requires_auth);
- break;
-
- default:
- g_warn_if_reached ();
- }
}
if (CAMEL_IS_LOCAL_SETTINGS (settings)) {