use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method queueMoveOrCopy.
private void queueMoveOrCopy(Account account, String srcFolder, String destFolder, boolean isCopy, List<String> uids, Map<String, String> uidMap) {
if (uidMap == null || uidMap.isEmpty()) {
queueMoveOrCopy(account, srcFolder, destFolder, isCopy, uids);
} else {
if (account.getErrorFolderName().equals(srcFolder)) {
return;
}
PendingCommand command = PendingMoveOrCopy.create(srcFolder, destFolder, isCopy, uidMap);
queuePendingCommand(account, command);
}
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method notifyUserIfCertificateProblem.
public void notifyUserIfCertificateProblem(Account account, Exception exception, boolean incoming) {
if (!(exception instanceof CertificateValidationException)) {
return;
}
CertificateValidationException cve = (CertificateValidationException) exception;
if (!cve.needsUserAttention()) {
return;
}
notificationController.showCertificateErrorNotification(account, incoming);
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method listFoldersSynchronous.
/**
* Lists folders that are available locally and remotely. This method calls
* listFoldersCallback for local folders before it returns, and then for
* remote folders at some later point. If there are no local folders
* includeRemote is forced by this method. This method is called in the
* foreground.
* TODO this needs to cache the remote folder list
*/
public void listFoldersSynchronous(final Account account, final boolean refreshRemote, final MessagingListener listener) {
for (MessagingListener l : getListeners(listener)) {
l.listFoldersStarted(account);
}
List<LocalFolder> localFolders = null;
if (!account.isAvailable(context)) {
Timber.i("not listing folders of unavailable account");
} else {
try {
LocalStore localStore = account.getLocalStore();
localFolders = localStore.getPersonalNamespaces(false);
if (refreshRemote || localFolders.isEmpty()) {
doRefreshRemote(account, listener);
return;
}
for (MessagingListener l : getListeners(listener)) {
l.listFolders(account, localFolders);
}
} catch (Exception e) {
for (MessagingListener l : getListeners(listener)) {
l.listFoldersFailed(account, e.getMessage());
}
addErrorMessage(account, null, e);
return;
} finally {
if (localFolders != null) {
for (Folder localFolder : localFolders) {
closeFolder(localFolder);
}
}
}
}
for (MessagingListener l : getListeners(listener)) {
l.listFoldersFinished(account);
}
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method refreshRemoteSynchronous.
@VisibleForTesting
void refreshRemoteSynchronous(final Account account, final MessagingListener listener) {
List<LocalFolder> localFolders = null;
try {
Store store = account.getRemoteStore();
List<? extends Folder> remoteFolders = store.getPersonalNamespaces(false);
LocalStore localStore = account.getLocalStore();
Set<String> remoteFolderNames = new HashSet<>();
List<LocalFolder> foldersToCreate = new LinkedList<>();
localFolders = localStore.getPersonalNamespaces(false);
Set<String> localFolderNames = new HashSet<>();
for (Folder localFolder : localFolders) {
localFolderNames.add(localFolder.getName());
}
for (Folder remoteFolder : remoteFolders) {
if (!localFolderNames.contains(remoteFolder.getName())) {
LocalFolder localFolder = localStore.getFolder(remoteFolder.getName());
foldersToCreate.add(localFolder);
}
remoteFolderNames.add(remoteFolder.getName());
}
localStore.createFolders(foldersToCreate, account.getDisplayCount());
localFolders = localStore.getPersonalNamespaces(false);
/*
* Clear out any folders that are no longer on the remote store.
*/
for (Folder localFolder : localFolders) {
String localFolderName = localFolder.getName();
// special placeholder folder "-NONE-".
if (K9.FOLDER_NONE.equals(localFolderName)) {
localFolder.delete(false);
}
if (!account.isSpecialFolder(localFolderName) && !remoteFolderNames.contains(localFolderName)) {
localFolder.delete(false);
}
}
localFolders = localStore.getPersonalNamespaces(false);
for (MessagingListener l : getListeners(listener)) {
l.listFolders(account, localFolders);
}
for (MessagingListener l : getListeners(listener)) {
l.listFoldersFinished(account);
}
} catch (Exception e) {
for (MessagingListener l : getListeners(listener)) {
l.listFoldersFailed(account, "");
}
addErrorMessage(account, null, e);
} finally {
if (localFolders != null) {
for (Folder localFolder : localFolders) {
closeFolder(localFolder);
}
}
}
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class MessagingController method removeFlagFromCache.
private void removeFlagFromCache(final Account account, final List<Long> messageIds, final Flag flag) {
EmailProviderCache cache = EmailProviderCache.getCache(account.getUuid(), context);
String columnName = LocalStore.getColumnNameForFlag(flag);
cache.removeValueForMessages(messageIds, columnName);
}
Aggregations