Search in sources :

Example 1 with CryptoResultAnnotation

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

the class MessageCryptoHelper method onCryptoOperationFailed.

private void onCryptoOperationFailed(OpenPgpError error) {
    CryptoResultAnnotation annotation;
    if (currentCryptoPart.type == CryptoPartType.PGP_SIGNED) {
        MimeBodyPart replacementPart = getMultipartSignedContentPartIfAvailable(currentCryptoPart.part);
        annotation = CryptoResultAnnotation.createOpenPgpSignatureErrorAnnotation(error, replacementPart);
    } else {
        annotation = CryptoResultAnnotation.createOpenPgpEncryptionErrorAnnotation(error);
    }
    addCryptoResultAnnotationToMessage(annotation);
    onCryptoFinished();
}
Also used : CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart)

Example 2 with CryptoResultAnnotation

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

the class MessageCryptoHelper method onCryptoOperationCanceled.

private void onCryptoOperationCanceled() {
    // see https://github.com/k9mail/k-9/issues/1878
    if (currentCryptoPart != null) {
        CryptoResultAnnotation errorPart = CryptoResultAnnotation.createOpenPgpCanceledAnnotation();
        addCryptoResultAnnotationToMessage(errorPart);
    }
    onCryptoFinished();
}
Also used : CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation)

Example 3 with CryptoResultAnnotation

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

the class MessageCryptoHelper method addCryptoResultAnnotationToMessage.

private void addCryptoResultAnnotationToMessage(CryptoResultAnnotation resultAnnotation) {
    Part part = currentCryptoPart.part;
    messageAnnotations.put(part, resultAnnotation);
    propagateEncapsulatedSignedPart(resultAnnotation, part);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part)

Example 4 with CryptoResultAnnotation

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

the class MessageCryptoSplitter method split.

@Nullable
public static CryptoMessageParts split(@NonNull Message message, @Nullable MessageCryptoAnnotations annotations) {
    ArrayList<Part> extraParts = new ArrayList<>();
    Part primaryPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, extraParts);
    if (primaryPart == null) {
        return null;
    }
    if (annotations == null) {
        CryptoResultAnnotation rootPartAnnotation = CryptoResultAnnotation.createErrorAnnotation(CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null);
        return new CryptoMessageParts(primaryPart, rootPartAnnotation, extraParts);
    }
    CryptoResultAnnotation rootPartAnnotation = annotations.get(primaryPart);
    Part rootPart;
    if (rootPartAnnotation != null && rootPartAnnotation.hasReplacementData()) {
        rootPart = rootPartAnnotation.getReplacementData();
    } else {
        rootPart = primaryPart;
    }
    return new CryptoMessageParts(rootPart, rootPartAnnotation, extraParts);
}
Also used : Part(com.fsck.k9.mail.Part) CryptoResultAnnotation(com.fsck.k9.mailstore.CryptoResultAnnotation) ArrayList(java.util.ArrayList) Nullable(android.support.annotation.Nullable)

Example 5 with CryptoResultAnnotation

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

the class MessageViewInfoExtractor method extractMessageForView.

@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations annotations) throws MessagingException {
    Part rootPart;
    CryptoResultAnnotation cryptoResultAnnotation;
    List<Part> extraParts;
    CryptoMessageParts cryptoMessageParts = MessageCryptoSplitter.split(message, annotations);
    if (cryptoMessageParts != null) {
        rootPart = cryptoMessageParts.contentPart;
        cryptoResultAnnotation = cryptoMessageParts.contentCryptoAnnotation;
        extraParts = cryptoMessageParts.extraParts;
    } else {
        if (annotations != null && !annotations.isEmpty()) {
            Timber.e("Got message annotations but no crypto root part!");
        }
        rootPart = message;
        cryptoResultAnnotation = null;
        extraParts = null;
    }
    List<AttachmentViewInfo> attachmentInfos = new ArrayList<>();
    ViewableExtractedText viewable = extractViewableAndAttachments(Collections.singletonList(rootPart), attachmentInfos);
    List<AttachmentViewInfo> extraAttachmentInfos = new ArrayList<>();
    String extraViewableText = null;
    if (extraParts != null) {
        ViewableExtractedText extraViewable = extractViewableAndAttachments(extraParts, extraAttachmentInfos);
        extraViewableText = extraViewable.text;
    }
    AttachmentResolver attachmentResolver = AttachmentResolver.createFromPart(rootPart);
    boolean isMessageIncomplete = !message.isSet(Flag.X_DOWNLOADED_FULL) || MessageExtractor.hasMissingParts(message);
    return MessageViewInfo.createWithExtractedContent(message, isMessageIncomplete, rootPart, viewable.html, attachmentInfos, cryptoResultAnnotation, attachmentResolver, extraViewableText, extraAttachmentInfos);
}
Also used : CryptoMessageParts(com.fsck.k9.ui.crypto.MessageCryptoSplitter.CryptoMessageParts) Part(com.fsck.k9.mail.Part) ArrayList(java.util.ArrayList) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

CryptoResultAnnotation (com.fsck.k9.mailstore.CryptoResultAnnotation)7 Part (com.fsck.k9.mail.Part)5 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)4 BodyPart (com.fsck.k9.mail.BodyPart)3 ArrayList (java.util.ArrayList)3 PendingIntent (android.app.PendingIntent)1 Nullable (android.support.annotation.Nullable)1 WorkerThread (android.support.annotation.WorkerThread)1 Body (com.fsck.k9.mail.Body)1 Multipart (com.fsck.k9.mail.Multipart)1 CryptoMessageParts (com.fsck.k9.ui.crypto.MessageCryptoSplitter.CryptoMessageParts)1 Stack (java.util.Stack)1 OpenPgpDecryptionResult (org.openintents.openpgp.OpenPgpDecryptionResult)1 OpenPgpSignatureResult (org.openintents.openpgp.OpenPgpSignatureResult)1