use of com.fsck.k9.mailstore.MessageViewInfo 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);
}
use of com.fsck.k9.mailstore.MessageViewInfo in project k-9 by k9mail.
the class MessageCompose method processMessageToForward.
private void processMessageToForward(MessageViewInfo messageViewInfo) throws MessagingException {
Message message = messageViewInfo.message;
String subject = message.getSubject();
if (subject != null && !subject.toLowerCase(Locale.US).startsWith("fwd:")) {
subjectView.setText("Fwd: " + subject);
} else {
subjectView.setText(subject);
}
// even if there are multiple references.
if (!TextUtils.isEmpty(message.getMessageId())) {
repliedToMessageId = message.getMessageId();
referencedMessageIds = repliedToMessageId;
} else {
Timber.d("could not get Message-ID.");
}
// Quote the message and setup the UI.
quotedMessagePresenter.processMessageToForward(messageViewInfo);
attachmentPresenter.processMessageToForward(messageViewInfo);
}
use of com.fsck.k9.mailstore.MessageViewInfo in project k-9 by k9mail.
the class MessageLoaderHelper method onLoadMessageFromDatabaseFinished.
@UiThread
private void onLoadMessageFromDatabaseFinished() {
if (callback == null) {
throw new IllegalStateException("unexpected call when callback is already detached");
}
callback.onMessageDataLoadFinished(localMessage);
boolean downloadedCompletely = localMessage.isSet(Flag.X_DOWNLOADED_FULL);
boolean downloadedPartially = localMessage.isSet(Flag.X_DOWNLOADED_PARTIAL);
boolean messageIncomplete = !downloadedCompletely && !downloadedPartially;
if (messageIncomplete) {
startDownloadingMessageBody(false);
return;
}
if (onlyLoadMetadata) {
MessageViewInfo messageViewInfo = MessageViewInfo.createForMetadataOnly(localMessage, !downloadedCompletely);
onDecodeMessageFinished(messageViewInfo);
return;
}
String openPgpProvider = account.getOpenPgpProvider();
if (openPgpProvider != null) {
startOrResumeCryptoOperation(openPgpProvider);
return;
}
startOrResumeDecodeMessage();
}
use of com.fsck.k9.mailstore.MessageViewInfo in project k-9 by k9mail.
the class MessageCompose method processMessageToForward.
private void processMessageToForward(MessageViewInfo messageViewInfo, boolean asAttachment) throws MessagingException {
Message message = messageViewInfo.message;
String subject = messageViewInfo.subject;
if (subject != null && !subject.toLowerCase(Locale.US).startsWith("fwd:")) {
subjectView.setText("Fwd: " + subject);
} else {
subjectView.setText(subject);
}
// even if there are multiple references.
if (!TextUtils.isEmpty(message.getMessageId())) {
repliedToMessageId = message.getMessageId();
referencedMessageIds = repliedToMessageId;
} else {
Timber.d("could not get Message-ID.");
}
// Quote the message and setup the UI.
if (asAttachment) {
attachmentPresenter.processMessageToForwardAsAttachment(messageViewInfo);
} else {
quotedMessagePresenter.processMessageToForward(messageViewInfo);
attachmentPresenter.processMessageToForward(messageViewInfo);
}
setIdentityFromMessage(message);
}
use of com.fsck.k9.mailstore.MessageViewInfo in project k-9 by k9mail.
the class MessageCompose method processMessageToReplyTo.
private void processMessageToReplyTo(MessageViewInfo messageViewInfo) throws MessagingException {
Message message = messageViewInfo.message;
if (messageViewInfo.subject != null) {
final String subject = PREFIX.matcher(messageViewInfo.subject).replaceFirst("");
if (!subject.toLowerCase(Locale.US).startsWith("re:")) {
subjectView.setText("Re: " + subject);
} else {
subjectView.setText(subject);
}
} else {
subjectView.setText("");
}
/*
* If a reply-to was included with the message use that, otherwise use the from
* or sender address.
*/
boolean isReplyAll = action == Action.REPLY_ALL;
recipientPresenter.initFromReplyToMessage(message, isReplyAll);
if (message.getMessageId() != null && message.getMessageId().length() > 0) {
repliedToMessageId = message.getMessageId();
String[] refs = message.getReferences();
if (refs != null && refs.length > 0) {
referencedMessageIds = TextUtils.join("", refs) + " " + repliedToMessageId;
} else {
referencedMessageIds = repliedToMessageId;
}
} else {
Timber.d("could not get Message-ID.");
}
// Quote the message and setup the UI.
quotedMessagePresenter.initFromReplyToMessage(messageViewInfo, action);
if (action == Action.REPLY || action == Action.REPLY_ALL) {
setIdentityFromMessage(message);
}
}
Aggregations