aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/keypair_details
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog/keypair_details')
-rw-r--r--src/ui/dialog/keypair_details/KeyDetailsDialog.cpp23
-rw-r--r--src/ui/dialog/keypair_details/KeyDetailsDialog.h2
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp14
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.h6
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.cpp76
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.h5
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp101
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.h7
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp43
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.h4
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.cpp27
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.h4
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp25
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.h6
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp24
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.h6
16 files changed, 180 insertions, 193 deletions
diff --git a/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
index b3cb3a9d..273d3316 100644
--- a/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
@@ -36,29 +36,28 @@
#include "ui/dialog/keypair_details/KeyPairUIDTab.h"
namespace GpgFrontend::UI {
-KeyDetailsDialog::KeyDetailsDialog(int channel, const GpgKey& key,
+KeyDetailsDialog::KeyDetailsDialog(int channel, const GpgKeyPtr& key,
QWidget* parent)
: GeneralDialog(typeid(KeyDetailsDialog).name(), parent),
current_gpg_context_channel_(channel) {
tab_widget_ = new QTabWidget();
tab_widget_->addTab(
- new KeyPairDetailTab(current_gpg_context_channel_, key.ID(), tab_widget_),
+ new KeyPairDetailTab(current_gpg_context_channel_, key, tab_widget_),
tr("KeyPair"));
- if (!key.IsRevoked()) {
+ if (!key->IsRevoked()) {
tab_widget_->addTab(
- new KeyPairUIDTab(current_gpg_context_channel_, key.ID(), tab_widget_),
+ new KeyPairUIDTab(current_gpg_context_channel_, key, tab_widget_),
tr("UIDs"));
-
- tab_widget_->addTab(new KeyPairSubkeyTab(current_gpg_context_channel_,
- key.ID(), tab_widget_),
- tr("Keychain"));
- tab_widget_->addTab(new KeyPairOperaTab(current_gpg_context_channel_,
- key.ID(), tab_widget_),
- tr("Operations"));
+ tab_widget_->addTab(
+ new KeyPairSubkeyTab(current_gpg_context_channel_, key, tab_widget_),
+ tr("Keychain"));
+ tab_widget_->addTab(
+ new KeyPairOperaTab(current_gpg_context_channel_, key, tab_widget_),
+ tr("Operations"));
}
- QString m_key_id = key.ID();
+ QString m_key_id = key->ID();
connect(UISignalStation::GetInstance(), &UISignalStation::SignalKeyRevoked,
this, [this, m_key_id](const QString& key_id) {
if (key_id == m_key_id) this->close();
diff --git a/src/ui/dialog/keypair_details/KeyDetailsDialog.h b/src/ui/dialog/keypair_details/KeyDetailsDialog.h
index 2c7121d1..35694a27 100644
--- a/src/ui/dialog/keypair_details/KeyDetailsDialog.h
+++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.h
@@ -39,7 +39,7 @@ class KeyDetailsDialog : public GeneralDialog {
Q_OBJECT
public:
- explicit KeyDetailsDialog(int channel, const GpgKey& key,
+ explicit KeyDetailsDialog(int channel, const GpgKeyPtr& key,
QWidget* parent = nullptr);
private:
diff --git a/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
index 754999a2..d641c4d3 100644
--- a/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
@@ -28,19 +28,17 @@
#include "KeyNewUIDDialog.h"
-#include "core/GpgModel.h"
-#include "core/function/gpg/GpgKeyGetter.h"
+#include <utility>
+
#include "core/function/gpg/GpgUIDOperator.h"
#include "ui/UISignalStation.h"
namespace GpgFrontend::UI {
-KeyNewUIDDialog::KeyNewUIDDialog(int channel, const KeyId& key_id,
- QWidget* parent)
+KeyNewUIDDialog::KeyNewUIDDialog(int channel, GpgKeyPtr key, QWidget* parent)
: GeneralDialog(typeid(KeyNewUIDDialog).name(), parent),
current_gpg_context_channel_(channel),
- m_key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)) {
- assert(m_key_.IsGood());
+ m_key_(std::move(key)) {
+ assert(m_key_ != nullptr);
name_ = new QLineEdit();
name_->setMinimumWidth(240);
@@ -51,7 +49,7 @@ KeyNewUIDDialog::KeyNewUIDDialog(int channel, const KeyId& key_id,
create_button_ = new QPushButton("Create");
error_label_ = new QLabel();
- auto grid_layout = new QGridLayout();
+ auto* grid_layout = new QGridLayout();
grid_layout->addWidget(new QLabel(tr("Name")), 0, 0);
grid_layout->addWidget(new QLabel(tr("Email")), 1, 0);
grid_layout->addWidget(new QLabel(tr("Comment")), 2, 0);
diff --git a/src/ui/dialog/keypair_details/KeyNewUIDDialog.h b/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
index 45124665..f298a46b 100644
--- a/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
@@ -45,7 +45,7 @@ class KeyNewUIDDialog : public GeneralDialog {
* @param key
* @param parent
*/
- KeyNewUIDDialog(int channel, const KeyId& key, QWidget* parent = nullptr);
+ KeyNewUIDDialog(int channel, GpgKeyPtr key, QWidget* parent = nullptr);
signals:
/**
@@ -64,7 +64,7 @@ class KeyNewUIDDialog : public GeneralDialog {
private:
int current_gpg_context_channel_;
- GpgKey m_key_; ///<
+ GpgKeyPtr m_key_; ///<
QLineEdit* name_{}; ///<
QLineEdit* email_{}; ///<
@@ -85,6 +85,6 @@ class KeyNewUIDDialog : public GeneralDialog {
* @return true
* @return false
*/
- bool check_email_address(const QString& str);
+ auto check_email_address(const QString& str) -> bool;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
index 5a646ec0..fcdc139e 100644
--- a/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
@@ -28,23 +28,21 @@
#include "KeyPairDetailTab.h"
-#include "core/GpgModel.h"
+#include <utility>
+
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/model/GpgKey.h"
#include "core/module/ModuleManager.h"
-#include "core/thread/TaskRunnerGetter.h"
#include "core/utils/CommonUtils.h"
#include "ui/UISignalStation.h"
namespace GpgFrontend::UI {
-KeyPairDetailTab::KeyPairDetailTab(int channel, const QString& key_id,
- QWidget* parent)
+KeyPairDetailTab::KeyPairDetailTab(int channel, GpgKeyPtr key, QWidget* parent)
: QWidget(parent),
current_gpg_context_channel_(channel),
- key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)) {
- assert(key_.IsGood());
+ key_(std::move(key)) {
+ assert(key_->IsGood());
owner_box_ = new QGroupBox(tr("Owner"));
key_box_ = new QGroupBox(tr("Primary Key"));
@@ -183,8 +181,8 @@ void KeyPairDetailTab::slot_copy_fingerprint() {
void KeyPairDetailTab::slot_refresh_key_info() {
// Show the situation that primary key not exists.
primary_key_exist_var_label_->setText(
- key_.IsHasMasterKey() ? tr("Exists") : tr("Not Exists"));
- if (!key_.IsHasMasterKey()) {
+ key_->IsHasMasterKey() ? tr("Exists") : tr("Not Exists"));
+ if (!key_->IsHasMasterKey()) {
auto palette_expired = primary_key_exist_var_label_->palette();
palette_expired.setColor(primary_key_exist_var_label_->foregroundRole(),
Qt::red);
@@ -196,7 +194,7 @@ void KeyPairDetailTab::slot_refresh_key_info() {
primary_key_exist_var_label_->setPalette(palette_valid);
}
- if (key_.IsExpired()) {
+ if (key_->IsExpired()) {
auto palette_expired = expire_var_label_->palette();
palette_expired.setColor(expire_var_label_->foregroundRole(), Qt::red);
expire_var_label_->setPalette(palette_expired);
@@ -206,42 +204,42 @@ void KeyPairDetailTab::slot_refresh_key_info() {
expire_var_label_->setPalette(palette_valid);
}
- name_var_label_->setText(key_.Name());
- email_var_label_->setText(key_.Email());
+ name_var_label_->setText(key_->Name());
+ email_var_label_->setText(key_->Email());
- comment_var_label_->setText(key_.Comment());
- key_id_var_label_->setText(key_.ID());
+ comment_var_label_->setText(key_->Comment());
+ key_id_var_label_->setText(key_->ID());
QString buffer;
QTextStream usage_steam(&buffer);
- if (key_.IsHasCertCap()) {
+ if (key_->IsHasCertCap()) {
usage_steam << tr("Certificate") << " ";
}
- if (key_.IsHasEncrCap()) usage_steam << tr("Encrypt") << " ";
- if (key_.IsHasSignCap()) usage_steam << tr("Sign") << " ";
- if (key_.IsHasAuthCap()) usage_steam << tr("Auth") << " ";
+ if (key_->IsHasEncrCap()) usage_steam << tr("Encrypt") << " ";
+ if (key_->IsHasSignCap()) usage_steam << tr("Sign") << " ";
+ if (key_->IsHasAuthCap()) usage_steam << tr("Auth") << " ";
usage_var_label_->setText(usage_steam.readAll());
QString buffer_2;
QTextStream actual_usage_steam(&buffer_2);
- if (key_.IsHasActualCertCap()) {
+ if (key_->IsHasActualCertCap()) {
actual_usage_steam << tr("Certificate") << " ";
}
- if (key_.IsHasActualEncrCap()) {
+ if (key_->IsHasActualEncrCap()) {
actual_usage_steam << tr("Encrypt") << " ";
}
- if (key_.IsHasActualSignCap()) {
+ if (key_->IsHasActualSignCap()) {
actual_usage_steam << tr("Sign") << " ";
}
- if (key_.IsHasActualAuthCap()) {
+ if (key_->IsHasActualAuthCap()) {
actual_usage_steam << tr("Auth") << " ";
}
actual_usage_var_label_->setText(actual_usage_steam.readAll());
- owner_trust_var_label_->setText(key_.OwnerTrust());
+ owner_trust_var_label_->setText(key_->OwnerTrust());
QString key_size_val;
QString key_expire_val;
@@ -250,41 +248,41 @@ void KeyPairDetailTab::slot_refresh_key_info() {
QString key_algo_detail_val;
QString key_last_update_val;
- key_size_val = QString::number(key_.PrimaryKeyLength());
+ key_size_val = QString::number(key_->PrimaryKeyLength());
- if (key_.ExpirationTime().toSecsSinceEpoch() == 0) {
+ if (key_->ExpirationTime().toSecsSinceEpoch() == 0) {
expire_var_label_->setText(tr("Never Expire"));
} else {
- expire_var_label_->setText(QLocale().toString((key_.ExpirationTime())));
+ expire_var_label_->setText(QLocale().toString((key_->ExpirationTime())));
}
- key_algo_val = key_.PublicKeyAlgo();
- key_algo_detail_val = key_.Algo();
+ key_algo_val = key_->PublicKeyAlgo();
+ key_algo_detail_val = key_->Algo();
- created_var_label_->setText(QLocale().toString(key_.CreationTime()));
+ created_var_label_->setText(QLocale().toString(key_->CreationTime()));
- if (key_.LastUpdateTime().toSecsSinceEpoch() == 0) {
+ if (key_->LastUpdateTime().toSecsSinceEpoch() == 0) {
last_update_var_label_->setText(tr("No Data"));
} else {
- last_update_var_label_->setText(QLocale().toString(key_.LastUpdateTime()));
+ last_update_var_label_->setText(QLocale().toString(key_->LastUpdateTime()));
}
key_size_var_label_->setText(key_size_val);
algorithm_var_label_->setText(key_algo_val);
algorithm_detail_var_label_->setText(key_algo_detail_val);
- fingerprint_var_label_->setText(BeautifyFingerprint(key_.Fingerprint()));
+ fingerprint_var_label_->setText(BeautifyFingerprint(key_->Fingerprint()));
fingerprint_var_label_->setWordWrap(true); // for x448 and ed448
icon_label_->hide();
exp_label_->hide();
- if (key_.IsExpired()) {
+ if (key_->IsExpired()) {
slot_refresh_notice(":/icons/warning.png",
tr("Warning: The primary key has expired."));
- } else if (key_.IsRevoked()) {
+ } else if (key_->IsRevoked()) {
slot_refresh_notice(":/icons/warning.png",
tr("Warning: The primary key has been revoked."));
- } else if (key_.IsPrivateKey() && !key_.IsHasMasterKey()) {
+ } else if (key_->IsPrivateKey() && !key_->IsHasMasterKey()) {
slot_refresh_notice(":/icons/warning.png",
tr("Warning: The primary key is not exists."));
} else {
@@ -294,9 +292,9 @@ void KeyPairDetailTab::slot_refresh_key_info() {
void KeyPairDetailTab::slot_refresh_key() {
// refresh the key
- GpgKey refreshed_key =
- GpgKeyGetter::GetInstance(current_gpg_context_channel_).GetKey(key_.ID());
- assert(refreshed_key.IsGood());
+ auto refreshed_key = GpgKeyGetter::GetInstance(current_gpg_context_channel_)
+ .GetKeyPtr(key_->ID());
+ assert(refreshed_key != nullptr);
std::swap(this->key_, refreshed_key);
@@ -316,7 +314,7 @@ void KeyPairDetailTab::slot_query_key_publish_state() {
return;
}
- const auto fpr = key_.Fingerprint();
+ const auto fpr = key_->Fingerprint();
Module::TriggerEvent(
"REQUEST_GET_PUBLIC_KEY_BY_FINGERPRINT",
diff --git a/src/ui/dialog/keypair_details/KeyPairDetailTab.h b/src/ui/dialog/keypair_details/KeyPairDetailTab.h
index da58e36e..d388a4af 100644
--- a/src/ui/dialog/keypair_details/KeyPairDetailTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.h
@@ -29,6 +29,7 @@
#pragma once
#include "core/model/GpgKey.h"
+#include "core/typedef/GpgTypedef.h"
namespace GpgFrontend::UI {
@@ -68,7 +69,7 @@ class KeyPairDetailTab : public QWidget {
private:
int current_gpg_context_channel_;
- GpgKey key_; ///<
+ GpgKeyPtr key_; ///<
QGroupBox* owner_box_; ///< Groupbox containing owner information
QGroupBox* key_box_; ///< Groupbox containing key information
@@ -103,7 +104,7 @@ class KeyPairDetailTab : public QWidget {
* @param key_id
* @param parent
*/
- explicit KeyPairDetailTab(int channel, const QString& key_id,
+ explicit KeyPairDetailTab(int channel, GpgKeyPtr key,
QWidget* parent = nullptr);
};
diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index 936997a9..dddbb545 100644
--- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -30,7 +30,6 @@
#include "KeySetExpireDateDialog.h"
#include "core/function/GlobalSettingStation.h"
-#include "core/function/gpg//GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyOpera.h"
#include "core/model/GpgKey.h"
@@ -46,13 +45,9 @@
namespace GpgFrontend::UI {
-KeyPairOperaTab::KeyPairOperaTab(int channel, const QString& key_id,
- QWidget* parent)
- : QWidget(parent),
- current_gpg_context_channel_(channel),
- m_key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)) {
- assert(m_key_.IsGood());
+KeyPairOperaTab::KeyPairOperaTab(int channel, GpgKeyPtr key, QWidget* parent)
+ : QWidget(parent), current_gpg_context_channel_(channel), m_key_(key) {
+ assert(m_key_ != nullptr);
// Set Menu
CreateOperaMenu();
@@ -69,13 +64,13 @@ KeyPairOperaTab::KeyPairOperaTab(int channel, const QString& key_id,
connect(export_public_button, &QPushButton::clicked, this,
&KeyPairOperaTab::slot_export_public_key);
- if (m_key_.IsPrivateKey()) {
+ if (m_key_->IsPrivateKey()) {
auto* export_private_button = new QPushButton(tr("Export Private Key"));
export_private_button->setStyleSheet("text-align:center;");
export_private_button->setMenu(secret_key_export_opera_menu_);
export_h_box_layout->addWidget(export_private_button);
- if (m_key_.IsHasMasterKey()) {
+ if (m_key_->IsHasMasterKey()) {
auto* edit_expires_button =
new QPushButton(tr("Modify Expiration Datetime (Primary Key)"));
connect(edit_expires_button, &QPushButton::clicked, this,
@@ -104,7 +99,7 @@ KeyPairOperaTab::KeyPairOperaTab(int channel, const QString& key_id,
advance_h_box_layout->addWidget(key_server_opera_button);
if (Module::IsModuleActivate(kPaperKeyModuleID)) {
- if (!m_key_.IsPrivateKey()) {
+ if (!m_key_->IsPrivateKey()) {
auto* import_paper_key_button = new QPushButton(tr("Import A Paper Key"));
import_paper_key_button->setStyleSheet("text-align:center;");
connect(import_paper_key_button, &QPushButton::clicked, this,
@@ -113,7 +108,7 @@ KeyPairOperaTab::KeyPairOperaTab(int channel, const QString& key_id,
}
}
- if (m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()) {
+ if (m_key_->IsPrivateKey() && m_key_->IsHasMasterKey()) {
auto* revoke_cert_opera_button =
new QPushButton(tr("Revoke Certificate Operation"));
revoke_cert_opera_button->setStyleSheet("text-align:center;");
@@ -136,7 +131,8 @@ KeyPairOperaTab::KeyPairOperaTab(int channel, const QString& key_id,
opera_key_box->setLayout(vbox_p_k);
m_vbox->addWidget(opera_key_box);
// modify owner trust of public key
- if (!m_key_.IsPrivateKey()) vbox_p_k->addWidget(set_owner_trust_level_button);
+ if (!m_key_->IsPrivateKey())
+ vbox_p_k->addWidget(set_owner_trust_level_button);
vbox_p_k->addWidget(modify_tofu_button);
m_vbox->addStretch(0);
@@ -155,7 +151,7 @@ void KeyPairOperaTab::CreateOperaMenu() {
new QAction(tr("Publish Public Key to Key Server"), this);
connect(upload_key_pair, &QAction::triggered, this,
&KeyPairOperaTab::slot_publish_key_to_server);
- if (!(m_key_.IsPrivateKey() && m_key_.IsHasMasterKey())) {
+ if (!(m_key_->IsPrivateKey() && m_key_->IsHasMasterKey())) {
upload_key_pair->setDisabled(true);
}
@@ -165,7 +161,7 @@ void KeyPairOperaTab::CreateOperaMenu() {
&KeyPairOperaTab::slot_update_key_from_server);
// when a key has primary key, it should always upload to keyserver.
- if (m_key_.IsHasMasterKey()) {
+ if (m_key_->IsHasMasterKey()) {
update_key_pair->setDisabled(true);
}
@@ -178,7 +174,7 @@ void KeyPairOperaTab::CreateOperaMenu() {
new QAction(tr("Export Full Secret Key"), this);
connect(export_full_secret_key, &QAction::triggered, this,
&KeyPairOperaTab::slot_export_private_key);
- if (!m_key_.IsPrivateKey()) export_full_secret_key->setDisabled(true);
+ if (!m_key_->IsPrivateKey()) export_full_secret_key->setDisabled(true);
auto* export_shortest_secret_key =
new QAction(tr("Export Shortest Secret Key"), this);
@@ -189,12 +185,12 @@ void KeyPairOperaTab::CreateOperaMenu() {
secret_key_export_opera_menu_->addAction(export_shortest_secret_key);
// only work with RSA
- if (m_key_.Algo() == "RSA" && Module::IsModuleActivate(kPaperKeyModuleID)) {
+ if (m_key_->Algo() == "RSA" && Module::IsModuleActivate(kPaperKeyModuleID)) {
auto* export_secret_key_as_paper_key = new QAction(
tr("Export Secret Key As A Paper Key") + QString(" (BETA)"), this);
connect(export_secret_key_as_paper_key, &QAction::triggered, this,
&KeyPairOperaTab::slot_export_paper_key);
- if (!m_key_.IsPrivateKey()) {
+ if (!m_key_->IsPrivateKey()) {
export_secret_key_as_paper_key->setDisabled(true);
}
secret_key_export_opera_menu_->addAction(export_secret_key_as_paper_key);
@@ -228,11 +224,11 @@ void KeyPairOperaTab::slot_export_public_key() {
// generate a file name
#if defined(_WIN32) || defined(WIN32)
- auto file_string =
- m_key_.Name() + "[" + m_key_.Email() + "](" + m_key_.ID() + ")_pub.asc";
+ auto file_string = m_key_->Name() + "[" + m_key_->Email() + "](" +
+ m_key_->ID() + ")_pub.asc";
#else
- auto file_string =
- m_key_.Name() + "<" + m_key_.Email() + ">(" + m_key_.ID() + ")_pub.asc";
+ auto file_string = m_key_->Name() + "<" + m_key_->Email() + ">(" +
+ m_key_->ID() + ")_pub.asc";
#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
@@ -277,11 +273,11 @@ void KeyPairOperaTab::slot_export_short_private_key() {
// generate a file name
#if defined(_WIN32) || defined(WIN32)
- auto file_string = m_key_.Name() + "[" + m_key_.Email() + "](" +
- m_key_.ID() + ")_short_secret.asc";
+ auto file_string = m_key_->Name() + "[" + m_key_->Email() + "](" +
+ m_key_->ID() + ")_short_secret.asc";
#else
- auto file_string = m_key_.Name() + "<" + m_key_.Email() + ">(" +
- m_key_.ID() + ")_short_secret.asc";
+ auto file_string = m_key_->Name() + "<" + m_key_->Email() + ">(" +
+ m_key_->ID() + ")_short_secret.asc";
#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
@@ -328,11 +324,11 @@ void KeyPairOperaTab::slot_export_private_key() {
// generate a file name
#if defined(_WIN32) || defined(WIN32)
- auto file_string = m_key_.Name() + "[" + m_key_.Email() + "](" +
- m_key_.ID() + ")_full_secret.asc";
+ auto file_string = m_key_->Name() + "[" + m_key_->Email() + "](" +
+ m_key_->ID() + ")_full_secret.asc";
#else
- auto file_string = m_key_.Name() + "<" + m_key_.Email() + ">(" +
- m_key_.ID() + ")_full_secret.asc";
+ auto file_string = m_key_->Name() + "<" + m_key_->Email() + ">(" +
+ m_key_->ID() + ")_full_secret.asc";
#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
@@ -351,8 +347,8 @@ void KeyPairOperaTab::slot_export_private_key() {
}
void KeyPairOperaTab::slot_modify_edit_datetime() {
- auto* dialog = new KeySetExpireDateDialog(current_gpg_context_channel_,
- m_key_.ID(), this);
+ auto* dialog =
+ new KeySetExpireDateDialog(current_gpg_context_channel_, m_key_, this);
dialog->show();
}
@@ -362,7 +358,7 @@ void KeyPairOperaTab::slot_publish_key_to_server() {
GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
.ExportKey(m_key_, false, true, false);
- auto fpr = m_key_.Fingerprint();
+ auto fpr = m_key_->Fingerprint();
auto key_text = gf_buffer.ConvertToQByteArray();
Module::TriggerEvent(
@@ -434,8 +430,9 @@ void KeyPairOperaTab::slot_publish_key_to_server() {
return;
}
- auto keys = KeyIdArgsList{m_key_.ID()};
- auto* dialog = new KeyUploadDialog(current_gpg_context_channel_, keys, this);
+ auto keys = KeyIdArgsList{m_key_->ID()};
+ auto* dialog =
+ new KeyUploadDialog(current_gpg_context_channel_, {m_key_}, this);
dialog->show();
dialog->SlotUpload();
}
@@ -443,11 +440,11 @@ void KeyPairOperaTab::slot_publish_key_to_server() {
void KeyPairOperaTab::slot_update_key_from_server() {
if (Module::IsModuleActivate(kKeyServerSyncModuleID)) {
CommonUtils::GetInstance()->ImportKeyByKeyServerSyncModule(
- this, current_gpg_context_channel_, {m_key_.Fingerprint()});
+ this, current_gpg_context_channel_, {m_key_->Fingerprint()});
return;
}
- CommonUtils::GetInstance()->ImportKeyFromKeyServer(
- current_gpg_context_channel_, {m_key_.ID()});
+ CommonUtils::GetInstance()->ImportGpgKeyFromKeyServer(
+ current_gpg_context_channel_, {m_key_});
}
void KeyPairOperaTab::slot_gen_revoke_cert() {
@@ -464,11 +461,11 @@ void KeyPairOperaTab::slot_gen_revoke_cert() {
QString m_output_file_name;
#if defined(_WIN32) || defined(WIN32)
- auto file_string = m_key_.Name() + "[" + m_key_.Email() + "](" +
- m_key_.ID() + ").rev";
+ auto file_string = m_key_->Name() + "[" + m_key_->Email() + "](" +
+ m_key_->ID() + ").rev";
#else
- auto file_string = m_key_.Name() + "<" + m_key_.Email() +
- ">(" + m_key_.ID() + ").rev";
+ auto file_string = m_key_->Name() + "<" + m_key_->Email() +
+ ">(" + m_key_->ID() + ").rev";
#endif
QFileDialog dialog(this, tr("Generate revocation certificate"),
@@ -529,7 +526,7 @@ void KeyPairOperaTab::slot_modify_tofu_policy() {
void KeyPairOperaTab::slot_set_owner_trust_level() {
auto* function = new SetOwnerTrustLevel(this);
- function->Exec(current_gpg_context_channel_, m_key_.ID());
+ function->Exec(current_gpg_context_channel_, m_key_);
function->deleteLater();
}
@@ -581,7 +578,7 @@ void KeyPairOperaTab::slot_import_revoke_cert() {
return;
}
- emit UISignalStation::GetInstance() -> SignalKeyRevoked(m_key_.ID());
+ emit UISignalStation::GetInstance() -> SignalKeyRevoked(m_key_->ID());
CommonUtils::GetInstance()->SlotImportKeys(
nullptr, current_gpg_context_channel_, rev_file.readAll());
}
@@ -620,11 +617,11 @@ void KeyPairOperaTab::slot_export_paper_key() {
// generate a file name
#if defined(_WIN32) || defined(WIN32)
- auto file_string = m_key_.Name() + "[" + m_key_.Email() + "](" +
- m_key_.ID() + ")_paper_key.txt";
+ auto file_string = m_key_->Name() + "[" + m_key_->Email() + "](" +
+ m_key_->ID() + ")_paper_key.txt";
#else
- auto file_string = m_key_.Name() + "<" + m_key_.Email() + ">(" +
- m_key_.ID() + ")_paper_key.txt";
+ auto file_string = m_key_->Name() + "<" + m_key_->Email() + ">(" +
+ m_key_->ID() + ")_paper_key.txt";
#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
@@ -674,11 +671,11 @@ void KeyPairOperaTab::slot_import_paper_key() {
// generate a file name
#if defined(_WIN32) || defined(WIN32)
- auto file_string = m_key_.Name() + "[" + m_key_.Email() + "](" + m_key_.ID() +
- ")_paper_key.txt";
+ auto file_string = m_key_->Name() + "[" + m_key_->Email() + "](" +
+ m_key_->ID() + ")_paper_key.txt";
#else
- auto file_string = m_key_.Name() + "<" + m_key_.Email() + ">(" + m_key_.ID() +
- ")_paper_key.txt";
+ auto file_string = m_key_->Name() + "<" + m_key_->Email() + ">(" +
+ m_key_->ID() + ")_paper_key.txt";
#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.h b/src/ui/dialog/keypair_details/KeyPairOperaTab.h
index 9e1f2a23..729a7d74 100644
--- a/src/ui/dialog/keypair_details/KeyPairOperaTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.h
@@ -28,7 +28,7 @@
#pragma once
-#include "core/model/GpgKey.h"
+#include "core/typedef/GpgTypedef.h"
namespace GpgFrontend {
class GpgImportInformation;
@@ -44,7 +44,7 @@ class KeyPairOperaTab : public QWidget {
* @param key_id
* @param parent
*/
- KeyPairOperaTab(int channel, const QString& key_id, QWidget* parent);
+ KeyPairOperaTab(int channel, GpgKeyPtr key, QWidget* parent);
/**
* @brief Create a Opera Menu object
@@ -140,10 +140,9 @@ class KeyPairOperaTab : public QWidget {
private:
int current_gpg_context_channel_;
- GpgKey m_key_; ///<
+ GpgKeyPtr m_key_; ///<
QMenu* key_server_opera_menu_{}; ///<
QMenu* rev_cert_opera_menu_{};
QMenu* secret_key_export_opera_menu_{}; ///<
-
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index c4e93b62..011ea1ed 100644
--- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -28,7 +28,8 @@
#include "KeyPairSubkeyTab.h"
-#include "core/GpgModel.h"
+#include <utility>
+
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyManager.h"
@@ -43,13 +44,11 @@
namespace GpgFrontend::UI {
-KeyPairSubkeyTab::KeyPairSubkeyTab(int channel, const QString& key_id,
- QWidget* parent)
+KeyPairSubkeyTab::KeyPairSubkeyTab(int channel, GpgKeyPtr key, QWidget* parent)
: QWidget(parent),
current_gpg_context_channel_(channel),
- key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)) {
- assert(key_.IsGood());
+ key_(std::move(key)) {
+ assert(key_ != nullptr);
create_subkey_list();
create_subkey_opera_menu();
@@ -61,7 +60,7 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(int channel, const QString& key_id,
auto* add_subkey_button = new QPushButton(tr("New Subkey"));
auto* add_adsk_button = new QPushButton(tr("Add ADSK(s)"));
- if (!key_.IsPrivateKey() || !key_.IsHasMasterKey()) {
+ if (!key_->IsPrivateKey() || !key_->IsHasMasterKey()) {
add_subkey_button->setDisabled(true);
add_subkey_button->hide();
@@ -202,7 +201,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_list() {
subkey_list_->setSelectionMode(QAbstractItemView::SingleSelection);
this->buffered_subkeys_.clear();
- for (auto& s_key : key_.SubKeys()) {
+ for (auto& s_key : key_->SubKeys()) {
this->buffered_subkeys_.push_back(std::move(s_key));
}
@@ -281,14 +280,14 @@ void KeyPairSubkeyTab::slot_refresh_subkey_list() {
void KeyPairSubkeyTab::slot_add_subkey() {
auto* dialog =
- new SubkeyGenerateDialog(current_gpg_context_channel_, key_.ID(), this);
+ new SubkeyGenerateDialog(current_gpg_context_channel_, key_, this);
dialog->show();
}
void KeyPairSubkeyTab::slot_add_adsk() {
QStringList except_key_ids;
- except_key_ids.append(key_.ID());
- for (const auto& s_key : key_.SubKeys()) {
+ except_key_ids.append(key_->ID());
+ for (const auto& s_key : key_->SubKeys()) {
except_key_ids.append(s_key.ID());
}
@@ -382,7 +381,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() {
QString buffer;
QTextStream usage_steam(&buffer);
- usage_var_label_->setText(GetUsagesBySubkey(s_key));
+ usage_var_label_->setText(GetUsagesByAbstractKey(&s_key));
// Show the situation that secret key not exists.
master_key_exist_var_label_->setText(s_key.IsSecretKey() ? tr("Exists")
@@ -424,7 +423,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() {
export_subkey_button_->setText(s_key.IsHasCertCap() ? tr("Export Primary Key")
: tr("Export Subkey"));
export_subkey_button_->setDisabled(
- !key_.IsPrivateKey() || s_key.IsHasCertCap() || !s_key.IsSecretKey());
+ !key_->IsPrivateKey() || s_key.IsHasCertCap() || !s_key.IsSecretKey());
key_type_var_label_->setText(s_key.IsHasCertCap() ? tr("Primary Key")
: tr("Subkey"));
@@ -467,14 +466,14 @@ void KeyPairSubkeyTab::create_subkey_opera_menu() {
void KeyPairSubkeyTab::slot_edit_subkey() {
auto* dialog =
- new KeySetExpireDateDialog(current_gpg_context_channel_, key_.ID(),
+ new KeySetExpireDateDialog(current_gpg_context_channel_, key_,
get_selected_subkey().Fingerprint(), this);
dialog->show();
}
void KeyPairSubkeyTab::contextMenuEvent(QContextMenuEvent* event) {
// must have primary key before do any actions on subkey
- if (key_.IsHasMasterKey() && !subkey_list_->selectedItems().isEmpty()) {
+ if (key_->IsHasMasterKey() && !subkey_list_->selectedItems().isEmpty()) {
const auto& s_key = get_selected_subkey();
if (s_key.IsHasCertCap()) return;
@@ -501,9 +500,9 @@ auto KeyPairSubkeyTab::get_selected_subkey() -> const GpgSubKey& {
}
void KeyPairSubkeyTab::slot_refresh_key_info() {
- key_ =
- GpgKeyGetter::GetInstance(current_gpg_context_channel_).GetKey(key_.ID());
- assert(key_.IsGood());
+ key_ = GpgKeyGetter::GetInstance(current_gpg_context_channel_)
+ .GetKeyPtr(key_->ID());
+ assert(key_ != nullptr);
}
void KeyPairSubkeyTab::slot_export_subkey() {
@@ -532,10 +531,10 @@ void KeyPairSubkeyTab::slot_export_subkey() {
// generate a file name
#if defined(_WIN32) || defined(WIN32)
auto file_string =
- key_.Name() + "[" + key_.Email() + "](" + s_key.ID() + ")_s_key.asc";
+ key_->Name() + "[" + key_->Email() + "](" + s_key.ID() + ")_s_key.asc";
#else
auto file_string =
- key_.Name() + "<" + key_.Email() + ">(" + s_key.ID() + ")_s_key.asc";
+ key_->Name() + "<" + key_->Email() + ">(" + s_key.ID() + ")_s_key.asc";
#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
@@ -567,7 +566,7 @@ void KeyPairSubkeyTab::slot_delete_subkey() {
if (ret != QMessageBox::Yes) return;
int index = 0;
- for (const auto& sk : key_.SubKeys()) {
+ for (const auto& sk : key_->SubKeys()) {
if (sk.Fingerprint() == s_key.Fingerprint()) {
break;
}
@@ -616,7 +615,7 @@ void KeyPairSubkeyTab::slot_revoke_subkey() {
if (ret != QMessageBox::Yes) return;
int index = 0;
- for (const auto& sk : key_.SubKeys()) {
+ for (const auto& sk : key_->SubKeys()) {
if (sk.Fingerprint() == s_key.Fingerprint()) {
break;
}
diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
index d06ee032..3d9eeb50 100644
--- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
@@ -45,7 +45,7 @@ class KeyPairSubkeyTab : public QWidget {
* @param key
* @param parent
*/
- KeyPairSubkeyTab(int channel, const QString& key, QWidget* parent);
+ KeyPairSubkeyTab(int channel, GpgKeyPtr key, QWidget* parent);
private:
/**
@@ -68,7 +68,7 @@ class KeyPairSubkeyTab : public QWidget {
auto get_selected_subkey() -> const GpgSubKey&;
int current_gpg_context_channel_;
- GpgKey key_; ///<
+ GpgKeyPtr key_; ///<
QTableWidget* subkey_list_{}; ///<
QContainer<GpgSubKey> buffered_subkeys_; ///<
diff --git a/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
index a010a6ea..73428f39 100644
--- a/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
@@ -28,7 +28,8 @@
#include "KeyPairUIDTab.h"
-#include "core/GpgModel.h"
+#include <utility>
+
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyManager.h"
#include "core/function/gpg/GpgUIDOperator.h"
@@ -40,13 +41,11 @@
namespace GpgFrontend::UI {
-KeyPairUIDTab::KeyPairUIDTab(int channel, const QString& key_id,
- QWidget* parent)
+KeyPairUIDTab::KeyPairUIDTab(int channel, GpgKeyPtr key, QWidget* parent)
: QWidget(parent),
current_gpg_context_channel_(channel),
- m_key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)) {
- assert(m_key_.IsGood());
+ m_key_(std::move(key)) {
+ assert(m_key_ != nullptr);
create_uid_list();
create_sign_list();
@@ -57,7 +56,7 @@ KeyPairUIDTab::KeyPairUIDTab(int channel, const QString& key_id,
auto* add_uid_button = new QPushButton(tr("New UID"));
- if (!m_key_.IsHasMasterKey()) {
+ if (!m_key_->IsHasMasterKey()) {
add_uid_button->setDisabled(true);
}
uid_buttons_layout->addWidget(add_uid_button);
@@ -176,7 +175,7 @@ void KeyPairUIDTab::slot_refresh_uid_list() {
this->buffered_uids_.clear();
- for (auto& uid : m_key_.UIDs()) {
+ for (auto& uid : m_key_->UIDs()) {
this->buffered_uids_.push_back(std::move(uid));
}
@@ -316,7 +315,7 @@ void KeyPairUIDTab::slot_add_sign() {
void KeyPairUIDTab::slot_add_uid() {
auto* key_new_uid_dialog =
- new KeyNewUIDDialog(current_gpg_context_channel_, m_key_.ID(), this);
+ new KeyNewUIDDialog(current_gpg_context_channel_, m_key_, this);
connect(key_new_uid_dialog, &KeyNewUIDDialog::finished, this,
&KeyPairUIDTab::slot_add_uid_result);
connect(key_new_uid_dialog, &KeyNewUIDDialog::finished, key_new_uid_dialog,
@@ -434,7 +433,7 @@ void KeyPairUIDTab::create_uid_popup_menu() {
connect(del_uid_act_, &QAction::triggered, this,
&KeyPairUIDTab::slot_del_uid);
- if (m_key_.IsHasMasterKey()) {
+ if (m_key_->IsHasMasterKey()) {
uid_popup_menu_->addAction(set_primary_uid_act_);
uid_popup_menu_->addAction(sign_uid_act_);
uid_popup_menu_->addAction(rev_uid_act_);
@@ -516,9 +515,9 @@ void KeyPairUIDTab::slot_del_sign() {
void KeyPairUIDTab::slot_refresh_key() {
// refresh the key
- GpgKey refreshed_key = GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(m_key_.ID());
- assert(refreshed_key.IsGood());
+ auto refreshed_key = GpgKeyGetter::GetInstance(current_gpg_context_channel_)
+ .GetKeyPtr(m_key_->ID());
+ assert(refreshed_key != nullptr);
std::swap(this->m_key_, refreshed_key);
@@ -537,7 +536,7 @@ void KeyPairUIDTab::slot_rev_uid() {
return;
}
- const auto uids = m_key_.UIDs();
+ const auto uids = m_key_->UIDs();
QString message = tr("<h3>Revoke UID Confirmation</h3><br />"
"<b>UID:</b> %1<br /><br />"
diff --git a/src/ui/dialog/keypair_details/KeyPairUIDTab.h b/src/ui/dialog/keypair_details/KeyPairUIDTab.h
index 3f98e54b..ecae16b5 100644
--- a/src/ui/dialog/keypair_details/KeyPairUIDTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.h
@@ -43,7 +43,7 @@ class KeyPairUIDTab : public QWidget {
* @param key_id
* @param parent
*/
- KeyPairUIDTab(int channel, const QString& key_id, QWidget* parent);
+ KeyPairUIDTab(int channel, GpgKeyPtr key, QWidget* parent);
signals:
@@ -138,7 +138,7 @@ class KeyPairUIDTab : public QWidget {
private:
int current_gpg_context_channel_;
- GpgKey m_key_;
+ GpgKeyPtr m_key_;
QTableWidget* uid_list_{}; ///<
QTableWidget* sig_list_{}; ///<
QTabWidget* tofu_tabs_{}; ///<
diff --git a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
index 4880bd3d..b2d8d424 100644
--- a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
@@ -28,8 +28,9 @@
#include "KeySetExpireDateDialog.h"
+#include <utility>
+
#include "core/function/GlobalSettingStation.h"
-#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyOpera.h"
#include "core/utils/GpgUtils.h"
#include "ui/UISignalStation.h"
@@ -37,29 +38,27 @@
namespace GpgFrontend::UI {
-KeySetExpireDateDialog::KeySetExpireDateDialog(int channel, const KeyId& key_id,
+KeySetExpireDateDialog::KeySetExpireDateDialog(int channel, GpgKeyPtr key,
QWidget* parent)
: GeneralDialog(typeid(KeySetExpireDateDialog).name(), parent),
ui_(GpgFrontend::SecureCreateSharedObject<
Ui_ModifiedExpirationDateTime>()),
current_gpg_context_channel_(channel),
- m_key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)) {
- assert(m_key_.IsGood());
+ m_key_(std::move(key)) {
+ assert(m_key_->IsGood());
init();
}
-KeySetExpireDateDialog::KeySetExpireDateDialog(int channel, const KeyId& key_id,
+KeySetExpireDateDialog::KeySetExpireDateDialog(int channel, GpgKeyPtr key,
QString subkey_fpr,
QWidget* parent)
: GeneralDialog(typeid(KeySetExpireDateDialog).name(), parent),
ui_(GpgFrontend::SecureCreateSharedObject<
Ui_ModifiedExpirationDateTime>()),
current_gpg_context_channel_(channel),
- m_key_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
- .GetKey(key_id)),
+ m_key_(std::move(key)),
m_subkey_(std::move(subkey_fpr)) {
- assert(m_key_.IsGood());
+ assert(m_key_ != nullptr);
init();
}
@@ -101,7 +100,7 @@ void KeySetExpireDateDialog::init() {
ui_->dateEdit->setMinimumDateTime(min_date_time);
// set default date time to expire date time
- auto current_expire_time = m_key_.ExpirationTime();
+ auto current_expire_time = m_key_->ExpirationTime();
ui_->dateEdit->setDateTime(current_expire_time);
ui_->timeEdit->setDateTime(current_expire_time);
@@ -114,11 +113,11 @@ void KeySetExpireDateDialog::init() {
UISignalStation::GetInstance(),
&UISignalStation::SignalKeyDatabaseRefresh);
- if (m_key_.ExpirationTime().toSecsSinceEpoch() == 0) {
+ if (m_key_->ExpirationTime().toSecsSinceEpoch() == 0) {
ui_->noExpirationCheckBox->setCheckState(Qt::Checked);
} else {
- ui_->dateEdit->setDateTime(m_key_.ExpirationTime());
- ui_->timeEdit->setDateTime(m_key_.ExpirationTime());
+ ui_->dateEdit->setDateTime(m_key_->ExpirationTime());
+ ui_->timeEdit->setDateTime(m_key_->ExpirationTime());
}
ui_->titleLabel->setText(tr("Modified Expiration Date (Local Time)"));
diff --git a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
index 6617ff83..b75339a0 100644
--- a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
@@ -47,7 +47,7 @@ class KeySetExpireDateDialog : public GeneralDialog {
* @param key_id
* @param parent
*/
- explicit KeySetExpireDateDialog(int channel, const KeyId& key_id,
+ explicit KeySetExpireDateDialog(int channel, GpgKeyPtr key_id,
QWidget* parent = nullptr);
/**
@@ -57,7 +57,7 @@ class KeySetExpireDateDialog : public GeneralDialog {
* @param subkey_fpr
* @param parent
*/
- explicit KeySetExpireDateDialog(int channel, const KeyId& key_id,
+ explicit KeySetExpireDateDialog(int channel, GpgKeyPtr key,
QString subkey_fpr,
QWidget* parent = nullptr);
@@ -77,7 +77,7 @@ class KeySetExpireDateDialog : public GeneralDialog {
std::shared_ptr<Ui_ModifiedExpirationDateTime> ui_; ///<
int current_gpg_context_channel_; ///<
- const GpgKey m_key_; ///<
+ const GpgKeyPtr m_key_; ///<
const SubkeyId m_subkey_; ///<
private slots:
diff --git a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
index 2c4a8c59..46027428 100644
--- a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
@@ -28,22 +28,21 @@
#include "KeyUIDSignDialog.h"
-#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyManager.h"
#include "ui/UISignalStation.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-KeyUIDSignDialog::KeyUIDSignDialog(int channel, const GpgKey& key,
+KeyUIDSignDialog::KeyUIDSignDialog(int channel, const GpgKeyPtr& key,
const QString& uid, QWidget* parent)
: GeneralDialog(typeid(KeyUIDSignDialog).name(), parent),
current_gpg_context_channel_(channel),
m_uid_(uid),
m_key_(key) {
- assert(m_key_.IsGood());
+ assert(m_key_ != nullptr);
+ const auto key_id = m_key_->ID();
- const auto key_id = m_key_.ID();
m_key_list_ = new KeyList(
channel, KeyMenuAbility::kCOLUMN_FILTER | KeyMenuAbility::kSEARCH_BAR,
GpgKeyTableColumn::kNAME | GpgKeyTableColumn::kEMAIL_ADDRESS |
@@ -51,10 +50,11 @@ KeyUIDSignDialog::KeyUIDSignDialog(int channel, const GpgKey& key,
this);
m_key_list_->AddListGroupTab(
tr("Signers"), "signers", GpgKeyTableDisplayMode::kPRIVATE_KEY,
- [key_id](const GpgKey& key) -> bool {
- return !(key.IsDisabled() || !key.IsHasCertCap() ||
- !key.IsHasMasterKey() || key.IsExpired() || key.IsRevoked() ||
- key_id == key.ID());
+ [key_id](const GpgAbstractKey* key) -> bool {
+ if (key->KeyType() != GpgAbstractKeyType::kGPG_KEY) return false;
+ return !(key->IsDisabled() || !key->IsHasCertCap() ||
+ !dynamic_cast<const GpgKey*>(key)->IsHasMasterKey() ||
+ key->IsExpired() || key->IsRevoked() || key_id == key->ID());
});
m_key_list_->SlotRefresh();
@@ -103,13 +103,11 @@ KeyUIDSignDialog::KeyUIDSignDialog(int channel, const GpgKey& key,
&UISignalStation::SignalKeyDatabaseRefresh);
}
-void KeyUIDSignDialog::slot_sign_key(bool clicked) {
+void KeyUIDSignDialog::slot_sign_key(bool) {
// Set Signers
- auto key_ids = m_key_list_->GetChecked();
- auto keys =
- GpgKeyGetter::GetInstance(current_gpg_context_channel_).GetKeys(key_ids);
+ auto keys = m_key_list_->GetSelectedKeys();
assert(std::all_of(keys.begin(), keys.end(),
- [](const auto& key) { return key.IsGood(); }));
+ [](const auto& key) { return key->IsGood(); }));
auto expires = std::make_unique<QDateTime>(expires_edit_->dateTime());
diff --git a/src/ui/dialog/keypair_details/KeyUIDSignDialog.h b/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
index e40529fd..317cffdf 100644
--- a/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
@@ -45,8 +45,8 @@ class KeyUIDSignDialog : public GeneralDialog {
* @param uid
* @param parent
*/
- explicit KeyUIDSignDialog(int channel, const GpgKey& key, const QString& uid,
- QWidget* parent = nullptr);
+ explicit KeyUIDSignDialog(int channel, const GpgKeyPtr& key,
+ const QString& uid, QWidget* parent = nullptr);
signals:
/**
@@ -63,7 +63,7 @@ class KeyUIDSignDialog : public GeneralDialog {
QCheckBox* non_expire_check_; ///<
QString m_uid_; ///<
- const GpgKey& m_key_; ///<
+ const GpgKeyPtr& m_key_; ///<
private slots:
/**