Remove ImapSync's dependency on K9

This commit is contained in:
cketti 2018-06-02 15:13:18 +02:00
parent 478b740d8b
commit 0fb76aa93b
5 changed files with 22 additions and 11 deletions

View file

@ -30,4 +30,9 @@ interface BackendFolder {
FALSE,
TRUE
}
companion object {
// TODO: Change the interface to be able to hide this (ugly) implementation detail.
const val LOCAL_UID_PREFIX = "K9LOCAL:"
}
}

View file

@ -8,6 +8,7 @@ data class SyncConfig(
val earliestPollDate: Date?,
val syncRemoteDeletions: Boolean,
val maximumAutoDownloadMessageSize: Int,
val defaultVisibleLimit: Int,
val syncFlags: Set<Flag>
) {
enum class ExpungePolicy {

View file

@ -801,6 +801,7 @@ public class MessagingController {
account.getEarliestPollDate(),
account.syncRemoteDeletions(),
account.getMaximumAutoDownloadMessageSize(),
K9.DEFAULT_VISIBLE_LIMIT,
SYNC_FLAGS);
ControllerSyncListener syncListener = new ControllerSyncListener(account, listener);

View file

@ -12,7 +12,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import com.fsck.k9.K9;
import com.fsck.k9.backend.api.BackendFolder;
import com.fsck.k9.backend.api.BackendFolder.MoreMessages;
import com.fsck.k9.backend.api.BackendStorage;
@ -125,7 +124,7 @@ class ImapSync {
int visibleLimit = backendFolder.getVisibleLimit();
if (visibleLimit < 0) {
visibleLimit = K9.DEFAULT_VISIBLE_LIMIT;
visibleLimit = syncConfig.getDefaultVisibleLimit();
}
final List<Message> remoteMessages = new ArrayList<>();
@ -184,7 +183,8 @@ class ImapSync {
if (syncConfig.getSyncRemoteDeletions()) {
List<String> destroyMessageUids = new ArrayList<>();
for (String localMessageUid : localUidMap.keySet()) {
if (!localMessageUid.startsWith(K9.LOCAL_UID_PREFIX) && remoteUidMap.get(localMessageUid) == null) {
if (!localMessageUid.startsWith(BackendFolder.LOCAL_UID_PREFIX) &&
remoteUidMap.get(localMessageUid) == null) {
destroyMessageUids.add(localMessageUid);
}
}
@ -461,7 +461,6 @@ class ImapSync {
public void messageFinished(T message, int number, int ofTotal) {
try {
if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) {
if (K9.isDebug()) {
if (message.isSet(Flag.DELETED)) {
Timber.v("Newly downloaded message %s:%s:%s was marked deleted on server, " +
"skipping", accountName, folder, message.getUid());
@ -469,7 +468,7 @@ class ImapSync {
Timber.d("Newly downloaded message %s is older than %s, skipping",
message.getUid(), earliestDate);
}
}
progress.incrementAndGet();
//TODO: This might be the source of poll count errors in the UI. Is todo always the same as ofTotal

View file

@ -7,6 +7,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.fsck.k9.K9;
import com.fsck.k9.RobolectricTest;
import com.fsck.k9.backend.api.BackendFolder;
import com.fsck.k9.backend.api.BackendStorage;
@ -349,6 +350,7 @@ public class ImapSyncTest extends RobolectricTest {
null,
true,
MAXIMUM_SMALL_MESSAGE_SIZE,
K9.DEFAULT_VISIBLE_LIMIT,
MessagingController.SYNC_FLAGS);
}
@ -367,6 +369,7 @@ public class ImapSyncTest extends RobolectricTest {
syncConfig.getEarliestPollDate(),
syncConfig.getSyncRemoteDeletions(),
syncConfig.getMaximumAutoDownloadMessageSize(),
syncConfig.getDefaultVisibleLimit(),
syncConfig.getSyncFlags());
}
@ -376,6 +379,7 @@ public class ImapSyncTest extends RobolectricTest {
syncConfig.getEarliestPollDate(),
syncRemoteDeletions,
syncConfig.getMaximumAutoDownloadMessageSize(),
syncConfig.getDefaultVisibleLimit(),
syncConfig.getSyncFlags());
}
@ -385,6 +389,7 @@ public class ImapSyncTest extends RobolectricTest {
earliestPollDate,
true,
syncConfig.getMaximumAutoDownloadMessageSize(),
syncConfig.getDefaultVisibleLimit(),
syncConfig.getSyncFlags());
}
}