diff options
Diffstat (limited to 'src/gpg/result_analyse/VerifyResultAnalyse.cpp')
-rw-r--r-- | src/gpg/result_analyse/VerifyResultAnalyse.cpp | 159 |
1 files changed, 81 insertions, 78 deletions
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp index e7c3276a..f794b31c 100644 --- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp +++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp @@ -26,8 +26,9 @@ #include "gpg/function/GpgKeyGetter.h" #include "gpg/result_analyse/VerifyResultAnalyse.h" -GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(gpgme_error_t error, gpgme_verify_result_t result) { +GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(GpgError error, GpgVerifyResult result) : error(errror), result(std::move(result)) {} +void GpgFrontend::VerifyResultAnalyse::do_analyse() { qDebug() << "Verify Result Analyse Started"; stream << tr("[#] Verify Operation "); @@ -64,81 +65,81 @@ GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(gpgme_error_t error, gpgme canContinue = false; setStatus(-1); break; - case GPG_ERR_NO_ERROR: - stream << QApplication::tr("A "); - if (sign->summary & GPGME_SIGSUM_GREEN) { - stream << QApplication::tr("Good "); - } - if (sign->summary & GPGME_SIGSUM_RED) { - stream << QApplication::tr("Bad "); - } - if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) { - stream << QApplication::tr("Expired "); - } - if (sign->summary & GPGME_SIGSUM_KEY_MISSING) { - stream << QApplication::tr("Missing Key's "); - } - if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) { - stream << QApplication::tr("Revoked Key's "); - } - if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) { - stream << QApplication::tr("Expired Key's "); - } - if (sign->summary & GPGME_SIGSUM_CRL_MISSING) { - stream << QApplication::tr("Missing CRL's "); - } - - if (sign->summary & GPGME_SIGSUM_VALID) { - stream << QApplication::tr("Signature Fully Valid.") << Qt::endl; - } else { - stream << QApplication::tr("Signature Not Fully Valid.") << Qt::endl; - } - - if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) { - if (!printSigner(stream, sign)) setStatus(0); - } else { - stream << QApplication::tr("Key is NOT present with ID 0x") << QString(sign->fpr) << Qt::endl; - } - - setStatus(1); - - break; - case GPG_ERR_NO_PUBKEY: - stream << QApplication::tr("A signature could NOT be verified due to a Missing Key\n"); - setStatus(-1); - break; - case GPG_ERR_CERT_REVOKED: - stream << QApplication::tr( - "A signature is valid but the key used to verify the signature has been revoked\n"); - if (!printSigner(stream, sign)) { - setStatus(0); - } - setStatus(-1); - break; - case GPG_ERR_SIG_EXPIRED: - stream << QApplication::tr("A signature is valid but expired\n"); - if (!printSigner(stream, sign)) { - setStatus(0); - } - setStatus(-1); - break; - case GPG_ERR_KEY_EXPIRED: - stream << QApplication::tr( - "A signature is valid but the key used to verify the signature has expired.\n"); - if (!printSigner(stream, sign)) { - setStatus(0); - } - break; - case GPG_ERR_GENERAL: - stream << QApplication::tr( - "There was some other error which prevented the signature verification.\n"); - status = -1; - canContinue = false; - break; - default: - stream << QApplication::tr("Error for key with fingerprint ") << - GpgFrontend::GpgContext::beautifyFingerprint(QString(sign->fpr)); - setStatus(-1); + case GPG_ERR_NO_ERROR: + stream << QApplication::tr("A "); + if (sign->summary & GPGME_SIGSUM_GREEN) { + stream << QApplication::tr("Good "); + } + if (sign->summary & GPGME_SIGSUM_RED) { + stream << QApplication::tr("Bad "); + } + if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) { + stream << QApplication::tr("Expired "); + } + if (sign->summary & GPGME_SIGSUM_KEY_MISSING) { + stream << QApplication::tr("Missing Key's "); + } + if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) { + stream << QApplication::tr("Revoked Key's "); + } + if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) { + stream << QApplication::tr("Expired Key's "); + } + if (sign->summary & GPGME_SIGSUM_CRL_MISSING) { + stream << QApplication::tr("Missing CRL's "); + } + + if (sign->summary & GPGME_SIGSUM_VALID) { + stream << QApplication::tr("Signature Fully Valid.") << Qt::endl; + } else { + stream << QApplication::tr("Signature Not Fully Valid.") << Qt::endl; + } + + if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) { + if (!print_signer(stream, sign)) setStatus(0); + } else { + stream << QApplication::tr("Key is NOT present with ID 0x") << QString(sign->fpr) << Qt::endl; + } + + setStatus(1); + + break; + case GPG_ERR_NO_PUBKEY: + stream << QApplication::tr("A signature could NOT be verified due to a Missing Key\n"); + setStatus(-1); + break; + case GPG_ERR_CERT_REVOKED: + stream << QApplication::tr( + "A signature is valid but the key used to verify the signature has been revoked\n"); + if (!print_signer(stream, sign)) { + setStatus(0); + } + setStatus(-1); + break; + case GPG_ERR_SIG_EXPIRED: + stream << QApplication::tr("A signature is valid but expired\n"); + if (!print_signer(stream, sign)) { + setStatus(0); + } + setStatus(-1); + break; + case GPG_ERR_KEY_EXPIRED: + stream << QApplication::tr( + "A signature is valid but the key used to verify the signature has expired.\n"); + if (!print_signer(stream, sign)) { + setStatus(0); + } + break; + case GPG_ERR_GENERAL: + stream << QApplication::tr( + "There was some other error which prevented the signature verification.\n"); + status = -1; + canContinue = false; + break; + default: + stream << QApplication::tr("Error for key with fingerprint ") << + GpgFrontend::GpgContext::beautifyFingerprint(QString(sign->fpr)); + setStatus(-1); } stream << Qt::endl; sign = sign->next; @@ -147,7 +148,8 @@ GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(gpgme_error_t error, gpgme } } -bool GpgFrontend::VerifyResultAnalyse::printSigner(QTextStream &stream, gpgme_signature_t sign) { + +bool GpgFrontend::VerifyResultAnalyse::print_signer(QTextStream &stream, gpgme_signature_t sign) { bool keyFound = true; auto key = GpgFrontend::GpgKeyGetter::getInstance().getKey(sign->fpr); @@ -163,4 +165,5 @@ bool GpgFrontend::VerifyResultAnalyse::printSigner(QTextStream &stream, gpgme_si stream << tr(" Date & Time: ") << QDateTime::fromTime_t(sign->timestamp).toString() << Qt::endl; stream << Qt::endl; return keyFound; -}
\ No newline at end of file +} + |