Added option to disable emptying connection pool

This commit is contained in:
M66B 2021-11-24 10:39:28 +01:00
parent 78d8c9e004
commit 77575ff716
4 changed files with 28 additions and 4 deletions

View File

@ -147,6 +147,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAuthLogin;
private SwitchCompat swAuthNtlm;
private SwitchCompat swAuthSasl;
private SwitchCompat swEmptyPool;
private SwitchCompat swIdleDone;
private SwitchCompat swExactAlarms;
private SwitchCompat swInfra;
@ -182,7 +183,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"protocol", "debug", "log_level",
"query_threads", "wal", "checkpoints", "sqlite_cache",
"chunk_size", "use_modseq", "perform_expunge", "uid_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "idle_done",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "empty_pool", "idle_done",
"exact_alarms", "infra", "dup_msgids", "test_iab"
};
@ -281,6 +282,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAuthLogin = view.findViewById(R.id.swAuthLogin);
swAuthNtlm = view.findViewById(R.id.swAuthNtlm);
swAuthSasl = view.findViewById(R.id.swAuthSasl);
swEmptyPool = view.findViewById(R.id.swEmptyPool);
swIdleDone = view.findViewById(R.id.swIdleDone);
swExactAlarms = view.findViewById(R.id.swExactAlarms);
swInfra = view.findViewById(R.id.swInfra);
@ -882,6 +884,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swEmptyPool.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("empty_pool", checked).apply();
}
});
swIdleDone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1370,6 +1379,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAuthLogin.setChecked(prefs.getBoolean("auth_login", true));
swAuthNtlm.setChecked(prefs.getBoolean("auth_ntlm", true));
swAuthSasl.setChecked(prefs.getBoolean("auth_sasl", true));
swEmptyPool.setChecked(prefs.getBoolean("empty_pool", true));
swIdleDone.setChecked(prefs.getBoolean("idle_done", true));
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
swInfra.setChecked(prefs.getBoolean("infra", false));

View File

@ -151,7 +151,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
"download_headers", "download_eml",
"prefer_ip4", "bind_socket", "standalone_vpn", "tcp_keep_alive", "ssl_harden", // force reconnect
"experiments", "debug", "protocol", // force reconnect
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "idle_done", // force reconnect
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "empty_pool", "idle_done", // force reconnect
"exact_alarms" // force schedule
));
@ -1339,6 +1339,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
// Debug
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean subscriptions = prefs.getBoolean("subscriptions", false);
boolean empty_pool = prefs.getBoolean("empty_pool", true);
boolean debug = (prefs.getBoolean("debug", false) || BuildConfig.DEBUG);
final EmailService iservice = new EmailService(
@ -1785,7 +1786,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
handling = all;
if (istore instanceof IMAPStore) {
if (empty_pool && istore instanceof IMAPStore) {
getMainHandler().removeCallbacks(purge);
if (handling.size() == 0)
getMainHandler().postDelayed(purge, PURGE_DELAY);

View File

@ -865,6 +865,18 @@
app:layout_constraintTop_toBottomOf="@id/swAuthNtlm"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEmptyPool"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_empty_pool"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAuthSasl"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swIdleDone"
android:layout_width="0dp"
@ -874,7 +886,7 @@
android:text="@string/title_advanced_idle_done"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAuthSasl"
app:layout_constraintTop_toBottomOf="@id/swEmptyPool"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -679,6 +679,7 @@
<string name="title_advanced_auth_ntlm" translatable="false">NTLM</string>
<string name="title_advanced_auth_sasl" translatable="false">SASL</string>
<string name="title_advanced_idle_done" translatable="false">IDLE/DONE</string>
<string name="title_advanced_empty_pool" translatable="false">Empty connection pool</string>
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>