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 // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 168, version = 169,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -1656,6 +1656,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `self` INTEGER NOT NULL DEFAULT 1"); 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") @Query("UPDATE identity SET sign_key_alias = :alias WHERE id = :id")
int setIdentitySignKeyAlias(long id, String alias); 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") @Query("UPDATE identity SET error = :error WHERE id = :id")
int setIdentityError(long id, String error); int setIdentityError(long id, String error);

@ -634,6 +634,17 @@ public class EmailService implements AutoCloseable {
return (SMTPTransport) iservice; 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 { boolean hasCapability(String capability) throws MessagingException {
Store store = getStore(); Store store = getStore();
if (store instanceof IMAPStore) if (store instanceof IMAPStore)

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

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

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

@ -555,6 +555,10 @@ public class ServiceSend extends ServiceBase {
throw new IOException("Test"); throw new IOException("Test");
db.identity().setIdentityState(ident.id, "connected"); 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(); Address[] to = imessage.getAllRecipients();
String via = "via " + ident.host + "/" + ident.user + String via = "via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to); " to " + TextUtils.join(", ", to);

Loading…
Cancel
Save