aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/result_analyse/VerifyResultAnalyse.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-12-01 17:25:46 +0000
committerSaturneric <[email protected]>2021-12-01 17:53:09 +0000
commit1ae8663decb3163b92d32b80cefb46eb678a5af6 (patch)
tree8e8cb58cacfe12827438b0524917cb0926f926cb /src/gpg/result_analyse/VerifyResultAnalyse.cpp
parentAdd & Modified (diff)
downloadGpgFrontend-1ae8663decb3163b92d32b80cefb46eb678a5af6.tar.gz
GpgFrontend-1ae8663decb3163b92d32b80cefb46eb678a5af6.zip
Add i18n Support
1. Remove Qt Linguist. 2. Add GNU gettext libraries. 3. Modified source codes to meet with i18n support.
Diffstat (limited to 'src/gpg/result_analyse/VerifyResultAnalyse.cpp')
-rw-r--r--src/gpg/result_analyse/VerifyResultAnalyse.cpp203
1 files changed, 104 insertions, 99 deletions
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
index 598329dd..849c2051 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp
+++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
@@ -1,7 +1,7 @@
/**
- * This file is part of GPGFrontend.
+ * This file is part of GpgFrontend.
*
- * GPGFrontend is free software: you can redistribute it and/or modify
+ * GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@@ -23,6 +23,7 @@
*/
#include "gpg/result_analyse/VerifyResultAnalyse.h"
+
#include "GpgFrontend.h"
#include "gpg/GpgConstants.h"
#include "gpg/function/GpgKeyGetter.h"
@@ -32,14 +33,14 @@ GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(GpgError error,
: error(error), result(std::move(result)) {}
void GpgFrontend::VerifyResultAnalyse::do_analyse() {
- LOG(INFO) << "Verify Result Analyse Started";
+ LOG(INFO) << _("Verify Result Analyse Started");
- stream << "[#] Verify Operation ";
+ stream << "[#] " << _("Verify Operation") << " ";
if (gpgme_err_code(error) == GPG_ERR_NO_ERROR)
- stream << "[Success]" << std::endl;
+ stream << "[" << _("Success") << "]" << std::endl;
else {
- stream << "[Failed] " << gpgme_strerror(error) << std::endl;
+ stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl;
setStatus(-1);
}
@@ -48,105 +49,108 @@ void GpgFrontend::VerifyResultAnalyse::do_analyse() {
auto sign = result->signatures;
if (sign == nullptr) {
- stream << "[>] Not Signature Found" << std::endl;
+ stream << "[>] " << _("Not Signature Found") << std::endl;
setStatus(0);
return;
}
- stream << "[>] Signed On "
+ stream << "[>] " << _("Signed On") << " "
<< boost::posix_time::to_iso_string(
boost::posix_time::from_time_t(sign->timestamp))
<< std::endl;
- stream << std::endl << "[>] Signatures:" << std::endl;
+ stream << std::endl << "[>] " << _("Signatures") << ":" << std::endl;
bool canContinue = true;
while (sign && canContinue) {
switch (gpg_err_code(sign->status)) {
- case GPG_ERR_BAD_SIGNATURE:
- stream << "One or More Bad Signatures." << std::endl;
- canContinue = false;
- setStatus(-1);
- break;
- case GPG_ERR_NO_ERROR:
- stream << "A ";
- if (sign->summary & GPGME_SIGSUM_GREEN) {
- stream << "Good ";
- }
- if (sign->summary & GPGME_SIGSUM_RED) {
- stream << "Bad ";
- }
- if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) {
- stream << "Expired ";
- }
- if (sign->summary & GPGME_SIGSUM_KEY_MISSING) {
- stream << "Missing Key's ";
- }
- if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) {
- stream << "Revoked Key's ";
- }
- if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) {
- stream << "Expired Key's ";
- }
- if (sign->summary & GPGME_SIGSUM_CRL_MISSING) {
- stream << "Missing CRL's ";
- }
-
- if (sign->summary & GPGME_SIGSUM_VALID) {
- stream << "Signature Fully Valid." << std::endl;
- } else {
- stream << "Signature Not Fully Valid." << std::endl;
- }
-
- if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) {
- if (!print_signer(stream, sign))
+ case GPG_ERR_BAD_SIGNATURE:
+ stream << _("One or More Bad Signatures.") << std::endl;
+ canContinue = false;
+ setStatus(-1);
+ break;
+ case GPG_ERR_NO_ERROR:
+ stream << _("A") << " ";
+ if (sign->summary & GPGME_SIGSUM_GREEN) {
+ stream << _("Good") << " ";
+ }
+ if (sign->summary & GPGME_SIGSUM_RED) {
+ stream << _("Bad") << " ";
+ }
+ if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) {
+ stream << _("Expired") << " ";
+ }
+ if (sign->summary & GPGME_SIGSUM_KEY_MISSING) {
+ stream << _("Missing Key's") << " ";
+ }
+ if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) {
+ stream << _("Revoked Key's") << " ";
+ }
+ if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) {
+ stream << _("Expired Key's") << " ";
+ }
+ if (sign->summary & GPGME_SIGSUM_CRL_MISSING) {
+ stream << _("Missing CRL's") << " ";
+ }
+
+ if (sign->summary & GPGME_SIGSUM_VALID) {
+ stream << _("Signature Fully Valid.") << std::endl;
+ } else {
+ stream << _("Signature Not Fully Valid.") << std::endl;
+ }
+
+ if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) {
+ if (!print_signer(stream, sign)) setStatus(0);
+ } else {
+ stream << _("Key is NOT present with ID 0x") << sign->fpr
+ << std::endl;
+ }
+
+ setStatus(1);
+
+ break;
+ case GPG_ERR_NO_PUBKEY:
+ stream << _("A signature could NOT be verified due to a Missing Key")
+ << std::endl;
+ setStatus(-1);
+ break;
+ case GPG_ERR_CERT_REVOKED:
+ stream << _("A signature is valid but the key used to verify the "
+ "signature has been revoked")
+ << std::endl;
+ if (!print_signer(stream, sign)) {
+ setStatus(0);
+ }
+ setStatus(-1);
+ break;
+ case GPG_ERR_SIG_EXPIRED:
+ stream << _("A signature is valid but expired") << std::endl;
+ if (!print_signer(stream, sign)) {
+ setStatus(0);
+ }
+ setStatus(-1);
+ break;
+ case GPG_ERR_KEY_EXPIRED:
+ stream << _("A signature is valid but the key used to "
+ "verify the signature has expired.")
+ << std::endl;
+ if (!print_signer(stream, sign)) {
setStatus(0);
- } else {
- stream << "Key is NOT present with ID 0x" << sign->fpr << std::endl;
- }
-
- setStatus(1);
-
- break;
- case GPG_ERR_NO_PUBKEY:
- stream << "A signature could NOT be verified due to a Missing "
- "Key\n";
- setStatus(-1);
- break;
- case GPG_ERR_CERT_REVOKED:
- stream << "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 << "A signature is valid but expired\n";
- if (!print_signer(stream, sign)) {
- setStatus(0);
- }
- setStatus(-1);
- break;
- case GPG_ERR_KEY_EXPIRED:
- stream << "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 << "There was some other error which prevented "
- "the signature verification.\n";
- status = -1;
- canContinue = false;
- break;
- default:
- auto fpr = std::string(sign->fpr);
- stream << "Error for key with fingerprint "
- << GpgFrontend::beautify_fingerprint(fpr);
- setStatus(-1);
+ }
+ break;
+ case GPG_ERR_GENERAL:
+ stream << _("There was some other error which prevented "
+ "the signature verification.")
+ << std::endl;
+ status = -1;
+ canContinue = false;
+ break;
+ default:
+ auto fpr = std::string(sign->fpr);
+ stream << _("Error for key with fingerprint") << " "
+ << GpgFrontend::beautify_fingerprint(fpr);
+ setStatus(-1);
}
stream << std::endl;
sign = sign->next;
@@ -161,18 +165,19 @@ bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream,
auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(sign->fpr);
if (!key.good()) {
- stream << " Signed By: "
- << "<unknown>" << std::endl;
+ stream << " " << _("Signed By") << ": "
+ << "<" << _("Unknown") << ">" << std::endl;
setStatus(0);
keyFound = false;
} else {
- stream << " Signed By: " << key.uids()->front().uid() << std::endl;
+ stream << " " << _("Signed By") << ": " << key.uids()->front().uid()
+ << std::endl;
}
- stream << " Public Key Algo: " << gpgme_pubkey_algo_name(sign->pubkey_algo)
- << std::endl;
- stream << " Hash Algo: " << gpgme_hash_algo_name(sign->hash_algo)
- << std::endl;
- stream << " Date & Time: "
+ stream << " " << _("Public Key Algo") << ": "
+ << gpgme_pubkey_algo_name(sign->pubkey_algo) << std::endl;
+ stream << " " << _("Hash Algo") << ": "
+ << gpgme_hash_algo_name(sign->hash_algo) << std::endl;
+ stream << " " << _("Date & Time") << ": "
<< boost::posix_time::to_iso_string(
boost::posix_time::from_time_t(sign->timestamp))
<< std::endl;