aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/result_analyse/VerifyResultAnalyse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpg/result_analyse/VerifyResultAnalyse.cpp')
-rw-r--r--src/gpg/result_analyse/VerifyResultAnalyse.cpp84
1 files changed, 41 insertions, 43 deletions
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
index 44f4a3af..bb88b7e7 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp
+++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
@@ -5,20 +5,28 @@
#include "GpgFrontend.h"
#include "gpg/result_analyse/VerifyResultAnalyse.h"
-VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_signature_t sign) : mCtx(ctx) {
+VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_verify_result_t result)
+ : mCtx(ctx) {
- textSteam << "Verify Report: " << endl;
+ if(result == nullptr) {
+ return;
+ }
+
+ stream << "# Verify Report: " << endl << "-----" << endl;
+ stream << "Status: " << gpgme_strerror(error) << endl;
+
+ auto sign = result->signatures;
if (sign == nullptr){
- textSteam << "> Not Signature Found" << endl;
+ stream << "> Not Signature Found" << endl;
status = -1;
return;
}
- textSteam << "> It was Signed ON " << QDateTime::fromTime_t(sign->timestamp).toString() << endl;
+ stream << "> It was Signed ON " << QDateTime::fromTime_t(sign->timestamp).toString() << endl;
- textSteam << endl << "> It Contains:" << endl;
+ stream << endl << "> It Contains:" << endl;
bool canContinue = true;
@@ -26,88 +34,91 @@ VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_signature
switch (gpg_err_code(sign->status)) {
case GPG_ERR_BAD_SIGNATURE:
- textSteam << QApplication::tr("One or More Bad Signatures.") << endl;
+ stream << QApplication::tr("One or More Bad Signatures.") << endl;
canContinue = false;
setStatus(-1);
break;
case GPG_ERR_NO_ERROR:
- textSteam << QApplication::tr("A ");
+ stream << QApplication::tr("A ");
if(sign->summary & GPGME_SIGSUM_GREEN) {
- textSteam << QApplication::tr("Good ");
+ stream << QApplication::tr("Good ");
}
if(sign->summary & GPGME_SIGSUM_RED) {
- textSteam << QApplication::tr("Bad ");
+ stream << QApplication::tr("Bad ");
}
if(sign->summary & GPGME_SIGSUM_SIG_EXPIRED) {
- textSteam << QApplication::tr("Expired ");
+ stream << QApplication::tr("Expired ");
}
if(sign->summary & GPGME_SIGSUM_KEY_MISSING) {
- textSteam << QApplication::tr("Missing Key's ");
+ stream << QApplication::tr("Missing Key's ");
}
if(sign->summary & GPGME_SIGSUM_KEY_REVOKED) {
- textSteam << QApplication::tr("Revoked Key's ");
+ stream << QApplication::tr("Revoked Key's ");
}
if(sign->summary & GPGME_SIGSUM_KEY_EXPIRED) {
- textSteam << QApplication::tr("Expired Key's ");
+ stream << QApplication::tr("Expired Key's ");
}
if(sign->summary & GPGME_SIGSUM_CRL_MISSING) {
- textSteam << QApplication::tr("Missing CRL's ");
+ stream << QApplication::tr("Missing CRL's ");
}
if(sign->summary & GPGME_SIGSUM_VALID) {
- textSteam << QApplication::tr("Signature Fully Valid.") << endl;
+ stream << QApplication::tr("Signature Fully Valid.") << endl;
} else {
- textSteam << QApplication::tr("Signature NOT Fully Valid.") << endl;
+ stream << QApplication::tr("Signature NOT Fully Valid.") << endl;
}
if(!(sign->status & GPGME_SIGSUM_KEY_MISSING)) {
- if(!printSigner(textSteam, sign)) {
+ if(!printSigner(stream, sign)) {
setStatus(0);
}
} else {
- textSteam << QApplication::tr("Key is NOT present with ID 0x") << QString(sign->fpr) << endl;
+ stream << QApplication::tr("Key is NOT present with ID 0x") << QString(sign->fpr) << endl;
}
setStatus(1);
break;
case GPG_ERR_NO_PUBKEY:
- textSteam << QApplication::tr("A signature could NOT be verified due to a Missing Key\n");
+ stream << QApplication::tr("A signature could NOT be verified due to a Missing Key\n");
setStatus(-1);
break;
case GPG_ERR_CERT_REVOKED:
- textSteam << QApplication::tr("A signature is valid but the key used to verify the signature has been revoked\n");
- if(!printSigner(textSteam, sign)) {
+ 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:
- textSteam << QApplication::tr("A signature is valid but expired\n");
- if(!printSigner(textSteam, sign)) {
+ stream << QApplication::tr("A signature is valid but expired\n");
+ if(!printSigner(stream, sign)) {
setStatus(0);
}
setStatus(-1);
break;
case GPG_ERR_KEY_EXPIRED:
- textSteam << QApplication::tr("A signature is valid but the key used to verify the signature has expired.\n");
- if(!printSigner(textSteam, sign)) {
+ 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:
- textSteam << QApplication::tr("There was some other error which prevented the signature verification.\n");
+ stream << QApplication::tr("There was some other error which prevented the signature verification.\n");
status = -1;
canContinue = false;
break;
default:
- textSteam << QApplication::tr("Error for key with fingerprint ") <<
- GpgME::GpgContext::beautifyFingerprint(QString(sign->fpr));
+ stream << QApplication::tr("Error for key with fingerprint ") <<
+ GpgME::GpgContext::beautifyFingerprint(QString(sign->fpr));
setStatus(-1);
}
- textSteam << endl;
+ stream << endl;
sign = sign->next;
}
+
+ stream << "-----" << endl;
+ stream << endl;
}
bool VerifyResultAnalyse::printSigner(QTextStream &stream, gpgme_signature_t sign) {
@@ -126,17 +137,4 @@ bool VerifyResultAnalyse::printSigner(QTextStream &stream, gpgme_signature_t sig
stream << endl;
return keyFound;
-}
-
-const QString &VerifyResultAnalyse::getResultReport() const{
- return verifyLabelText;
-}
-
-int VerifyResultAnalyse::getStatus() const {
- return status;
-}
-
-void VerifyResultAnalyse::setStatus(int mStatus) {
- if(mStatus < status)
- status = mStatus;
-}
+} \ No newline at end of file