Messagelib

textplain.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Sandro Knauß <sknauss@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "textplain.h"
8
9#include "messagepart.h"
10#include "objecttreeparser.h"
11
12#include <KMime/Content>
13
14using namespace MimeTreeParser;
15
16const TextPlainBodyPartFormatter *TextPlainBodyPartFormatter::self;
17
18const Interface::BodyPartFormatter *TextPlainBodyPartFormatter::create()
19{
20 if (!self) {
21 self = new TextPlainBodyPartFormatter();
22 }
23 return self;
24}
25
26MessagePart::Ptr TextPlainBodyPartFormatter::process(Interface::BodyPart &part) const
27{
28 KMime::Content *node = part.content();
29 const bool isFirstTextPart = (node->topLevel()->textContent() == node);
30
32 if (isFirstTextPart) {
33 mp = TextMessagePart::Ptr(new TextMessagePart(part.objectTreeParser(), node, part.source()->decryptMessage()));
34 } else {
35 mp = TextMessagePart::Ptr(new AttachmentMessagePart(part.objectTreeParser(), node, part.source()->decryptMessage()));
36 }
37
38 part.processResult()->setInlineSignatureState(mp->signatureState());
39 part.processResult()->setInlineEncryptionState(mp->encryptionState());
40
41 part.nodeHelper()->setNodeDisplayedEmbedded(node, true);
42
43 return mp;
44}
Content * topLevel() const
Content * textContent()
interface of message body parts.
Definition bodypart.h:45
virtual MimeTreeParser::ObjectTreeParser * objectTreeParser() const =0
For making it easier to refactor, add objectTreeParser.
virtual MimeTreeParser::NodeHelper * nodeHelper() const =0
Ok, this is ugly, exposing the node helper here, but there is too much useful stuff in there for real...
virtual KMime::Content * content() const =0
Returns the KMime::Content node represented here.
virtual bool decryptMessage() const =0
Return true if an encrypted mail should be decrypted.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.