+ ModestAuthProtocol protocol_authentication_incoming =
+ MODEST_PROTOCOL_AUTH_PASSWORD;
+ /* If we use an encrypted protocol then there is no need to encrypt the password */
+ if (!modest_protocol_info_is_secure(protocol_security_incoming))
+ {
+ if (gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth))) {
+ GList *list_auth_methods =
+ modest_maemo_utils_get_supported_secure_authentication_methods (dialog->incoming_protocol,
+ hostname, port_num, GTK_WINDOW (dialog));
+ if (list_auth_methods) {
+ /* Use the first supported method.
+ * TODO: Should we prioritize them, to prefer a particular one? */
+ GList* method;
+ for (method = list_auth_methods; method != NULL; method = g_list_next(method))
+ {
+ ModestAuthProtocol proto = (ModestAuthProtocol)(GPOINTER_TO_INT(list_auth_methods->data));
+ // Allow secure methods, e.g MD5 only
+ if (modest_protocol_info_auth_is_secure(proto))
+ {
+ protocol_authentication_incoming = proto;
+ break;
+ }
+ }
+ g_list_free (list_auth_methods);
+ }
+ if (list_auth_methods == NULL ||
+ !modest_protocol_info_auth_is_secure(protocol_authentication_incoming))
+ {
+ GtkWidget* error_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog),
+ GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, _("Server does not support secure authentication!"));
+ gtk_dialog_run(GTK_DIALOG(error_dialog));
+ gtk_widget_destroy(error_dialog);
+ /* This is a nasty hack. jschmid. */
+ /* Don't let the dialog close */
+ g_signal_stop_emission_by_name (dialog, "response");
+ return FALSE;
+ }
+ }
+ }
+
+ modest_server_account_set_secure_auth (dialog->account_manager, incoming_account_name, protocol_authentication_incoming);