Search in sources :

Example 41 with MimeBodyPart

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

the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize.

@Test
public void extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize() throws Exception {
    MimeBodyPart part = new MimeBodyPart();
    part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"" + TEST_SIZE + "\"");
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
    assertEquals(TEST_SIZE, attachmentViewInfo.size);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Example 42 with MimeBodyPart

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

the class PreviewTextExtractorTest method extractPreview_withEmptyBody_shouldThrow.

@Test(expected = PreviewExtractionException.class)
public void extractPreview_withEmptyBody_shouldThrow() throws Exception {
    Part part = new MimeBodyPart(null, "text/plain");
    previewTextExtractor.extractPreview(part);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 43 with MimeBodyPart

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

the class MessageCryptoHelper method addErrorAnnotation.

private void addErrorAnnotation(Part part, CryptoError error, MimeBodyPart replacementPart) {
    CryptoResultAnnotation annotation = CryptoResultAnnotation.createErrorAnnotation(error, replacementPart);
    messageAnnotations.put(part, annotation);
}
Also used : CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation)

Example 44 with MimeBodyPart

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

the class MessageCryptoHelper method handleCryptoOperationSuccess.

private void handleCryptoOperationSuccess(MimeBodyPart outputPart) {
    OpenPgpDecryptionResult decryptionResult = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_DECRYPTION);
    OpenPgpSignatureResult signatureResult = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
    PendingIntent pendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
    CryptoResultAnnotation resultAnnotation = CryptoResultAnnotation.createOpenPgpResultAnnotation(decryptionResult, signatureResult, pendingIntent, outputPart);
    onCryptoOperationSuccess(resultAnnotation);
}
Also used : OpenPgpDecryptionResult(org.openintents.openpgp.OpenPgpDecryptionResult) CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation) PendingIntent(android.app.PendingIntent) OpenPgpSignatureResult(org.openintents.openpgp.OpenPgpSignatureResult)

Example 45 with MimeBodyPart

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

the class MessageCryptoHelper method addFoundInlinePgpParts.

private void addFoundInlinePgpParts(List<Part> foundParts) {
    for (Part part : foundParts) {
        if (!currentMessage.getFlags().contains(Flag.X_DOWNLOADED_FULL)) {
            if (MessageDecryptVerifier.isPartPgpInlineEncrypted(part)) {
                addErrorAnnotation(part, CryptoError.OPENPGP_ENCRYPTED_BUT_INCOMPLETE, NO_REPLACEMENT_PART);
            } else {
                MimeBodyPart replacementPart = extractClearsignedTextReplacementPart(part);
                addErrorAnnotation(part, CryptoError.OPENPGP_SIGNED_BUT_INCOMPLETE, replacementPart);
            }
            continue;
        }
        CryptoPart cryptoPart = new CryptoPart(CryptoPartType.PGP_INLINE, part);
        partsToDecryptOrVerify.add(cryptoPart);
    }
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart)

Aggregations

MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)42 Test (org.junit.Test)22 Part (com.fsck.k9.mail.Part)15 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)15 TextBody (com.fsck.k9.mail.internet.TextBody)11 AttachmentViewInfo (com.fsck.k9.mailstore.AttachmentViewInfo)11 BodyPart (com.fsck.k9.mail.BodyPart)9 MessagingException (com.fsck.k9.mail.MessagingException)7 Uri (android.net.Uri)5 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)5 PendingIntent (android.app.PendingIntent)4 Body (com.fsck.k9.mail.Body)4 Multipart (com.fsck.k9.mail.Multipart)4 CryptoResultAnnotation (com.fsck.k9.mailstore.CryptoResultAnnotation)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 OpenPgpDataSource (org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource)4 Intent (android.content.Intent)3 BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)3 InputStream (java.io.InputStream)3