diff options
author | saturneric <[email protected]> | 2025-02-03 18:01:26 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2025-02-03 18:01:26 +0000 |
commit | d3d94f5b7a3e60b3bbb73e832bab7cf2d44a1600 (patch) | |
tree | 5cc7838f1325b076b91bb898fd0da3cfcb60b455 /src/ui/dialog/import_export | |
parent | doc: update README.md (diff) | |
parent | fix: set pb range when size of operas > 1 (diff) | |
download | GpgFrontend-d3d94f5b7a3e60b3bbb73e832bab7cf2d44a1600.tar.gz GpgFrontend-d3d94f5b7a3e60b3bbb73e832bab7cf2d44a1600.zip |
Merge branch 'develop'
Diffstat (limited to 'src/ui/dialog/import_export')
6 files changed, 27 insertions, 29 deletions
diff --git a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp index 762c79b7..7aab31b5 100644 --- a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp +++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp @@ -31,11 +31,11 @@ #include "core/GpgModel.h" #include "core/function/KeyPackageOperator.h" #include "core/function/gpg/GpgKeyGetter.h" -#include "ui/UserInterfaceUtils.h" +#include "ui/function/GpgOperaHelper.h" #include "ui_ExportKeyPackageDialog.h" GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( - int channel, KeyIdArgsListPtr key_ids, QWidget* parent) + int channel, KeyIdArgsList key_ids, QWidget* parent) : GeneralDialog(typeid(ExportKeyPackageDialog).name(), parent), ui_(GpgFrontend::SecureCreateSharedObject<Ui_exportKeyPackageDialog>()), current_gpg_context_channel_(channel), @@ -98,26 +98,26 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog( // get suitable key ids auto keys = GpgKeyGetter::GetInstance(current_gpg_context_channel_) .GetKeys(key_ids_); - assert(std::all_of(keys->begin(), keys->end(), + 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) { + 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(keys_new_end, keys.end()); - if (keys->empty()) { + if (keys.empty()) { QMessageBox::critical(this, tr("Error"), tr("No key is suitable to export.")); return; } - CommonUtils::WaitForOpera( + GpgOperaHelper::WaitForOpera( this, tr("Generating"), [this, keys](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 diff --git a/src/ui/dialog/import_export/ExportKeyPackageDialog.h b/src/ui/dialog/import_export/ExportKeyPackageDialog.h index bf8e92a6..07722a21 100644 --- a/src/ui/dialog/import_export/ExportKeyPackageDialog.h +++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.h @@ -50,13 +50,13 @@ class ExportKeyPackageDialog : public GeneralDialog { * @param key_ids * @param parent */ - explicit ExportKeyPackageDialog(int channel, KeyIdArgsListPtr key_ids, + explicit ExportKeyPackageDialog(int channel, KeyIdArgsList key_ids, QWidget* parent); private: std::shared_ptr<Ui_exportKeyPackageDialog> ui_; ///< int current_gpg_context_channel_; - KeyIdArgsListPtr key_ids_; ///< - QString passphrase_; ///< + KeyIdArgsList key_ids_; ///< + QString passphrase_; ///< }; } // namespace GpgFrontend::UI diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp index e81cc2e8..e3c66245 100644 --- a/src/ui/dialog/import_export/KeyServerImportDialog.cpp +++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp @@ -43,8 +43,7 @@ KeyServerImportDialog::KeyServerImportDialog(int channel, QWidget* parent) : GeneralDialog("key_server_import_dialog", parent), current_gpg_context_channel_(channel) { auto forbid_all_gnupg_connection = - GlobalSettingStation::GetInstance() - .GetSettings() + GetSettings() .value("network/forbid_all_gnupg_connection", false) .toBool(); if (forbid_all_gnupg_connection) { @@ -360,7 +359,7 @@ void KeyServerImportDialog::slot_search_finished( } void KeyServerImportDialog::slot_import() { - std::vector<QString> key_ids; + KeyIdArgsList key_ids; const int row_count = keys_table_->rowCount(); for (int i = 0; i < row_count; ++i) { if (keys_table_->item(i, 2)->isSelected()) { @@ -377,7 +376,7 @@ void KeyServerImportDialog::slot_import() { } } -void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) { +void KeyServerImportDialog::SlotImport(const KeyIdArgsList& keys) { // keyserver host url QString target_keyserver; @@ -388,18 +387,17 @@ void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) { KeyServerSO key_server(SettingsObject("key_server")); target_keyserver = key_server.GetTargetServer(); } - std::vector<QString> key_ids; - for (const auto& key_id : *keys) { + KeyIdArgsList key_ids; + for (const auto& key_id : keys) { key_ids.push_back(key_id); } SlotImport(key_ids, target_keyserver); } -void KeyServerImportDialog::SlotImport(std::vector<QString> key_ids, +void KeyServerImportDialog::SlotImport(QStringList key_ids, QString keyserver_url) { - auto* task = - new KeyServerImportTask(std::move(keyserver_url), - current_gpg_context_channel_, std::move(key_ids)); + auto* task = new KeyServerImportTask(keyserver_url, + current_gpg_context_channel_, key_ids); connect(task, &KeyServerImportTask::SignalKeyServerImportResult, this, &KeyServerImportDialog::slot_import_finished); diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.h b/src/ui/dialog/import_export/KeyServerImportDialog.h index e4ee2367..25c55c3e 100644 --- a/src/ui/dialog/import_export/KeyServerImportDialog.h +++ b/src/ui/dialog/import_export/KeyServerImportDialog.h @@ -59,7 +59,7 @@ class KeyServerImportDialog : public GeneralDialog { * * @param keys */ - void SlotImport(const KeyIdArgsListPtr& keys); + void SlotImport(const KeyIdArgsList& keys); /** * @brief @@ -67,7 +67,7 @@ class KeyServerImportDialog : public GeneralDialog { * @param keyIds * @param keyserverUrl */ - void SlotImport(std::vector<QString> key_ids_list, QString keyserver_url); + void SlotImport(KeyIdArgsList key_ids_list, QString keyserver_url); signals: @@ -127,7 +127,7 @@ class KeyServerImportDialog : public GeneralDialog { * * @param in_data */ - void import_keys(ByteArrayPtr in_data); + void import_keys(ByteArray in_data); /** * @brief Set the loading object diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp index 9a02ea0e..efa72802 100644 --- a/src/ui/dialog/import_export/KeyUploadDialog.cpp +++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp @@ -41,13 +41,13 @@ namespace GpgFrontend::UI { -KeyUploadDialog::KeyUploadDialog(int channel, const KeyIdArgsListPtr& keys_ids, +KeyUploadDialog::KeyUploadDialog(int channel, const KeyIdArgsList& keys_ids, QWidget* parent) : GeneralDialog(typeid(KeyUploadDialog).name(), parent), current_gpg_context_channel_(channel), m_keys_(GpgKeyGetter::GetInstance(current_gpg_context_channel_) .GetKeys(keys_ids)) { - assert(std::all_of(m_keys_->begin(), m_keys_->end(), + assert(std::all_of(m_keys_.begin(), m_keys_.end(), [](const auto& key) { return key.IsGood(); })); auto* pb = new QProgressBar(); @@ -70,7 +70,7 @@ KeyUploadDialog::KeyUploadDialog(int channel, const KeyIdArgsListPtr& keys_ids, void KeyUploadDialog::SlotUpload() { GpgKeyImportExporter::GetInstance(current_gpg_context_channel_) - .ExportKeys(*m_keys_, false, true, false, false, + .ExportKeys(m_keys_, false, true, false, false, [=](GpgError err, const DataObjectPtr& data_obj) { if (CheckGpgError(err) != GPG_ERR_NO_ERROR) { CommonUtils::RaiseMessageBox(this, err); diff --git a/src/ui/dialog/import_export/KeyUploadDialog.h b/src/ui/dialog/import_export/KeyUploadDialog.h index 3085ba0a..36616037 100644 --- a/src/ui/dialog/import_export/KeyUploadDialog.h +++ b/src/ui/dialog/import_export/KeyUploadDialog.h @@ -48,7 +48,7 @@ class KeyUploadDialog : public GeneralDialog { * @param keys_ids * @param parent */ - explicit KeyUploadDialog(int channel, const KeyIdArgsListPtr& keys_ids, + explicit KeyUploadDialog(int channel, const KeyIdArgsList& keys_ids, QWidget* parent); public slots: @@ -76,7 +76,7 @@ class KeyUploadDialog : public GeneralDialog { private: int current_gpg_context_channel_; - KeyListPtr m_keys_; ///< + GpgKeyList m_keys_; ///< QByteArray m_key_data_; ///< }; |