use of com.fsck.k9.mail.store.webdav.WebDavFolder in project k-9 by k9mail.
the class WebDavSync method fetchUnsyncedMessages.
private void fetchUnsyncedMessages(final SyncConfig syncConfig, final WebDavFolder remoteFolder, List<WebDavMessage> unsyncedMessages, final List<WebDavMessage> smallMessages, final List<WebDavMessage> largeMessages, final AtomicInteger progress, final int todo, FetchProfile fp, final SyncListener listener) throws MessagingException {
final String folder = remoteFolder.getServerId();
final Date earliestDate = syncConfig.getEarliestPollDate();
remoteFolder.fetch(unsyncedMessages, fp, new MessageRetrievalListener<WebDavMessage>() {
@Override
public void messageFinished(WebDavMessage message, int number, int ofTotal) {
try {
if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) {
if (message.isSet(Flag.DELETED)) {
Timber.v("Newly downloaded message %s:%s:%s was marked deleted on server, " + "skipping", accountName, folder, message.getUid());
} else {
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
listener.syncProgress(folder, progress.get(), todo);
return;
}
if (syncConfig.getMaximumAutoDownloadMessageSize() > 0 && message.getSize() > syncConfig.getMaximumAutoDownloadMessageSize()) {
largeMessages.add(message);
} else {
smallMessages.add(message);
}
} catch (Exception e) {
Timber.e(e, "Error while storing downloaded message.");
}
}
@Override
public void messageStarted(String uid, int number, int ofTotal) {
}
@Override
public void messagesFinished(int total) {
// FIXME this method is almost never invoked by various Stores! Don't rely on it unless fixed!!
}
}, syncConfig.getMaximumAutoDownloadMessageSize());
}
Aggregations