Messagelib

objecttreeemptysource.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected]
3  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #include "objecttreeemptysource.h"
9 #include "viewer/attachmentstrategy.h"
10 #include "viewer/csshelperbase.h"
11 #include "viewer/viewer_p.h"
12 
13 #include <MimeTreeParser/BodyPartFormatter>
14 #include <MimeTreeParser/BodyPartFormatterFactory>
15 
16 #include "messagepartthemes/default/defaultrenderer.h"
17 
18 #include "messageviewer_debug.h"
19 
20 using namespace MessageViewer;
21 
22 namespace MessageViewer
23 {
24 class EmptySourcePrivate
25 {
26 public:
27  EmptySourcePrivate() = default;
28 
29  bool mAllowDecryption = false;
30 };
31 }
32 
33 EmptySource::EmptySource()
34  : MimeTreeParser::Interface::ObjectTreeSource()
35  , d(new MessageViewer::EmptySourcePrivate)
36 {
37 }
38 
39 EmptySource::~EmptySource() = default;
40 
41 bool EmptySource::decryptMessage() const
42 {
43  return d->mAllowDecryption;
44 }
45 
46 bool EmptySource::htmlLoadExternal() const
47 {
48  return false;
49 }
50 
51 void EmptySource::setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes)
52 {
53  Q_UNUSED(mode)
54  Q_UNUSED(availableModes)
55 }
56 
57 MimeTreeParser::Util::HtmlMode EmptySource::preferredMode() const
58 {
60 }
61 
62 void EmptySource::setAllowDecryption(bool allowDecryption)
63 {
64  d->mAllowDecryption = allowDecryption;
65 }
66 
67 const QTextCodec *EmptySource::overrideCodec()
68 {
69  return nullptr;
70 }
71 
72 QString EmptySource::createMessageHeader(KMime::Message *message)
73 {
74  Q_UNUSED(message)
75  return {}; // do nothing
76 }
77 
78 const AttachmentStrategy *EmptySource::attachmentStrategy() const
79 {
80  return AttachmentStrategy::smart();
81 }
82 
83 HtmlWriter *EmptySource::htmlWriter() const
84 {
85  return nullptr;
86 }
87 
88 CSSHelperBase *EmptySource::cssHelper() const
89 {
90  return nullptr;
91 }
92 
93 bool EmptySource::autoImportKeys() const
94 {
95  return true;
96 }
97 
98 const MimeTreeParser::BodyPartFormatterFactory *EmptySource::bodyPartFormatterFactory()
99 {
100  return MimeTreeParser::BodyPartFormatterFactory::instance();
101 }
102 
103 void EmptySource::render(const MimeTreeParser::MessagePartPtr &msgPart, bool showOnlyOneMimePart)
104 {
105  if (!htmlWriter()) {
106  qCWarning(MESSAGEVIEWER_LOG) << "no htmlWriter - skipping rendering.";
107  return;
108  }
109 
110  auto renderer = DefaultRenderer(cssHelper());
111  renderer.setAttachmentStrategy(attachmentStrategy());
112  renderer.setCreateMessageHeader(std::bind(&EmptySource::createMessageHeader, this, std::placeholders::_1));
113  renderer.setHtmlLoadExternal(htmlLoadExternal());
114  renderer.setIsPrinting(isPrinting());
115  renderer.setLevelQuote(levelQuote());
116  renderer.setShowEmoticons(showEmoticons());
117  renderer.setShowExpandQuotesMark(showExpandQuotesMark());
118  renderer.setShowOnlyOneMimePart(showOnlyOneMimePart);
119  renderer.setShowSignatureDetails(showSignatureDetails());
120  renderer.setShowEncryptionDetails(showEncryptionDetails());
121 
122  renderer.render(msgPart, htmlWriter());
123 }
124 
125 bool EmptySource::isPrinting() const
126 {
127  return false;
128 }
129 
130 bool EmptySource::showEmoticons() const
131 {
132  return false;
133 }
134 
135 bool EmptySource::showExpandQuotesMark() const
136 {
137  return false;
138 }
139 
140 bool EmptySource::showSignatureDetails() const
141 {
142  return false;
143 }
144 
145 bool EmptySource::showEncryptionDetails() const
146 {
147  return false;
148 }
149 
150 int EmptySource::levelQuote() const
151 {
152  return 1;
153 }
@ Html
A HTML message, non-multipart.
The CSSHelperBase class.
Definition: csshelperbase.h:26
HtmlMode
Describes the type of the displayed message.
An interface for HTML sinks.
Definition: htmlwriter.h:28
The place to obtain BodyPartFormatter candidates for a given mime type.
The AttachmentStrategy class.
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Mar 24 2023 04:08:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.