Added login before send option

This commit is contained in:
M66B
2024-05-22 10:03:40 +02:00
parent 562c6e51e6
commit 2a5e1685e0
7 changed files with 3083 additions and 3 deletions

View File

@@ -108,6 +108,7 @@ public class FragmentIdentity extends FragmentBase {
private EditText etUser;
private TextInputLayout tilPassword;
private TextView tvPasswordStorage;
private CheckBox cbLogin;
private Button btnCertificate;
private TextView tvCertificate;
private EditText etRealm;
@@ -218,6 +219,7 @@ public class FragmentIdentity extends FragmentBase {
etUser = view.findViewById(R.id.etUser);
tilPassword = view.findViewById(R.id.tilPassword);
tvPasswordStorage = view.findViewById(R.id.tvPasswordStorage);
cbLogin = view.findViewById(R.id.cbLoginBeforeSend);
btnCertificate = view.findViewById(R.id.btnCertificate);
tvCertificate = view.findViewById(R.id.tvCertificate);
etRealm = view.findViewById(R.id.etRealm);
@@ -799,6 +801,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("provider", provider);
args.putString("user", etUser.getText().toString().trim());
args.putString("password", tilPassword.getEditText().getText().toString());
args.putBoolean("login", cbLogin.isChecked());
args.putString("certificate", certificate);
args.putString("realm", etRealm.getText().toString());
args.putString("fingerprint", cbTrust.isChecked() ? (String) cbTrust.getTag() : null);
@@ -854,6 +857,7 @@ public class FragmentIdentity extends FragmentBase {
String provider = args.getString("provider");
String user = args.getString("user").trim();
String password = args.getString("password");
boolean login = args.getBoolean("login");
String certificate = args.getString("certificate");
String realm = args.getString("realm");
String fingerprint = args.getString("fingerprint");
@@ -1019,6 +1023,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.password, password))
return true;
if (!Objects.equals(identity.login, login))
return true;
if (!Objects.equals(identity.certificate_alias, certificate))
return true;
if (!Objects.equals(identity.realm, realm))
@@ -1087,6 +1093,7 @@ public class FragmentIdentity extends FragmentBase {
Integer.parseInt(port) != identity.port ||
!user.equals(identity.user) ||
!password.equals(identity.password) ||
!Objects.equals(login, identity.login) ||
!Objects.equals(certificate, identity.certificate_alias) ||
!Objects.equals(realm, identityRealm) ||
!Objects.equals(fingerprint, identity.fingerprint) ||
@@ -1103,6 +1110,14 @@ public class FragmentIdentity extends FragmentBase {
// Check SMTP server
Long server_max_size = null;
if (check) {
if (login) {
EntityAccount a = db.account().getAccount(account);
if (a != null)
try (EmailService iaccount = new EmailService(context, a, EmailService.PURPOSE_CHECK, true)) {
iaccount.connect(a);
}
}
// Create transport
String protocol = (encryption == EmailService.ENCRYPTION_SSL ? "smtps" : "smtp");
try (EmailService iservice = new EmailService(context,
@@ -1148,6 +1163,7 @@ public class FragmentIdentity extends FragmentBase {
identity.auth_type = auth;
identity.user = user;
identity.password = password;
identity.login = login;
identity.certificate_alias = certificate;
identity.provider = provider;
identity.realm = realm;
@@ -1331,6 +1347,7 @@ public class FragmentIdentity extends FragmentBase {
etPort.setText(identity == null ? null : Long.toString(identity.port));
etUser.setText(identity == null ? null : identity.user);
tilPassword.getEditText().setText(identity == null ? null : identity.password);
cbLogin.setChecked((identity != null && identity.login));
certificate = (identity == null ? null : identity.certificate_alias);
tvCertificate.setText(certificate == null ? getString(R.string.title_optional) : certificate);
etRealm.setText(identity == null ? null : identity.realm);