diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java
index 53f2580999..5194304326 100644
--- a/app/src/main/java/eu/faircode/email/EmailService.java
+++ b/app/src/main/java/eu/faircode/email/EmailService.java
@@ -30,7 +30,10 @@ import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.SubjectKeyIdentifier;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -92,6 +95,7 @@ public class EmailService implements AutoCloseable {
private boolean harden;
private boolean useip;
private String ehlo;
+ private boolean log;
private boolean debug;
private Properties properties;
private Session isession;
@@ -150,6 +154,7 @@ public class EmailService implements AutoCloseable {
properties = MessageHelper.getSessionProperties();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ this.log = prefs.getBoolean("protocol", false);
this.harden = prefs.getBoolean("ssl_harden", false);
boolean auth_plain = prefs.getBoolean("auth_plain", true);
@@ -515,7 +520,27 @@ public class EmailService implements AutoCloseable {
String user, String password,
SSLSocketFactoryService factory) throws MessagingException {
isession = Session.getInstance(properties, null);
- isession.setDebug(debug);
+
+ isession.setDebug(debug || log);
+ if (debug || log)
+ isession.setDebugOut(new PrintStream(new OutputStream() {
+ private ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ @Override
+ public void write(int b) {
+ if (((char) b) == '\n') {
+ String line = bos.toString();
+ if (!line.endsWith("ignoring socket timeout"))
+ if (debug)
+ android.util.Log.i("javamail", user + " " + line);
+ else
+ EntityLog.log(context, user + " " + line);
+ bos.reset();
+ } else
+ bos.write(b);
+ }
+ }));
+
//System.setProperty("mail.socket.debug", Boolean.toString(debug));
isession.addProvider(new GmailSSLProvider());
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
index a960e6b65f..661572df13 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
@@ -89,6 +89,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Button btnApp;
private Button btnMore;
+ private SwitchCompat swProtocol;
private SwitchCompat swDebug;
private SwitchCompat swAuthPlain;
private SwitchCompat swAuthLogin;
@@ -106,7 +107,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{
"shortcuts", "fts", "english", "watchdog", "updates",
"experiments", "query_threads", "crash_reports", "cleanup_attachments",
- "debug", "auth_plain", "auth_login", "auth_sasl"
+ "protocol", "debug", "auth_plain", "auth_login", "auth_sasl"
};
private final static String[] RESET_QUESTIONS = new String[]{
@@ -149,6 +150,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
btnApp = view.findViewById(R.id.btnApp);
btnMore = view.findViewById(R.id.btnMore);
+ swProtocol = view.findViewById(R.id.swProtocol);
swDebug = view.findViewById(R.id.swDebug);
swAuthPlain = view.findViewById(R.id.swAuthPlain);
swAuthLogin = view.findViewById(R.id.swAuthLogin);
@@ -339,6 +341,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
+ swProtocol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("protocol", checked).apply();
+ }
+ });
+
swAuthPlain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -596,6 +605,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvUuid.setText(prefs.getString("uuid", null));
swCleanupAttachments.setChecked(prefs.getBoolean("cleanup_attachments", false));
+ swProtocol.setChecked(prefs.getBoolean("protocol", false));
swDebug.setChecked(prefs.getBoolean("debug", false));
swAuthPlain.setChecked(prefs.getBoolean("auth_plain", true));
swAuthLogin.setChecked(prefs.getBoolean("auth_login", true));
diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
index af154eba97..7fecb7489a 100644
--- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
+++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
@@ -130,7 +130,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static final List PREF_RELOAD = Collections.unmodifiableList(Arrays.asList(
"ssl_harden", // force reconnect
"badge", "unseen_ignored", // force update badge/widget
- "debug" // force reconnect
+ "protocol", "debug" // force reconnect
));
static final int PI_ALARM = 1;
diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml
index a5e6d0dce4..d35011563f 100644
--- a/app/src/main/res/layout/fragment_options_misc.xml
+++ b/app/src/main/res/layout/fragment_options_misc.xml
@@ -327,6 +327,30 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnApp" />
+
+
+
+
Try experimental features
Limit parallel database access
Send error reports
+ Protocol logging
Debug mode
Delete attachments of old messages
Cleanup
@@ -585,6 +586,7 @@
Enabling this improves search performance, but also increases battery and storage space usage
This will restart the app
List of current experimental features
+ This will significantly increase battery and storage space usage!
Enable extra logging and show debug information at various places
When manually cleaning, this will remove attachments from messages that are no longer synchronized
This will delete all temporary files