aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-01-26 18:33:11 +0000
committersaturneric <[email protected]>2025-01-26 18:33:11 +0000
commit8e7d3d6ac723917f73dcdb188b0056b1798c0ffb (patch)
tree4e33b07c5b743d9cd4b390a01aab6075a94c5ec8
parentfeat: allow file batch operations (diff)
downloadGpgFrontend-8e7d3d6ac723917f73dcdb188b0056b1798c0ffb.tar.gz
GpgFrontend-8e7d3d6ac723917f73dcdb188b0056b1798c0ffb.zip
fix: optimums unknown fpr verifying helper
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp2
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.h4
-rw-r--r--src/ui/UserInterfaceUtils.cpp2
-rw-r--r--src/ui/UserInterfaceUtils.h2
-rw-r--r--src/ui/main_window/MainWindow.h2
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp31
-rw-r--r--src/ui/main_window/MainWindowGpgOperaFunction.cpp115
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp20
8 files changed, 61 insertions, 117 deletions
diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
index 9512189d..e2fc21f0 100644
--- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
@@ -256,6 +256,6 @@ auto GpgFrontend::GpgVerifyResultAnalyse::TakeChargeOfResult()
}
auto GpgFrontend::GpgVerifyResultAnalyse::GetUnknownSignatures() const
- -> QList<QString> {
+ -> QStringList {
return unknown_signer_fpr_list_;
}
diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.h b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
index b3e318b8..b5f681ab 100644
--- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
@@ -67,7 +67,7 @@ class GPGFRONTEND_CORE_EXPORT GpgVerifyResultAnalyse : public GpgResultAnalyse {
*
* @return QList<QString>
*/
- [[nodiscard]] auto GetUnknownSignatures() const -> QList<QString>;
+ [[nodiscard]] auto GetUnknownSignatures() const -> QStringList;
protected:
/**
@@ -99,7 +99,7 @@ class GPGFRONTEND_CORE_EXPORT GpgVerifyResultAnalyse : public GpgResultAnalyse {
GpgError error_; ///<
GpgVerifyResult result_; ///<
- QList<QString> unknown_signer_fpr_list_;
+ QStringList unknown_signer_fpr_list_;
};
} // namespace GpgFrontend
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index ea5bb3d9..74e2c82a 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -663,7 +663,7 @@ void CommonUtils::ImportKeyFromKeyServer(int channel,
}
void CommonUtils::ImportKeyByKeyServerSyncModule(QWidget *parent, int channel,
- const QList<QString> &fprs) {
+ const QStringList &fprs) {
if (!Module::IsModuleActivate(kKeyServerSyncModuleID)) {
return;
}
diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h
index 81de99ed..c543bf58 100644
--- a/src/ui/UserInterfaceUtils.h
+++ b/src/ui/UserInterfaceUtils.h
@@ -238,7 +238,7 @@ class CommonUtils : public QWidget {
* @param channel
*/
void ImportKeyByKeyServerSyncModule(QWidget* parent, int channel,
- const QList<QString>& fprs);
+ const QStringList& fprs);
/**
* @brief
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h
index 357a3ed5..cc3ffd0e 100644
--- a/src/ui/main_window/MainWindow.h
+++ b/src/ui/main_window/MainWindow.h
@@ -455,7 +455,7 @@ class MainWindow : public GeneralMainWindow {
*
* @param result_analyse
*/
- void slot_verifying_unknown_signature_helper(const GpgVerifyResultAnalyse& r);
+ void slot_verifying_unknown_signature_helper(const QStringList& fprs);
/**
* @brief
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index bfda5a8b..baf21396 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -599,15 +599,12 @@ void MainWindow::build_operas_file_verify(
slot_result_analyse_show_helper(result_analyse);
- if (!result_analyse.GetUnknownSignatures().isEmpty() &&
- Module::IsModuleActivate(kKeyServerSyncModuleID)) {
- slot_verifying_unknown_signature_helper(result_analyse);
- }
-
opera_results.append(
{result_analyse.GetStatus(),
result_analyse.GetResultReport(),
QFileInfo(path.isEmpty() ? o_path : path).fileName()});
+
+ context->unknown_fprs = result_analyse.GetUnknownSignatures();
});
};
@@ -658,6 +655,11 @@ void MainWindow::SlotFileVerify(const QContainer<QString>& paths) {
if (f_context != nullptr) build_operas_file_verify(f_context);
execute_operas_helper(tr("Verifying"), contexts);
+
+ if (!contexts->unknown_fprs.isEmpty() &&
+ Module::IsModuleActivate(kKeyServerSyncModuleID)) {
+ slot_verifying_unknown_signature_helper(contexts->unknown_fprs);
+ }
}
void MainWindow::build_operas_file_encrypt_sign(
@@ -871,11 +873,8 @@ void MainWindow::build_operas_file_decrypt_verify(
verify_result_analyse.GetResultReport(),
QFileInfo(path).fileName()});
- if (!verify_result_analyse.GetUnknownSignatures().isEmpty() &&
- Module::IsModuleActivate(kKeyServerSyncModuleID)) {
- slot_verifying_unknown_signature_helper(
- verify_result_analyse);
- }
+ context->unknown_fprs =
+ verify_result_analyse.GetUnknownSignatures();
});
};
@@ -929,11 +928,8 @@ void MainWindow::build_operas_archive_decrypt_verify(
verify_result_analyse.GetResultReport(),
QFileInfo(path).fileName()});
- if (!verify_result_analyse.GetUnknownSignatures().isEmpty() &&
- Module::IsModuleActivate(kKeyServerSyncModuleID)) {
- slot_verifying_unknown_signature_helper(
- verify_result_analyse);
- }
+ context->unknown_fprs =
+ verify_result_analyse.GetUnknownSignatures();
});
};
@@ -974,6 +970,11 @@ void MainWindow::SlotFileDecryptVerify(const QContainer<QString>& paths) {
}
execute_operas_helper(tr("Decrypting and Verifying"), contexts);
+
+ if (!contexts->unknown_fprs.isEmpty() &&
+ Module::IsModuleActivate(kKeyServerSyncModuleID)) {
+ slot_verifying_unknown_signature_helper(contexts->unknown_fprs);
+ }
};
void MainWindow::SlotFileVerifyEML(const QString& path) {
diff --git a/src/ui/main_window/MainWindowGpgOperaFunction.cpp b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
index 4432d4e4..d9d2000f 100644
--- a/src/ui/main_window/MainWindowGpgOperaFunction.cpp
+++ b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
@@ -289,7 +289,8 @@ void MainWindow::SlotVerify() {
if (!result_analyse.GetUnknownSignatures().isEmpty() &&
Module::IsModuleActivate(kKeyServerSyncModuleID)) {
- slot_verifying_unknown_signature_helper(result_analyse);
+ slot_verifying_unknown_signature_helper(
+ result_analyse.GetUnknownSignatures());
}
});
});
@@ -306,64 +307,34 @@ void MainWindow::SlotVerify(const QByteArray& raw_data,
[this, raw_data_buffer, signature_buffer](const OperaWaitingHd& hd) {
GpgFrontend::GpgBasicOperator::GetInstance(
m_key_list_->GetCurrentGpgContextChannel())
- .Verify(
- raw_data_buffer, signature_buffer,
- [this, hd](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 ||
- data_obj == nullptr ||
- !data_obj->Check<GpgVerifyResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
- auto verify_result =
- ExtractParams<GpgVerifyResult>(data_obj, 0);
-
- // analyse result
- auto result_analyse = GpgVerifyResultAnalyse(
- m_key_list_->GetCurrentGpgContextChannel(), err,
- verify_result);
- result_analyse.Analyse();
- slot_result_analyse_show_helper(result_analyse);
+ .Verify(raw_data_buffer, signature_buffer,
+ [this, hd](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ hd();
- if (!result_analyse.GetUnknownSignatures().isEmpty() &&
- Module::IsModuleActivate(kKeyServerSyncModuleID)) {
- LOG_D() << "try to sync missing key info from server"
- << result_analyse.GetUnknownSignatures();
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgVerifyResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+ auto verify_result =
+ ExtractParams<GpgVerifyResult>(data_obj, 0);
- QString fingerprint_list;
- for (const auto& fingerprint :
- result_analyse.GetUnknownSignatures()) {
- fingerprint_list += fingerprint + "\n";
- }
+ // analyse result
+ auto result_analyse = GpgVerifyResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ verify_result);
+ result_analyse.Analyse();
+ slot_result_analyse_show_helper(result_analyse);
- // Interaction with user
- auto user_response = QMessageBox::question(
- this, tr("Missing Keys"),
- tr("Some signatures cannot be verified because the "
- "corresponding keys are missing.\n\n"
- "The following fingerprints are missing:\n%1\n\n"
- "Would you like to fetch these keys from the key "
- "server?")
- .arg(fingerprint_list),
- QMessageBox::Yes | QMessageBox::No);
-
- if (user_response == QMessageBox::Yes) {
- CommonUtils::GetInstance()
- ->ImportKeyByKeyServerSyncModule(
- this, m_key_list_->GetCurrentGpgContextChannel(),
- result_analyse.GetUnknownSignatures());
- } else {
- QMessageBox::information(
- this, tr("Verification Incomplete"),
- tr("Verification was incomplete due to missing "
- "keys. You can manually import the keys later."));
- }
- }
- });
+ if (!result_analyse.GetUnknownSignatures().isEmpty() &&
+ Module::IsModuleActivate(kKeyServerSyncModuleID)) {
+ slot_verifying_unknown_signature_helper(
+ result_analyse.GetUnknownSignatures());
+ }
+ });
});
}
@@ -516,36 +487,8 @@ void MainWindow::SlotDecryptVerify() {
if (!verify_result_analyse.GetUnknownSignatures().isEmpty() &&
Module::IsModuleActivate(kKeyServerSyncModuleID)) {
- LOG_D() << "try to sync missing key info from server"
- << verify_result_analyse.GetUnknownSignatures();
-
- QString fingerprint_list;
- for (const auto& fingerprint :
- verify_result_analyse.GetUnknownSignatures()) {
- fingerprint_list += fingerprint + "\n";
- }
-
- // Interaction with user
- auto user_response = QMessageBox::question(
- this, tr("Missing Keys"),
- tr("Some signatures cannot be verified because the "
- "corresponding keys are missing.\n\n"
- "The following fingerprints are missing:\n%1\n\n"
- "Would you like to fetch these keys from the key "
- "server?")
- .arg(fingerprint_list),
- QMessageBox::Yes | QMessageBox::No);
-
- if (user_response == QMessageBox::Yes) {
- CommonUtils::GetInstance()->ImportKeyByKeyServerSyncModule(
- this, m_key_list_->GetCurrentGpgContextChannel(),
- verify_result_analyse.GetUnknownSignatures());
- } else {
- QMessageBox::information(
- this, tr("Verification Incomplete"),
- tr("Verification was incomplete due to missing "
- "keys. You can manually import the keys later."));
- }
+ slot_verifying_unknown_signature_helper(
+ verify_result_analyse.GetUnknownSignatures());
}
});
});
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index ee66aebb..a5a56c1f 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -450,17 +450,18 @@ void MainWindow::SlotVerifyEML() {
}
void MainWindow::slot_verifying_unknown_signature_helper(
- const GpgVerifyResultAnalyse& result_analyse) {
- if (!Module::IsModuleActivate(kKeyServerSyncModuleID)) return;
+ const QStringList& fprs) {
+ if (!Module::IsModuleActivate(kKeyServerSyncModuleID) || fprs.empty()) return;
- LOG_D() << "try to sync missing key info from server: "
- << result_analyse.GetUnknownSignatures();
+ auto fpr_set = QSet<QString>(fprs.begin(), fprs.end());
- QString fingerprint_list;
- for (const auto& fingerprint : result_analyse.GetUnknownSignatures()) {
- fingerprint_list += fingerprint + "\n";
+ QString fpr_list;
+ for (const auto& fpr : fpr_set) {
+ fpr_list += fpr + "\n";
}
+ LOG_D() << "try to sync missing key info from server: " << fpr_set;
+
// Interaction with user
auto user_response =
QMessageBox::question(this, tr("Missing Keys"),
@@ -470,13 +471,12 @@ void MainWindow::slot_verifying_unknown_signature_helper(
"missing:\n%1\n\n"
"Would you like to fetch these keys from "
"the key server?")
- .arg(fingerprint_list),
+ .arg(fpr_list),
QMessageBox::Yes | QMessageBox::No);
if (user_response == QMessageBox::Yes) {
CommonUtils::GetInstance()->ImportKeyByKeyServerSyncModule(
- this, m_key_list_->GetCurrentGpgContextChannel(),
- result_analyse.GetUnknownSignatures());
+ this, m_key_list_->GetCurrentGpgContextChannel(), fpr_set.values());
} else {
QMessageBox::information(
this, tr("Verification Incomplete"),