Fetch SMTP max message size

pull/183/head
M66B 5 years ago
parent e109fa4b46
commit b39ed003b6

File diff suppressed because it is too large Load Diff

@ -61,7 +61,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 168,
version = 169,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1656,6 +1656,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `self` INTEGER NOT NULL DEFAULT 1");
}
})
.addMigrations(new Migration(168, 169) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `max_size` INTEGER");
}
});
}

@ -112,6 +112,9 @@ public interface DaoIdentity {
@Query("UPDATE identity SET sign_key_alias = :alias WHERE id = :id")
int setIdentitySignKeyAlias(long id, String alias);
@Query("UPDATE identity SET max_size = :max_size WHERE id = :id")
int setIdentityMaxSize(long id, Integer max_size);
@Query("UPDATE identity SET error = :error WHERE id = :id")
int setIdentityError(long id, String error);

@ -634,6 +634,17 @@ public class EmailService implements AutoCloseable {
return (SMTPTransport) iservice;
}
Integer getMaxSize() {
SMTPTransport transport = getTransport();
String size = transport.getExtensionParameter("SIZE");
if (!TextUtils.isEmpty(size) && TextUtils.isDigitsOnly(size))
return Integer.parseInt(size);
return null;
}
boolean hasCapability(String capability) throws MessagingException {
Store store = getStore();
if (store instanceof IMAPStore)

@ -116,6 +116,7 @@ public class EntityIdentity {
public String state;
public String error;
public Long last_connected;
public Integer max_size;
String getProtocol() {
return (starttls ? "smtp" : "smtps");
@ -294,7 +295,8 @@ public class EntityIdentity {
Objects.equals(this.sign_key_alias, other.sign_key_alias) &&
Objects.equals(this.state, other.state) &&
Objects.equals(this.error, other.error) &&
Objects.equals(this.last_connected, other.last_connected));
Objects.equals(this.last_connected, other.last_connected) &&
Objects.equals(this.max_size, other.max_size));
} else
return false;
}

@ -1037,7 +1037,8 @@ public class FragmentAccount extends FragmentBase {
!account.password.equals(password) ||
!Objects.equals(account.certificate_alias, certificate) ||
!Objects.equals(realm, accountRealm) ||
!Objects.equals(account.fingerprint, fingerprint)));
!Objects.equals(account.fingerprint, fingerprint) ||
BuildConfig.DEBUG));
Log.i("Account check=" + check);
Long last_connected = null;

@ -817,7 +817,8 @@ public class FragmentIdentity extends FragmentBase {
!Objects.equals(realm, identityRealm) ||
!Objects.equals(fingerprint, identity.fingerprint) ||
use_ip != identity.use_ip ||
!Objects.equals(ehlo, identity.ehlo)));
!Objects.equals(ehlo, identity.ehlo) ||
BuildConfig.DEBUG));
Log.i("Identity check=" + check);
Long last_connected = null;
@ -825,6 +826,7 @@ public class FragmentIdentity extends FragmentBase {
last_connected = identity.last_connected;
// Check SMTP server
Integer max_size = null;
if (check) {
// Create transport
String protocol = (starttls ? "smtp" : "smtps");
@ -836,6 +838,7 @@ public class FragmentIdentity extends FragmentBase {
auth, provider,
user, password,
certificate, fingerprint);
max_size = iservice.getMaxSize();
}
}
@ -888,6 +891,8 @@ public class FragmentIdentity extends FragmentBase {
identity.sign_key_alias = null;
identity.error = null;
identity.last_connected = last_connected;
if (max_size != null)
identity.max_size = max_size;
if (identity.primary)
db.identity().resetPrimary(account);

@ -555,6 +555,10 @@ public class ServiceSend extends ServiceBase {
throw new IOException("Test");
db.identity().setIdentityState(ident.id, "connected");
Integer max_size = iservice.getMaxSize();
if (max_size != null)
db.identity().setIdentityMaxSize(ident.id, max_size);
Address[] to = imessage.getAllRecipients();
String via = "via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to);

Loading…
Cancel
Save