+ /* Set camel-specific options: */
+
+ /* Enable secure connection settings: */
+ /* printf("DEBUG: %s: security=%d\n", __FUNCTION__, account_data->security); */
+ const gchar* option_security = NULL;
+ switch (account_data->security) {
+ case MODEST_PROTOCOL_CONNECTION_NORMAL:
+ option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER;
+ break;
+ case MODEST_PROTOCOL_CONNECTION_SSL:
+ /* Apparently, use of "IMAPS" (specified in our UI spec), implies
+ * use of the "wrapped" option: */
+ option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WRAPPED;
+ break;
+ case MODEST_PROTOCOL_CONNECTION_TLS:
+ option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_TLS;
+ break;
+ case MODEST_PROTOCOL_CONNECTION_TLS_OP:
+ /* This is not actually in our UI: */
+ option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
+ break;
+ default:
+ break;
+ }
+
+ if(option_security)
+ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
+ option_security);
+
+ /* Secure authentication: */
+ /* printf("DEBUG: %s: secure-auth=%d\n", __FUNCTION__, account_data->secure_auth); */
+ const gchar* auth_mech_name = NULL;
+ switch (account_data->secure_auth) {
+ case MODEST_PROTOCOL_AUTH_NONE:
+ /* IMAP and POP need at least a password,
+ * which camel uses if we specify NULL.
+ * This setting should never happen anyway. */
+ if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP ||
+ account_data->proto == MODEST_PROTOCOL_STORE_POP)
+ auth_mech_name = NULL;
+ else if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
+ auth_mech_name = MODEST_ACCOUNT_AUTH_ANONYMOUS;
+ else
+ auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
+ break;
+
+ case MODEST_PROTOCOL_AUTH_PASSWORD:
+ /* Camel use a password for IMAP or POP if we specify NULL,
+ * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
+ * (POP is know to report an error for Login too. Probably Password and Plain too.) */
+ if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP)
+ auth_mech_name = NULL;
+ else if (account_data->proto == MODEST_PROTOCOL_STORE_POP)
+ auth_mech_name = NULL;
+ else
+ auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
+ break;
+
+ case MODEST_PROTOCOL_AUTH_CRAMMD5:
+ auth_mech_name = MODEST_ACCOUNT_AUTH_CRAMMD5;
+ break;
+
+ default:
+ g_warning ("%s: Unhandled secure authentication setting %d for "
+ "account=%s (%s)", __FUNCTION__, account_data->secure_auth,
+ account_data->account_name, account_data->hostname);
+ break;
+ }
+
+ if(auth_mech_name)
+ tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
+
+ if (modest_protocol_info_protocol_is_store(account_data->proto) &&
+ (account_data->proto == MODEST_PROTOCOL_STORE_IMAP) ) {
+ /* Other connection options, needed for IMAP. */
+ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
+ MODEST_ACCOUNT_OPTION_USE_LSUB);
+ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
+ MODEST_ACCOUNT_OPTION_CHECK_ALL);