Changeset View
Changeset View
Standalone View
Standalone View
mimetreeparser/src/viewer/messagepart.cpp
| Show First 20 Lines • Show All 915 Lines • ▼ Show 20 Line(s) | 914 | if (partMetaData()->isSigned) { | |||
|---|---|---|---|---|---|
| 916 | partMetaData()->status_code = signatureToStatus(signature); | 916 | partMetaData()->status_code = signatureToStatus(signature); | ||
| 917 | partMetaData()->isGoodSignature = partMetaData()->status_code & GPGME_SIG_STAT_GOOD; | 917 | partMetaData()->isGoodSignature = partMetaData()->status_code & GPGME_SIG_STAT_GOOD; | ||
| 918 | // save extended signature status flags | 918 | // save extended signature status flags | ||
| 919 | partMetaData()->sigSummary = signature.summary(); | 919 | partMetaData()->sigSummary = signature.summary(); | ||
| 920 | 920 | | |||
| 921 | if (partMetaData()->isGoodSignature && !key.keyID()) { | 921 | if (partMetaData()->isGoodSignature && !key.keyID()) { | ||
| 922 | // Search for the key by its fingerprint so that we can check for | 922 | // Search for the key by its fingerprint so that we can check for | ||
| 923 | // trust etc. | 923 | // trust etc. | ||
| 924 | QGpgME::KeyListJob *job = mCryptoProto->keyListJob(false); // local, no sigs | 924 | QGpgME::KeyListJob *job = mCryptoProto->keyListJob(false, false, false); // local, no sigs | ||
| 925 | if (!job) { | 925 | if (!job) { | ||
| 926 | qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. "; | 926 | qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. "; | ||
| 927 | } else { | 927 | } else { | ||
| 928 | std::vector<GpgME::Key> found_keys; | 928 | std::vector<GpgME::Key> found_keys; | ||
| 929 | // As we are local it is ok to make this synchronous | 929 | // As we are local it is ok to make this synchronous | ||
| 930 | GpgME::KeyListResult res = job->exec(QStringList(QLatin1String(signature.fingerprint())), false, found_keys); | 930 | GpgME::KeyListResult res = job->exec(QStringList(QLatin1String(signature.fingerprint())), false, found_keys); | ||
| 931 | if (res.error()) { | 931 | if (res.error()) { | ||
| 932 | qCDebug(MIMETREEPARSER_LOG) << "Error while searching key for Fingerprint: " << signature.fingerprint(); | 932 | qCDebug(MIMETREEPARSER_LOG) << "Error while searching key for Fingerprint: " << signature.fingerprint(); | ||
| ▲ Show 20 Lines • Show All 282 Lines • ▼ Show 20 Line(s) | 1211 | if (m) { | |||
| 1215 | partMetaData()->isSigned = verifyResult.signatures().size() > 0; | 1215 | partMetaData()->isSigned = verifyResult.signatures().size() > 0; | ||
| 1216 | 1216 | | |||
| 1217 | if (verifyResult.signatures().size() > 0) { | 1217 | if (verifyResult.signatures().size() > 0) { | ||
| 1218 | auto subPart = SignedMessagePart::Ptr(new SignedMessagePart(mOtp, MessagePart::text(), mCryptoProto, mFromAddress, content())); | 1218 | auto subPart = SignedMessagePart::Ptr(new SignedMessagePart(mOtp, MessagePart::text(), mCryptoProto, mFromAddress, content())); | ||
| 1219 | subPart->setVerificationResult(m, nullptr); | 1219 | subPart->setVerificationResult(m, nullptr); | ||
| 1220 | appendSubPart(subPart); | 1220 | appendSubPart(subPart); | ||
| 1221 | } | 1221 | } | ||
| 1222 | 1222 | | |||
| 1223 | mDecryptRecipients = decryptResult.recipients(); | 1223 | mDecryptRecipients.clear(); | ||
| 1224 | for (const auto &recipient : decryptResult.recipients()) { | ||||
| 1225 | GpgME::Key key; | ||||
| 1226 | QGpgME::KeyListJob *job = mCryptoProto->keyListJob(false, false, false); // local, no sigs | ||||
| 1227 | if (!job) { | ||||
| 1228 | qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. "; | ||||
| 1229 | } else { | ||||
| 1230 | std::vector<GpgME::Key> found_keys; | ||||
| 1231 | // As we are local it is ok to make this synchronous | ||||
| 1232 | GpgME::KeyListResult res = job->exec(QStringList(QLatin1String(recipient.keyID())), false, found_keys); | ||||
| 1233 | if (res.error()) { | ||||
| 1234 | qCDebug(MIMETREEPARSER_LOG) << "Error while searching key for Fingerprint: " << recipient.keyID(); | ||||
| 1235 | } | ||||
| 1236 | if (found_keys.size() > 1) { | ||||
| 1237 | // Should not Happen | ||||
| 1238 | qCDebug(MIMETREEPARSER_LOG) << "Oops: Found more then one Key for Fingerprint: " << recipient.keyID(); | ||||
| 1239 | } | ||||
| 1240 | if (found_keys.size() != 1) { | ||||
| 1241 | // Should not Happen at this point | ||||
| 1242 | qCDebug(MIMETREEPARSER_LOG) << "Oops: Found no Key for Fingerprint: " << recipient.keyID(); | ||||
| 1243 | } else { | ||||
| 1244 | key = found_keys[0]; | ||||
| 1245 | } | ||||
| 1246 | } | ||||
| 1247 | mDecryptRecipients.push_back(std::make_pair(recipient, key)); | ||||
| 1248 | } | ||||
| 1224 | bDecryptionOk = !decryptResult.error(); | 1249 | bDecryptionOk = !decryptResult.error(); | ||
| 1225 | // std::stringstream ss; | 1250 | // std::stringstream ss; | ||
| 1226 | // ss << decryptResult << '\n' << verifyResult; | 1251 | // ss << decryptResult << '\n' << verifyResult; | ||
| 1227 | // qCDebug(MIMETREEPARSER_LOG) << ss.str().c_str(); | 1252 | // qCDebug(MIMETREEPARSER_LOG) << ss.str().c_str(); | ||
| 1228 | 1253 | | |||
| 1229 | if (!bDecryptionOk && partMetaData()->isSigned) { | 1254 | if (!bDecryptionOk && partMetaData()->isSigned) { | ||
| 1230 | //Only a signed part | 1255 | //Only a signed part | ||
| 1231 | partMetaData()->isEncrypted = false; | 1256 | partMetaData()->isEncrypted = false; | ||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||