- 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;
+ TnyPair *option_security = NULL;
+ const gchar* auth_mech_name = NULL;
+ ModestProtocolType protocol_type;
+ ModestProtocol *protocol;
+ ModestProtocolType security_type;
+ ModestProtocol *security;
+ ModestProtocolType auth_protocol_type;
+ ModestProtocol *auth_protocol;
+ ModestProtocolRegistry *protocol_registry;
+ const gchar *security_option_string;
+ const gchar *username;
+ const gchar *hostname;
+ guint port;
+
+ /* First of all delete old options */
+ tny_camel_account_clear_options (TNY_CAMEL_ACCOUNT (tny_account));
+
+ protocol_type = modest_server_account_settings_get_protocol (server_settings);
+ security_type = modest_server_account_settings_get_security_protocol (server_settings);
+ auth_protocol_type = modest_server_account_settings_get_auth_protocol (server_settings);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+ security = modest_protocol_registry_get_protocol_by_type (protocol_registry, security_type);
+ auth_protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, auth_protocol_type);
+
+ security_option_string = modest_protocol_get (security, MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION);
+ if (security_option_string) {
+ option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL, security_option_string);
+ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account), option_security);
+ g_object_unref (option_security);