Persist account capabilities

pull/199/head
M66B 3 years ago
parent 27942e1e0d
commit 3c1f44f1b1

File diff suppressed because it is too large Load Diff

@ -65,7 +65,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 198,
version = 199,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2028,6 +2028,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `message` ADD COLUMN `show_full` INTEGER NOT NULL DEFAULT 0");
}
}).addMigrations(new Migration(198, 199) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `capability_idle` INTEGER");
db.execSQL("ALTER TABLE `account` ADD COLUMN `capability_utf8` INTEGER");
}
}).addMigrations(new Migration(199, 200) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);

@ -184,6 +184,12 @@ public interface DaoAccount {
@Query("UPDATE account SET max_size = :max_size WHERE id = :id AND NOT (max_size IS :max_size)")
int setAccountMaxSize(long id, Long max_size);
@Query("UPDATE account" +
" SET capability_idle = :idle, capability_utf8 = :utf8" +
" WHERE id = :id" +
" AND NOT (capability_idle IS :idle AND capability_utf8 IS :utf8)")
int setAccountCapabilities(long id, Boolean idle, Boolean utf8);
@Query("UPDATE account SET warning = :warning WHERE id = :id AND NOT (warning IS :warning)")
int setAccountWarning(long id, String warning);

@ -146,6 +146,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
public Long last_connected;
public Long backoff_until;
public Long max_size;
public Boolean capability_idle;
public Boolean capability_utf8;
boolean isGmail() {
return "imap.gmail.com".equalsIgnoreCase(host);

@ -695,7 +695,9 @@ public class FragmentAccount extends FragmentBase {
certificate, fingerprint);
result.idle = iservice.hasCapability("IDLE");
result.utf8 = iservice.hasCapability("UTF8=ACCEPT");
result.utf8 =
iservice.hasCapability("UTF8=ACCEPT") ||
iservice.hasCapability("UTF8=ONLY");
for (Folder ifolder : iservice.getStore().getDefaultFolder().list("*")) {
// Check folder attributes

@ -1282,6 +1282,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
// https://tools.ietf.org/html/rfc2177
final boolean capIdle = iservice.hasCapability("IDLE");
final boolean capUtf8 =
iservice.hasCapability("UTF8=ACCEPT") ||
iservice.hasCapability("UTF8=ONLY");
Log.i(account.name + " idle=" + capIdle);
if (!capIdle || account.poll_interval < OPTIMIZE_KEEP_ALIVE_INTERVAL)
optimizeAccount(account, "IDLE");
@ -1289,6 +1292,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
final boolean capNotify = iservice.hasCapability("NOTIFY");
db.account().setAccountState(account.id, "connected");
db.account().setAccountCapabilities(account.id, capIdle, capUtf8);
db.account().setAccountError(account.id, null);
db.account().setAccountWarning(account.id, null);

Loading…
Cancel
Save