File indexing completed on 2024-06-23 05:19:20
0001 /* 0002 SPDX-FileCopyrightText: 2016 Sandro Knauß <sknauss@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "textplain.h" 0008 0009 #include "messagepart.h" 0010 #include "objecttreeparser.h" 0011 0012 #include <KMime/Content> 0013 0014 using namespace MimeTreeParser; 0015 0016 const TextPlainBodyPartFormatter *TextPlainBodyPartFormatter::self; 0017 0018 const Interface::BodyPartFormatter *TextPlainBodyPartFormatter::create() 0019 { 0020 if (!self) { 0021 self = new TextPlainBodyPartFormatter(); 0022 } 0023 return self; 0024 } 0025 0026 MessagePart::Ptr TextPlainBodyPartFormatter::process(Interface::BodyPart &part) const 0027 { 0028 KMime::Content *node = part.content(); 0029 const bool isFirstTextPart = (node->topLevel()->textContent() == node); 0030 0031 TextMessagePart::Ptr mp; 0032 if (isFirstTextPart) { 0033 mp = TextMessagePart::Ptr(new TextMessagePart(part.objectTreeParser(), node, part.source()->decryptMessage())); 0034 } else { 0035 mp = TextMessagePart::Ptr(new AttachmentMessagePart(part.objectTreeParser(), node, part.source()->decryptMessage())); 0036 } 0037 0038 part.processResult()->setInlineSignatureState(mp->signatureState()); 0039 part.processResult()->setInlineEncryptionState(mp->encryptionState()); 0040 0041 part.nodeHelper()->setNodeDisplayedEmbedded(node, true); 0042 0043 return mp; 0044 }