Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/viewer/messagepart.cpp
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | 17 | 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "messagepart.h" | 20 | #include "messagepart.h" | ||
21 | #include "messageviewer_debug.h" | 21 | #include "messageviewer_debug.h" | ||
22 | #include "objecttreeparser.h" | 22 | #include "objecttreeparser.h" | ||
23 | 23 | | |||
24 | #include <MessageCore/StringUtil> | ||||
25 | | ||||
26 | #include <libkleo/importjob.h> | ||||
27 | | ||||
24 | #include <interfaces/htmlwriter.h> | 28 | #include <interfaces/htmlwriter.h> | ||
25 | #include <htmlwriter/queuehtmlwriter.h> | 29 | #include <htmlwriter/queuehtmlwriter.h> | ||
26 | #include <kmime/kmime_content.h> | 30 | #include <kmime/kmime_content.h> | ||
27 | #include <gpgme++/key.h> | 31 | #include <gpgme++/key.h> | ||
28 | #include <gpgme.h> | 32 | #include <gpgme.h> | ||
29 | #include <KLocalizedString> | | |||
30 | 33 | | |||
31 | #include <QTextCodec> | 34 | #include <QTextCodec> | ||
35 | #include <QApplication> | ||||
36 | | ||||
37 | #include <KLocalizedString> | ||||
32 | 38 | | |||
33 | using namespace MessageViewer; | 39 | using namespace MessageViewer; | ||
34 | 40 | | |||
35 | //--------CryptoBlock------------------- | 41 | //--------CryptoBlock------------------- | ||
36 | CryptoBlock::CryptoBlock(ObjectTreeParser *otp, | 42 | CryptoBlock::CryptoBlock(ObjectTreeParser *otp, | ||
37 | PartMetaData *block, | 43 | PartMetaData *block, | ||
38 | const Kleo::CryptoBackend::Protocol *cryptoProto, | 44 | const Kleo::CryptoBackend::Protocol *cryptoProto, | ||
39 | const QString &fromAddress, | 45 | const QString &fromAddress, | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 104 | { | |||
99 | if (!entered) { | 105 | if (!entered) { | ||
100 | return; | 106 | return; | ||
101 | } | 107 | } | ||
102 | 108 | | |||
103 | mWriter->queue(QStringLiteral("</div>")); | 109 | mWriter->queue(QStringLiteral("</div>")); | ||
104 | entered = false; | 110 | entered = false; | ||
105 | } | 111 | } | ||
106 | 112 | | |||
113 | | ||||
114 | TextBlock::TextBlock(MessageViewer::HtmlWriter *writer, MessageViewer::NodeHelper *nodeHelper, KMime::Content *node, bool link) | ||||
115 | : mWriter(writer) | ||||
116 | , mNodeHelper(nodeHelper) | ||||
117 | , mNode(node) | ||||
118 | , mLink(link) | ||||
119 | { | ||||
120 | internalEnter(); | ||||
121 | } | ||||
122 | | ||||
123 | TextBlock::~TextBlock() | ||||
124 | { | ||||
125 | internalExit(); | ||||
126 | } | ||||
127 | | ||||
128 | void TextBlock::internalEnter() | ||||
129 | { | ||||
130 | if (!mWriter || entered) { | ||||
131 | return; | ||||
132 | } | ||||
133 | entered = true; | ||||
134 | | ||||
135 | const QString label = MessageCore::StringUtil::quoteHtmlChars(NodeHelper::fileName(mNode), true); | ||||
136 | | ||||
137 | const QString comment = | ||||
138 | MessageCore::StringUtil::quoteHtmlChars(mNode->contentDescription()->asUnicodeString(), true); | ||||
139 | | ||||
140 | const QString dir = QApplication::isRightToLeft() ? QStringLiteral("rtl") : QStringLiteral("ltr"); | ||||
141 | | ||||
142 | mWriter->queue(QLatin1String("<table cellspacing=\"1\" class=\"textAtm\">" | ||||
143 | "<tr class=\"textAtmH\"><td dir=\"") + dir + QLatin1String("\">")); | ||||
144 | if (!mLink) | ||||
145 | mWriter->queue(QLatin1String("<a href=\"") + mNodeHelper->asHREF(mNode, QStringLiteral("body")) + QLatin1String("\">") | ||||
146 | + label + QLatin1String("</a>")); | ||||
147 | else { | ||||
148 | mWriter->queue(label); | ||||
149 | } | ||||
150 | if (!comment.isEmpty()) { | ||||
151 | mWriter->queue(QLatin1String("<br/>") + comment); | ||||
152 | } | ||||
153 | mWriter->queue(QLatin1String("</td></tr><tr class=\"textAtmB\"><td>")); | ||||
154 | } | ||||
155 | | ||||
156 | void TextBlock::internalExit() | ||||
157 | { | ||||
158 | if (!entered) { | ||||
159 | return; | ||||
160 | } | ||||
161 | | ||||
162 | entered = false; | ||||
163 | | ||||
164 | mWriter->queue(QStringLiteral("</td></tr></table>")); | ||||
165 | } | ||||
166 | | ||||
107 | //------MessagePart----------------------- | 167 | //------MessagePart----------------------- | ||
108 | MessagePart::MessagePart(ObjectTreeParser *otp, | 168 | MessagePart::MessagePart(ObjectTreeParser *otp, | ||
109 | const QString &text) | 169 | const QString &text) | ||
110 | : mText(text) | 170 | : mText(text) | ||
111 | , mOtp(otp) | 171 | , mOtp(otp) | ||
112 | , mSubOtp(Q_NULLPTR) | 172 | , mSubOtp(Q_NULLPTR) | ||
113 | { | 173 | { | ||
114 | 174 | | |||
▲ Show 20 Lines • Show All 419 Lines • Show Last 20 Lines |