Cloud sync: equals

pull/212/head
M66B 2 years ago
parent 94d7c74d27
commit 2eb9a5ade8

@ -562,7 +562,17 @@ public abstract class DB extends RoomDatabase {
" BEGIN" + " BEGIN" +
" UPDATE account SET last_modified = strftime('%s') * 1000" + " UPDATE account SET last_modified = strftime('%s') * 1000" +
" WHERE id = NEW.id" + " WHERE id = NEW.id" +
" AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" + " AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password)" +
" AND OLD.keep_alive_ok IS NEW.keep_alive_ok" +
" AND OLD.keep_alive_failed IS NEW.keep_alive_failed" +
" AND OLD.keep_alive_succeeded IS NEW.keep_alive_succeeded" +
" AND OLD.quota_usage IS NEW.quota_usage" +
" AND OLD.thread IS NEW.thread" +
" AND OLD.state IS NEW.state" +
" AND OLD.warning IS NEW.warning" +
" AND OLD.error IS NEW.error" +
" AND OLD.last_connected IS NEW.last_connected" +
" AND OLD.backoff_until IS NEW.backoff_until;" +
" END"); " END");
db.execSQL("CREATE TRIGGER IF NOT EXISTS identity_update" + db.execSQL("CREATE TRIGGER IF NOT EXISTS identity_update" +
@ -570,6 +580,9 @@ public abstract class DB extends RoomDatabase {
" BEGIN" + " BEGIN" +
" UPDATE identity SET last_modified = strftime('%s') * 1000" + " UPDATE identity SET last_modified = strftime('%s') * 1000" +
" WHERE id = NEW.id" + " WHERE id = NEW.id" +
" AND OLD.state IS NEW.state" +
" AND OLD.error IS NEW.error" +
" AND OLD.last_connected IS NEW.last_connected" +
" AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" + " AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" +
" END"); " END");
} }

@ -429,8 +429,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
} }
public static boolean areEqual(EntityAccount a1, EntityAccount other, boolean auth, boolean state) { public static boolean areEqual(EntityAccount a1, EntityAccount other, boolean auth, boolean state) {
return (Objects.equals(a1.uuid, other.uuid) && return (Objects.equals(a1.order, other.order) &&
Objects.equals(a1.order, other.order) && Objects.equals(a1.uuid, other.uuid) &&
a1.protocol.equals(other.protocol) && a1.protocol.equals(other.protocol) &&
a1.host.equals(other.host) && a1.host.equals(other.host) &&
a1.encryption.equals(other.encryption) && a1.encryption.equals(other.encryption) &&
@ -440,43 +440,57 @@ public class EntityAccount extends EntityOrder implements Serializable {
Objects.equals(a1.provider, other.provider) && Objects.equals(a1.provider, other.provider) &&
a1.user.equals(other.user) && a1.user.equals(other.user) &&
(!auth || a1.password.equals(other.password)) && (!auth || a1.password.equals(other.password)) &&
// certificate
Objects.equals(a1.certificate_alias, other.certificate_alias) && Objects.equals(a1.certificate_alias, other.certificate_alias) &&
Objects.equals(a1.realm, other.realm) && Objects.equals(a1.realm, other.realm) &&
Objects.equals(a1.fingerprint, other.fingerprint) &&
Objects.equals(a1.name, other.name) && Objects.equals(a1.name, other.name) &&
Objects.equals(a1.category, other.category) && Objects.equals(a1.category, other.category) &&
// signature
Objects.equals(a1.color, other.color) && Objects.equals(a1.color, other.color) &&
Objects.equals(a1.calendar, other.calendar) && Objects.equals(a1.calendar, other.calendar) &&
a1.synchronize.equals(other.synchronize) && a1.synchronize.equals(other.synchronize) &&
Objects.equals(a1.ondemand, other.ondemand) &&
Objects.equals(a1.poll_exempted, other.poll_exempted) &&
a1.primary.equals(other.primary) && a1.primary.equals(other.primary) &&
a1.notify.equals(other.notify) && a1.notify.equals(other.notify) &&
a1.browse.equals(other.browse) && a1.browse.equals(other.browse) &&
a1.leave_on_server.equals(other.leave_on_server) && a1.leave_on_server.equals(other.leave_on_server) &&
Objects.equals(a1.leave_deleted, other.leave_deleted) &&
a1.leave_on_device.equals(other.leave_on_device) && a1.leave_on_device.equals(other.leave_on_device) &&
Objects.equals(a1.max_messages, other.max_messages) && Objects.equals(a1.max_messages, other.max_messages) &&
a1.auto_seen.equals(other.auto_seen) && a1.auto_seen.equals(other.auto_seen) &&
// separator
Objects.equals(a1.swipe_left, other.swipe_left) && Objects.equals(a1.swipe_left, other.swipe_left) &&
Objects.equals(a1.swipe_right, other.swipe_right) && Objects.equals(a1.swipe_right, other.swipe_right) &&
Objects.equals(a1.move_to, other.move_to) &&
a1.poll_interval.equals(other.poll_interval) && a1.poll_interval.equals(other.poll_interval) &&
Objects.equals(a1.keep_alive_noop, other.keep_alive_noop) &&
(!state || Objects.equals(a1.keep_alive_ok, other.keep_alive_ok)) &&
(!state || Objects.equals(a1.keep_alive_failed, other.keep_alive_failed)) &&
(!state || Objects.equals(a1.keep_alive_succeeded, other.keep_alive_succeeded)) &&
a1.partial_fetch == other.partial_fetch && a1.partial_fetch == other.partial_fetch &&
a1.ignore_size == other.ignore_size && a1.ignore_size == other.ignore_size &&
a1.use_date == other.use_date && a1.use_date == other.use_date &&
a1.use_received == other.use_received && a1.use_received == other.use_received &&
// prefix
a1.unicode == other.unicode && a1.unicode == other.unicode &&
Objects.equals(a1.conditions, other.conditions) && Objects.equals(a1.conditions, other.conditions) &&
(!state || Objects.equals(a1.quota_usage, other.quota_usage)) && (!state || Objects.equals(a1.quota_usage, other.quota_usage)) &&
(!state || Objects.equals(a1.quota_limit, other.quota_limit)) && Objects.equals(a1.quota_limit, other.quota_limit) &&
(!state || Objects.equals(a1.created, other.created)) && Objects.equals(a1.created, other.created) &&
Objects.equals(a1.tbd, other.tbd) && Objects.equals(a1.tbd, other.tbd) &&
// thread
(!state || Objects.equals(a1.state, other.state)) && (!state || Objects.equals(a1.state, other.state)) &&
(!state || Objects.equals(a1.warning, other.warning)) && (!state || Objects.equals(a1.warning, other.warning)) &&
(!state || Objects.equals(a1.error, other.error)) && (!state || Objects.equals(a1.error, other.error)) &&
(!state || Objects.equals(a1.last_connected, other.last_connected)) && (!state || Objects.equals(a1.last_connected, other.last_connected)) &&
(!state || Objects.equals(a1.backoff_until, other.backoff_until)) && (!state || Objects.equals(a1.backoff_until, other.backoff_until)) &&
(!state || Objects.equals(a1.max_size, other.max_size)) && Objects.equals(a1.max_size, other.max_size) &&
(!state || Objects.equals(a1.capabilities, other.capabilities)) && Objects.equals(a1.capabilities, other.capabilities) &&
(!state || Objects.equals(a1.capability_idle, other.capability_idle)) && Objects.equals(a1.capability_idle, other.capability_idle) &&
(!state || Objects.equals(a1.capability_utf8, other.capability_utf8)) && Objects.equals(a1.capability_utf8, other.capability_utf8) &&
(!state || Objects.equals(a1.capability_uidl, other.capability_uidl)) && Objects.equals(a1.capability_uidl, other.capability_uidl) &&
(!state || Objects.equals(a1.last_modified, other.last_modified))); (!state || Objects.equals(a1.last_modified, other.last_modified)));
} }

@ -345,8 +345,10 @@ public class EntityIdentity {
Objects.equals(i1.provider, other.provider) && Objects.equals(i1.provider, other.provider) &&
i1.user.equals(other.user) && i1.user.equals(other.user) &&
(!auth || i1.password.equals(other.password)) && (!auth || i1.password.equals(other.password)) &&
// certificate
Objects.equals(i1.certificate_alias, other.certificate_alias) && Objects.equals(i1.certificate_alias, other.certificate_alias) &&
Objects.equals(i1.realm, other.realm) && Objects.equals(i1.realm, other.realm) &&
Objects.equals(i1.fingerprint, other.fingerprint) &&
i1.use_ip == other.use_ip && i1.use_ip == other.use_ip &&
Objects.equals(i1.ehlo, other.ehlo) && Objects.equals(i1.ehlo, other.ehlo) &&
i1.synchronize.equals(other.synchronize) && i1.synchronize.equals(other.synchronize) &&
@ -359,12 +361,23 @@ public class EntityIdentity {
Objects.equals(i1.cc, other.cc) && Objects.equals(i1.cc, other.cc) &&
Objects.equals(i1.bcc, other.bcc) && Objects.equals(i1.bcc, other.bcc) &&
Objects.equals(i1.internal, other.internal) && Objects.equals(i1.internal, other.internal) &&
Objects.equals(i1.unicode, other.unicode) &&
Objects.equals(i1.octetmime, other.octetmime) &&
// plain_only
Objects.equals(i1.sign_default, other.sign_default) &&
Objects.equals(i1.encrypt_default, other.encrypt_default) &&
Objects.equals(i1.encrypt, other.encrypt) &&
// delivery_receipt
// read_receipt
// store_sent
// sent_folder
Objects.equals(i1.sign_key, other.sign_key) && Objects.equals(i1.sign_key, other.sign_key) &&
Objects.equals(i1.sign_key_alias, other.sign_key_alias) && Objects.equals(i1.sign_key_alias, other.sign_key_alias) &&
Objects.equals(i1.tbd, other.tbd) &&
(!state || Objects.equals(i1.state, other.state)) && (!state || Objects.equals(i1.state, other.state)) &&
(!state || Objects.equals(i1.error, other.error)) && (!state || Objects.equals(i1.error, other.error)) &&
(!state || Objects.equals(i1.last_connected, other.last_connected)) && (!state || Objects.equals(i1.last_connected, other.last_connected)) &&
(!state || Objects.equals(i1.max_size, other.max_size)) && Objects.equals(i1.max_size, other.max_size) &&
(!state || Objects.equals(i1.last_modified, other.last_modified))); (!state || Objects.equals(i1.last_modified, other.last_modified)));
} }

Loading…
Cancel
Save