aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-11-26 10:55:40 +0000
committersaturneric <[email protected]>2024-11-26 10:55:40 +0000
commit83be6ce63a832890592f8cec9e2102663f0e8a36 (patch)
tree040ddd5f9e180eaf8f5ae2d2eea902ede2c94074
parentfeat: support verifying email through eml data (diff)
downloadGpgFrontend-83be6ce63a832890592f8cec9e2102663f0e8a36.tar.gz
GpgFrontend-83be6ce63a832890592f8cec9e2102663f0e8a36.zip
feat: improve ui logic of email verification and make project structure better
-rw-r--r--gpgfrontend.qrc1
m---------modules0
-rw-r--r--resource/lfs/icons/email-check.pngbin0 -> 5942 bytes
-rw-r--r--src/ui/UserInterfaceUtils.cpp29
-rw-r--r--src/ui/UserInterfaceUtils.h32
-rw-r--r--src/ui/main_window/MainWindow.h54
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp80
-rw-r--r--src/ui/main_window/MainWindowGpgOperaFunction.cpp21
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp198
-rw-r--r--src/ui/main_window/MainWindowUI.cpp18
-rw-r--r--src/ui/widgets/PlainTextEditorPage.cpp4
11 files changed, 296 insertions, 141 deletions
diff --git a/gpgfrontend.qrc b/gpgfrontend.qrc
index b4269ebd..d53dc1d3 100644
--- a/gpgfrontend.qrc
+++ b/gpgfrontend.qrc
@@ -103,6 +103,7 @@
<file alias="minus.png">resource/lfs/icons/minus.png</file>
<file alias="database.png">resource/lfs/icons/database.png</file>
<file alias="publish.png">resource/lfs/icons/publish.png</file>
+ <file alias="email-check.png">resource/lfs/icons/email-check.png</file>
</qresource>
<qresource prefix="/test/key">
<file alias="pv1.key">resource/lfs/test/data/pv1.key</file>
diff --git a/modules b/modules
-Subproject 7238486de0c4f13f61626f0bccfc7502c45f979
+Subproject 37bbb836f049e03b0bbdde20ac3d837b3667647
diff --git a/resource/lfs/icons/email-check.png b/resource/lfs/icons/email-check.png
new file mode 100644
index 00000000..e8791725
--- /dev/null
+++ b/resource/lfs/icons/email-check.png
Binary files differ
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index fc90fa7c..b8fc9961 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -91,35 +91,6 @@ void ImportUnknownKeyFromKeyserver(
}
}
-void refresh_info_board(InfoBoardWidget *info_board, int status,
- const QString &report_text) {
- if (status < 0) {
- info_board->SlotRefresh(report_text, INFO_ERROR_CRITICAL);
- } else if (status > 0) {
- info_board->SlotRefresh(report_text, INFO_ERROR_OK);
- } else {
- info_board->SlotRefresh(report_text, INFO_ERROR_WARN);
- }
-}
-
-void process_result_analyse(TextEdit *edit, InfoBoardWidget *info_board,
- const GpgResultAnalyse &result_analyse) {
- info_board->AssociateTabWidget(edit->tab_widget_);
- refresh_info_board(info_board, result_analyse.GetStatus(),
- result_analyse.GetResultReport());
-}
-
-void process_result_analyse(TextEdit *edit, InfoBoardWidget *info_board,
- const GpgResultAnalyse &result_analyse_a,
- const GpgResultAnalyse &result_analyse_b) {
- info_board->AssociateTabWidget(edit->tab_widget_);
-
- refresh_info_board(
- info_board,
- std::min(result_analyse_a.GetStatus(), result_analyse_b.GetStatus()),
- result_analyse_a.GetResultReport() + result_analyse_b.GetResultReport());
-}
-
void process_operation(QWidget *parent, const QString &waiting_title,
const Thread::Task::TaskRunnable func,
const Thread::Task::TaskCallback callback,
diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h
index 650d049e..dab442dd 100644
--- a/src/ui/UserInterfaceUtils.h
+++ b/src/ui/UserInterfaceUtils.h
@@ -69,38 +69,6 @@ void ImportUnknownKeyFromKeyserver(QWidget* parent,
/**
* @brief
*
- * @param info_board
- * @param status
- * @param report_text
- */
-void refresh_info_board(InfoBoardWidget* info_board, int status,
- const QString& report_text);
-
-/**
- * @brief
- *
- * @param edit
- * @param info_board
- * @param result_analyse
- */
-void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
- const GpgResultAnalyse& result_analyse);
-
-/**
- * @brief
- *
- * @param edit
- * @param info_board
- * @param result_analyse_a
- * @param result_analyse_b
- */
-void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
- const GpgResultAnalyse& result_analyse_a,
- const GpgResultAnalyse& result_analyse_b);
-
-/**
- * @brief
- *
* @param parent
* @param waiting_title
* @param func
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h
index 35620843..884e26ed 100644
--- a/src/ui/main_window/MainWindow.h
+++ b/src/ui/main_window/MainWindow.h
@@ -32,7 +32,9 @@
namespace GpgFrontend {
class GpgPassphraseContext;
-}
+class GpgResultAnalyse;
+class GpgVerifyResultAnalyse;
+} // namespace GpgFrontend
namespace GpgFrontend::UI {
@@ -396,6 +398,53 @@ class MainWindow : public GeneralMainWindow {
*/
void slot_verify_email_by_eml_data(const QByteArray& buffer);
+ /**
+ * @brief
+ *
+ * @param buffer
+ */
+ void slot_verify_email_by_eml_data_result_helper(
+ const QMap<QString, QString>& p);
+
+ /**
+ * @brief
+ *
+ * @param result_analyse
+ */
+ void slot_verifying_unknown_signature_helper(const GpgVerifyResultAnalyse& r);
+
+ /**
+ * @brief
+ *
+ * @param result_analyse
+ */
+ void slot_result_analyse_show_helper(const GpgResultAnalyse& r);
+
+ /**
+ * @brief
+ *
+ * @param r_a
+ * @param r_b
+ */
+ void slot_result_analyse_show_helper(const GpgResultAnalyse& r_a,
+ const GpgResultAnalyse& r_b);
+
+ /**
+ * @brief
+ *
+ * @param result_analyse
+ */
+ void slot_eml_verify_show_helper(const QString& email_info,
+ const GpgVerifyResultAnalyse& r);
+
+ /**
+ * @brief
+ *
+ * @param status
+ * @param text
+ */
+ void slot_refresh_info_board(int status, const QString& text);
+
private:
/**
* @details Create actions for the main-menu and the context-menu of the
@@ -460,6 +509,7 @@ class MainWindow : public GeneralMainWindow {
QToolBar*
special_edit_tool_bar_{}; ///< Toolbar holding special edit actions
QToolBar* key_tool_bar_{}; ///< Toolbar holding key operations
+ QToolBar* email_tool_bar_{};
QToolButton*
import_button_{}; ///< Tool button for import dropdown menu in toolbar
QDockWidget* key_list_dock_{}; ///< Encrypt Dock
@@ -530,7 +580,7 @@ class MainWindow : public GeneralMainWindow {
QAction* import_key_from_file_act_{}; ///<
QAction* import_key_from_clipboard_act_{}; ///<
QAction* import_key_from_key_server_act_{}; ///<
- QAction* verify_email_by_eml_data_{}; ///<
+ QAction* verify_email_by_eml_data_act_{}; ///<
QLabel* status_bar_icon_{}; ///<
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index 599fe4d6..12c06312 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -111,7 +111,7 @@ void MainWindow::SlotFileEncrypt(const QString& path) {
result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
this->slot_refresh_current_file_view();
});
});
@@ -163,7 +163,7 @@ void MainWindow::SlotFileEncrypt(const QString& path) {
m_key_list_->GetCurrentGpgContextChannel(), err, result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
this->slot_refresh_current_file_view();
});
});
@@ -237,7 +237,7 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) {
result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
this->slot_refresh_current_file_view();
});
});
@@ -289,7 +289,7 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) {
m_key_list_->GetCurrentGpgContextChannel(), err, result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
this->slot_refresh_current_file_view();
});
});
@@ -343,7 +343,7 @@ void MainWindow::SlotFileDecrypt(const QString& path) {
m_key_list_->GetCurrentGpgContextChannel(), err, result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
this->slot_refresh_current_file_view();
});
});
@@ -396,7 +396,7 @@ void MainWindow::SlotArchiveDecrypt(const QString& path) {
m_key_list_->GetCurrentGpgContextChannel(), err, result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
this->slot_refresh_current_file_view();
});
});
@@ -459,29 +459,29 @@ void MainWindow::SlotFileSign(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Signing"), [=](const OperaWaitingHd& op_hd) {
GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
- .SignFile(
- {keys->begin(), keys->end()}, path,
- !non_ascii_at_file_operation, sig_file_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 ||
- data_obj == nullptr ||
- !data_obj->Check<GpgSignResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgSignResult>(data_obj, 0);
- auto result_analyse = GpgSignResultAnalyse(
- m_key_list_->GetCurrentGpgContextChannel(), err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ .SignFile({keys->begin(), keys->end()}, path,
+ !non_ascii_at_file_operation, sig_file_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgSignResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgSignResult>(data_obj, 0);
+ auto result_analyse = GpgSignResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ result);
+ result_analyse.Analyse();
+
+ slot_result_analyse_show_helper(result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -553,7 +553,7 @@ void MainWindow::SlotFileVerify(const QString& path) {
m_key_list_->GetCurrentGpgContextChannel(), err, result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (!result_analyse.GetUnknownSignatures().isEmpty() &&
Module::IsModuleActivate(kKeyServerSyncModuleID)) {
@@ -706,9 +706,8 @@ void MainWindow::SlotFileEncryptSign(const QString& path) {
sign_result);
sign_result_analyse.Analyse();
- process_result_analyse(edit_, info_board_,
- encrypt_result_analyse,
- sign_result_analyse);
+ slot_result_analyse_show_helper(encrypt_result_analyse,
+ sign_result_analyse);
this->slot_refresh_current_file_view();
});
@@ -827,9 +826,8 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) {
sign_result);
sign_result_analyse.Analyse();
- process_result_analyse(edit_, info_board_,
- encrypt_result_analyse,
- sign_result_analyse);
+ slot_result_analyse_show_helper(encrypt_result_analyse,
+ sign_result_analyse);
this->slot_refresh_current_file_view();
});
@@ -893,9 +891,8 @@ void MainWindow::SlotFileDecryptVerify(const QString& path) {
verify_result);
verify_result_analyse.Analyse();
- process_result_analyse(edit_, info_board_,
- decrypt_result_analyse,
- verify_result_analyse);
+ slot_result_analyse_show_helper(decrypt_result_analyse,
+ verify_result_analyse);
this->slot_refresh_current_file_view();
@@ -996,9 +993,8 @@ void MainWindow::SlotArchiveDecryptVerify(const QString& path) {
verify_result);
verify_result_analyse.Analyse();
- process_result_analyse(edit_, info_board_,
- decrypt_result_analyse,
- verify_result_analyse);
+ slot_result_analyse_show_helper(decrypt_result_analyse,
+ verify_result_analyse);
// pause this feature
// if (verify_result_analyse.GetStatus() == -2) {
diff --git a/src/ui/main_window/MainWindowGpgOperaFunction.cpp b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
index 7a7c206c..2bfb09b8 100644
--- a/src/ui/main_window/MainWindowGpgOperaFunction.cpp
+++ b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
@@ -86,7 +86,7 @@ void MainWindow::SlotEncrypt() {
m_key_list_->GetCurrentGpgContextChannel(), err,
result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
edit_->SlotFillTextEditWithText(
@@ -143,7 +143,7 @@ void MainWindow::SlotEncrypt() {
auto result_analyse = GpgEncryptResultAnalyse(
m_key_list_->GetCurrentGpgContextChannel(), err, result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
edit_->SlotFillTextEditWithText(
@@ -209,7 +209,7 @@ void MainWindow::SlotSign() {
m_key_list_->GetCurrentGpgContextChannel(), err,
sign_result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
edit_->SlotFillTextEditWithText(
@@ -247,7 +247,7 @@ void MainWindow::SlotDecrypt() {
m_key_list_->GetCurrentGpgContextChannel(), err,
decrypt_result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
edit_->SlotFillTextEditWithText(
@@ -288,7 +288,7 @@ void MainWindow::SlotVerify() {
m_key_list_->GetCurrentGpgContextChannel(), err,
verify_result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (!result_analyse.GetUnknownSignatures().isEmpty() &&
Module::IsModuleActivate(kKeyServerSyncModuleID)) {
@@ -360,7 +360,7 @@ void MainWindow::SlotVerify(const QByteArray& raw_data,
m_key_list_->GetCurrentGpgContextChannel(), err,
verify_result);
result_analyse.Analyse();
- process_result_analyse(edit_, info_board_, result_analyse);
+ slot_result_analyse_show_helper(result_analyse);
if (!result_analyse.GetUnknownSignatures().isEmpty() &&
Module::IsModuleActivate(kKeyServerSyncModuleID)) {
@@ -489,9 +489,8 @@ void MainWindow::SlotEncryptSign() {
sign_result_analyse.Analyse();
// show analyse result
- process_result_analyse(edit_, info_board_,
- encrypt_result_analyse,
- sign_result_analyse);
+ slot_result_analyse_show_helper(encrypt_result_analyse,
+ sign_result_analyse);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
edit_->SlotFillTextEditWithText(
@@ -541,8 +540,8 @@ void MainWindow::SlotDecryptVerify() {
verify_result_analyse.Analyse();
// show analyse result
- process_result_analyse(edit_, info_board_, decrypt_result_analyse,
- verify_result_analyse);
+ slot_result_analyse_show_helper(decrypt_result_analyse,
+ verify_result_analyse);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
edit_->SlotFillTextEditWithText(
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index b4a59a14..66ce14e0 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -27,6 +27,7 @@
*/
#include "MainWindow.h"
+#include "core/function/gpg/GpgBasicOperator.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/module/ModuleManager.h"
@@ -355,24 +356,45 @@ void MainWindow::slot_verify_email_by_eml_data(const QByteArray& buffer) {
[=](Module::EventIdentifier i, Module::Event::ListenerIdentifier ei,
Module::Event::Params p) {
LOG_D() << "EMAIL_VERIFY_EML_DATA callback: " << i << ei;
- if (p["ret"] != "0" || !p["error_msg"].isEmpty()) {
+ if (p["ret"] != "0" || !p["err"].isEmpty()) {
LOG_E() << "An error occurred trying to verify email, "
- << "error message: " << p["error_msg"]
- << "reply data: " << p["reply_data"];
- } else if (p.contains("signature") && p.contains("mime")) {
- const auto mime = QByteArray::fromBase64(p["mime"].toLatin1());
- const auto signature =
- QByteArray::fromBase64(p["signature"].toLatin1());
-
- auto part_mime_content_hash =
- QCryptographicHash::hash(mime, QCryptographicHash::Sha1);
- LOG_D() << "get raw data of mime part, size:" << mime.size()
- << "sha1 hash:" << part_mime_content_hash.toHex();
-
- SlotVerify(mime, signature);
- } else {
- LOG_E() << "mime or signature data is missing";
+ << "error message: " << p["err"];
+
+ if (p["ret"] == "-2") {
+ QString detailed_error = p["err"];
+
+ QString info =
+ tr("# EML Data Error\n\n"
+ "The provided EML data does not conform to the "
+ "structure described in RFC 3156 and cannot be "
+ "validated.\n\n"
+ "Details: %1\n\n"
+ "What is EML Data?\n"
+ "EML is a file format used to represent email messages. "
+ "It typically contains the entire contents of an email, "
+ "including headers, "
+ "body text, attachments, and metadata. In order to validate "
+ "the email properly, it is necessary to provide the "
+ "complete, original EML "
+ "data.\n\n"
+ "For more information about the expected EML structure, "
+ "please refer to the RFC 3156 standard:\n"
+ "%2\n\n"
+ "Please ensure the EML data follows the standard and try "
+ "again.")
+ .arg(detailed_error)
+ .arg("https://www.rfc-editor.org/rfc/rfc3156.txt");
+ slot_refresh_info_board(-2, info);
+ }
+
+ return;
}
+
+ if (p.contains("signature") && p.contains("mime")) {
+ slot_verify_email_by_eml_data_result_helper(p);
+ }
+
+ LOG_E() << "mime or signature data is missing";
});
}
@@ -387,4 +409,148 @@ void MainWindow::SlotVerifyEML() {
slot_verify_email_by_eml_data(buffer);
}
+void MainWindow::slot_verifying_unknown_signature_helper(
+ const GpgVerifyResultAnalyse& result_analyse) {
+ LOG_D() << "try to sync missing key info from server"
+ << result_analyse.GetUnknownSignatures();
+
+ QString fingerprint_list;
+ for (const auto& fingerprint : 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(),
+ 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."));
+ }
+}
+
+void MainWindow::slot_verify_email_by_eml_data_result_helper(
+ const QMap<QString, QString>& p) {
+ const auto mime = QByteArray::fromBase64(p["mime"].toLatin1());
+ const auto signature = QByteArray::fromBase64(p["signature"].toLatin1());
+
+ auto timestamp = p.value("datetime", "-1").toLongLong();
+ auto datetime = tr("None");
+ if (timestamp > 0) {
+ datetime = QLocale().toString(QDateTime::fromMSecsSinceEpoch(timestamp));
+ }
+
+ QString email_info;
+ email_info.append("# Email Information\n\n");
+ email_info.append(QString("- %1: %2\n")
+ .arg(tr("From"))
+ .arg(p.value("from", tr("Unknown"))));
+ email_info.append(
+ QString("- %1: %2\n").arg(tr("To")).arg(p.value("to", tr("Unknown"))));
+ email_info.append(QString("- %1: %2\n")
+ .arg(tr("Subject"))
+ .arg(p.value("subject", tr("None"))));
+ email_info.append(
+ QString("- %1: %2\n").arg(tr("CC")).arg(p.value("cc", tr("None"))));
+ email_info.append(
+ QString("- %1: %2\n").arg(tr("BCC")).arg(p.value("bcc", tr("None"))));
+ email_info.append(QString("- %1: %2\n").arg(tr("Date")).arg(datetime));
+ email_info.append("\n");
+
+ // set input buffer
+ auto raw_data_buffer = GFBuffer(mime);
+ auto signature_buffer = GFBuffer(signature);
+
+ CommonUtils::WaitForOpera(
+ this, tr("Verifying"),
+ [this, email_info, raw_data_buffer,
+ signature_buffer](const OperaWaitingHd& hd) {
+ GpgFrontend::GpgBasicOperator::GetInstance(
+ m_key_list_->GetCurrentGpgContextChannel())
+ .Verify(
+ raw_data_buffer, signature_buffer,
+ [this, email_info, 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();
+ auto verify_result_report = result_analyse.GetResultReport();
+
+ slot_refresh_info_board(result_analyse.GetStatus(),
+ email_info + verify_result_report);
+
+ if (!result_analyse.GetUnknownSignatures().isEmpty() &&
+ Module::IsModuleActivate(kKeyServerSyncModuleID)) {
+ slot_verifying_unknown_signature_helper(result_analyse);
+ return;
+ }
+ });
+ });
+}
+
+void MainWindow::slot_eml_verify_show_helper(const QString& email_info,
+ const GpgVerifyResultAnalyse& r) {}
+
+void MainWindow::slot_result_analyse_show_helper(
+ const GpgResultAnalyse& result_analyse) {
+ slot_refresh_info_board(result_analyse.GetStatus(),
+ result_analyse.GetResultReport());
+}
+
+void MainWindow::slot_refresh_info_board(int status, const QString& text) {
+ if (edit_->tab_widget_ != nullptr) {
+ info_board_->AssociateTabWidget(edit_->tab_widget_);
+ }
+
+ if (status < 0) {
+ info_board_->SlotRefresh(text, INFO_ERROR_CRITICAL);
+ } else if (status > 0) {
+ info_board_->SlotRefresh(text, INFO_ERROR_OK);
+ } else {
+ info_board_->SlotRefresh(text, INFO_ERROR_WARN);
+ }
+}
+
+void MainWindow::slot_result_analyse_show_helper(const GpgResultAnalyse& r_a,
+ const GpgResultAnalyse& r_b) {
+ if (edit_->tab_widget_ != nullptr) {
+ info_board_->AssociateTabWidget(edit_->tab_widget_);
+ }
+
+ slot_refresh_info_board(std::min(r_a.GetStatus(), r_b.GetStatus()),
+ r_a.GetResultReport() + r_b.GetResultReport());
+}
+
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp
index 70bf300b..0b46e31d 100644
--- a/src/ui/main_window/MainWindowUI.cpp
+++ b/src/ui/main_window/MainWindowUI.cpp
@@ -426,10 +426,11 @@ void MainWindow::create_actions() {
* E-Mmail Menu
*/
if (Module::IsModuleActivate(kEmailModuleID)) {
- verify_email_by_eml_data_ = new QAction(tr("Verify E-Mail"), this);
- verify_email_by_eml_data_->setIcon(QIcon(":/icons/verify.png"));
- verify_email_by_eml_data_->setToolTip(tr("Verify RAW E-Mail Data (EML)"));
- connect(verify_email_by_eml_data_, &QAction::triggered, this, [this]() {
+ verify_email_by_eml_data_act_ = new QAction(tr("Verify E-Mail"), this);
+ verify_email_by_eml_data_act_->setIcon(QIcon(":/icons/email-check.png"));
+ verify_email_by_eml_data_act_->setToolTip(
+ tr("Verify RAW E-Mail Data (EML)"));
+ connect(verify_email_by_eml_data_act_, &QAction::triggered, this, [this]() {
if (edit_->SlotCurPageFileTreeView() != nullptr) {
const auto* file_tree_view = edit_->SlotCurPageFileTreeView();
const auto path = file_tree_view->GetSelected();
@@ -640,7 +641,7 @@ void MainWindow::create_menus() {
if (Module::IsModuleActivate(kEmailModuleID)) {
email_menu_ = menuBar()->addMenu(tr("E-Mail"));
- email_menu_->addAction(verify_email_by_eml_data_);
+ email_menu_->addAction(verify_email_by_eml_data_act_);
}
view_menu_ = menuBar()->addMenu(tr("View"));
@@ -702,6 +703,13 @@ void MainWindow::create_tool_bars() {
special_edit_tool_bar_->hide();
view_menu_->addAction(special_edit_tool_bar_->toggleViewAction());
+ if (Module::IsModuleActivate(kEmailModuleID)) {
+ email_tool_bar_ = addToolBar(tr("E-Mail"));
+ email_tool_bar_->setObjectName("emailToolBar");
+ email_tool_bar_->addAction(verify_email_by_eml_data_act_);
+ view_menu_->addAction(email_tool_bar_->toggleViewAction());
+ }
+
// Add dropdown menu for key import to keytoolbar
import_button_ = new QToolButton();
import_button_->setMenu(import_key_menu_);
diff --git a/src/ui/widgets/PlainTextEditorPage.cpp b/src/ui/widgets/PlainTextEditorPage.cpp
index b6066a30..c1c679a6 100644
--- a/src/ui/widgets/PlainTextEditorPage.cpp
+++ b/src/ui/widgets/PlainTextEditorPage.cpp
@@ -211,10 +211,6 @@ void PlainTextEditorPage::slot_insert_text(QByteArray bytes_data) {
read_bytes_ += bytes_data.size();
- if (bytes_data.contains("VusEk")) {
- LOG_D() << "WWWWWWW PPP: " << bytes_data;
- }
-
// insert the text to the text page
this->GetTextPage()->insertPlainText(bytes_data);
this->ui_->characterLabel->setText(