Commit 88ae138e authored by Sandro Knauß's avatar Sandro Knauß

make parsed mailstructire attementstrategy independent

parent 06c109d7
......@@ -55,9 +55,14 @@ Interface::MessagePart::Ptr TextPlainBodyPartFormatter::process(Interface::BodyP
KMime::Content *node = part.content();
const bool isFirstTextPart = (node->topLevel()->textContent() == node);
IconType iconType = NoIcon;
if (!isFirstTextPart && part.objectTreeParser()->attachmentStrategy()->defaultDisplay(node) != AttachmentStrategy::Inline &&
!part.objectTreeParser()->showOnlyOneMimePart()) {
return MessagePart::Ptr();
iconType = MimeTreeParser::IconExternal;
}
if (!isFirstTextPart && (part.objectTreeParser()->attachmentStrategy()->defaultDisplay(node) == AttachmentStrategy::None) && !part.objectTreeParser()->showOnlyOneMimePart()) {
part.nodeHelper()->setNodeDisplayedHidden(node, true);
}
part.objectTreeParser()->extractNodeInfos(node, isFirstTextPart);
......@@ -66,10 +71,11 @@ Interface::MessagePart::Ptr TextPlainBodyPartFormatter::process(Interface::BodyP
const bool bDrawFrame = !isFirstTextPart
&& !part.objectTreeParser()->showOnlyOneMimePart()
&& !label.isEmpty();
&& !label.isEmpty()
&& iconType == MimeTreeParser::NoIcon;
const QString fileName = part.nodeHelper()->writeNodeToTempFile(node);
TextMessagePart::Ptr mp(new TextMessagePart(part.objectTreeParser(), node, bDrawFrame, !fileName.isEmpty(), part.source()->decryptMessage(), MimeTreeParser::NoIcon));
TextMessagePart::Ptr mp(new TextMessagePart(part.objectTreeParser(), node, bDrawFrame, !fileName.isEmpty(), part.source()->decryptMessage(), iconType));
part.processResult()->setInlineSignatureState(mp->signatureState());
part.processResult()->setInlineEncryptionState(mp->encryptionState());
......
......@@ -1557,9 +1557,7 @@ TextMessagePart::TextMessagePart(ObjectTreeParser *otp, KMime::Content *node, bo
return;
}
if (mAsIcon == MimeTreeParser::NoIcon) {
parseContent();
}
parseContent();
}
TextMessagePart::~TextMessagePart()
......@@ -1702,6 +1700,10 @@ void TextMessagePart::writePartIcon()
void TextMessagePart::html(bool decorate)
{
if (mOtp->nodeHelper()->isNodeDisplayedHidden(mNode)) {
return;
}
const HTMLBlock::Ptr aBlock(attachmentBlock());
HTMLBlock::Ptr block;
MimeTreeParser::HtmlWriter *writer = mOtp->htmlWriter();
......
......@@ -358,7 +358,9 @@ Interface::MessagePart::Ptr ObjectTreeParser::defaultHandling(KMime::Content *no
QByteArray cid = node->contentID()->identifier();
htmlWriter()->embedPart(cid, href);
nodeHelper()->setNodeDisplayedEmbedded(node, true);
return MessagePart::Ptr();
mNodeHelper->setNodeDisplayedHidden(node, true);
const auto mp = TextMessagePart::Ptr(new TextMessagePart(this, node, false, false, mSource->decryptMessage(), MimeTreeParser::IconInline));
return mp;
}
Interface::MessagePart::Ptr mp;
ProcessResult processResult(mNodeHelper);
......@@ -377,7 +379,8 @@ Interface::MessagePart::Ptr ObjectTreeParser::defaultHandling(KMime::Content *no
!showOnlyOneMimePart() &&
node->parent() /* message is not an attachment */) {
mNodeHelper->setNodeDisplayedHidden(node, true);
return MessagePart::Ptr();
const auto mp = TextMessagePart::Ptr(new TextMessagePart(this, node, false, false, mSource->decryptMessage(), MimeTreeParser::IconInline));
return mp;
}
bool asIcon = true;
......@@ -406,13 +409,9 @@ Interface::MessagePart::Ptr ObjectTreeParser::defaultHandling(KMime::Content *no
*/
if (asIcon) {
if (!(as && as->defaultDisplay(node) == AttachmentStrategy::None) ||
showOnlyOneMimePart()) {
// Write the node as icon only
return TextMessagePart::Ptr(new TextMessagePart(this, node, false, false, mSource->decryptMessage(), MimeTreeParser::IconExternal));
} else {
mNodeHelper->setNodeDisplayedHidden(node, true);
}
bool hidePart = (as && as->defaultDisplay(node) == AttachmentStrategy::None) || showOnlyOneMimePart();
mNodeHelper->setNodeDisplayedHidden(node, hidePart);
return TextMessagePart::Ptr(new TextMessagePart(this, node, false, false, mSource->decryptMessage(), MimeTreeParser::IconExternal));
} else if (result.isImage()) {
// Embed the image
mNodeHelper->setNodeDisplayedEmbedded(node, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment