From 18011bb9ed0ed4977a15e5d1e1e7d052da49b143 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 30 May 2020 16:17:54 +0200 Subject: [PATCH] Added option to disable SASL authentication --- .../main/java/eu/faircode/email/EmailService.java | 8 ++++++-- .../eu/faircode/email/FragmentOptionsMisc.java | 13 ++++++++++++- app/src/main/res/layout/fragment_options_misc.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index b585647023..104171f4b0 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -142,6 +142,8 @@ public class EmailService implements AutoCloseable { boolean socks_enabled = prefs.getBoolean("socks_enabled", false); String socks_proxy = prefs.getString("socks_proxy", "localhost:9050"); + boolean sasl = prefs.getBoolean("sasl", true); + // SOCKS proxy if (socks_enabled) { String[] address = socks_proxy.split(":"); @@ -160,8 +162,10 @@ public class EmailService implements AutoCloseable { properties.put("mail.event.executor", executor); properties.put("mail." + protocol + ".sasl.enable", "true"); - properties.put("mail." + protocol + ".sasl.mechanisms", "CRAM-MD5"); - properties.put("mail." + protocol + ".sasl.realm", realm == null ? "" : realm); + if (sasl) { + properties.put("mail." + protocol + ".sasl.mechanisms", "CRAM-MD5"); + properties.put("mail." + protocol + ".sasl.realm", realm == null ? "" : realm); + } properties.put("mail." + protocol + ".auth.ntlm.domain", realm == null ? "" : realm); // writetimeout: one thread overhead diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 70a07e38ef..e9c932d904 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -70,6 +70,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private TextView tvFtsPro; private SwitchCompat swEnglish; private SwitchCompat swWatchdog; + private SwitchCompat swSasl; private SwitchCompat swOptimize; private SwitchCompat swUpdates; private SwitchCompat swExperiments; @@ -93,7 +94,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private Group grpDebug; private final static String[] RESET_OPTIONS = new String[]{ - "shortcuts", "fts", "english", "watchdog", "auto_optimize", "updates", + "shortcuts", "fts", "english", "watchdog", "sasl", "auto_optimize", "updates", "experiments", "crash_reports", "debug", "cleanup_attachments" }; @@ -124,6 +125,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc tvFtsPro = view.findViewById(R.id.tvFtsPro); swEnglish = view.findViewById(R.id.swEnglish); swWatchdog = view.findViewById(R.id.swWatchdog); + swSasl = view.findViewById(R.id.swSasl); swOptimize = view.findViewById(R.id.swOptimize); swUpdates = view.findViewById(R.id.swUpdates); swExperiments = view.findViewById(R.id.swExperiments); @@ -223,6 +225,14 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swSasl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("sasl", checked).apply(); + ServiceSynchronize.reload(getContext(), -1L, false, "sasl=" + checked); + } + }); + swOptimize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -508,6 +518,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swFts.setChecked(prefs.getBoolean("fts", false)); swEnglish.setChecked(prefs.getBoolean("english", false)); swWatchdog.setChecked(prefs.getBoolean("watchdog", true)); + swSasl.setChecked(prefs.getBoolean("sasl", true)); swOptimize.setChecked(prefs.getBoolean("auto_optimize", false)); swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setVisibility( diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 2d4b6a8130..05311340ee 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -146,6 +146,18 @@ app:layout_constraintTop_toBottomOf="@id/tvEnglishHint" app:switchPadding="12dp" /> + + %1$d / %2$d messages indexed (%3$s) Use US country settings Periodically check if FairEmail is still active + CRAM-MD5 Automatically optimize settings Check for updates Try experimental features