Search in sources :

Example 26 with Account

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

the class MessagingController method setFlagForThreadsInCache.

private void setFlagForThreadsInCache(final Account account, final List<Long> threadRootIds, final Flag flag, final boolean newState) {
    EmailProviderCache cache = EmailProviderCache.getCache(account.getUuid(), context);
    String columnName = LocalStore.getColumnNameForFlag(flag);
    String value = Integer.toString((newState) ? 1 : 0);
    cache.setValueForThreads(threadRootIds, columnName, value);
}
Also used : EmailProviderCache(com.fsck.k9.cache.EmailProviderCache)

Example 27 with Account

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

the class MessagingController method processPendingEmptyTrash.

void processPendingEmptyTrash(Account account) throws MessagingException {
    Store remoteStore = account.getRemoteStore();
    Folder remoteFolder = remoteStore.getFolder(account.getTrashFolderName());
    try {
        if (remoteFolder.exists()) {
            remoteFolder.open(Folder.OPEN_MODE_RW);
            remoteFolder.setFlags(Collections.singleton(Flag.DELETED), true);
            if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
                remoteFolder.expunge();
            }
            // When we empty trash, we need to actually synchronize the folder
            // or local deletes will never get cleaned up
            synchronizeFolder(account, remoteFolder, true, 0, null);
            compact(account, null);
        }
    } finally {
        closeFolder(remoteFolder);
    }
}
Also used : LocalStore(com.fsck.k9.mailstore.LocalStore) Store(com.fsck.k9.mail.Store) Pop3Store(com.fsck.k9.mail.store.pop3.Pop3Store) Folder(com.fsck.k9.mail.Folder) LocalFolder(com.fsck.k9.mailstore.LocalFolder)

Example 28 with Account

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

the class MlfUtils method getOpenFolder.

static LocalFolder getOpenFolder(String folderName, Account account) throws MessagingException {
    LocalStore localStore = account.getLocalStore();
    LocalFolder localFolder = localStore.getFolder(folderName);
    localFolder.open(Folder.OPEN_MODE_RO);
    return localFolder;
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 29 with Account

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

the class MessageListFragment method changeSort.

/**
     * Change the sort type and sort order used for the message list.
     *
     * @param sortType
     *         Specifies which field to use for sorting the message list.
     * @param sortAscending
     *         Specifies the sort order. If this argument is {@code null} the default search order
     *         for the sort type is used.
     */
// FIXME: Don't save the changes in the UI thread
private void changeSort(SortType sortType, Boolean sortAscending) {
    this.sortType = sortType;
    Account account = this.account;
    if (account != null) {
        account.setSortType(this.sortType);
        if (sortAscending == null) {
            this.sortAscending = account.isSortAscending(this.sortType);
        } else {
            this.sortAscending = sortAscending;
        }
        account.setSortAscending(this.sortType, this.sortAscending);
        sortDateAscending = account.isSortAscending(SortType.SORT_DATE);
        account.save(preferences);
    } else {
        K9.setSortType(this.sortType);
        if (sortAscending == null) {
            this.sortAscending = K9.isSortAscending(this.sortType);
        } else {
            this.sortAscending = sortAscending;
        }
        K9.setSortAscending(this.sortType, this.sortAscending);
        sortDateAscending = K9.isSortAscending(SortType.SORT_DATE);
        StorageEditor editor = preferences.getStorage().edit();
        K9.save(editor);
        editor.commit();
    }
    reSort();
}
Also used : Account(com.fsck.k9.Account) StorageEditor(com.fsck.k9.preferences.StorageEditor)

Example 30 with Account

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

the class MessageListFragment method groupMessagesByAccount.

private Map<Account, List<MessageReference>> groupMessagesByAccount(final List<MessageReference> messages) {
    Map<Account, List<MessageReference>> messagesByAccount = new HashMap<>();
    for (MessageReference message : messages) {
        Account account = preferences.getAccount(message.getAccountUuid());
        List<MessageReference> msgList = messagesByAccount.get(account);
        if (msgList == null) {
            msgList = new ArrayList<>();
            messagesByAccount.put(account, msgList);
        }
        msgList.add(message);
    }
    return messagesByAccount;
}
Also used : Account(com.fsck.k9.Account) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) MessageReference(com.fsck.k9.activity.MessageReference)

Aggregations

Account (com.fsck.k9.Account)122 Test (org.junit.Test)81 MessagingException (com.fsck.k9.mail.MessagingException)53 LocalFolder (com.fsck.k9.mailstore.LocalFolder)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)43 LocalStore (com.fsck.k9.mailstore.LocalStore)42 ArrayList (java.util.ArrayList)34 MessageReference (com.fsck.k9.activity.MessageReference)32 Message (com.fsck.k9.mail.Message)29 Folder (com.fsck.k9.mail.Folder)27 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)25 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)22 IOException (java.io.IOException)22 Cursor (android.database.Cursor)21 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)20 Store (com.fsck.k9.mail.Store)20 SearchAccount (com.fsck.k9.search.SearchAccount)20 PendingIntent (android.app.PendingIntent)19 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)19 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)18