Messagelib

objecttreeemptysource.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
3 SPDX-FileCopyrightText: 2009 Andras Mantia <andras@kdab.net>
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
20using namespace MessageViewer;
21
22namespace MessageViewer
23{
24class EmptySourcePrivate
25{
26public:
27 EmptySourcePrivate() = default;
28
29 bool mAllowDecryption = false;
30};
31}
32
33EmptySource::EmptySource()
34 : MimeTreeParser::Interface::ObjectTreeSource()
35 , d(new MessageViewer::EmptySourcePrivate)
36{
37}
38
39EmptySource::~EmptySource() = default;
40
42{
43 return d->mAllowDecryption;
44}
45
47{
48 return false;
49}
50
52{
53 Q_UNUSED(mode)
54 Q_UNUSED(availableModes)
55}
56
61
62void EmptySource::setAllowDecryption(bool allowDecryption)
63{
64 d->mAllowDecryption = allowDecryption;
65}
66
68{
69 return {};
70}
71
72QString EmptySource::createMessageHeader(KMime::Message *message)
73{
74 Q_UNUSED(message)
75 return {}; // do nothing
76}
77
78const AttachmentStrategy *EmptySource::attachmentStrategy() const
79{
80 return AttachmentStrategy::smart();
81}
82
83HtmlWriter *EmptySource::htmlWriter() const
84{
85 return nullptr;
86}
87
88CSSHelperBase *EmptySource::cssHelper() const
89{
90 return nullptr;
91}
92
94{
95 return true;
96}
97
98const MimeTreeParser::BodyPartFormatterFactory *EmptySource::bodyPartFormatterFactory()
99{
100 return MimeTreeParser::BodyPartFormatterFactory::instance();
101}
102
103void 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
125bool EmptySource::isPrinting() const
126{
127 return false;
128}
129
130bool EmptySource::showEmoticons() const
131{
132 return false;
133}
134
135bool EmptySource::showExpandQuotesMark() const
136{
137 return false;
138}
139
140bool EmptySource::showSignatureDetails() const
141{
142 return false;
143}
144
145bool EmptySource::showEncryptionDetails() const
146{
147 return false;
148}
149
150int EmptySource::levelQuote() const
151{
152 return 1;
153}
The AttachmentStrategy class.
The CSSHelperBase class.
MimeTreeParser::Util::HtmlMode preferredMode() const override
Return the mode that is the preferred to display.
bool autoImportKeys() const override
should keys be imported automatically
virtual bool htmlLoadExternal() const
Return true if external sources should be loaded in a html mail.
QByteArray overrideCodecName() const override
The override codec that should be used for the mail.
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList< MimeTreeParser::Util::HtmlMode > &availableModes) override
Sets the type of mail that is currently displayed.
bool decryptMessage() const override
Return true if an encrypted mail should be decrypted.
An interface for HTML sinks.
Definition htmlwriter.h:29
The place to obtain BodyPartFormatter candidates for a given mime type.
HtmlMode
Describes the type of the displayed message.
@ Html
A HTML message, non-multipart.
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.