diff options
Diffstat (limited to 'src/ui/dialog/import_export/ExportKeyPackageDialog.cpp')
-rw-r--r-- | src/ui/dialog/import_export/ExportKeyPackageDialog.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp index 7aab31b5..325eba98 100644 --- a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp +++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp @@ -28,18 +28,16 @@ #include "ExportKeyPackageDialog.h" -#include "core/GpgModel.h" #include "core/function/KeyPackageOperator.h" -#include "core/function/gpg/GpgKeyGetter.h" #include "ui/function/GpgOperaHelper.h" #include "ui_ExportKeyPackageDialog.h" GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( - int channel, KeyIdArgsList key_ids, QWidget* parent) + int channel, GpgAbstractKeyPtrList keys, QWidget* parent) : GeneralDialog(typeid(ExportKeyPackageDialog).name(), parent), ui_(GpgFrontend::SecureCreateSharedObject<Ui_exportKeyPackageDialog>()), current_gpg_context_channel_(channel), - key_ids_(std::move(key_ids)) { + keys_(std::move(keys)) { ui_->setupUi(this); ui_->nameValueLabel->setText(KeyPackageOperator::GenerateKeyPackageName()); @@ -95,29 +93,23 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( return; } - // get suitable key ids - auto keys = GpgKeyGetter::GetInstance(current_gpg_context_channel_) - .GetKeys(key_ids_); - assert(std::all_of(keys.begin(), keys.end(), - [](const auto& key) { return key.IsGood(); })); - - auto keys_new_end = - std::remove_if(keys.begin(), keys.end(), [this](const auto& key) { - return ui_->noPublicKeyCheckBox->isChecked() && !key.IsPrivateKey(); + auto it = + std::remove_if(keys_.begin(), keys_.end(), [this](const auto& key) { + return ui_->noPublicKeyCheckBox->isChecked() && !key->IsPrivateKey(); }); - keys.erase(keys_new_end, keys.end()); + keys_.erase(it, keys_.end()); - if (keys.empty()) { + if (keys_.empty()) { QMessageBox::critical(this, tr("Error"), tr("No key is suitable to export.")); return; } GpgOperaHelper::WaitForOpera( - this, tr("Generating"), [this, keys](const OperaWaitingHd& op_hd) { + this, tr("Generating"), [this](const OperaWaitingHd& op_hd) { KeyPackageOperator::GenerateKeyPackage( ui_->outputPathLabel->text(), ui_->nameValueLabel->text(), - current_gpg_context_channel_, keys, passphrase_, + current_gpg_context_channel_, keys_, passphrase_, ui_->includeSecretKeyCheckBox->isChecked(), [=](GFError err, const DataObjectPtr&) { // stop waiting |