@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations cryptoAnnotations,
boolean openPgpProviderConfigured) throws MessagingException {
ArrayList<Part> extraParts = new ArrayList<>();
Part cryptoContentPart = MessageCryptoStructureDetector.findPrimaryEncryptedOrSignedPart(message, extraParts);
if (cryptoContentPart == null) {
if (cryptoAnnotations != null && !cryptoAnnotations.isEmpty()) {
Timber.e("Got crypto message cryptoContentAnnotations but no crypto root part!");
}
MessageViewInfo messageViewInfo = extractSimpleMessageForView(message, message);
return messageViewInfo.withSubject(message.getSubject(), false);
}
boolean isOpenPgpEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) &&
MessageCryptoStructureDetector.isMultipartEncryptedOpenPgpProtocol(cryptoContentPart)) ||
MessageCryptoStructureDetector.isPartPgpInlineEncrypted(cryptoContentPart);
if (!openPgpProviderConfigured && isOpenPgpEncrypted) {
CryptoResultAnnotation noProviderAnnotation = CryptoResultAnnotation.createErrorAnnotation(
CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null);
return MessageViewInfo.createWithErrorState(message, false)
.withCryptoData(noProviderAnnotation, null, null);
}
MessageViewInfo messageViewInfo = getMessageContent(message, cryptoAnnotations, extraParts, cryptoContentPart);
messageViewInfo = extractSubject(messageViewInfo);
return messageViewInfo;
}