Commit b6e09bc6 authored by Sandro Knauß's avatar Sandro Knauß

use object parameters

parent 375bda85
...@@ -1845,7 +1845,7 @@ void CryptoMessagePart::startDecryption(KMime::Content *data) ...@@ -1845,7 +1845,7 @@ void CryptoMessagePart::startDecryption(KMime::Content *data)
} }
if (mMetaData.isSigned) { if (mMetaData.isSigned) {
sigStatusToMetaData(mSignatures, mCryptoProto, mMetaData, GpgME::Key()); sigStatusToMetaData();
mVerifiedText = mDecryptedData; mVerifiedText = mDecryptedData;
} }
...@@ -1989,19 +1989,20 @@ static int signatureToStatus(const GpgME::Signature &sig) ...@@ -1989,19 +1989,20 @@ static int signatureToStatus(const GpgME::Signature &sig)
} }
} }
void CryptoMessagePart::sigStatusToMetaData(const std::vector <GpgME::Signature> &signatures, const Kleo::CryptoBackend::Protocol *cryptProto, PartMetaData &messagePart, GpgME::Key key) void CryptoMessagePart::sigStatusToMetaData()
{ {
if (messagePart.isSigned) { GpgME::Key key;
GpgME::Signature signature = signatures.front(); if (mMetaData.isSigned) {
messagePart.status_code = signatureToStatus(signature); GpgME::Signature signature = mSignatures.front();
messagePart.isGoodSignature = messagePart.status_code & GPGME_SIG_STAT_GOOD; mMetaData.status_code = signatureToStatus(signature);
mMetaData.isGoodSignature = mMetaData.status_code & GPGME_SIG_STAT_GOOD;
// save extended signature status flags // save extended signature status flags
messagePart.sigSummary = signature.summary(); mMetaData.sigSummary = signature.summary();
if (messagePart.isGoodSignature && !key.keyID()) { if (mMetaData.isGoodSignature && !key.keyID()) {
// Search for the key by it's fingerprint so that we can check for // Search for the key by it's fingerprint so that we can check for
// trust etc. // trust etc.
Kleo::KeyListJob *job = cryptProto->keyListJob(false); // local, no sigs Kleo::KeyListJob *job = mCryptoProto->keyListJob(false); // local, no sigs
if (!job) { if (!job) {
qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. "; qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. ";
} else { } else {
...@@ -2025,14 +2026,14 @@ void CryptoMessagePart::sigStatusToMetaData(const std::vector <GpgME::Signature> ...@@ -2025,14 +2026,14 @@ void CryptoMessagePart::sigStatusToMetaData(const std::vector <GpgME::Signature>
} }
if (key.keyID()) { if (key.keyID()) {
messagePart.keyId = key.keyID(); mMetaData.keyId = key.keyID();
} }
if (messagePart.keyId.isEmpty()) { if (mMetaData.keyId.isEmpty()) {
messagePart.keyId = signature.fingerprint(); mMetaData.keyId = signature.fingerprint();
} }
messagePart.keyTrust = signature.validity(); mMetaData.keyTrust = signature.validity();
if (key.numUserIDs() > 0 && key.userID(0).id()) { if (key.numUserIDs() > 0 && key.userID(0).id()) {
messagePart.signer = Kleo::DN(key.userID(0).id()).prettyDN(); mMetaData.signer = Kleo::DN(key.userID(0).id()).prettyDN();
} }
for (uint iMail = 0; iMail < key.numUserIDs(); ++iMail) { for (uint iMail = 0; iMail < key.numUserIDs(); ++iMail) {
// The following if /should/ always result in TRUE but we // The following if /should/ always result in TRUE but we
...@@ -2045,25 +2046,25 @@ void CryptoMessagePart::sigStatusToMetaData(const std::vector <GpgME::Signature> ...@@ -2045,25 +2046,25 @@ void CryptoMessagePart::sigStatusToMetaData(const std::vector <GpgME::Signature>
email = email.mid(1, email.length() - 2); email = email.mid(1, email.length() - 2);
} }
if (!email.isEmpty()) { if (!email.isEmpty()) {
messagePart.signerMailAddresses.append(email); mMetaData.signerMailAddresses.append(email);
} }
} }
} }
if (signature.creationTime()) { if (signature.creationTime()) {
messagePart.creationTime.setTime_t(signature.creationTime()); mMetaData.creationTime.setTime_t(signature.creationTime());
} else { } else {
messagePart.creationTime = QDateTime(); mMetaData.creationTime = QDateTime();
} }
if (messagePart.signer.isEmpty()) { if (mMetaData.signer.isEmpty()) {
if (key.numUserIDs() > 0 && key.userID(0).name()) { if (key.numUserIDs() > 0 && key.userID(0).name()) {
messagePart.signer = Kleo::DN(key.userID(0).name()).prettyDN(); mMetaData.signer = Kleo::DN(key.userID(0).name()).prettyDN();
} }
if (!messagePart.signerMailAddresses.empty()) { if (!mMetaData.signerMailAddresses.empty()) {
if (messagePart.signer.isEmpty()) { if (mMetaData.signer.isEmpty()) {
messagePart.signer = messagePart.signerMailAddresses.front(); mMetaData.signer = mMetaData.signerMailAddresses.front();
} else { } else {
messagePart.signer += QLatin1String(" <") + messagePart.signerMailAddresses.front() + QLatin1Char('>'); mMetaData.signer += QLatin1String(" <") + mMetaData.signerMailAddresses.front() + QLatin1Char('>');
} }
} }
} }
...@@ -2087,7 +2088,7 @@ void CryptoMessagePart::startVerificationDetached(const QByteArray &text, KMime: ...@@ -2087,7 +2088,7 @@ void CryptoMessagePart::startVerificationDetached(const QByteArray &text, KMime:
okVerify(text, signature); okVerify(text, signature);
if (mMetaData.isSigned) { if (mMetaData.isSigned) {
sigStatusToMetaData(mSignatures, mCryptoProto, mMetaData, GpgME::Key()); sigStatusToMetaData();
} else { } else {
mMetaData.creationTime = QDateTime(); mMetaData.creationTime = QDateTime();
} }
......
...@@ -444,7 +444,7 @@ private: ...@@ -444,7 +444,7 @@ private:
*/ */
bool okVerify(const QByteArray &data, const QByteArray &signature); bool okVerify(const QByteArray &data, const QByteArray &signature);
void sigStatusToMetaData(const std::vector <GpgME::Signature> &signatures, const Kleo::CryptoBackend::Protocol *cryptProto, PartMetaData &messagePart, GpgME::Key key); void sigStatusToMetaData();
protected: protected:
bool mPassphraseError; bool mPassphraseError;
bool mNoSecKey; bool mNoSecKey;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment