Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/viewer/messagepart.cpp
Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Line(s) | 231 | if (mNode) { | |||
---|---|---|---|---|---|
232 | if (textNode && !signature.isEmpty()) { | 232 | if (textNode && !signature.isEmpty()) { | ||
233 | mTextNode = textNode; | 233 | mTextNode = textNode; | ||
234 | mVerifiedText = text; | 234 | mVerifiedText = text; | ||
235 | } | 235 | } | ||
236 | } | 236 | } | ||
237 | 237 | | |||
238 | } | 238 | } | ||
239 | 239 | | |||
240 | void CryptoMessagePart::writeDeferredDecryptionBlock() const | ||||
241 | { | ||||
242 | Q_ASSERT(!mMetaData->isEncrypted); | ||||
243 | Q_ASSERT(mDecryptMessage); | ||||
244 | | ||||
245 | MessageViewer::HtmlWriter* writer = mOtp->htmlWriter(); | ||||
246 | if (!writer) { | ||||
247 | return; | ||||
248 | } | ||||
249 | | ||||
250 | const QString iconName = QLatin1String("file:///") + KIconLoader::global()->iconPath(QStringLiteral("document-decrypt"), | ||||
251 | KIconLoader::Small); | ||||
252 | writer->queue(QLatin1String("<div style=\"font-size:large; text-align:center;" | ||||
253 | "padding-top:20pt;\">") | ||||
254 | + i18n("This message is encrypted.") | ||||
255 | + QLatin1String("</div>" | ||||
256 | "<div style=\"text-align:center; padding-bottom:20pt;\">" | ||||
257 | "<a href=\"kmail:decryptMessage\">" | ||||
258 | "<img src=\"") + iconName + QLatin1String("\"/>") | ||||
259 | + i18n("Decrypt Message") | ||||
260 | + QLatin1String("</a></div>")); | ||||
261 | } | ||||
262 | | ||||
240 | void CryptoMessagePart::html(bool decorate) const | 263 | void CryptoMessagePart::html(bool decorate) const | ||
241 | { | 264 | { | ||
242 | 265 | | |||
243 | bool hideErrors = false; | 266 | bool hideErrors = false; | ||
244 | MessageViewer::HtmlWriter* writer = mOtp->htmlWriter(); | 267 | MessageViewer::HtmlWriter* writer = mOtp->htmlWriter(); | ||
245 | if (!writer) { | 268 | if (!writer) { | ||
246 | if (mNode && (mDecryptMessage || !mVerifiedText.isEmpty())) { | 269 | if (mNode && (mDecryptMessage || !mVerifiedText.isEmpty())) { | ||
247 | //TODO: Bad hack, we need the TempNodeParsing anycase | 270 | //TODO: Bad hack, we need the TempNodeParsing anycase | ||
248 | // but till we not make sure that the nodeparsing also creates html directly we need to have this hack. | 271 | // but till we not make sure that the nodeparsing also creates html directly we need to have this hack. | ||
249 | if (!mVerifiedText.isEmpty() && mTextNode) { | 272 | if (!mVerifiedText.isEmpty() && mTextNode) { | ||
250 | auto otp = new ObjectTreeParser(mOtp, true); | 273 | auto otp = new ObjectTreeParser(mOtp, true); | ||
251 | otp->setAllowAsync(mOtp->allowAsync()); | 274 | otp->setAllowAsync(mOtp->allowAsync()); | ||
252 | otp->parseObjectTreeInternal(mTextNode); | 275 | otp->parseObjectTreeInternal(mTextNode); | ||
253 | mOtp->copyContentFrom(otp); | 276 | mOtp->copyContentFrom(otp); | ||
254 | } else if (!mVerifiedText.isEmpty()) { | 277 | } else if (!mVerifiedText.isEmpty()) { | ||
255 | mOtp->createAndParseTempNode(mNode, mVerifiedText.constData(), "opaque signed data"); | 278 | mOtp->createAndParseTempNode(mNode, mVerifiedText.constData(), "opaque signed data"); | ||
256 | } else { | 279 | } else { | ||
257 | mOtp->createAndParseTempNode(mNode, mDecryptedData.constData(), "encrypted node"); | 280 | mOtp->createAndParseTempNode(mNode, mDecryptedData.constData(), "encrypted node"); | ||
258 | } | 281 | } | ||
259 | } | 282 | } | ||
260 | return; | 283 | return; | ||
261 | } | 284 | } | ||
262 | 285 | | |||
263 | if (mMetaData->isEncrypted && !mDecryptMessage) { | 286 | if (mMetaData->isEncrypted && !mDecryptMessage) { | ||
264 | mOtp->writeDeferredDecryptionBlock(); | 287 | mMetaData->isDecryptable = true; | ||
288 | } | ||||
289 | | ||||
290 | if (mMetaData->isEncrypted && !mDecryptMessage) { | ||||
291 | const CryptoBlock block(mOtp, mMetaData, mCryptoProto, mFromAddress, mNode); | ||||
292 | writeDeferredDecryptionBlock(); | ||||
265 | } else if (mMetaData->inProgress) { | 293 | } else if (mMetaData->inProgress) { | ||
266 | mOtp->writeDecryptionInProgressBlock(); | 294 | const CryptoBlock block(mOtp, mMetaData, mCryptoProto, mFromAddress, mNode); | ||
295 | // In progress has no special body | ||||
267 | } else if (mMetaData->isEncrypted && !mMetaData->isDecryptable) { | 296 | } else if (mMetaData->isEncrypted && !mMetaData->isDecryptable) { | ||
268 | const CryptoBlock block(mOtp, mMetaData, mCryptoProto, mFromAddress, mNode); | 297 | const CryptoBlock block(mOtp, mMetaData, mCryptoProto, mFromAddress, mNode); | ||
269 | writer->queue(text()); //Do not quote ErrorText | 298 | writer->queue(text()); //Do not quote ErrorText | ||
270 | } else { | 299 | } else { | ||
271 | if (mMetaData->isSigned && mVerifiedText.isEmpty() && !hideErrors) { | 300 | if (mMetaData->isSigned && mVerifiedText.isEmpty() && !hideErrors) { | ||
301 | const CryptoBlock block(mOtp, mMetaData, mCryptoProto, mFromAddress, mNode); | ||||
272 | writer->queue(QStringLiteral("<hr><b><h2>")); | 302 | writer->queue(QStringLiteral("<hr><b><h2>")); | ||
273 | writer->queue(i18n("The crypto engine returned no cleartext data.")); | 303 | writer->queue(i18n("The crypto engine returned no cleartext data.")); | ||
274 | writer->queue(QStringLiteral("</h2></b>")); | 304 | writer->queue(QStringLiteral("</h2></b>")); | ||
275 | writer->queue(QStringLiteral("<br/> <br/>")); | 305 | writer->queue(QStringLiteral("<br/> <br/>")); | ||
276 | writer->queue(i18n("Status: ")); | 306 | writer->queue(i18n("Status: ")); | ||
277 | if (!mMetaData->status.isEmpty()) { | 307 | if (!mMetaData->status.isEmpty()) { | ||
278 | writer->queue(QStringLiteral("<i>")); | 308 | writer->queue(QStringLiteral("<i>")); | ||
279 | writer->queue(mMetaData->status); | 309 | writer->queue(mMetaData->status); | ||
Show All 22 Lines |