aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/GpgContext.cpp25
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.cpp25
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.h1
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp25
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.h1
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp21
6 files changed, 85 insertions, 13 deletions
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp
index a5213134..68aedf4a 100644
--- a/src/core/GpgContext.cpp
+++ b/src/core/GpgContext.cpp
@@ -40,6 +40,7 @@
#include "core/GpgModel.h"
#include "core/common/CoreCommonUtil.h"
#include "core/function/CoreSignalStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgCommandExecutor.h"
#include "core/thread/TaskRunnerGetter.h"
#include "thread/Task.h"
@@ -219,8 +220,22 @@ void GpgContext::post_init_ctx() {
// preload info
auto &info = GetInfo();
- // listen passphrase input event
- SetPassphraseCb(custom_passphrase_cb);
+ auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
+
+ bool use_pinentry_as_password_input_dialog = false;
+ try {
+ use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+
+ // use custom qt dialog to replace pinentry
+ if (!use_pinentry_as_password_input_dialog) {
+ SetPassphraseCb(custom_passphrase_cb);
+ }
+
connect(this, &GpgContext::SignalNeedUserInputPassphrase,
CoreSignalStation::GetInstance(),
&CoreSignalStation::SignalNeedUserInputPassphrase);
@@ -372,6 +387,12 @@ const GpgInfo &GpgContext::GetInfo(bool refresh) {
auto component_name = info_split_list[0];
auto component_desc = info_split_list[1];
auto component_path = info_split_list[2];
+
+#ifdef WINDOWS
+ // replace some special substrings on windows platform
+ boost::replace_all(component_path, "%3a", ":");
+#endif
+
auto binary_checksum = check_binary_chacksum(component_path);
SPDLOG_DEBUG(
diff --git a/src/ui/dialog/key_generate/KeygenDialog.cpp b/src/ui/dialog/key_generate/KeygenDialog.cpp
index d6f61215..f103f0b1 100644
--- a/src/ui/dialog/key_generate/KeygenDialog.cpp
+++ b/src/ui/dialog/key_generate/KeygenDialog.cpp
@@ -53,6 +53,16 @@ KeyGenDialog::KeyGenDialog(QWidget* parent)
SPDLOG_ERROR("setting operation error: longer_expiration_date");
}
+ bool use_pinentry_as_password_input_dialog = false;
+ try {
+ use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+ use_pinentry_ = use_pinentry_as_password_input_dialog;
+
max_date_time_ = longer_expiration_date
? QDateTime::currentDateTime().toLocalTime().addYears(30)
: QDateTime::currentDateTime().toLocalTime().addYears(2);
@@ -111,7 +121,8 @@ void KeyGenDialog::slot_key_gen_accept() {
error_stream << " " << _("Expiration time too long.") << std::endl;
}
- if (passphrase_edit_->isEnabled() && passphrase_edit_->text().size() == 0) {
+ if (!use_pinentry_ && passphrase_edit_->isEnabled() &&
+ passphrase_edit_->text().size() == 0) {
error_stream << " " << _("Password is empty.") << std::endl;
}
@@ -139,7 +150,7 @@ void KeyGenDialog::slot_key_gen_accept() {
#endif
}
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->SetTempCacheValue(
"__key_passphrase", this->passphrase_edit_->text().toStdString());
}
@@ -160,7 +171,7 @@ void KeyGenDialog::slot_key_gen_accept() {
dialog->close();
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->ResetTempCacheValue("__key_passphrase");
}
@@ -391,6 +402,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
expire_check_box_->setCheckState(Qt::Unchecked);
passphrase_edit_->setEchoMode(QLineEdit::Password);
+ passphrase_edit_->setHidden(use_pinentry_);
no_pass_phrase_check_box_ = new QCheckBox(this);
no_pass_phrase_check_box_->setCheckState(Qt::Unchecked);
@@ -404,8 +416,9 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
vbox1->addWidget(new QLabel(QString(_("Never Expire")) + ": "), 3, 3);
vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 4, 0);
vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 5, 0);
- vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 6, 0);
- vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase")) + ": "), 6, 3);
+ if (!use_pinentry_)
+ vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 6, 0);
+ vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase"))), 6, 3);
vbox1->addWidget(name_edit_, 0, 1, 1, 3);
vbox1->addWidget(email_edit_, 1, 1, 1, 3);
@@ -414,7 +427,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
vbox1->addWidget(expire_check_box_, 3, 2);
vbox1->addWidget(key_size_spin_box_, 4, 1);
vbox1->addWidget(key_type_combo_box_, 5, 1);
- vbox1->addWidget(passphrase_edit_, 6, 1);
+ if (!use_pinentry_) vbox1->addWidget(passphrase_edit_, 6, 1);
vbox1->addWidget(no_pass_phrase_check_box_, 6, 2);
auto basicInfoGroupBox = new QGroupBox();
diff --git a/src/ui/dialog/key_generate/KeygenDialog.h b/src/ui/dialog/key_generate/KeygenDialog.h
index a1d7f39a..31b5f9c7 100644
--- a/src/ui/dialog/key_generate/KeygenDialog.h
+++ b/src/ui/dialog/key_generate/KeygenDialog.h
@@ -103,6 +103,7 @@ class KeyGenDialog : public GeneralDialog {
///< of the Key
QDateTime max_date_time_; ///<
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
+ bool use_pinentry_ = false;
/**
* @brief
diff --git a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
index 50f38413..1569fc5d 100644
--- a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
@@ -52,6 +52,16 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent)
SPDLOG_ERROR("setting operation error: longer_expiration_date");
}
+ bool use_pinentry_as_password_input_dialog = false;
+ try {
+ use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+ use_pinentry_ = use_pinentry_as_password_input_dialog;
+
max_date_time_ = longer_expiration_date
? QDateTime::currentDateTime().toLocalTime().addYears(30)
: QDateTime::currentDateTime().toLocalTime().addYears(2);
@@ -148,20 +158,24 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() {
expire_check_box_ = new QCheckBox(this);
expire_check_box_->setCheckState(Qt::Unchecked);
+ passphrase_edit_->setEchoMode(QLineEdit::Password);
+ passphrase_edit_->setHidden(use_pinentry_);
+
auto* vbox1 = new QGridLayout;
vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 0, 0);
vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 1, 0);
vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 2, 0);
vbox1->addWidget(new QLabel(QString(_("Never Expire"))), 2, 3);
- vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 3, 0);
+ if (!use_pinentry_)
+ vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 3, 0);
vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase"))), 3, 3);
vbox1->addWidget(key_type_combo_box_, 0, 1);
vbox1->addWidget(key_size_spin_box_, 1, 1);
vbox1->addWidget(date_edit_, 2, 1);
vbox1->addWidget(expire_check_box_, 2, 2);
- vbox1->addWidget(passphrase_edit_, 3, 1);
+ if (!use_pinentry_) vbox1->addWidget(passphrase_edit_, 3, 1);
vbox1->addWidget(no_pass_phrase_check_box_, 3, 2);
auto basicInfoGroupBox = new QGroupBox();
@@ -265,7 +279,8 @@ void SubkeyGenerateDialog::slot_key_gen_accept() {
err_stream << " " << _("Expiration time no more than 2 years.") << " ";
}
- if (passphrase_edit_->isEnabled() && passphrase_edit_->text().size() == 0) {
+ if (!use_pinentry_ && passphrase_edit_->isEnabled() &&
+ passphrase_edit_->text().size() == 0) {
err_stream << " " << _("Password is empty.") << std::endl;
}
@@ -286,7 +301,7 @@ void SubkeyGenerateDialog::slot_key_gen_accept() {
#endif
}
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->SetTempCacheValue(
"__key_passphrase", this->passphrase_edit_->text().toStdString());
}
@@ -307,7 +322,7 @@ void SubkeyGenerateDialog::slot_key_gen_accept() {
}
waiting_dialog->close();
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->ResetTempCacheValue("__key_passphrase");
}
diff --git a/src/ui/dialog/key_generate/SubkeyGenerateDialog.h b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
index 731bb951..2b88bd61 100644
--- a/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
@@ -74,6 +74,7 @@ class SubkeyGenerateDialog : public GeneralDialog {
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
QDateTime max_date_time_; ///<
+ bool use_pinentry_ = false;
/**
* @brief Create a key usage group box object
diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index 7e48b4e1..623dae79 100644
--- a/src/ui/dialog/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
@@ -57,6 +57,8 @@ GeneralTab::GeneralTab(QWidget* parent)
ui_->gnupgDatabaseBox->setTitle(_("GnuPG"));
ui_->asciiModeCheckBox->setText(_("No ASCII Mode"));
+ ui_->usePinentryAsPasswordInputDialogCheckBox->setText(
+ _("Use Pinentry as Password Input Dialog"));
ui_->useCustomGnuPGInstallPathCheckBox->setText(_("Use Custom GnuPG"));
ui_->useCustomGnuPGInstallPathButton->setText(_("Select GnuPG Path"));
ui_->keyDatabseUseCustomCheckBox->setText(
@@ -260,6 +262,16 @@ void GeneralTab::SetSettings() {
SPDLOG_ERROR("setting operation error: use_custom_gnupg_install_path");
}
+ try {
+ bool use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ if (use_pinentry_as_password_input_dialog)
+ ui_->usePinentryAsPasswordInputDialogCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+
this->slot_update_custom_gnupg_install_path_label(
ui_->useCustomGnuPGInstallPathCheckBox->checkState());
}
@@ -343,6 +355,15 @@ void GeneralTab::ApplySettings() {
general["use_custom_gnupg_install_path"] =
ui_->useCustomGnuPGInstallPathCheckBox->isChecked();
}
+
+ if (!general.exists("use_pinentry_as_password_input_dialog"))
+ general.add("use_pinentry_as_password_input_dialog",
+ libconfig::Setting::TypeBoolean) =
+ ui_->usePinentryAsPasswordInputDialogCheckBox->isChecked();
+ else {
+ general["use_pinentry_as_password_input_dialog"] =
+ ui_->usePinentryAsPasswordInputDialogCheckBox->isChecked();
+ }
}
#ifdef MULTI_LANG_SUPPORT