Search in sources :

Example 26 with LocalMessage

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

the class MessageLoaderHelper method startOrResumeCryptoOperation.

// process with crypto helper
private void startOrResumeCryptoOperation() {
    RetainFragment<MessageCryptoHelper> retainCryptoHelperFragment = getMessageCryptoHelperRetainFragment(true);
    if (retainCryptoHelperFragment.hasData()) {
        messageCryptoHelper = retainCryptoHelperFragment.getData();
    }
    if (messageCryptoHelper == null || messageCryptoHelper.isConfiguredForOutdatedCryptoProvider()) {
        messageCryptoHelper = new MessageCryptoHelper(context);
        retainCryptoHelperFragment.setData(messageCryptoHelper);
    }
    messageCryptoHelper.asyncStartOrResumeProcessingMessage(localMessage, messageCryptoCallback, cachedDecryptionResult);
}
Also used : MessageCryptoHelper(com.fsck.k9.ui.crypto.MessageCryptoHelper)

Example 27 with LocalMessage

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

the class ReconstructMessageFromDatabaseTest method testThatByteIdenticalCopyOfMessageIsReconstructed.

public void testThatByteIdenticalCopyOfMessageIsReconstructed() throws IOException, MessagingException {
    LocalFolder folder = createFolderInDatabase();
    MimeMessage message = parseMessage();
    saveMessageToDatabase(folder, message);
    LocalMessage localMessage = readMessageFromDatabase(folder, message);
    String reconstructedMessage = writeMessageToString(localMessage);
    assertEquals(MESSAGE_SOURCE, reconstructedMessage);
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage)

Example 28 with LocalMessage

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

the class MessagingControllerTest method synchronizeMailboxSynchronous_withAccountSetToSyncRemoteDeletions_shouldNotDeleteLocalCopiesOfExistingMessagesAfterEarliestPollDate.

@Test
public void synchronizeMailboxSynchronous_withAccountSetToSyncRemoteDeletions_shouldNotDeleteLocalCopiesOfExistingMessagesAfterEarliestPollDate() throws Exception {
    messageCountInRemoteFolder(1);
    Date dateOfEarliestPoll = new Date();
    LocalMessage localMessage = localMessageWithCopyOnServer();
    when(account.syncRemoteDeletions()).thenReturn(true);
    when(account.getEarliestPollDate()).thenReturn(dateOfEarliestPoll);
    when(localMessage.olderThan(dateOfEarliestPoll)).thenReturn(false);
    when(localFolder.getMessages(null)).thenReturn(Collections.singletonList(localMessage));
    controller.synchronizeMailboxSynchronous(account, FOLDER_NAME, listener, remoteFolder);
    verify(localFolder, never()).destroyMessages(messageListCaptor.capture());
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) Date(java.util.Date) Test(org.junit.Test)

Example 29 with LocalMessage

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

the class MessagingControllerTest method localMessageWithCopyOnServer.

private LocalMessage localMessageWithCopyOnServer() throws MessagingException {
    String messageUid = "UID";
    Message remoteMessage = mock(Message.class);
    LocalMessage localMessage = mock(LocalMessage.class);
    when(remoteMessage.getUid()).thenReturn(messageUid);
    when(localMessage.getUid()).thenReturn(messageUid);
    when(remoteFolder.getMessages(anyInt(), anyInt(), any(Date.class), any(MessageRetrievalListener.class))).thenReturn(Collections.singletonList(remoteMessage));
    return localMessage;
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) LocalMessage(com.fsck.k9.mailstore.LocalMessage) Message(com.fsck.k9.mail.Message) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) MessageRetrievalListener(com.fsck.k9.mail.MessageRetrievalListener)

Example 30 with LocalMessage

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

the class AttachmentController method downloadAttachment.

private void downloadAttachment(LocalPart localPart, final Runnable attachmentDownloadedCallback) {
    String accountUuid = localPart.getAccountUuid();
    Account account = Preferences.getPreferences(context).getAccount(accountUuid);
    LocalMessage message = localPart.getMessage();
    messageViewFragment.showAttachmentLoadingDialog();
    controller.loadAttachment(account, message, attachment.part, new SimpleMessagingListener() {

        @Override
        public void loadAttachmentFinished(Account account, Message message, Part part) {
            messageViewFragment.hideAttachmentLoadingDialogOnMainThread();
            messageViewFragment.runOnMainThread(attachmentDownloadedCallback);
        }

        @Override
        public void loadAttachmentFailed(Account account, Message message, Part part, String reason) {
            messageViewFragment.hideAttachmentLoadingDialogOnMainThread();
        }
    });
}
Also used : Account(com.fsck.k9.Account) LocalMessage(com.fsck.k9.mailstore.LocalMessage) LocalMessage(com.fsck.k9.mailstore.LocalMessage) Message(com.fsck.k9.mail.Message) Part(com.fsck.k9.mail.Part) LocalPart(com.fsck.k9.mailstore.LocalPart) SimpleMessagingListener(com.fsck.k9.controller.SimpleMessagingListener)

Aggregations

LocalMessage (com.fsck.k9.mailstore.LocalMessage)42 Test (org.junit.Test)23 FetchProfile (com.fsck.k9.mail.FetchProfile)19 Message (com.fsck.k9.mail.Message)19 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)19 MessagingException (com.fsck.k9.mail.MessagingException)15 LocalFolder (com.fsck.k9.mailstore.LocalFolder)13 LocalStore (com.fsck.k9.mailstore.LocalStore)12 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)10 ArrayList (java.util.ArrayList)9 Notification (android.app.Notification)8 Part (com.fsck.k9.mail.Part)8 MessageReference (com.fsck.k9.activity.MessageReference)7 Multipart (com.fsck.k9.mail.Multipart)7 Date (java.util.Date)7 HashMap (java.util.HashMap)7 SuppressLint (android.annotation.SuppressLint)6 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)6 IOException (java.io.IOException)6 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)5