fix: discover and fix some bugs
This commit is contained in:
parent
bb6488d84c
commit
9ea9c03263
@ -131,7 +131,7 @@ auto StartApplication(InitArgs args) -> int {
|
|||||||
SPDLOG_INFO("GpgFrontend is about to exit.");
|
SPDLOG_INFO("GpgFrontend is about to exit.");
|
||||||
|
|
||||||
// deep restart mode
|
// deep restart mode
|
||||||
if (return_from_event_loop_code == GpgFrontend::kRestartCode ||
|
if (return_from_event_loop_code == GpgFrontend::kDeepRestartCode ||
|
||||||
return_from_event_loop_code == kCrashCode) {
|
return_from_event_loop_code == kCrashCode) {
|
||||||
// log for debug
|
// log for debug
|
||||||
SPDLOG_DEBUG(
|
SPDLOG_DEBUG(
|
||||||
|
@ -54,7 +54,7 @@ class GPGFRONTEND_CORE_EXPORT CoreSignalStation : public QObject {
|
|||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void SignalUserInputPassphraseDone(QString passparase);
|
void SignalUserInputPassphraseDone();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <gpg-error.h>
|
#include <gpg-error.h>
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
#include <qeventloop.h>
|
||||||
|
#include <qobject.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "core/function/CoreSignalStation.h"
|
#include "core/function/CoreSignalStation.h"
|
||||||
@ -42,6 +44,7 @@
|
|||||||
#include "core/utils/CacheUtils.h"
|
#include "core/utils/CacheUtils.h"
|
||||||
#include "core/utils/CommonUtils.h"
|
#include "core/utils/CommonUtils.h"
|
||||||
#include "core/utils/GpgUtils.h"
|
#include "core/utils/GpgUtils.h"
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -256,8 +259,15 @@ class GpgContext::Impl : public SingletonFunctionObject<GpgContext::Impl> {
|
|||||||
if (passphrase.empty()) {
|
if (passphrase.empty()) {
|
||||||
// user input passphrase
|
// user input passphrase
|
||||||
SPDLOG_DEBUG("might need user to input passparase");
|
SPDLOG_DEBUG("might need user to input passparase");
|
||||||
passphrase = p_ctx->ShowPasswordInputDialog();
|
|
||||||
|
p_ctx->ShowPasswordInputDialog();
|
||||||
|
passphrase = GetTempCacheValue("__key_passphrase");
|
||||||
|
|
||||||
|
SPDLOG_DEBUG("use may has inputed the passphrase");
|
||||||
|
|
||||||
if (passphrase.empty()) {
|
if (passphrase.empty()) {
|
||||||
|
SPDLOG_ERROR("cannot get passphrase from use or passphrase is empty");
|
||||||
|
|
||||||
gpgme_io_write(fd, "\n", 1);
|
gpgme_io_write(fd, "\n", 1);
|
||||||
return gpgme_error_from_errno(GPG_ERR_CANCELED);
|
return gpgme_error_from_errno(GPG_ERR_CANCELED);
|
||||||
}
|
}
|
||||||
@ -285,27 +295,16 @@ class GpgContext::Impl : public SingletonFunctionObject<GpgContext::Impl> {
|
|||||||
return GPG_ERR_NO_ERROR;
|
return GPG_ERR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ShowPasswordInputDialog() -> std::string {
|
void ShowPasswordInputDialog() {
|
||||||
emit parent_->SignalNeedUserInputPassphrase();
|
emit parent_->SignalNeedUserInputPassphrase();
|
||||||
|
|
||||||
std::string final_passphrase;
|
QEventLoop looper;
|
||||||
bool input_done = false;
|
QObject::connect(CoreSignalStation::GetInstance(),
|
||||||
SPDLOG_DEBUG("loop start to wait from user");
|
&CoreSignalStation::SignalUserInputPassphraseDone, &looper,
|
||||||
auto connection = QObject::connect(
|
&QEventLoop::quit);
|
||||||
CoreSignalStation::GetInstance(),
|
looper.exec();
|
||||||
&CoreSignalStation::SignalUserInputPassphraseDone, parent_,
|
|
||||||
[&](const QString &passphrase) {
|
|
||||||
SPDLOG_DEBUG("SignalUserInputPassphraseDone emitted");
|
|
||||||
final_passphrase = passphrase.toStdString();
|
|
||||||
input_done = true;
|
|
||||||
});
|
|
||||||
while (!input_done) {
|
|
||||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 800);
|
|
||||||
}
|
|
||||||
QObject::disconnect(connection);
|
|
||||||
|
|
||||||
SPDLOG_DEBUG("lopper end");
|
SPDLOG_DEBUG("show password input dialog done");
|
||||||
return final_passphrase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -390,7 +389,7 @@ GpgContext::operator gpgme_ctx_t() const {
|
|||||||
return static_cast<gpgme_ctx_t>(*p_);
|
return static_cast<gpgme_ctx_t>(*p_);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GpgContext::ShowPasswordInputDialog() -> std::string {
|
void GpgContext::ShowPasswordInputDialog() {
|
||||||
return p_->ShowPasswordInputDialog();
|
return p_->ShowPasswordInputDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class GPGFRONTEND_CORE_EXPORT GpgContext
|
|||||||
|
|
||||||
void SetPassphraseCb(gpgme_passphrase_cb_t passphrase_cb) const;
|
void SetPassphraseCb(gpgme_passphrase_cb_t passphrase_cb) const;
|
||||||
|
|
||||||
auto ShowPasswordInputDialog() -> std::string;
|
void ShowPasswordInputDialog();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SignalNeedUserInputPassphrase();
|
void SignalNeedUserInputPassphrase();
|
||||||
|
@ -28,17 +28,15 @@
|
|||||||
|
|
||||||
#include "SignalStation.h"
|
#include "SignalStation.h"
|
||||||
|
|
||||||
#include "ui/UserInterfaceUtils.h"
|
|
||||||
|
|
||||||
namespace GpgFrontend::UI {
|
namespace GpgFrontend::UI {
|
||||||
|
|
||||||
std::unique_ptr<SignalStation> SignalStation::_instance = nullptr;
|
std::unique_ptr<SignalStation> SignalStation::instance = nullptr;
|
||||||
|
|
||||||
SignalStation* SignalStation::GetInstance() {
|
auto SignalStation::GetInstance() -> SignalStation* {
|
||||||
if (_instance == nullptr) {
|
if (instance == nullptr) {
|
||||||
_instance = std::make_unique<SignalStation>();
|
instance = std::make_unique<SignalStation>();
|
||||||
}
|
}
|
||||||
return _instance.get();
|
return instance.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GpgFrontend::UI
|
} // namespace GpgFrontend::UI
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui/GpgFrontendUI.h"
|
|
||||||
#include "ui/widgets/InfoBoardWidget.h"
|
#include "ui/widgets/InfoBoardWidget.h"
|
||||||
|
|
||||||
namespace GpgFrontend::UI {
|
namespace GpgFrontend::UI {
|
||||||
@ -39,7 +38,7 @@ namespace GpgFrontend::UI {
|
|||||||
*/
|
*/
|
||||||
class SignalStation : public QObject {
|
class SignalStation : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
static std::unique_ptr<SignalStation> _instance;
|
static std::unique_ptr<SignalStation> instance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -47,7 +46,7 @@ class SignalStation : public QObject {
|
|||||||
*
|
*
|
||||||
* @return SignalStation*
|
* @return SignalStation*
|
||||||
*/
|
*/
|
||||||
static SignalStation* GetInstance();
|
static auto GetInstance() -> SignalStation*;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -36,13 +36,14 @@
|
|||||||
#include "core/GpgConstants.h"
|
#include "core/GpgConstants.h"
|
||||||
#include "core/function/CacheManager.h"
|
#include "core/function/CacheManager.h"
|
||||||
#include "core/function/CoreSignalStation.h"
|
#include "core/function/CoreSignalStation.h"
|
||||||
#include "core/function/GlobalSettingStation.h"
|
|
||||||
#include "core/function/gpg/GpgKeyGetter.h"
|
#include "core/function/gpg/GpgKeyGetter.h"
|
||||||
#include "core/module/ModuleManager.h"
|
#include "core/module/ModuleManager.h"
|
||||||
#include "core/thread/Task.h"
|
#include "core/thread/Task.h"
|
||||||
#include "core/thread/TaskRunner.h"
|
#include "core/thread/TaskRunner.h"
|
||||||
#include "core/thread/TaskRunnerGetter.h"
|
#include "core/thread/TaskRunnerGetter.h"
|
||||||
|
#include "core/utils/CacheUtils.h"
|
||||||
#include "core/utils/IOUtils.h"
|
#include "core/utils/IOUtils.h"
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
#include "ui/SignalStation.h"
|
#include "ui/SignalStation.h"
|
||||||
#include "ui/dialog/WaitingDialog.h"
|
#include "ui/dialog/WaitingDialog.h"
|
||||||
#include "ui/dialog/gnupg/GnuPGControllerDialog.h"
|
#include "ui/dialog/gnupg/GnuPGControllerDialog.h"
|
||||||
@ -436,7 +437,7 @@ void CommonUtils::SlotImportKeyFromKeyServer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommonUtils::slot_update_key_status() {
|
void CommonUtils::slot_update_key_status() {
|
||||||
auto refresh_task = new Thread::Task(
|
auto *refresh_task = new Thread::Task(
|
||||||
[](DataObjectPtr) -> int {
|
[](DataObjectPtr) -> int {
|
||||||
// flush key cache for all GpgKeyGetter Intances.
|
// flush key cache for all GpgKeyGetter Intances.
|
||||||
for (const auto &channel_id : GpgKeyGetter::GetAllChannelId()) {
|
for (const auto &channel_id : GpgKeyGetter::GetAllChannelId()) {
|
||||||
@ -446,8 +447,7 @@ void CommonUtils::slot_update_key_status() {
|
|||||||
},
|
},
|
||||||
"update_key_database_task");
|
"update_key_database_task");
|
||||||
connect(refresh_task, &Thread::Task::SignalTaskEnd, this,
|
connect(refresh_task, &Thread::Task::SignalTaskEnd, this,
|
||||||
&CommonUtils::SignalKeyDatabaseRefreshDone,
|
&CommonUtils::SignalKeyDatabaseRefreshDone);
|
||||||
Qt::BlockingQueuedConnection);
|
|
||||||
|
|
||||||
// post the task to the default task runner
|
// post the task to the default task runner
|
||||||
Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask(
|
Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask(
|
||||||
@ -464,11 +464,10 @@ void CommonUtils::slot_popup_passphrase_input_dialog() {
|
|||||||
dialog->resize(500, 80);
|
dialog->resize(500, 80);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
|
|
||||||
QString password = dialog->textValue();
|
SetTempCacheValue("__key_passphrase", dialog->textValue().toStdString());
|
||||||
dialog->deleteLater();
|
|
||||||
|
|
||||||
// send signal
|
// send signal
|
||||||
emit SignalUserInputPassphraseDone(password);
|
emit SignalUserInputPassphraseDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonUtils::SlotRestartApplication(int code) {
|
void CommonUtils::SlotRestartApplication(int code) {
|
||||||
|
@ -198,7 +198,7 @@ class CommonUtils : public QWidget {
|
|||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void SignalUserInputPassphraseDone(QString passphrase);
|
void SignalUserInputPassphraseDone();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -166,7 +166,7 @@ void KeyGenDialog::slot_key_gen_accept() {
|
|||||||
ResetTempCacheValue("__key_passphrase");
|
ResetTempCacheValue("__key_passphrase");
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_DEBUG("generate done");
|
SPDLOG_DEBUG("key generation done");
|
||||||
|
|
||||||
if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
|
if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
|
||||||
auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
|
auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
|
||||||
@ -177,14 +177,15 @@ void KeyGenDialog::slot_key_gen_accept() {
|
|||||||
msg_box->setModal(true);
|
msg_box->setModal(true);
|
||||||
msg_box->open();
|
msg_box->open();
|
||||||
|
|
||||||
SPDLOG_DEBUG("generate success");
|
SPDLOG_DEBUG("key generate successful");
|
||||||
|
|
||||||
emit SignalKeyGenerated();
|
emit SignalKeyGenerated();
|
||||||
this->close();
|
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(this, _("Failure"), _("Key generation failed."));
|
QMessageBox::critical(this, _("Failure"), _("Key generation failed."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->done(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* create error message
|
* create error message
|
||||||
@ -200,7 +201,7 @@ void KeyGenDialog::slot_key_gen_accept() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeyGenDialog::slot_expire_box_changed() {
|
void KeyGenDialog::slot_expire_box_changed() {
|
||||||
if (expire_check_box_->checkState()) {
|
if (expire_check_box_->checkState() != 0U) {
|
||||||
date_edit_->setEnabled(false);
|
date_edit_->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
date_edit_->setEnabled(true);
|
date_edit_->setEnabled(true);
|
||||||
|
@ -45,32 +45,32 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
|
|||||||
create_uid_popup_menu();
|
create_uid_popup_menu();
|
||||||
create_sign_popup_menu();
|
create_sign_popup_menu();
|
||||||
|
|
||||||
auto uidButtonsLayout = new QGridLayout();
|
auto* uid_buttons_layout = new QGridLayout();
|
||||||
|
|
||||||
auto addUIDButton = new QPushButton(_("New UID"));
|
auto* add_uid_button = new QPushButton(_("New UID"));
|
||||||
auto manageUIDButton = new QPushButton(_("UID Management"));
|
auto manage_uid_button = new QPushButton(_("UID Management"));
|
||||||
|
|
||||||
if (m_key_.IsHasMasterKey()) {
|
if (m_key_.IsHasMasterKey()) {
|
||||||
manageUIDButton->setMenu(manage_selected_uid_menu_);
|
manage_uid_button->setMenu(manage_selected_uid_menu_);
|
||||||
} else {
|
} else {
|
||||||
manageUIDButton->setDisabled(true);
|
manage_uid_button->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
uidButtonsLayout->addWidget(addUIDButton, 0, 1);
|
uid_buttons_layout->addWidget(add_uid_button, 0, 1);
|
||||||
uidButtonsLayout->addWidget(manageUIDButton, 0, 2);
|
uid_buttons_layout->addWidget(manage_uid_button, 0, 2);
|
||||||
|
|
||||||
auto grid_layout = new QGridLayout();
|
auto* grid_layout = new QGridLayout();
|
||||||
|
|
||||||
grid_layout->addWidget(uid_list_, 0, 0);
|
grid_layout->addWidget(uid_list_, 0, 0);
|
||||||
grid_layout->addLayout(uidButtonsLayout, 1, 0);
|
grid_layout->addLayout(uid_buttons_layout, 1, 0);
|
||||||
grid_layout->setContentsMargins(0, 10, 0, 0);
|
grid_layout->setContentsMargins(0, 10, 0, 0);
|
||||||
|
|
||||||
auto uid_group_box = new QGroupBox();
|
auto* uid_group_box = new QGroupBox();
|
||||||
uid_group_box->setLayout(grid_layout);
|
uid_group_box->setLayout(grid_layout);
|
||||||
uid_group_box->setTitle(_("UIDs"));
|
uid_group_box->setTitle(_("UIDs"));
|
||||||
|
|
||||||
auto tofu_group_box = new QGroupBox();
|
auto* tofu_group_box = new QGroupBox();
|
||||||
auto tofu_vbox_layout = new QVBoxLayout();
|
auto* tofu_vbox_layout = new QVBoxLayout();
|
||||||
tofu_group_box->setLayout(tofu_vbox_layout);
|
tofu_group_box->setLayout(tofu_vbox_layout);
|
||||||
tofu_group_box->setTitle(_("TOFU"));
|
tofu_group_box->setTitle(_("TOFU"));
|
||||||
#if !defined(RELEASE)
|
#if !defined(RELEASE)
|
||||||
@ -78,25 +78,25 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
|
|||||||
tofu_vbox_layout->addWidget(tofu_tabs_);
|
tofu_vbox_layout->addWidget(tofu_tabs_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto sign_grid_layout = new QGridLayout();
|
auto* sign_grid_layout = new QGridLayout();
|
||||||
sign_grid_layout->addWidget(sig_list_, 0, 0);
|
sign_grid_layout->addWidget(sig_list_, 0, 0);
|
||||||
sign_grid_layout->setContentsMargins(0, 10, 0, 0);
|
sign_grid_layout->setContentsMargins(0, 10, 0, 0);
|
||||||
|
|
||||||
auto sign_group_box = new QGroupBox();
|
auto* sign_group_box = new QGroupBox();
|
||||||
sign_group_box->setLayout(sign_grid_layout);
|
sign_group_box->setLayout(sign_grid_layout);
|
||||||
sign_group_box->setTitle(_("Signature of Selected UID"));
|
sign_group_box->setTitle(_("Signature of Selected UID"));
|
||||||
|
|
||||||
auto vboxLayout = new QVBoxLayout();
|
auto* vbox_layout = new QVBoxLayout();
|
||||||
vboxLayout->addWidget(uid_group_box);
|
vbox_layout->addWidget(uid_group_box);
|
||||||
#if !defined(RELEASE)
|
#if !defined(RELEASE)
|
||||||
// Function needed testing
|
// Function needed testing
|
||||||
vboxLayout->addWidget(tofu_group_box);
|
vbox_layout->addWidget(tofu_group_box);
|
||||||
#endif
|
#endif
|
||||||
vboxLayout->addWidget(sign_group_box);
|
vbox_layout->addWidget(sign_group_box);
|
||||||
|
|
||||||
vboxLayout->setContentsMargins(0, 0, 0, 0);
|
vbox_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
connect(addUIDButton, &QPushButton::clicked, this,
|
connect(add_uid_button, &QPushButton::clicked, this,
|
||||||
&KeyPairUIDTab::slot_add_uid);
|
&KeyPairUIDTab::slot_add_uid);
|
||||||
connect(uid_list_, &QTableWidget::itemSelectionChanged, this,
|
connect(uid_list_, &QTableWidget::itemSelectionChanged, this,
|
||||||
&KeyPairUIDTab::slot_refresh_tofu_info);
|
&KeyPairUIDTab::slot_refresh_tofu_info);
|
||||||
@ -112,7 +112,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
|
|||||||
SignalStation::GetInstance(),
|
SignalStation::GetInstance(),
|
||||||
&SignalStation::SignalKeyDatabaseRefresh);
|
&SignalStation::SignalKeyDatabaseRefresh);
|
||||||
|
|
||||||
setLayout(vboxLayout);
|
setLayout(vbox_layout);
|
||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
slot_refresh_uid_list();
|
slot_refresh_uid_list();
|
||||||
@ -184,13 +184,13 @@ void KeyPairUIDTab::slot_refresh_uid_list() {
|
|||||||
uid_list_->setRowCount(buffered_uids_.size());
|
uid_list_->setRowCount(buffered_uids_.size());
|
||||||
|
|
||||||
for (const auto& uid : buffered_uids_) {
|
for (const auto& uid : buffered_uids_) {
|
||||||
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
|
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.GetName()));
|
||||||
uid_list_->setItem(row, 1, tmp0);
|
uid_list_->setItem(row, 1, tmp0);
|
||||||
|
|
||||||
auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
|
auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.GetEmail()));
|
||||||
uid_list_->setItem(row, 2, tmp1);
|
uid_list_->setItem(row, 2, tmp1);
|
||||||
|
|
||||||
auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
|
auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.GetComment()));
|
||||||
uid_list_->setItem(row, 3, tmp2);
|
uid_list_->setItem(row, 3, tmp2);
|
||||||
|
|
||||||
auto* tmp3 = new QTableWidgetItem(QString::number(row));
|
auto* tmp3 = new QTableWidgetItem(QString::number(row));
|
||||||
@ -243,10 +243,11 @@ void KeyPairUIDTab::slot_refresh_tofu_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairUIDTab::slot_refresh_sig_list() {
|
void KeyPairUIDTab::slot_refresh_sig_list() {
|
||||||
int uidRow = 0, sigRow = 0;
|
int uid_row = 0;
|
||||||
|
int sig_row = 0;
|
||||||
for (const auto& uid : buffered_uids_) {
|
for (const auto& uid : buffered_uids_) {
|
||||||
// Only Show Selected UID Signatures
|
// Only Show Selected UID Signatures
|
||||||
if (!uid_list_->item(uidRow++, 0)->isSelected()) {
|
if (!uid_list_->item(uid_row++, 0)->isSelected()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,22 +264,22 @@ void KeyPairUIDTab::slot_refresh_sig_list() {
|
|||||||
|
|
||||||
for (const auto& sig : buffered_signatures_) {
|
for (const auto& sig : buffered_signatures_) {
|
||||||
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(sig.GetKeyID()));
|
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(sig.GetKeyID()));
|
||||||
sig_list_->setItem(sigRow, 0, tmp0);
|
sig_list_->setItem(sig_row, 0, tmp0);
|
||||||
|
|
||||||
if (gpgme_err_code(sig.GetStatus()) == GPG_ERR_NO_PUBKEY) {
|
if (gpgme_err_code(sig.GetStatus()) == GPG_ERR_NO_PUBKEY) {
|
||||||
auto* tmp2 = new QTableWidgetItem("<Unknown>");
|
auto* tmp2 = new QTableWidgetItem("<Unknown>");
|
||||||
sig_list_->setItem(sigRow, 1, tmp2);
|
sig_list_->setItem(sig_row, 1, tmp2);
|
||||||
|
|
||||||
auto* tmp3 = new QTableWidgetItem("<Unknown>");
|
auto* tmp3 = new QTableWidgetItem("<Unknown>");
|
||||||
sig_list_->setItem(sigRow, 2, tmp3);
|
sig_list_->setItem(sig_row, 2, tmp3);
|
||||||
} else {
|
} else {
|
||||||
auto* tmp2 =
|
auto* tmp2 =
|
||||||
new QTableWidgetItem(QString::fromStdString(sig.GetName()));
|
new QTableWidgetItem(QString::fromStdString(sig.GetName()));
|
||||||
sig_list_->setItem(sigRow, 1, tmp2);
|
sig_list_->setItem(sig_row, 1, tmp2);
|
||||||
|
|
||||||
auto* tmp3 =
|
auto* tmp3 =
|
||||||
new QTableWidgetItem(QString::fromStdString(sig.GetEmail()));
|
new QTableWidgetItem(QString::fromStdString(sig.GetEmail()));
|
||||||
sig_list_->setItem(sigRow, 2, tmp3);
|
sig_list_->setItem(sig_row, 2, tmp3);
|
||||||
}
|
}
|
||||||
#ifdef GPGFRONTEND_GUI_QT6
|
#ifdef GPGFRONTEND_GUI_QT6
|
||||||
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
|
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
|
||||||
@ -287,12 +288,11 @@ void KeyPairUIDTab::slot_refresh_sig_list() {
|
|||||||
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
|
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
|
||||||
QDateTime::fromTime_t(to_time_t(sig.GetCreateTime()))));
|
QDateTime::fromTime_t(to_time_t(sig.GetCreateTime()))));
|
||||||
#endif
|
#endif
|
||||||
sig_list_->setItem(sigRow, 3, tmp4);
|
sig_list_->setItem(sig_row, 3, tmp4);
|
||||||
|
|
||||||
#ifdef GPGFRONTEND_GUI_QT6
|
#ifdef GPGFRONTEND_GUI_QT6
|
||||||
auto* tmp5 = new QTableWidgetItem(
|
auto* tmp5 = new QTableWidgetItem(
|
||||||
boost::posix_time::to_time_t(
|
boost::posix_time::to_time_t(sig.GetExpireTime()) == 0
|
||||||
boost::posix_time::ptime(sig.GetExpireTime())) == 0
|
|
||||||
? _("Never Expires")
|
? _("Never Expires")
|
||||||
: QLocale::system().toString(QDateTime::fromSecsSinceEpoch(
|
: QLocale::system().toString(QDateTime::fromSecsSinceEpoch(
|
||||||
to_time_t(sig.GetExpireTime()))));
|
to_time_t(sig.GetExpireTime()))));
|
||||||
@ -305,9 +305,9 @@ void KeyPairUIDTab::slot_refresh_sig_list() {
|
|||||||
QDateTime::fromTime_t(to_time_t(sig.GetExpireTime()))));
|
QDateTime::fromTime_t(to_time_t(sig.GetExpireTime()))));
|
||||||
#endif
|
#endif
|
||||||
tmp5->setTextAlignment(Qt::AlignCenter);
|
tmp5->setTextAlignment(Qt::AlignCenter);
|
||||||
sig_list_->setItem(sigRow, 4, tmp5);
|
sig_list_->setItem(sig_row, 4, tmp5);
|
||||||
|
|
||||||
sigRow++;
|
sig_row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -324,41 +324,43 @@ void KeyPairUIDTab::slot_add_sign() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto keySignDialog =
|
auto* key_sign_dialog =
|
||||||
new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
|
new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
|
||||||
keySignDialog->show();
|
key_sign_dialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
UIDArgsListPtr KeyPairUIDTab::get_uid_checked() {
|
auto KeyPairUIDTab::get_uid_checked() -> UIDArgsListPtr {
|
||||||
auto selected_uids = std::make_unique<UIDArgsList>();
|
auto selected_uids = std::make_unique<UIDArgsList>();
|
||||||
for (int i = 0; i < uid_list_->rowCount(); i++) {
|
for (int i = 0; i < uid_list_->rowCount(); i++) {
|
||||||
if (uid_list_->item(i, 0)->checkState() == Qt::Checked)
|
if (uid_list_->item(i, 0)->checkState() == Qt::Checked) {
|
||||||
selected_uids->push_back(buffered_uids_[i].GetUID());
|
selected_uids->push_back(buffered_uids_[i].GetUID());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return selected_uids;
|
return selected_uids;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairUIDTab::create_manage_uid_menu() {
|
void KeyPairUIDTab::create_manage_uid_menu() {
|
||||||
manage_selected_uid_menu_ = new QMenu(this);
|
manage_selected_uid_menu_ = new QMenu(this);
|
||||||
|
|
||||||
auto* signUIDAct = new QAction(_("Sign Selected UID(s)"), this);
|
auto* sign_uid_act = new QAction(_("Sign Selected UID(s)"), this);
|
||||||
connect(signUIDAct, &QAction::triggered, this, &KeyPairUIDTab::slot_add_sign);
|
connect(sign_uid_act, &QAction::triggered, this,
|
||||||
auto* delUIDAct = new QAction(_("Delete Selected UID(s)"), this);
|
&KeyPairUIDTab::slot_add_sign);
|
||||||
connect(delUIDAct, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid);
|
auto* del_uid_act = new QAction(_("Delete Selected UID(s)"), this);
|
||||||
|
connect(del_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid);
|
||||||
|
|
||||||
if (m_key_.IsHasMasterKey()) {
|
if (m_key_.IsHasMasterKey()) {
|
||||||
manage_selected_uid_menu_->addAction(signUIDAct);
|
manage_selected_uid_menu_->addAction(sign_uid_act);
|
||||||
manage_selected_uid_menu_->addAction(delUIDAct);
|
manage_selected_uid_menu_->addAction(del_uid_act);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairUIDTab::slot_add_uid() {
|
void KeyPairUIDTab::slot_add_uid() {
|
||||||
auto keyNewUIDDialog = new KeyNewUIDDialog(m_key_.GetId(), this);
|
auto* key_new_uid_dialog = new KeyNewUIDDialog(m_key_.GetId(), this);
|
||||||
connect(keyNewUIDDialog, &KeyNewUIDDialog::finished, this,
|
connect(key_new_uid_dialog, &KeyNewUIDDialog::finished, this,
|
||||||
&KeyPairUIDTab::slot_add_uid_result);
|
&KeyPairUIDTab::slot_add_uid_result);
|
||||||
connect(keyNewUIDDialog, &KeyNewUIDDialog::finished, keyNewUIDDialog,
|
connect(key_new_uid_dialog, &KeyNewUIDDialog::finished, key_new_uid_dialog,
|
||||||
&KeyPairUIDTab::deleteLater);
|
&KeyPairUIDTab::deleteLater);
|
||||||
keyNewUIDDialog->show();
|
key_new_uid_dialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairUIDTab::slot_add_uid_result(int result) {
|
void KeyPairUIDTab::slot_add_uid_result(int result) {
|
||||||
@ -414,9 +416,10 @@ void KeyPairUIDTab::slot_set_primary_uid() {
|
|||||||
auto selected_uids = get_uid_selected();
|
auto selected_uids = get_uid_selected();
|
||||||
|
|
||||||
if (selected_uids->empty()) {
|
if (selected_uids->empty()) {
|
||||||
auto emptyUIDMsg = new QMessageBox();
|
auto* empty_uid_msg = new QMessageBox();
|
||||||
emptyUIDMsg->setText("Please select one UID before doing this operation.");
|
empty_uid_msg->setText(
|
||||||
emptyUIDMsg->exec();
|
"Please select one UID before doing this operation.");
|
||||||
|
empty_uid_msg->exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +447,7 @@ void KeyPairUIDTab::slot_set_primary_uid() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UIDArgsListPtr KeyPairUIDTab::get_uid_selected() {
|
auto KeyPairUIDTab::get_uid_selected() -> UIDArgsListPtr {
|
||||||
auto uids = std::make_unique<UIDArgsList>();
|
auto uids = std::make_unique<UIDArgsList>();
|
||||||
for (int i = 0; i < uid_list_->rowCount(); i++) {
|
for (int i = 0; i < uid_list_->rowCount(); i++) {
|
||||||
if (uid_list_->item(i, 0)->isSelected()) {
|
if (uid_list_->item(i, 0)->isSelected()) {
|
||||||
@ -454,7 +457,7 @@ UIDArgsListPtr KeyPairUIDTab::get_uid_selected() {
|
|||||||
return uids;
|
return uids;
|
||||||
}
|
}
|
||||||
|
|
||||||
SignIdArgsListPtr KeyPairUIDTab::get_sign_selected() {
|
auto KeyPairUIDTab::get_sign_selected() -> SignIdArgsListPtr {
|
||||||
auto signatures = std::make_unique<SignIdArgsList>();
|
auto signatures = std::make_unique<SignIdArgsList>();
|
||||||
for (int i = 0; i < sig_list_->rowCount(); i++) {
|
for (int i = 0; i < sig_list_->rowCount(); i++) {
|
||||||
if (sig_list_->item(i, 0)->isSelected()) {
|
if (sig_list_->item(i, 0)->isSelected()) {
|
||||||
@ -468,20 +471,20 @@ SignIdArgsListPtr KeyPairUIDTab::get_sign_selected() {
|
|||||||
void KeyPairUIDTab::create_uid_popup_menu() {
|
void KeyPairUIDTab::create_uid_popup_menu() {
|
||||||
uid_popup_menu_ = new QMenu(this);
|
uid_popup_menu_ = new QMenu(this);
|
||||||
|
|
||||||
auto* serPrimaryUIDAct = new QAction(_("Set As Primary"), this);
|
auto* ser_primary_uid_act = new QAction(_("Set As Primary"), this);
|
||||||
connect(serPrimaryUIDAct, &QAction::triggered, this,
|
connect(ser_primary_uid_act, &QAction::triggered, this,
|
||||||
&KeyPairUIDTab::slot_set_primary_uid);
|
&KeyPairUIDTab::slot_set_primary_uid);
|
||||||
auto* signUIDAct = new QAction(_("Sign UID"), this);
|
auto* sign_uid_act = new QAction(_("Sign UID"), this);
|
||||||
connect(signUIDAct, &QAction::triggered, this,
|
connect(sign_uid_act, &QAction::triggered, this,
|
||||||
&KeyPairUIDTab::slot_add_sign_single);
|
&KeyPairUIDTab::slot_add_sign_single);
|
||||||
auto* delUIDAct = new QAction(_("Delete UID"), this);
|
auto* del_uid_act = new QAction(_("Delete UID"), this);
|
||||||
connect(delUIDAct, &QAction::triggered, this,
|
connect(del_uid_act, &QAction::triggered, this,
|
||||||
&KeyPairUIDTab::slot_del_uid_single);
|
&KeyPairUIDTab::slot_del_uid_single);
|
||||||
|
|
||||||
if (m_key_.IsHasMasterKey()) {
|
if (m_key_.IsHasMasterKey()) {
|
||||||
uid_popup_menu_->addAction(serPrimaryUIDAct);
|
uid_popup_menu_->addAction(ser_primary_uid_act);
|
||||||
uid_popup_menu_->addAction(signUIDAct);
|
uid_popup_menu_->addAction(sign_uid_act);
|
||||||
uid_popup_menu_->addAction(delUIDAct);
|
uid_popup_menu_->addAction(del_uid_act);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,9 +505,9 @@ void KeyPairUIDTab::slot_add_sign_single() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto keySignDialog =
|
auto* key_sign_dialog =
|
||||||
new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
|
new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
|
||||||
keySignDialog->show();
|
key_sign_dialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairUIDTab::slot_del_uid_single() {
|
void KeyPairUIDTab::slot_del_uid_single() {
|
||||||
@ -543,10 +546,11 @@ void KeyPairUIDTab::slot_del_uid_single() {
|
|||||||
void KeyPairUIDTab::create_sign_popup_menu() {
|
void KeyPairUIDTab::create_sign_popup_menu() {
|
||||||
sign_popup_menu_ = new QMenu(this);
|
sign_popup_menu_ = new QMenu(this);
|
||||||
|
|
||||||
auto* delSignAct = new QAction(_("Delete(Revoke) Key Signature"), this);
|
auto* del_sign_act = new QAction(_("Delete(Revoke) Key Signature"), this);
|
||||||
connect(delSignAct, &QAction::triggered, this, &KeyPairUIDTab::slot_del_sign);
|
connect(del_sign_act, &QAction::triggered, this,
|
||||||
|
&KeyPairUIDTab::slot_del_sign);
|
||||||
|
|
||||||
sign_popup_menu_->addAction(delSignAct);
|
sign_popup_menu_->addAction(del_sign_act);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairUIDTab::slot_del_sign() {
|
void KeyPairUIDTab::slot_del_sign() {
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "core/function/gpg/GpgContext.h"
|
#include "core/GpgModel.h"
|
||||||
#include "ui/dialog/import_export/KeyImportDetailDialog.h"
|
|
||||||
|
|
||||||
class Ui_KeyList;
|
class Ui_KeyList;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user