Search in sources :

Example 46 with LocalFolder

use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.

the class MessagingController method processPendingDelete.

void processPendingDelete(PendingDelete command, Account account) throws MessagingException {
    long folderId = command.folderId;
    List<String> uids = command.uids;
    Backend backend = getBackend(account);
    String folderServerId = getFolderServerId(account, folderId);
    backend.deleteMessages(folderServerId, uids);
    if (backend.getSupportsExpunge() && account.getExpungePolicy() == Expunge.EXPUNGE_IMMEDIATELY) {
        backend.expungeMessages(folderServerId, uids);
    }
    LocalStore localStore = localStoreProvider.getInstance(account);
    LocalFolder localFolder = localStore.getFolder(folderId);
    localFolder.open();
    destroyPlaceholderMessages(localFolder, uids);
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) Backend(com.fsck.k9.backend.api.Backend) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 47 with LocalFolder

use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.

the class MessagingController method updateFolderStatus.

private void updateFolderStatus(Account account, String folderServerId, String status) {
    try {
        LocalStore localStore = localStoreProvider.getInstance(account);
        LocalFolder localFolder = localStore.getFolder(folderServerId);
        localFolder.setStatus(status);
    } catch (MessagingException e) {
        Timber.w(e, "Couldn't update folder status for folder %s", folderServerId);
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) MessagingException(com.fsck.k9.mail.MessagingException) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 48 with LocalFolder

use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.

the class MessagingController method processPendingEmptyTrash.

void processPendingEmptyTrash(Account account) throws MessagingException {
    if (!account.hasTrashFolder()) {
        return;
    }
    long trashFolderId = account.getTrashFolderId();
    LocalStore localStore = localStoreProvider.getInstance(account);
    LocalFolder folder = localStore.getFolder(trashFolderId);
    folder.open();
    String trashFolderServerId = folder.getServerId();
    Backend backend = getBackend(account);
    backend.deleteAllMessages(trashFolderServerId);
    if (account.getExpungePolicy() == Expunge.EXPUNGE_IMMEDIATELY && backend.getSupportsExpunge()) {
        backend.expunge(trashFolderServerId);
    }
    // Remove all messages marked as deleted
    folder.destroyDeletedMessages();
    compact(account, null);
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) Backend(com.fsck.k9.backend.api.Backend) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 49 with LocalFolder

use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.

the class MessagingController method loadMoreMessages.

public void loadMoreMessages(Account account, long folderId, MessagingListener listener) {
    try {
        LocalStore localStore = localStoreProvider.getInstance(account);
        LocalFolder localFolder = localStore.getFolder(folderId);
        if (localFolder.getVisibleLimit() > 0) {
            localFolder.setVisibleLimit(localFolder.getVisibleLimit() + account.getDisplayCount());
        }
        synchronizeMailbox(account, folderId, false, listener);
    } catch (MessagingException me) {
        throw new RuntimeException("Unable to set visible limit on folder", me);
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) MessagingException(com.fsck.k9.mail.MessagingException) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 50 with LocalFolder

use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.

the class MessagingController method loadSearchResults.

public void loadSearchResults(Account account, long folderId, List<String> messageServerIds, MessagingListener listener) {
    threadPool.execute(() -> {
        if (listener != null) {
            listener.enableProgressIndicator(true);
        }
        try {
            LocalStore localStore = localStoreProvider.getInstance(account);
            LocalFolder localFolder = localStore.getFolder(folderId);
            if (!localFolder.exists()) {
                throw new MessagingException("Folder not found");
            }
            localFolder.open();
            loadSearchResultsSynchronous(account, messageServerIds, localFolder);
        } catch (MessagingException e) {
            Timber.e(e, "Exception in loadSearchResults");
        } finally {
            if (listener != null) {
                listener.enableProgressIndicator(false);
            }
        }
    });
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) MessagingException(com.fsck.k9.mail.MessagingException) LocalStore(com.fsck.k9.mailstore.LocalStore)

Aggregations

LocalFolder (com.fsck.k9.mailstore.LocalFolder)62 LocalStore (com.fsck.k9.mailstore.LocalStore)47 MessagingException (com.fsck.k9.mail.MessagingException)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)40 Message (com.fsck.k9.mail.Message)20 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)20 Folder (com.fsck.k9.mail.Folder)17 FetchProfile (com.fsck.k9.mail.FetchProfile)15 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)13 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)13 ArrayList (java.util.ArrayList)13 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)11 SuppressLint (android.annotation.SuppressLint)10 Backend (com.fsck.k9.backend.api.Backend)10 Store (com.fsck.k9.mail.Store)10 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)10 IOException (java.io.IOException)9 Date (java.util.Date)9 Test (org.junit.Test)9 Account (com.fsck.k9.Account)7