Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/viewer/objecttreeparser.cpp
Show First 20 Lines • Show All 2373 Lines • ▼ Show 20 Line(s) | 2373 | } else { | |||
---|---|---|---|---|---|
2374 | messagePart.signer += QLatin1String(" <") + messagePart.signerMailAddresses.front() + QLatin1Char('>'); | 2374 | messagePart.signer += QLatin1String(" <") + messagePart.signerMailAddresses.front() + QLatin1Char('>'); | ||
2375 | } | 2375 | } | ||
2376 | } | 2376 | } | ||
2377 | } | 2377 | } | ||
2378 | } | 2378 | } | ||
2379 | } | 2379 | } | ||
2380 | 2380 | | |||
2381 | //----------------------------------------------------------------------------- | 2381 | //----------------------------------------------------------------------------- | ||
2382 | void ObjectTreeParser::writeBodyStr(const QByteArray &aStr, const QTextCodec *aCodec, | 2382 | QVector<MessagePart::Ptr> ObjectTreeParser::writeBodyStr2(const QByteArray &aStr, const QTextCodec *aCodec, | ||
2383 | const QString &fromAddress, | 2383 | const QString &fromAddress, | ||
2384 | KMMsgSignatureState &inlineSignatureState, | 2384 | KMMsgSignatureState &inlineSignatureState, | ||
2385 | KMMsgEncryptionState &inlineEncryptionState, | 2385 | KMMsgEncryptionState &inlineEncryptionState) | ||
2386 | bool decorate) | | |||
2387 | { | 2386 | { | ||
2388 | const QString dir = (QApplication::isRightToLeft() ? QStringLiteral("rtl") : QStringLiteral("ltr")); | | |||
2389 | //QString headerStr = QString::fromLatin1("<div dir=\"%1\">").arg(dir); | | |||
2390 | | ||||
2391 | inlineSignatureState = KMMsgNotSigned; | 2387 | inlineSignatureState = KMMsgNotSigned; | ||
2392 | inlineEncryptionState = KMMsgNotEncrypted; | 2388 | inlineEncryptionState = KMMsgNotEncrypted; | ||
2393 | QList<Block> blocks = prepareMessageForDecryption(aStr); | 2389 | QList<Block> blocks = prepareMessageForDecryption(aStr); | ||
2394 | 2390 | | |||
2395 | bool updatePlainText = false; // If there are encrypted or signed parts inside the node | | |||
2396 | // we need to update mPlainTextContent | | |||
2397 | | ||||
2398 | QVector<MessagePart::Ptr> mpl; | 2391 | QVector<MessagePart::Ptr> mpl; | ||
2399 | 2392 | | |||
2400 | if (!blocks.isEmpty()) { | 2393 | if (!blocks.isEmpty()) { | ||
2401 | 2394 | | |||
2402 | if (blocks.count() > 1 || blocks.at(0).type() != MessageViewer::NoPgpBlock) { | 2395 | if (blocks.count() > 1 || blocks.at(0).type() != MessageViewer::NoPgpBlock) { | ||
2403 | const Kleo::CryptoBackend::Protocol *cryptProto = Kleo::CryptoBackendFactory::instance()->openpgp(); | 2396 | const Kleo::CryptoBackend::Protocol *cryptProto = Kleo::CryptoBackendFactory::instance()->openpgp(); | ||
2404 | setCryptoProtocol(cryptProto); | 2397 | setCryptoProtocol(cryptProto); | ||
2405 | } | 2398 | } | ||
Show All 16 Lines | 2413 | Q_FOREACH (const Block &block, blocks) { | |||
2422 | if (!fullySignedOrEncryptedTmp) { | 2415 | if (!fullySignedOrEncryptedTmp) { | ||
2423 | fullySignedOrEncrypted = false; | 2416 | fullySignedOrEncrypted = false; | ||
2424 | } | 2417 | } | ||
2425 | 2418 | | |||
2426 | if (block.type() == NoPgpBlock && !block.text().trimmed().isEmpty()) { | 2419 | if (block.type() == NoPgpBlock && !block.text().trimmed().isEmpty()) { | ||
2427 | fullySignedOrEncryptedTmp = false; | 2420 | fullySignedOrEncryptedTmp = false; | ||
2428 | mpl.append(MessagePart::Ptr(new MessagePart(this, aCodec->toUnicode(block.text())))); | 2421 | mpl.append(MessagePart::Ptr(new MessagePart(this, aCodec->toUnicode(block.text())))); | ||
2429 | } else if (block.type() == PgpMessageBlock) { | 2422 | } else if (block.type() == PgpMessageBlock) { | ||
2430 | updatePlainText = true; | | |||
2431 | CryptoMessagePart::Ptr mp(new CryptoMessagePart(this, QString(), cryptoProtocol(), fromAddress, 0)); | 2423 | CryptoMessagePart::Ptr mp(new CryptoMessagePart(this, QString(), cryptoProtocol(), fromAddress, 0)); | ||
2432 | mpl.append(mp); | 2424 | mpl.append(mp); | ||
2433 | if (!mSource->decryptMessage()) { | 2425 | if (!mSource->decryptMessage()) { | ||
2434 | continue; | 2426 | continue; | ||
2435 | } | 2427 | } | ||
2436 | mp->startDecryption(block.text(), aCodec); | 2428 | mp->startDecryption(block.text(), aCodec); | ||
2437 | if (mp->partMetaData()->inProgress) { | 2429 | if (mp->partMetaData()->inProgress) { | ||
2438 | continue; | 2430 | continue; | ||
2439 | } | 2431 | } | ||
2440 | } else if (block.type() == ClearsignedBlock) { | 2432 | } else if (block.type() == ClearsignedBlock) { | ||
2441 | CryptoMessagePart::Ptr mp(new CryptoMessagePart(this, QString(), cryptoProtocol(), fromAddress, 0)); | 2433 | CryptoMessagePart::Ptr mp(new CryptoMessagePart(this, QString(), cryptoProtocol(), fromAddress, 0)); | ||
2442 | mpl.append(mp); | 2434 | mpl.append(mp); | ||
2443 | updatePlainText = true; | | |||
2444 | mp->startVerification(block.text(), aCodec); | 2435 | mp->startVerification(block.text(), aCodec); | ||
2445 | } else { | 2436 | } else { | ||
2446 | continue; | 2437 | continue; | ||
2447 | } | 2438 | } | ||
2448 | 2439 | | |||
2449 | const PartMetaData *messagePart(mpl.last()->partMetaData()); | 2440 | const PartMetaData *messagePart(mpl.last()->partMetaData()); | ||
2450 | 2441 | | |||
2451 | if (!messagePart->isEncrypted && !messagePart->isSigned && !block.text().trimmed().isEmpty()) { | 2442 | if (!messagePart->isEncrypted && !messagePart->isSigned && !block.text().trimmed().isEmpty()) { | ||
Show All 13 Lines | |||||
2465 | if (fullySignedOrEncrypted) { | 2456 | if (fullySignedOrEncrypted) { | ||
2466 | if (inlineSignatureState == KMMsgPartiallySigned) { | 2457 | if (inlineSignatureState == KMMsgPartiallySigned) { | ||
2467 | inlineSignatureState = KMMsgFullySigned; | 2458 | inlineSignatureState = KMMsgFullySigned; | ||
2468 | } | 2459 | } | ||
2469 | if (inlineEncryptionState == KMMsgPartiallyEncrypted) { | 2460 | if (inlineEncryptionState == KMMsgPartiallyEncrypted) { | ||
2470 | inlineEncryptionState = KMMsgFullyEncrypted; | 2461 | inlineEncryptionState = KMMsgFullyEncrypted; | ||
2471 | } | 2462 | } | ||
2472 | } | 2463 | } | ||
2464 | } | ||||
2465 | return mpl; | ||||
2466 | } | ||||
2467 | | ||||
2468 | void ObjectTreeParser::writeBodyStr(const QByteArray &aStr, const QTextCodec *aCodec, | ||||
2469 | const QString &fromAddress, | ||||
2470 | KMMsgSignatureState &inlineSignatureState, | ||||
2471 | KMMsgEncryptionState &inlineEncryptionState, | ||||
2472 | bool decorate) | ||||
2473 | { | ||||
2474 | const auto mpl = writeBodyStr2(aStr, aCodec, fromAddress, inlineSignatureState, inlineEncryptionState); | ||||
2473 | 2475 | | |||
2476 | if (!mpl.isEmpty()) { | ||||
2474 | if (htmlWriter()) { | 2477 | if (htmlWriter()) { | ||
2475 | foreach (const MessagePart::Ptr &mp, mpl) { | 2478 | foreach (const MessagePart::Ptr &mp, mpl) { | ||
2476 | mp->html(decorate); | 2479 | mp->html(decorate); | ||
2477 | } | 2480 | } | ||
2478 | } | 2481 | } | ||
2479 | 2482 | | |||
2483 | const bool updatePlainText = (inlineSignatureState != KMMsgNotSigned | ||||
2484 | || inlineEncryptionState != KMMsgNotEncrypted); | ||||
2480 | if (updatePlainText || mPlainTextContent.isEmpty()) { | 2485 | if (updatePlainText || mPlainTextContent.isEmpty()) { | ||
2481 | mPlainTextContent.clear(); | 2486 | mPlainTextContent.clear(); | ||
2482 | foreach (const MessagePart::Ptr &mp, mpl) { | 2487 | foreach (const MessagePart::Ptr &mp, mpl) { | ||
2483 | mPlainTextContent += mp->text(); | 2488 | mPlainTextContent += mp->text(); | ||
2484 | } | 2489 | } | ||
2485 | mPlainTextContentCharset = aCodec->name(); | 2490 | mPlainTextContentCharset = aCodec->name(); | ||
2486 | } | 2491 | } | ||
2487 | } | 2492 | } | ||
▲ Show 20 Lines • Show All 412 Lines • Show Last 20 Lines |