- switch (auth_protocol) {
- 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 (protocol == MODEST_PROTOCOL_STORE_IMAP ||
- protocol == MODEST_PROTOCOL_STORE_POP)
- auth_mech_name = NULL;
- 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 (protocol == MODEST_PROTOCOL_STORE_IMAP)
- auth_mech_name = NULL;
- else if (protocol == 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_name=%s (%s)", __FUNCTION__, auth_protocol,
- account_name, modest_server_account_settings_get_hostname (server_settings));
- break;
+ if (MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
+ modest_account_protocol_has_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), auth_protocol_type)) {
+ auth_mech_name = modest_account_protocol_get_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), auth_protocol_type);
+ } else {
+ auth_mech_name = modest_protocol_get (auth_protocol, MODEST_PROTOCOL_AUTH_ACCOUNT_OPTION);