aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/main_window/MainWindowFileSlotFunction.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-10-26 13:43:14 +0000
committersaturneric <[email protected]>2024-10-26 13:43:14 +0000
commit24c28eb752aa611dd1670f3fa7ab6b358b052f1b (patch)
tree6a4f9af003fa4a86b7d7e29a965e37a231951092 /src/ui/main_window/MainWindowFileSlotFunction.cpp
parentfix: thread concurrent crash issue (diff)
downloadGpgFrontend-24c28eb752aa611dd1670f3fa7ab6b358b052f1b.tar.gz
GpgFrontend-24c28eb752aa611dd1670f3fa7ab6b358b052f1b.zip
fix: test basic operations of multi key db and solve issues
Diffstat (limited to 'src/ui/main_window/MainWindowFileSlotFunction.cpp')
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp703
1 files changed, 387 insertions, 316 deletions
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index 36cdb727..bad59303 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -89,33 +89,38 @@ void MainWindow::SlotFileEncrypt(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Symmetrically Encrypting"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().EncryptFileSymmetric(
- path, !non_ascii_at_file_operation, out_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 ||
- data_obj == nullptr ||
- !data_obj->Check<GpgEncryptResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
- auto result_analyse = GpgEncryptResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .EncryptFileSymmetric(
+ path, !non_ascii_at_file_operation, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgEncryptResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
+ auto result_analyse = GpgEncryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
return;
}
- auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
+ auto p_keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(key_ids);
// check key abilities
for (const auto& key : *p_keys) {
@@ -133,27 +138,30 @@ void MainWindow::SlotFileEncrypt(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Encrypting"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().EncryptFile(
- {p_keys->begin(), p_keys->end()}, path,
- !non_ascii_at_file_operation, out_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgEncryptResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
- auto result_analyse = GpgEncryptResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .EncryptFile(
+ {p_keys->begin(), p_keys->end()}, path,
+ !non_ascii_at_file_operation, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgEncryptResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
+ auto result_analyse = GpgEncryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err, result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -205,32 +213,37 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Archiving & Symmetrically Encrypting"),
[=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().EncryptDerectorySymmetric(
- path, !non_ascii_at_file_operation, out_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (data_obj == nullptr ||
- !data_obj->Check<GpgEncryptResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
- auto result_analyse = GpgEncryptResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .EncryptDerectorySymmetric(
+ path, !non_ascii_at_file_operation, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (data_obj == nullptr ||
+ !data_obj->Check<GpgEncryptResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
+ auto result_analyse = GpgEncryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
return;
}
- auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
+ auto p_keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(key_ids);
// check key abilities
for (const auto& key : *p_keys) {
@@ -248,27 +261,30 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Archiving & Encrypting"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().EncryptDirectory(
- {p_keys->begin(), p_keys->end()}, path,
- !non_ascii_at_file_operation, out_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgEncryptResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
- auto result_analyse = GpgEncryptResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .EncryptDirectory(
+ {p_keys->begin(), p_keys->end()}, path,
+ !non_ascii_at_file_operation, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgEncryptResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgEncryptResult>(data_obj, 0);
+ auto result_analyse = GpgEncryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err, result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -300,25 +316,29 @@ void MainWindow::SlotFileDecrypt(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Decrypting"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().DecryptFile(
- path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgDecryptResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgDecryptResult>(data_obj, 0);
- auto result_analyse = GpgDecryptResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .DecryptFile(
+ path, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgDecryptResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgDecryptResult>(data_obj, 0);
+ auto result_analyse = GpgDecryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err, result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -349,25 +369,29 @@ void MainWindow::SlotArchiveDecrypt(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Decrypting & Extrating"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().DecryptArchive(
- path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgDecryptResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgDecryptResult>(data_obj, 0);
- auto result_analyse = GpgDecryptResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .DecryptArchive(
+ path, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgDecryptResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgDecryptResult>(data_obj, 0);
+ auto result_analyse = GpgDecryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err, result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -381,7 +405,9 @@ void MainWindow::SlotFileSign(const QString& path) {
}
auto key_ids = m_key_list_->GetChecked();
- auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
+ auto keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(key_ids);
if (keys->empty()) {
QMessageBox::critical(
@@ -422,26 +448,30 @@ void MainWindow::SlotFileSign(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Signing"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().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(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
- this->slot_refresh_current_file_view();
- });
+ 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();
+ });
});
}
@@ -493,36 +523,39 @@ void MainWindow::SlotFileVerify(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Verifying"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().VerifyFile(
- data_file_path, sign_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<GpgVerifyResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
-
- auto result = ExtractParams<GpgVerifyResult>(data_obj, 0);
- auto result_analyse = GpgVerifyResultAnalyse(err, result);
- result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, result_analyse);
-
- // pause this feature
- // if (result_analyse.GetStatus() == -2) {
- // import_unknown_key_from_keyserver(this, result_analyse);
- // }
- // pause this feature
- // if (result_analyse.GetStatus() >= 0) {
- // show_verify_details(this, info_board_, err, result);
- // }
-
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .VerifyFile(
+ data_file_path, sign_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<GpgVerifyResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+
+ auto result = ExtractParams<GpgVerifyResult>(data_obj, 0);
+ auto result_analyse = GpgVerifyResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err, result);
+ result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_, result_analyse);
+
+ // pause this feature
+ // if (result_analyse.GetStatus() == -2) {
+ // import_unknown_key_from_keyserver(this, result_analyse);
+ // }
+ // pause this feature
+ // if (result_analyse.GetStatus() >= 0) {
+ // show_verify_details(this, info_board_, err, result);
+ // }
+
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -536,7 +569,9 @@ void MainWindow::SlotFileEncryptSign(const QString& path) {
// check selected keys
auto key_ids = m_key_list_->GetChecked();
- auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
+ auto p_keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(key_ids);
if (p_keys->empty()) {
QMessageBox::critical(
@@ -583,7 +618,8 @@ void MainWindow::SlotFileEncryptSign(const QString& path) {
if (ret == QMessageBox::Cancel) return;
}
- auto* signers_picker = new SignersPicker(this);
+ auto* signers_picker =
+ new SignersPicker(m_key_list_->GetCurrentGpgContextChannel(), this);
QEventLoop loop;
connect(signers_picker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
@@ -592,40 +628,48 @@ void MainWindow::SlotFileEncryptSign(const QString& path) {
if (!signers_picker->GetStatus()) return;
auto signer_key_ids = signers_picker->GetCheckedSigners();
- auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
+ auto p_signer_keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(signer_key_ids);
CommonUtils::WaitForOpera(
this, tr("Encrypting and Signing"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().EncryptSignFile(
- {p_keys->begin(), p_keys->end()},
- {p_signer_keys->begin(), p_signer_keys->end()}, path,
- !non_ascii_at_file_operation, out_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgEncryptResult, GpgSignResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
- auto encrypt_result =
- ExtractParams<GpgEncryptResult>(data_obj, 0);
- auto sign_result = ExtractParams<GpgSignResult>(data_obj, 1);
-
- auto encrypt_result_analyse =
- GpgEncryptResultAnalyse(err, encrypt_result);
- encrypt_result_analyse.Analyse();
-
- auto sign_result_analyse = GpgSignResultAnalyse(err, sign_result);
- sign_result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, encrypt_result_analyse,
- sign_result_analyse);
-
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .EncryptSignFile(
+ {p_keys->begin(), p_keys->end()},
+ {p_signer_keys->begin(), p_signer_keys->end()}, path,
+ !non_ascii_at_file_operation, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgEncryptResult, GpgSignResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+ auto encrypt_result =
+ ExtractParams<GpgEncryptResult>(data_obj, 0);
+ auto sign_result = ExtractParams<GpgSignResult>(data_obj, 1);
+
+ auto encrypt_result_analyse = GpgEncryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ encrypt_result);
+ encrypt_result_analyse.Analyse();
+
+ auto sign_result_analyse = GpgSignResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ sign_result);
+ sign_result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_,
+ encrypt_result_analyse,
+ sign_result_analyse);
+
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -639,7 +683,9 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) {
// check selected keys
auto key_ids = m_key_list_->GetChecked();
- auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
+ auto p_keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(key_ids);
if (p_keys->empty()) {
QMessageBox::critical(
@@ -686,7 +732,8 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) {
if (ret == QMessageBox::Cancel) return;
}
- auto* signers_picker = new SignersPicker(this);
+ auto* signers_picker =
+ new SignersPicker(m_key_list_->GetCurrentGpgContextChannel(), this);
QEventLoop loop;
connect(signers_picker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
@@ -695,41 +742,49 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) {
if (!signers_picker->GetStatus()) return;
auto signer_key_ids = signers_picker->GetCheckedSigners();
- auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
+ auto p_signer_keys =
+ GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .GetKeys(signer_key_ids);
CommonUtils::WaitForOpera(
this, tr("Archiving & Encrypting & Signing"),
[=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().EncryptSignDirectory(
- {p_keys->begin(), p_keys->end()},
- {p_signer_keys->begin(), p_signer_keys->end()}, path,
- !non_ascii_at_file_operation, out_path,
- [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgEncryptResult, GpgSignResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
- auto encrypt_result =
- ExtractParams<GpgEncryptResult>(data_obj, 0);
- auto sign_result = ExtractParams<GpgSignResult>(data_obj, 1);
-
- auto encrypt_result_analyse =
- GpgEncryptResultAnalyse(err, encrypt_result);
- encrypt_result_analyse.Analyse();
-
- auto sign_result_analyse = GpgSignResultAnalyse(err, sign_result);
- sign_result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, encrypt_result_analyse,
- sign_result_analyse);
-
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .EncryptSignDirectory(
+ {p_keys->begin(), p_keys->end()},
+ {p_signer_keys->begin(), p_signer_keys->end()}, path,
+ !non_ascii_at_file_operation, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgEncryptResult, GpgSignResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+ auto encrypt_result =
+ ExtractParams<GpgEncryptResult>(data_obj, 0);
+ auto sign_result = ExtractParams<GpgSignResult>(data_obj, 1);
+
+ auto encrypt_result_analyse = GpgEncryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ encrypt_result);
+ encrypt_result_analyse.Analyse();
+
+ auto sign_result_analyse = GpgSignResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ sign_result);
+ sign_result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_,
+ encrypt_result_analyse,
+ sign_result_analyse);
+
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -761,44 +816,52 @@ void MainWindow::SlotFileDecryptVerify(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Decrypting and Verifying"), [=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().DecryptVerifyFile(
- path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgDecryptResult, GpgVerifyResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
- auto decrypt_result =
- ExtractParams<GpgDecryptResult>(data_obj, 0);
- auto verify_result = ExtractParams<GpgVerifyResult>(data_obj, 1);
-
- auto decrypt_result_analyse =
- GpgDecryptResultAnalyse(err, decrypt_result);
- decrypt_result_analyse.Analyse();
-
- auto verify_result_analyse =
- GpgVerifyResultAnalyse(err, verify_result);
- verify_result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, decrypt_result_analyse,
- verify_result_analyse);
-
- // pause this feature
- // if (verify_result_analyse.GetStatus() == -2) {
- // import_unknown_key_from_keyserver(this,
- // verify_result_analyse);
- // }
- // pause this feature
- // if (verify_result_analyse.GetStatus() >= 0) {
- // show_verify_details(this, info_board_, err, verify_result);
- // }
-
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .DecryptVerifyFile(
+ path, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgDecryptResult, GpgVerifyResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+ auto decrypt_result =
+ ExtractParams<GpgDecryptResult>(data_obj, 0);
+ auto verify_result =
+ ExtractParams<GpgVerifyResult>(data_obj, 1);
+
+ auto decrypt_result_analyse = GpgDecryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ decrypt_result);
+ decrypt_result_analyse.Analyse();
+
+ auto verify_result_analyse = GpgVerifyResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ verify_result);
+ verify_result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_,
+ decrypt_result_analyse,
+ verify_result_analyse);
+
+ // pause this feature
+ // if (verify_result_analyse.GetStatus() == -2) {
+ // import_unknown_key_from_keyserver(this,
+ // verify_result_analyse);
+ // }
+ // pause this feature
+ // if (verify_result_analyse.GetStatus() >= 0) {
+ // show_verify_details(this, info_board_, err,
+ // verify_result);
+ // }
+
+ this->slot_refresh_current_file_view();
+ });
});
}
@@ -832,44 +895,52 @@ void MainWindow::SlotArchiveDecryptVerify(const QString& path) {
CommonUtils::WaitForOpera(
this, tr("Decrypting & Verifying & Extracting"),
[=](const OperaWaitingHd& op_hd) {
- GpgFileOpera::GetInstance().DecryptVerifyArchive(
- path, out_path, [=](GpgError err, const DataObjectPtr& data_obj) {
- // stop waiting
- op_hd();
-
- if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
- !data_obj->Check<GpgDecryptResult, GpgVerifyResult>()) {
- QMessageBox::critical(this, tr("Error"),
- tr("Unknown error occurred"));
- return;
- }
- auto decrypt_result =
- ExtractParams<GpgDecryptResult>(data_obj, 0);
- auto verify_result = ExtractParams<GpgVerifyResult>(data_obj, 1);
-
- auto decrypt_result_analyse =
- GpgDecryptResultAnalyse(err, decrypt_result);
- decrypt_result_analyse.Analyse();
-
- auto verify_result_analyse =
- GpgVerifyResultAnalyse(err, verify_result);
- verify_result_analyse.Analyse();
-
- process_result_analyse(edit_, info_board_, decrypt_result_analyse,
- verify_result_analyse);
-
- // pause this feature
- // if (verify_result_analyse.GetStatus() == -2) {
- // import_unknown_key_from_keyserver(this,
- // verify_result_analyse);
- // }
- // pause this feature
- // if (verify_result_analyse.GetStatus() >= 0) {
- // show_verify_details(this, info_board_, err, verify_result);
- // }
-
- this->slot_refresh_current_file_view();
- });
+ GpgFileOpera::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
+ .DecryptVerifyArchive(
+ path, out_path,
+ [=](GpgError err, const DataObjectPtr& data_obj) {
+ // stop waiting
+ op_hd();
+
+ if (CheckGpgError(err) == GPG_ERR_USER_1 ||
+ data_obj == nullptr ||
+ !data_obj->Check<GpgDecryptResult, GpgVerifyResult>()) {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Unknown error occurred"));
+ return;
+ }
+ auto decrypt_result =
+ ExtractParams<GpgDecryptResult>(data_obj, 0);
+ auto verify_result =
+ ExtractParams<GpgVerifyResult>(data_obj, 1);
+
+ auto decrypt_result_analyse = GpgDecryptResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ decrypt_result);
+ decrypt_result_analyse.Analyse();
+
+ auto verify_result_analyse = GpgVerifyResultAnalyse(
+ m_key_list_->GetCurrentGpgContextChannel(), err,
+ verify_result);
+ verify_result_analyse.Analyse();
+
+ process_result_analyse(edit_, info_board_,
+ decrypt_result_analyse,
+ verify_result_analyse);
+
+ // pause this feature
+ // if (verify_result_analyse.GetStatus() == -2) {
+ // import_unknown_key_from_keyserver(this,
+ // verify_result_analyse);
+ // }
+ // pause this feature
+ // if (verify_result_analyse.GetStatus() >= 0) {
+ // show_verify_details(this, info_board_, err,
+ // verify_result);
+ // }
+
+ this->slot_refresh_current_file_view();
+ });
});
}