From 06fcf7034d0ddb7444b57a1f9fe898eed7baafed Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 26 Jan 2024 01:23:46 +0800 Subject: feat: enhance analysed results of verification and signing --- .../result_analyse/GpgSignResultAnalyse.cpp | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/core/function/result_analyse/GpgSignResultAnalyse.cpp') diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp index bf429f38..6e3e5cf4 100644 --- a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp @@ -71,13 +71,32 @@ void GpgSignResultAnalyse::doAnalyse() { stream_ << Qt::endl; - auto singer_key = GpgKeyGetter::GetInstance().GetKey(new_sign->fpr); + QString fpr = new_sign->fpr == nullptr ? "" : new_sign->fpr; + auto singer_key = GpgKeyGetter::GetInstance().GetKey(fpr); if (singer_key.IsGood()) { - stream_ << "- " << tr("Signer") << ": " + stream_ << "- " << tr("Signed By") << ": " << singer_key.GetUIDs()->front().GetUID() << Qt::endl; + + auto subkeys = singer_key.GetSubKeys(); + auto it = std::find_if( + subkeys->begin(), subkeys->end(), + [fpr](const GpgSubKey &k) { return k.GetFingerprint() == fpr; }); + + if (it != subkeys->end()) { + auto &subkey = *it; + if (subkey.GetFingerprint() != singer_key.GetFingerprint()) { + stream_ << "- " << tr("Key ID") << ": " << singer_key.GetId() + << " (" << tr("Subkey") << ")" << Qt::endl; + } else { + stream_ << "- " << tr("Key ID") << ": " << singer_key.GetId() + << " (" << tr("Primary Key") << ")" << Qt::endl; + } + stream_ << "- " << tr("Key Create Date") << ": " + << QLocale().toString(subkey.GetCreateTime()) << Qt::endl; + } } else { - stream_ << "- " << tr("Signer") << ": " - << "" << Qt::endl; + stream_ << "- " << tr("Signed By") << "(" << tr("Fingerprint") << ")" + << ": " << (fpr.isEmpty() ? tr("") : fpr) << Qt::endl; } stream_ << "- " << tr("Public Key Algo") << ": " << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << Qt::endl; -- cgit v1.2.3