Added login before send option

pull/215/head
M66B 7 months ago
parent 562c6e51e6
commit 2a5e1685e0

File diff suppressed because it is too large Load Diff

@ -70,7 +70,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 293, version = 294,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -3004,6 +3004,12 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion); logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `last_touched` INTEGER"); db.execSQL("ALTER TABLE `message` ADD COLUMN `last_touched` INTEGER");
} }
}).addMigrations(new Migration(293, 294) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `login` INTEGER NOT NULL DEFAULT 0");
}
}).addMigrations(new Migration(998, 999) { }).addMigrations(new Migration(998, 999) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase db) { public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -88,6 +88,8 @@ public class EntityIdentity {
@NonNull @NonNull
public String password; public String password;
@NonNull @NonNull
public Boolean login;
@NonNull
public boolean certificate = false; // obsolete public boolean certificate = false; // obsolete
public String certificate_alias; public String certificate_alias;
public String realm; public String realm;

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

@ -800,6 +800,11 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
MicrosoftGraph.send(ServiceSend.this, ident, imessage); MicrosoftGraph.send(ServiceSend.this, ident, imessage);
end = new Date().getTime(); end = new Date().getTime();
} else { } else {
if (account != null)
try (EmailService iaccount = new EmailService(this, account, EmailService.PURPOSE_USE, debug)) {
iaccount.connect(account);
}
EmailService iservice = new EmailService(this, ident, EmailService.PURPOSE_USE, debug); EmailService iservice = new EmailService(this, ident, EmailService.PURPOSE_USE, debug);
try { try {
if (ident.envelopeFrom != null) if (ident.envelopeFrom != null)

@ -535,16 +535,25 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<CheckBox
android:id="@+id/cbLoginBeforeSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/title_login_before_send"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardServer" />
<Button <Button
android:id="@+id/btnCertificate" android:id="@+id/btnCertificate"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp" android:layout_marginTop="12dp"
android:tag="disable" android:tag="disable"
android:text="@string/title_client_certificate" android:text="@string/title_client_certificate"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardServer" /> app:layout_constraintTop_toBottomOf="@id/cbLoginBeforeSend" />
<TextView <TextView
android:id="@+id/tvCertificate" android:id="@+id/tvCertificate"
@ -1186,6 +1195,7 @@
tvProvider,spProvider, tvProvider,spProvider,
tvDomain,tvDomainHint,etDomain,btnAutoConfig, tvDomain,tvDomainHint,etDomain,btnAutoConfig,
cardServer, cardServer,
cbLoginBeforeSend,
btnCertificate,tvCertificate, btnCertificate,tvCertificate,
tvRealm,etRealm, tvRealm,etRealm,
cbUseIp,tvUseIpHint,tvEhlo,etEhlo,ibEhlo, cbUseIp,tvUseIpHint,tvEhlo,etEhlo,ibEhlo,

@ -1245,6 +1245,7 @@
<string name="title_password">Password</string> <string name="title_password">Password</string>
<string name="title_password_storage">How are passwords stored?</string> <string name="title_password_storage">How are passwords stored?</string>
<string name="title_case_sensitive">Usernames and passwords are usually case sensitive</string> <string name="title_case_sensitive">Usernames and passwords are usually case sensitive</string>
<string name="title_login_before_send">Login before sending</string>
<string name="title_client_certificate">Client certificate</string> <string name="title_client_certificate">Client certificate</string>
<string name="title_realm">Realm</string> <string name="title_realm">Realm</string>
<string name="title_use_ip">Use local IP address instead of host name</string> <string name="title_use_ip">Use local IP address instead of host name</string>

Loading…
Cancel
Save