+ModestAuthProtocol
+modest_server_account_get_secure_auth (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
+ gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH,
+ TRUE /* server account */);
+ if (value) {
+ result = get_secure_auth_for_conf_string (value);
+
+ g_free (value);
+ }
+
+ return result;
+}
+
+
+void
+modest_server_account_set_secure_auth (ModestAccountMgr *self,
+ const gchar* account_name, ModestAuthProtocol secure_auth)
+{
+ /* Get the conf string for the enum value: */
+ const gchar* str_value = NULL;
+ if (secure_auth == MODEST_PROTOCOL_AUTH_NONE)
+ str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE;
+ else if (secure_auth == MODEST_PROTOCOL_AUTH_PASSWORD)
+ str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD;
+ else if (secure_auth == MODEST_PROTOCOL_AUTH_CRAMMD5)
+ str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5;
+
+ /* Set it in the configuration: */
+ modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
+}
+
+static ModestConnectionProtocol
+get_security_for_conf_string(const gchar* value)
+{
+ ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ if (value) {
+ if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0)
+ result = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NORMAL) == 0) {
+ /* The UI has "Normal (TLS)": */
+ result = MODEST_PROTOCOL_CONNECTION_TLS;
+ } else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_SSL) == 0)
+ result = MODEST_PROTOCOL_CONNECTION_SSL;
+ }
+
+ return result;
+}
+
+ModestConnectionProtocol
+modest_server_account_get_security (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY,
+ TRUE /* server account */);
+ if (value) {
+ result = get_security_for_conf_string (value);
+
+ g_free (value);
+ }
+
+ return result;
+}
+
+void
+modest_server_account_set_security (ModestAccountMgr *self,
+ const gchar* account_name, ModestConnectionProtocol security)
+{
+ /* Get the conf string for the enum value: */
+ const gchar* str_value = NULL;
+ if (security == MODEST_PROTOCOL_CONNECTION_NORMAL)
+ str_value = MODEST_ACCOUNT_SECURITY_VALUE_NONE;
+ else if (security == MODEST_PROTOCOL_CONNECTION_TLS) {
+ /* The UI has "Normal (TLS)": */
+ str_value = MODEST_ACCOUNT_SECURITY_VALUE_NORMAL;
+ } else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
+ str_value = MODEST_ACCOUNT_SECURITY_VALUE_SSL;
+
+ /* Set it in the configuration: */
+ modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY, str_value, TRUE);
+}
+
+ModestServerAccountData*