Search in sources :

Example 6 with MessagingException

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

the class LocalFolder method setLastPush.

@Override
public void setLastPush(final long lastChecked) throws MessagingException {
    try {
        open(OPEN_MODE_RW);
        LocalFolder.super.setLastPush(lastChecked);
    } catch (MessagingException e) {
        throw new WrappedException(e);
    }
    updateFolderColumn("last_pushed", lastChecked);
}
Also used : WrappedException(com.fsck.k9.mailstore.LockableDatabase.WrappedException) MessagingException(com.fsck.k9.mail.MessagingException)

Example 7 with MessagingException

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

the class LocalFolder method setLastChecked.

@Override
public void setLastChecked(final long lastChecked) throws MessagingException {
    try {
        open(OPEN_MODE_RW);
        LocalFolder.super.setLastChecked(lastChecked);
    } catch (MessagingException e) {
        throw new WrappedException(e);
    }
    updateFolderColumn("last_updated", lastChecked);
}
Also used : WrappedException(com.fsck.k9.mailstore.LockableDatabase.WrappedException) MessagingException(com.fsck.k9.mail.MessagingException)

Example 8 with MessagingException

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

the class MessagingController method downloadSaneBody.

private void downloadSaneBody(Account account, Folder remoteFolder, LocalFolder localFolder, Message message) throws MessagingException {
    /*
         * The provider was unable to get the structure of the message, so
         * we'll download a reasonable portion of the messge and mark it as
         * incomplete so the entire thing can be downloaded later if the user
         * wishes to download it.
         */
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.BODY_SANE);
    /*
                 *  TODO a good optimization here would be to make sure that all Stores set
                 *  the proper size after this fetch and compare the before and after size. If
                 *  they equal we can mark this SYNCHRONIZED instead of PARTIALLY_SYNCHRONIZED
                 */
    remoteFolder.fetch(Collections.singletonList(message), fp, null);
    // Store the updated message locally
    localFolder.appendMessages(Collections.singletonList(message));
    Message localMessage = localFolder.getMessage(message.getUid());
    // Certain (POP3) servers give you the whole message even when you ask for only the first x Kb
    if (!message.isSet(Flag.X_DOWNLOADED_FULL)) {
        /*
                     * Mark the message as fully downloaded if the message size is smaller than
                     * the account's autodownload size limit, otherwise mark as only a partial
                     * download.  This will prevent the system from downloading the same message
                     * twice.
                     *
                     * If there is no limit on autodownload size, that's the same as the message
                     * being smaller than the max size
                     */
        if (account.getMaximumAutoDownloadMessageSize() == 0 || message.getSize() < account.getMaximumAutoDownloadMessageSize()) {
            localMessage.setFlag(Flag.X_DOWNLOADED_FULL, true);
        } else {
            // Set a flag indicating that the message has been partially downloaded and
            // is ready for view.
            localMessage.setFlag(Flag.X_DOWNLOADED_PARTIAL, true);
        }
    }
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile) LocalMessage(com.fsck.k9.mailstore.LocalMessage) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message)

Example 9 with MessagingException

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

the class MessagingController method moveMessageToDraftsFolder.

private void moveMessageToDraftsFolder(Account account, Folder localFolder, Store localStore, Message message) throws MessagingException {
    LocalFolder draftsFolder = (LocalFolder) localStore.getFolder(account.getDraftsFolderName());
    localFolder.moveMessages(Collections.singletonList(message), draftsFolder);
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder)

Example 10 with MessagingException

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

the class MessagingController method syncFlags.

private boolean syncFlags(LocalMessage localMessage, Message remoteMessage) throws MessagingException {
    boolean messageChanged = false;
    if (localMessage == null || localMessage.isSet(Flag.DELETED)) {
        return false;
    }
    if (remoteMessage.isSet(Flag.DELETED)) {
        if (localMessage.getFolder().syncRemoteDeletions()) {
            localMessage.setFlag(Flag.DELETED, true);
            messageChanged = true;
        }
    } else {
        for (Flag flag : MessagingController.SYNC_FLAGS) {
            if (remoteMessage.isSet(flag) != localMessage.isSet(flag)) {
                localMessage.setFlag(flag, remoteMessage.isSet(flag));
                messageChanged = true;
            }
        }
    }
    return messageChanged;
}
Also used : PendingSetFlag(com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag) Flag(com.fsck.k9.mail.Flag)

Aggregations

MessagingException (com.fsck.k9.mail.MessagingException)159 Test (org.junit.Test)73 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)52 LocalFolder (com.fsck.k9.mailstore.LocalFolder)49 LocalStore (com.fsck.k9.mailstore.LocalStore)49 ArrayList (java.util.ArrayList)49 Message (com.fsck.k9.mail.Message)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)42 IOException (java.io.IOException)42 FetchProfile (com.fsck.k9.mail.FetchProfile)30 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)28 ByteArrayOutputStream (java.io.ByteArrayOutputStream)27 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)26 BodyPart (com.fsck.k9.mail.BodyPart)23 Part (com.fsck.k9.mail.Part)22 Account (com.fsck.k9.Account)21 Body (com.fsck.k9.mail.Body)21 TextBody (com.fsck.k9.mail.internet.TextBody)21 Date (java.util.Date)20 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)18