Search in sources :

Example 71 with LocalFolder

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

the class SqlQueryBuilder method getFolderId.

private static long getFolderId(Account account, String folderName) {
    long folderId = 0;
    try {
        LocalStore localStore = account.getLocalStore();
        LocalFolder folder = localStore.getFolder(folderName);
        folder.open(Folder.OPEN_MODE_RO);
        folderId = folder.getId();
    } catch (MessagingException e) {
        //FIXME
        e.printStackTrace();
    }
    return folderId;
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) MessagingException(com.fsck.k9.mail.MessagingException) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 72 with LocalFolder

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

the class MessagingController method actOnMessageGroup.

private void actOnMessageGroup(Account account, long folderId, List<MessageReference> messageReferences, MessageActor actor) {
    try {
        LocalFolder messageFolder = localStoreProvider.getInstance(account).getFolder(folderId);
        List<LocalMessage> localMessages = messageFolder.getMessagesByReference(messageReferences);
        actor.act(account, messageFolder, localMessages);
    } catch (MessagingException e) {
        Timber.e(e, "Error loading account?!");
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) LocalMessage(com.fsck.k9.mailstore.LocalMessage) MessagingException(com.fsck.k9.mail.MessagingException)

Example 73 with LocalFolder

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

the class MessagingController method loadMessageMetadata.

public LocalMessage loadMessageMetadata(Account account, long folderId, String uid) throws MessagingException {
    LocalStore localStore = localStoreProvider.getInstance(account);
    LocalFolder localFolder = localStore.getFolder(folderId);
    localFolder.open();
    LocalMessage message = localFolder.getMessage(uid);
    if (message == null || message.getDatabaseId() == 0) {
        String folderName = localFolder.getName();
        throw new IllegalArgumentException("Message not found: folder=" + folderName + ", uid=" + uid);
    }
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.ENVELOPE);
    localFolder.fetch(Collections.singletonList(message), fp, null);
    return message;
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) LocalMessage(com.fsck.k9.mailstore.LocalMessage) FetchProfile(com.fsck.k9.mail.FetchProfile) LocalStore(com.fsck.k9.mailstore.LocalStore)

Example 74 with LocalFolder

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

the class MessagingController method clearFolderSynchronous.

@VisibleForTesting
protected void clearFolderSynchronous(Account account, long folderId) {
    try {
        LocalFolder localFolder = localStoreProvider.getInstance(account).getFolder(folderId);
        localFolder.open();
        localFolder.clearAllMessages();
    } catch (Exception e) {
        Timber.e(e, "clearFolder failed");
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) CertificateValidationException(com.fsck.k9.mail.CertificateValidationException) MessagingException(com.fsck.k9.mail.MessagingException) AuthenticationFailedException(com.fsck.k9.mail.AuthenticationFailedException) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 75 with LocalFolder

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

the class MessagingController method deleteDraft.

public void deleteDraft(final Account account, long id) {
    try {
        Long folderId = account.getDraftsFolderId();
        if (folderId == null) {
            Timber.w("No Drafts folder configured. Can't delete draft.");
            return;
        }
        LocalStore localStore = localStoreProvider.getInstance(account);
        LocalFolder localFolder = localStore.getFolder(folderId);
        localFolder.open();
        String uid = localFolder.getMessageUidById(id);
        if (uid != null) {
            MessageReference messageReference = new MessageReference(account.getUuid(), folderId, uid);
            deleteMessage(messageReference);
        }
    } catch (MessagingException me) {
        Timber.e(me, "Error deleting draft");
    }
}
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