Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/viewer/objecttreeparser.cpp
Show All 40 Lines | |||||
41 | #include "memento/cryptobodypartmemento.h" | 41 | #include "memento/cryptobodypartmemento.h" | ||
42 | #include "memento/decryptverifybodypartmemento.h" | 42 | #include "memento/decryptverifybodypartmemento.h" | ||
43 | #include "messagepart.h" | 43 | #include "messagepart.h" | ||
44 | #include "objecttreesourceif.h" | 44 | #include "objecttreesourceif.h" | ||
45 | 45 | | |||
46 | #include "partmetadata.h" | 46 | #include "partmetadata.h" | ||
47 | #include "attachmentstrategy.h" | 47 | #include "attachmentstrategy.h" | ||
48 | #include "interfaces/htmlwriter.h" | 48 | #include "interfaces/htmlwriter.h" | ||
49 | #include "widgets/htmlstatusbar.h" | | |||
50 | #include "csshelper.h" | 49 | #include "csshelper.h" | ||
51 | #include "viewer/bodypartformatterfactory.h" | 50 | #include "viewer/bodypartformatterfactory.h" | ||
52 | #include "viewer/partnodebodypart.h" | 51 | #include "viewer/partnodebodypart.h" | ||
53 | #include "interfaces/bodypartformatter.h" | 52 | #include "interfaces/bodypartformatter.h" | ||
54 | #include "settings/messageviewersettings.h" | 53 | #include "messageviewer/mimetype.h" | ||
55 | #include "messageviewer/messageviewerutil.h" | | |||
56 | #include "job/kleojobexecutor.h" | 54 | #include "job/kleojobexecutor.h" | ||
57 | #include "messageviewer/nodehelper.h" | 55 | #include "messageviewer/nodehelper.h" | ||
58 | #include "utils/iconnamecache.h" | 56 | #include "utils/iconnamecache.h" | ||
59 | #include "messageviewer_debug.h" | 57 | #include "messageviewer_debug.h" | ||
60 | #include "converthtmltoplaintext.h" | 58 | #include "converthtmltoplaintext.h" | ||
61 | 59 | | |||
62 | // KDEPIM includes | 60 | // KDEPIM includes | ||
63 | #include <MessageCore/StringUtil> | 61 | #include <MessageCore/StringUtil> | ||
Show All 16 Lines | |||||
80 | #include <kmime/kmime_message.h> | 78 | #include <kmime/kmime_message.h> | ||
81 | #include <kmime/kmime_headers.h> | 79 | #include <kmime/kmime_headers.h> | ||
82 | 80 | | |||
83 | // KDE includes | 81 | // KDE includes | ||
84 | 82 | | |||
85 | #include <KLocalizedString> | 83 | #include <KLocalizedString> | ||
86 | #include <QTemporaryFile> | 84 | #include <QTemporaryFile> | ||
87 | 85 | | |||
88 | #include <kcodecs.h> | 86 | #include <KCodecs> | ||
89 | #include <kconfiggroup.h> | | |||
90 | 87 | | |||
91 | #include <KEmailAddress> | 88 | #include <KEmailAddress> | ||
92 | #include <KTextToHTML> | 89 | #include <KTextToHTML> | ||
93 | 90 | | |||
94 | // Qt includes | 91 | // Qt includes | ||
95 | #include <QApplication> | 92 | #include <QApplication> | ||
96 | #include <QTextDocument> | 93 | #include <QTextDocument> | ||
97 | #include <QDir> | 94 | #include <QDir> | ||
▲ Show 20 Lines • Show All 1072 Lines • ▼ Show 20 Line(s) | 1166 | if (!smimeCrypto) { | |||
1170 | return MessagePart::Ptr(); | 1167 | return MessagePart::Ptr(); | ||
1171 | } | 1168 | } | ||
1172 | 1169 | | |||
1173 | const QString smimeType = node->contentType()->parameter(QStringLiteral("smime-type")).toLower(); | 1170 | const QString smimeType = node->contentType()->parameter(QStringLiteral("smime-type")).toLower(); | ||
1174 | 1171 | | |||
1175 | if (smimeType == QLatin1String("certs-only")) { | 1172 | if (smimeType == QLatin1String("certs-only")) { | ||
1176 | result.setNeverDisplayInline(true); | 1173 | result.setNeverDisplayInline(true); | ||
1177 | 1174 | | |||
1178 | CertMessagePart::Ptr mp(new CertMessagePart(this, node, smimeCrypto, MessageViewer::MessageViewerSettings::self()->autoImportKeys())); | 1175 | CertMessagePart::Ptr mp(new CertMessagePart(this, node, smimeCrypto, mSource->autoImportKeys())); | ||
1179 | return mp; | 1176 | return mp; | ||
1180 | } | 1177 | } | ||
1181 | 1178 | | |||
1182 | CryptoProtocolSaver cpws(this, smimeCrypto); | 1179 | CryptoProtocolSaver cpws(this, smimeCrypto); | ||
1183 | 1180 | | |||
1184 | bool isSigned = (smimeType == QLatin1String("signed-data")); | 1181 | bool isSigned = (smimeType == QLatin1String("signed-data")); | ||
1185 | bool isEncrypted = (smimeType == QLatin1String("enveloped-data")); | 1182 | bool isEncrypted = (smimeType == QLatin1String("enveloped-data")); | ||
1186 | 1183 | | |||
▲ Show 20 Lines • Show All 992 Lines • ▼ Show 20 Line(s) | 2169 | { | |||
2179 | return QStringLiteral("data:image/png;base64,%1").arg(QLatin1String(ba.toBase64().constData())); | 2176 | return QStringLiteral("data:image/png;base64,%1").arg(QLatin1String(ba.toBase64().constData())); | ||
2180 | } | 2177 | } | ||
2181 | 2178 | | |||
2182 | QString ObjectTreeParser::quotedHTML(const QString &s, bool decorate) | 2179 | QString ObjectTreeParser::quotedHTML(const QString &s, bool decorate) | ||
2183 | { | 2180 | { | ||
2184 | assert(cssHelper()); | 2181 | assert(cssHelper()); | ||
2185 | 2182 | | |||
2186 | KTextToHTML::Options convertFlags = KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText; | 2183 | KTextToHTML::Options convertFlags = KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText; | ||
2187 | if (decorate && MessageViewer::MessageViewerSettings::self()->showEmoticons()) { | 2184 | if (decorate && mSource->showEmoticons()) { | ||
2188 | convertFlags |= KTextToHTML::ReplaceSmileys; | 2185 | convertFlags |= KTextToHTML::ReplaceSmileys; | ||
2189 | } | 2186 | } | ||
2190 | QString htmlStr; | 2187 | QString htmlStr; | ||
2191 | const QString normalStartTag = cssHelper()->nonQuotedFontTag(); | 2188 | const QString normalStartTag = cssHelper()->nonQuotedFontTag(); | ||
2192 | QString quoteFontTag[3]; | 2189 | QString quoteFontTag[3]; | ||
2193 | QString deepQuoteFontTag[3]; | 2190 | QString deepQuoteFontTag[3]; | ||
2194 | for (int i = 0; i < 3; ++i) { | 2191 | for (int i = 0; i < 3; ++i) { | ||
2195 | quoteFontTag[i] = cssHelper()->quoteFontTag(i); | 2192 | quoteFontTag[i] = cssHelper()->quoteFontTag(i); | ||
Show All 13 Lines | |||||
2209 | while (pos > 0 && (s[pos - 1] == QLatin1Char(' ') || s[pos - 1] == QLatin1Char('\t'))) { | 2206 | while (pos > 0 && (s[pos - 1] == QLatin1Char(' ') || s[pos - 1] == QLatin1Char('\t'))) { | ||
2210 | pos--; | 2207 | pos--; | ||
2211 | } | 2208 | } | ||
2212 | beg = pos; | 2209 | beg = pos; | ||
2213 | 2210 | | |||
2214 | int currQuoteLevel = -2; // -2 == no previous lines | 2211 | int currQuoteLevel = -2; // -2 == no previous lines | ||
2215 | bool curHidden = false; // no hide any block | 2212 | bool curHidden = false; // no hide any block | ||
2216 | 2213 | | |||
2217 | if (MessageViewer::MessageViewerSettings::self()->showExpandQuotesMark()) { | 2214 | if (mSource->showExpandQuotesMark()) { | ||
2218 | // Cache Icons | 2215 | // Cache Icons | ||
2219 | if (mCollapseIcon.isEmpty()) { | 2216 | if (mCollapseIcon.isEmpty()) { | ||
2220 | mCollapseIcon = iconToDataUrl(IconNameCache::instance()->iconPath(QStringLiteral("quotecollapse"), 0)); | 2217 | mCollapseIcon = iconToDataUrl(IconNameCache::instance()->iconPath(QStringLiteral("quotecollapse"), 0)); | ||
2221 | } | 2218 | } | ||
2222 | if (mExpandIcon.isEmpty()) { | 2219 | if (mExpandIcon.isEmpty()) { | ||
2223 | mExpandIcon = iconToDataUrl(IconNameCache::instance()->iconPath(QStringLiteral("quoteexpand"), 0)); | 2220 | mExpandIcon = iconToDataUrl(IconNameCache::instance()->iconPath(QStringLiteral("quoteexpand"), 0)); | ||
2224 | } | 2221 | } | ||
2225 | } | 2222 | } | ||
Show All 33 Lines | 2240 | for (int p = 0; p < numberOfCaracters; ++p) { | |||
2259 | } | 2256 | } | ||
2260 | } /* for() */ | 2257 | } /* for() */ | ||
2261 | if (!foundQuote) { | 2258 | if (!foundQuote) { | ||
2262 | quoteLength = 0; | 2259 | quoteLength = 0; | ||
2263 | } | 2260 | } | ||
2264 | bool actHidden = false; | 2261 | bool actHidden = false; | ||
2265 | 2262 | | |||
2266 | // This quoted line needs be hidden | 2263 | // This quoted line needs be hidden | ||
2267 | if (MessageViewer::MessageViewerSettings::self()->showExpandQuotesMark() && mSource->levelQuote() >= 0 | 2264 | if (mSource->showExpandQuotesMark() && mSource->levelQuote() >= 0 | ||
2268 | && mSource->levelQuote() <= (actQuoteLevel)) { | 2265 | && mSource->levelQuote() <= (actQuoteLevel)) { | ||
2269 | actHidden = true; | 2266 | actHidden = true; | ||
2270 | } | 2267 | } | ||
2271 | 2268 | | |||
2272 | if (actQuoteLevel != currQuoteLevel) { | 2269 | if (actQuoteLevel != currQuoteLevel) { | ||
2273 | /* finish last quotelevel */ | 2270 | /* finish last quotelevel */ | ||
2274 | if (currQuoteLevel == -1) { | 2271 | if (currQuoteLevel == -1) { | ||
2275 | htmlStr.append(normalEndTag); | 2272 | htmlStr.append(normalEndTag); | ||
2276 | } else if (currQuoteLevel >= 0 && !curHidden) { | 2273 | } else if (currQuoteLevel >= 0 && !curHidden) { | ||
2277 | htmlStr.append(quoteEnd); | 2274 | htmlStr.append(quoteEnd); | ||
2278 | } | 2275 | } | ||
2279 | //Close blockquote | 2276 | //Close blockquote | ||
2280 | if (previousQuoteDepth > actQuoteLevel) { | 2277 | if (previousQuoteDepth > actQuoteLevel) { | ||
2281 | htmlStr += cssHelper()->addEndBlockQuote((previousQuoteDepth - actQuoteLevel)); | 2278 | htmlStr += cssHelper()->addEndBlockQuote((previousQuoteDepth - actQuoteLevel)); | ||
2282 | } | 2279 | } | ||
2283 | 2280 | | |||
2284 | /* start new quotelevel */ | 2281 | /* start new quotelevel */ | ||
2285 | if (actQuoteLevel == -1) { | 2282 | if (actQuoteLevel == -1) { | ||
2286 | htmlStr += normalStartTag; | 2283 | htmlStr += normalStartTag; | ||
2287 | } else { | 2284 | } else { | ||
2288 | if (MessageViewer::MessageViewerSettings::self()->showExpandQuotesMark()) { | 2285 | if (mSource->showExpandQuotesMark()) { | ||
2289 | if (actHidden) { | 2286 | if (actHidden) { | ||
2290 | //only show the QuoteMark when is the first line of the level hidden | 2287 | //only show the QuoteMark when is the first line of the level hidden | ||
2291 | if (!curHidden) { | 2288 | if (!curHidden) { | ||
2292 | //Expand all quotes | 2289 | //Expand all quotes | ||
2293 | htmlStr += QLatin1String("<div class=\"quotelevelmark\" >"); | 2290 | htmlStr += QLatin1String("<div class=\"quotelevelmark\" >"); | ||
2294 | htmlStr += QStringLiteral("<a href=\"kmail:levelquote?%1 \">" | 2291 | htmlStr += QStringLiteral("<a href=\"kmail:levelquote?%1 \">" | ||
2295 | "<img src=\"%2\" alt=\"\" title=\"\"/></a>") | 2292 | "<img src=\"%2\" alt=\"\" title=\"\"/></a>") | ||
2296 | .arg(-1) | 2293 | .arg(-1) | ||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |