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();
}
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();
}
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);
}
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);
}
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);
}
Aggregations