Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit da585c5e authored by Volker Krause's avatar Volker Krause

Make KMime::Content available properly in MessagePart

Summary:
Most MessagePart sub-classes were doing this themselves so far, but we
need this generically, e.g. to give render plugins access to header data.

Reviewers: knauss

Reviewed By: knauss

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D8071
parent 44e9aa65
......@@ -411,7 +411,7 @@ QString DefaultRendererPrivate::render(const MessagePartList::Ptr &mp)
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
renderSubParts(mp, htmlWriter);
......@@ -428,7 +428,7 @@ QString DefaultRendererPrivate::render(const MimeMessagePart::Ptr &mp)
HTMLBlock::Ptr rBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
if (mp->isRoot()) {
......@@ -468,7 +468,7 @@ QString DefaultRendererPrivate::render(const EncapsulatedRfc822MessagePart::Ptr
HTMLBlock::Ptr aBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
const auto html = t->render(&c);
htmlWriter->queue(html);
......@@ -497,7 +497,7 @@ QString DefaultRendererPrivate::render(const HtmlMessagePart::Ptr &mp)
QString bodyText = processHtml(mp->mBodyHTML, extraHead);
if (isHtmlPreferred) {
mp->mOtp->nodeHelper()->setNodeDisplayedEmbedded(mp->mNode, true);
mp->mOtp->nodeHelper()->setNodeDisplayedEmbedded(mp->content(), true);
mOldWriter->extraHead(extraHead);
}
......@@ -520,7 +520,7 @@ QString DefaultRendererPrivate::render(const HtmlMessagePart::Ptr &mp)
HTMLBlock::Ptr aBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
const auto html = t->render(&c);
htmlWriter->queue(html);
......@@ -530,7 +530,7 @@ QString DefaultRendererPrivate::render(const HtmlMessagePart::Ptr &mp)
QString DefaultRendererPrivate::renderEncrypted(const EncryptedMessagePart::Ptr &mp)
{
KMime::Content *node = mp->mNode;
KMime::Content *node = mp->content();
const auto metaData = *mp->partMetaData();
Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral(
......@@ -584,7 +584,7 @@ QString DefaultRendererPrivate::renderEncrypted(const EncryptedMessagePart::Ptr
QString DefaultRendererPrivate::renderSigned(const SignedMessagePart::Ptr &mp)
{
KMime::Content *node = mp->mNode;
KMime::Content *node = mp->content();
const auto metaData = *mp->partMetaData();
auto cryptoProto = mp->mCryptoProto;
......@@ -840,7 +840,7 @@ QString DefaultRendererPrivate::render(const SignedMessagePart::Ptr &mp)
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(),
mp->attachmentNode()));
mp->attachmentContent()));
}
htmlWriter->queue(renderSigned(mp));
}
......@@ -850,7 +850,7 @@ QString DefaultRendererPrivate::render(const SignedMessagePart::Ptr &mp)
HTMLBlock::Ptr aBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
if (mp->hasSubParts()) {
renderSubParts(mp, htmlWriter);
......@@ -875,7 +875,7 @@ QString DefaultRendererPrivate::render(const EncryptedMessagePart::Ptr &mp)
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(),
mp->attachmentNode()));
mp->attachmentContent()));
}
htmlWriter->queue(renderEncrypted(mp));
}
......@@ -886,7 +886,7 @@ QString DefaultRendererPrivate::render(const EncryptedMessagePart::Ptr &mp)
HTMLBlock::Ptr aBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
if (mp->hasSubParts()) {
......@@ -908,7 +908,7 @@ QString DefaultRendererPrivate::render(const AlternativeMessagePart::Ptr &mp)
HTMLBlock::Ptr aBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
auto mode = mp->preferredMode();
......@@ -962,7 +962,7 @@ QString DefaultRendererPrivate::render(const CertMessagePart::Ptr &mp)
HTMLBlock::Ptr aBlock;
if (mp->isAttachment()) {
aBlock
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentNode()));
= HTMLBlock::Ptr(new AttachmentMarkBlock(htmlWriter.data(), mp->attachmentContent()));
}
const auto html = t->render(&c);
htmlWriter->queue(html);
......
......@@ -169,7 +169,7 @@ HtmlOnlyPartRendered::HtmlOnlyPartRendered(MimeTreeParser::MessagePart::Ptr mp,
: mHtml(html)
{
mShowAttachmentBlock = mp->isAttachment();
mAttachmentNode = mp->attachmentNode();
mAttachmentNode = mp->attachmentContent();
}
HtmlOnlyPartRendered::~HtmlOnlyPartRendered()
......@@ -205,7 +205,7 @@ TextPartRendered::TextPartRendered(MimeTreeParser::TextMessagePart::Ptr mp)
: mShowAttachmentBlock(false)
, mAttachmentNode(nullptr)
{
auto node = mp->mNode;
auto node = mp->content();
auto nodeHelper = mp->mOtp->nodeHelper();
if (mp->isHidden()) {
......@@ -240,7 +240,7 @@ TextPartRendered::TextPartRendered(MimeTreeParser::TextMessagePart::Ptr mp)
mShowAttachmentBlock = mp->isAttachment();
mHtml = t->render(&c);
mAttachmentNode = mp->attachmentNode();
mAttachmentNode = mp->attachmentContent();
}
TextPartRendered::~TextPartRendered()
......
......@@ -48,7 +48,7 @@ const
return QSharedPointer<PartRendered>();
}
KMime::Content *node = mp->mNode;
KMime::Content *node = mp->content();
NodeHelper *nodeHelper = mp->mOtp->nodeHelper();
if (mp->isHidden()) {
......
This diff is collapsed.
......@@ -85,7 +85,18 @@ public:
virtual QString plaintextContent() const;
virtual QString htmlContent() const;
void setAttachmentFlag(KMime::Content *node);
/** The KMime::Content* node that's represented by this part.
* Can be @c nullptr, e.g. for sub-parts of an inline signed body part.
*/
KMime::Content *content() const;
void setContent(KMime::Content *node);
/** The KMime::Content* node that's the source of this part.
* This is not necessarily the same as content(), for example for
* broken-up multipart nodes.
*/
KMime::Content *attachmentContent() const;
void setAttachmentContent(KMime::Content *node);
bool isAttachment() const;
void setIsRoot(bool root);
......@@ -104,7 +115,6 @@ public:
bool hasSubParts() const;
Interface::ObjectTreeSource *source() const;
KMime::Content *attachmentNode() const;
protected:
void parseInternal(KMime::Content *node, bool onlyOneMimePart);
......@@ -144,7 +154,6 @@ public:
QString plaintextContent() const override;
QString htmlContent() const override;
private:
KMime::Content *mNode;
bool mOnlyOneMimePart;
friend class AlternativeMessagePart;
......@@ -188,9 +197,6 @@ public:
bool showLink() const;
bool showTextFrame() const;
protected:
KMime::Content *mNode = nullptr;
private:
void parseContent();
......@@ -241,7 +247,6 @@ public:
bool isHtml() const override;
private:
KMime::Content *mNode;
Interface::ObjectTreeSource *mSource;
QString mBodyHTML;
QByteArray mCharset;
......@@ -270,8 +275,6 @@ public:
void fix() const override;
private:
KMime::Content *mNode;
Util::HtmlMode mPreferredMode;
QMap<Util::HtmlMode, KMime::Content *> mChildNodes;
......@@ -293,7 +296,6 @@ public:
QString text() const override;
private:
KMime::Content *mNode;
bool mAutoImport;
GpgME::ImportResult mImportResult;
const QGpgME::Protocol *mCryptoProto;
......@@ -313,7 +315,6 @@ public:
void fix() const override;
private:
const KMime::Message::Ptr mMessage;
KMime::Content *mNode;
friend class DefaultRendererPrivate;
};
......@@ -362,7 +363,6 @@ protected:
bool mNoSecKey;
const QGpgME::Protocol *mCryptoProto;
QString mFromAddress;
KMime::Content *mNode = nullptr;
bool mDecryptMessage;
QByteArray mVerifiedText;
std::vector<GpgME::DecryptionResult::Recipient> mDecryptRecipients;
......@@ -406,7 +406,6 @@ private:
protected:
const QGpgME::Protocol *mCryptoProto;
QString mFromAddress;
KMime::Content *mNode = nullptr;
QByteArray mVerifiedText;
friend EncryptedMessagePart;
......
......@@ -174,7 +174,7 @@ void ObjectTreeParser::parseObjectTree(KMime::Content *node)
mParsedPart->fix();
if (auto mp = toplevelTextNode(mParsedPart)) {
if (auto _mp = mp.dynamicCast<TextMessagePart>()) {
extractNodeInfos(_mp->mNode, true);
extractNodeInfos(_mp->content(), true);
} else if (auto _mp = mp.dynamicCast<AlternativeMessagePart>()) {
if (_mp->mChildNodes.contains(Util::MultipartPlain)) {
extractNodeInfos(_mp->mChildNodes[Util::MultipartPlain], true);
......@@ -221,16 +221,14 @@ MessagePartPtr ObjectTreeParser::processType(KMime::Content *node, ProcessResult
processResult.setNeverDisplayInline(true);
mNodeHelper->setNodeDisplayedEmbedded(node, false);
auto mp = processType(node, processResult, QByteArrayLiteral("application/octet-stream"), onlyOneMimePart);
if (mp) {
mp->setAttachmentFlag(node);
}
mp->setAttachmentContent(node);
return mp;
} else if (r == Interface::BodyPartFormatter::Ok) {
processResult.setNeverDisplayInline(true);
return result;
}
} else {
result->setAttachmentFlag(node);
result->setAttachmentContent(node);
return result;
}
}
......
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