Search in sources :

Example 26 with MessageCryptoAnnotations

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

the class MessageCryptoStructureDetectorTest method findSigned__withEmptyProtocol__shouldReturnRoot.

@Test
public void findSigned__withEmptyProtocol__shouldReturnRoot() throws Exception {
    Message message = messageFromBody(multipart("signed", bodypart("text/plain", "content"), bodypart("application/pgp-signature")));
    List<Part> signedParts = MessageCryptoStructureDetector.findMultipartSignedParts(message, messageCryptoAnnotations);
    assertTrue(signedParts.isEmpty());
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) Test(org.junit.Test)

Example 27 with MessageCryptoAnnotations

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

the class MessageCryptoStructureDetectorTest method findSigned__withSimpleMultipartSigned__shouldReturnRoot.

@Test
public void findSigned__withSimpleMultipartSigned__shouldReturnRoot() throws Exception {
    Message message = messageFromBody(multipart("signed", "protocol=\"application/pgp-signature\"", bodypart("text/plain"), bodypart("application/pgp-signature")));
    List<Part> signedParts = MessageCryptoStructureDetector.findMultipartSignedParts(message, messageCryptoAnnotations);
    assertEquals(1, signedParts.size());
    assertSame(message, signedParts.get(0));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) Test(org.junit.Test)

Example 28 with MessageCryptoAnnotations

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

the class MessageLoaderHelper method startOrResumeDecodeMessage.

// decode message
private void startOrResumeDecodeMessage() {
    LocalMessageExtractorLoader loader = (LocalMessageExtractorLoader) loaderManager.<MessageViewInfo>getLoader(DECODE_MESSAGE_LOADER_ID);
    boolean isLoaderStale = (loader == null) || !loader.isCreatedFor(localMessage, messageCryptoAnnotations);
    if (isLoaderStale) {
        Timber.d("Creating new decode message loader");
        loaderManager.restartLoader(DECODE_MESSAGE_LOADER_ID, null, decodeMessageLoaderCallback);
    } else {
        Timber.d("Reusing decode message loader");
        loaderManager.initLoader(DECODE_MESSAGE_LOADER_ID, null, decodeMessageLoaderCallback);
    }
}
Also used : LocalMessageExtractorLoader(com.fsck.k9.ui.message.LocalMessageExtractorLoader)

Example 29 with MessageCryptoAnnotations

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

the class MessageCryptoHelper method asyncStartOrResumeProcessingMessage.

public void asyncStartOrResumeProcessingMessage(Message message, MessageCryptoCallback callback, OpenPgpDecryptionResult cachedDecryptionResult, boolean processSignedOnly) {
    if (this.currentMessage != null) {
        reattachCallback(message, callback);
        return;
    }
    this.messageAnnotations = new MessageCryptoAnnotations();
    this.state = State.START;
    this.currentMessage = message;
    this.cachedDecryptionResult = cachedDecryptionResult;
    this.callback = callback;
    this.processSignedOnly = processSignedOnly;
    nextStep();
}
Also used : MessageCryptoAnnotations(com.fsck.k9.mailstore.MessageCryptoAnnotations)

Example 30 with MessageCryptoAnnotations

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

the class MessageCryptoHelperTest method assertReturnsWithNoCryptoAnnotations.

private void assertReturnsWithNoCryptoAnnotations(MessageCryptoCallback messageCryptoCallback) {
    ArgumentCaptor<MessageCryptoAnnotations> captor = ArgumentCaptor.forClass(MessageCryptoAnnotations.class);
    verify(messageCryptoCallback).onCryptoOperationsFinished(captor.capture());
    verifyNoMoreInteractions(messageCryptoCallback);
    MessageCryptoAnnotations annotations = captor.getValue();
    assertTrue(annotations.isEmpty());
}
Also used : MessageCryptoAnnotations(com.fsck.k9.mailstore.MessageCryptoAnnotations)

Aggregations

MimeMessage (com.fsck.k9.mail.internet.MimeMessage)22 Test (org.junit.Test)22 Message (com.fsck.k9.mail.Message)20 Part (com.fsck.k9.mail.Part)19 BodyPart (com.fsck.k9.mail.BodyPart)18 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)12 K9RobolectricTest (com.fsck.k9.K9RobolectricTest)6 MessageCryptoAnnotations (com.fsck.k9.mailstore.MessageCryptoAnnotations)5 ArrayList (java.util.ArrayList)5 CryptoResultAnnotation (com.fsck.k9.mailstore.CryptoResultAnnotation)4 RobolectricTest (com.fsck.k9.RobolectricTest)2 Body (com.fsck.k9.mail.Body)2 Multipart (com.fsck.k9.mail.Multipart)2 Stack (java.util.Stack)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Nullable (android.support.annotation.Nullable)1 WorkerThread (android.support.annotation.WorkerThread)1 WorkerThread (androidx.annotation.WorkerThread)1 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)1