use of com.fsck.k9.mailstore.FolderDetailsAccessor in project k-9 by k9mail.
the class MessagingController method syncFolder.
private void syncFolder(Account account, long folderId, boolean notify, MessagingListener listener, Backend backend, NotificationState notificationState) {
ServerSettings serverSettings = account.getIncomingServerSettings();
if (serverSettings.isMissingCredentials()) {
handleAuthenticationFailure(account, true);
return;
}
Exception commandException = null;
try {
processPendingCommandsSynchronous(account);
} catch (Exception e) {
Timber.e(e, "Failure processing command, but allow message sync attempt");
commandException = e;
}
LocalFolder localFolder;
try {
LocalStore localStore = localStoreProvider.getInstance(account);
localFolder = localStore.getFolder(folderId);
localFolder.open();
} catch (MessagingException e) {
Timber.e(e, "syncFolder: Couldn't load local folder %d", folderId);
return;
}
// We can't sync local folders
if (localFolder.isLocalOnly()) {
return;
}
final boolean suppressNotifications;
if (notify) {
MessageStore messageStore = messageStoreManager.getMessageStore(account);
Long lastChecked = messageStore.getFolder(folderId, FolderDetailsAccessor::getLastChecked);
suppressNotifications = lastChecked == null;
} else {
suppressNotifications = true;
}
String folderServerId = localFolder.getServerId();
SyncConfig syncConfig = createSyncConfig(account);
ControllerSyncListener syncListener = new ControllerSyncListener(account, listener, suppressNotifications, notificationState);
backend.sync(folderServerId, syncConfig, syncListener);
if (commandException != null && !syncListener.syncFailed) {
String rootMessage = getRootCauseMessage(commandException);
Timber.e("Root cause failure in %s:%s was '%s'", account, folderServerId, rootMessage);
updateFolderStatus(account, folderServerId, rootMessage);
listener.synchronizeMailboxFailed(account, folderId, rootMessage);
}
}
Aggregations