fix: should select channel before any gpg operation
This commit is contained in:
parent
5bc8c1cd21
commit
aa90cf1eb9
@ -51,10 +51,11 @@ auto KeyPackageOperator::GeneratePassphrase(const QString& phrase_path,
|
|||||||
|
|
||||||
void KeyPackageOperator::GenerateKeyPackage(const QString& key_package_path,
|
void KeyPackageOperator::GenerateKeyPackage(const QString& key_package_path,
|
||||||
const QString& key_package_name,
|
const QString& key_package_name,
|
||||||
|
int channel,
|
||||||
const KeyArgsList& keys,
|
const KeyArgsList& keys,
|
||||||
QString& phrase, bool secret,
|
QString& phrase, bool secret,
|
||||||
const OperationCallback& cb) {
|
const OperationCallback& cb) {
|
||||||
GpgKeyImportExporter::GetInstance().ExportAllKeys(
|
GpgKeyImportExporter::GetInstance(channel).ExportAllKeys(
|
||||||
keys, secret, true, [=](GpgError err, const DataObjectPtr& data_obj) {
|
keys, secret, true, [=](GpgError err, const DataObjectPtr& data_obj) {
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
LOG_W() << "export keys error, reason: "
|
LOG_W() << "export keys error, reason: "
|
||||||
@ -86,6 +87,7 @@ void KeyPackageOperator::GenerateKeyPackage(const QString& key_package_path,
|
|||||||
|
|
||||||
void KeyPackageOperator::ImportKeyPackage(const QString& key_package_path,
|
void KeyPackageOperator::ImportKeyPackage(const QString& key_package_path,
|
||||||
const QString& phrase_path,
|
const QString& phrase_path,
|
||||||
|
int channel,
|
||||||
const OperationCallback& cb) {
|
const OperationCallback& cb) {
|
||||||
RunOperaAsync(
|
RunOperaAsync(
|
||||||
[=](const DataObjectPtr& data_object) -> GFError {
|
[=](const DataObjectPtr& data_object) -> GFError {
|
||||||
@ -120,7 +122,8 @@ void KeyPackageOperator::ImportKeyPackage(const QString& key_package_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto import_info_ptr =
|
auto import_info_ptr =
|
||||||
GpgKeyImportExporter::GetInstance().ImportKey(GFBuffer(key_data));
|
GpgKeyImportExporter::GetInstance(channel).ImportKey(
|
||||||
|
GFBuffer(key_data));
|
||||||
if (import_info_ptr == nullptr) return GPG_ERR_NO_DATA;
|
if (import_info_ptr == nullptr) return GPG_ERR_NO_DATA;
|
||||||
|
|
||||||
auto import_info = *import_info_ptr;
|
auto import_info = *import_info_ptr;
|
||||||
|
@ -69,7 +69,7 @@ class GPGFRONTEND_CORE_EXPORT KeyPackageOperator {
|
|||||||
* @return false if key package was not generated
|
* @return false if key package was not generated
|
||||||
*/
|
*/
|
||||||
static void GenerateKeyPackage(const QString &key_package_path,
|
static void GenerateKeyPackage(const QString &key_package_path,
|
||||||
const QString &key_package_name,
|
const QString &key_package_name, int channel,
|
||||||
const KeyArgsList &keys, QString &phrase,
|
const KeyArgsList &keys, QString &phrase,
|
||||||
bool secret, const OperationCallback &cb);
|
bool secret, const OperationCallback &cb);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class GPGFRONTEND_CORE_EXPORT KeyPackageOperator {
|
|||||||
* @return false if key package was not imported
|
* @return false if key package was not imported
|
||||||
*/
|
*/
|
||||||
static void ImportKeyPackage(const QString &key_package_path,
|
static void ImportKeyPackage(const QString &key_package_path,
|
||||||
const QString &phrase_path,
|
const QString &phrase_path, int channel,
|
||||||
const OperationCallback &cb);
|
const OperationCallback &cb);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -174,8 +174,7 @@ void GpgFileOpera::DecryptArchive(const QString& in_path,
|
|||||||
|
|
||||||
ArchiveFileOperator::ExtractArchiveFromDataExchanger(
|
ArchiveFileOperator::ExtractArchiveFromDataExchanger(
|
||||||
ex, out_path, [](GFError err, const DataObjectPtr&) {
|
ex, out_path, [](GFError err, const DataObjectPtr&) {
|
||||||
FLOG_D("extract archive from data exchanger operation, err: %d",
|
FLOG_D("extract archive from data exchanger operation, err: %d", err);
|
||||||
err);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
RunGpgOperaAsync(
|
RunGpgOperaAsync(
|
||||||
@ -201,7 +200,7 @@ void GpgFileOpera::SignFile(const KeyArgsList& keys, const QString& in_path,
|
|||||||
GpgError err;
|
GpgError err;
|
||||||
|
|
||||||
// Set Singers of this opera
|
// Set Singers of this opera
|
||||||
GpgBasicOperator::GetInstance().SetSigners(keys, ascii);
|
GpgBasicOperator::GetInstance(GetChannel()).SetSigners(keys, ascii);
|
||||||
|
|
||||||
GpgData data_in(in_path, true);
|
GpgData data_in(in_path, true);
|
||||||
GpgData data_out(out_path, false);
|
GpgData data_out(out_path, false);
|
||||||
@ -226,7 +225,7 @@ auto GpgFileOpera::SignFileSync(const KeyArgsList& keys, const QString& in_path,
|
|||||||
GpgError err;
|
GpgError err;
|
||||||
|
|
||||||
// Set Singers of this opera
|
// Set Singers of this opera
|
||||||
GpgBasicOperator::GetInstance().SetSigners(keys, ascii);
|
GpgBasicOperator::GetInstance(GetChannel()).SetSigners(keys, ascii);
|
||||||
|
|
||||||
GpgData data_in(in_path, true);
|
GpgData data_in(in_path, true);
|
||||||
GpgData data_out(out_path, false);
|
GpgData data_out(out_path, false);
|
||||||
@ -310,7 +309,8 @@ void GpgFileOpera::EncryptSignFile(const KeyArgsList& keys,
|
|||||||
// Last entry data_in array has to be nullptr
|
// Last entry data_in array has to be nullptr
|
||||||
recipients.emplace_back(nullptr);
|
recipients.emplace_back(nullptr);
|
||||||
|
|
||||||
GpgBasicOperator::GetInstance().SetSigners(signer_keys, ascii);
|
GpgBasicOperator::GetInstance(GetChannel())
|
||||||
|
.SetSigners(signer_keys, ascii);
|
||||||
|
|
||||||
GpgData data_in(in_path, true);
|
GpgData data_in(in_path, true);
|
||||||
GpgData data_out(out_path, false);
|
GpgData data_out(out_path, false);
|
||||||
@ -341,7 +341,8 @@ auto GpgFileOpera::EncryptSignFileSync(
|
|||||||
// Last entry data_in array has to be nullptr
|
// Last entry data_in array has to be nullptr
|
||||||
recipients.emplace_back(nullptr);
|
recipients.emplace_back(nullptr);
|
||||||
|
|
||||||
GpgBasicOperator::GetInstance().SetSigners(signer_keys, ascii);
|
GpgBasicOperator::GetInstance(GetChannel())
|
||||||
|
.SetSigners(signer_keys, ascii);
|
||||||
|
|
||||||
GpgData data_in(in_path, true);
|
GpgData data_in(in_path, true);
|
||||||
GpgData data_out(out_path, false);
|
GpgData data_out(out_path, false);
|
||||||
@ -376,7 +377,8 @@ void GpgFileOpera::EncryptSignDirectory(const KeyArgsList& keys,
|
|||||||
// Last entry data_in array has to be nullptr
|
// Last entry data_in array has to be nullptr
|
||||||
recipients.emplace_back(nullptr);
|
recipients.emplace_back(nullptr);
|
||||||
|
|
||||||
GpgBasicOperator::GetInstance().SetSigners(signer_keys, ascii);
|
GpgBasicOperator::GetInstance(GetChannel())
|
||||||
|
.SetSigners(signer_keys, ascii);
|
||||||
|
|
||||||
GpgData data_in(ex);
|
GpgData data_in(ex);
|
||||||
GpgData data_out(out_path, false);
|
GpgData data_out(out_path, false);
|
||||||
|
@ -196,7 +196,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) {
|
|||||||
int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; }
|
int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; }
|
||||||
|
|
||||||
void KeyGenPage::slot_generate_key_dialog() {
|
void KeyGenPage::slot_generate_key_dialog() {
|
||||||
(new KeyGenDialog(this))->show();
|
(new KeyGenDialog(kGpgFrontendDefaultChannel, this))->show();
|
||||||
wizard()->next();
|
wizard()->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,9 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
|
|||||||
CommonUtils::WaitForOpera(
|
CommonUtils::WaitForOpera(
|
||||||
this, tr("Generating"), [this, keys](const OperaWaitingHd& op_hd) {
|
this, tr("Generating"), [this, keys](const OperaWaitingHd& op_hd) {
|
||||||
KeyPackageOperator::GenerateKeyPackage(
|
KeyPackageOperator::GenerateKeyPackage(
|
||||||
ui_->outputPathLabel->text(), ui_->nameValueLabel->text(), *keys,
|
ui_->outputPathLabel->text(), ui_->nameValueLabel->text(),
|
||||||
passphrase_, ui_->includeSecretKeyCheckBox->isChecked(),
|
current_gpg_context_channel_, *keys, passphrase_,
|
||||||
|
ui_->includeSecretKeyCheckBox->isChecked(),
|
||||||
[=](GFError err, const DataObjectPtr&) {
|
[=](GFError err, const DataObjectPtr&) {
|
||||||
// stop waiting
|
// stop waiting
|
||||||
op_hd();
|
op_hd();
|
||||||
|
@ -41,8 +41,9 @@
|
|||||||
|
|
||||||
namespace GpgFrontend::UI {
|
namespace GpgFrontend::UI {
|
||||||
|
|
||||||
KeyGenDialog::KeyGenDialog(QWidget* parent)
|
KeyGenDialog::KeyGenDialog(int channel, QWidget* parent)
|
||||||
: GeneralDialog(typeid(KeyGenDialog).name(), parent) {
|
: GeneralDialog(typeid(KeyGenDialog).name(), parent),
|
||||||
|
default_gpg_context_channel_(channel) {
|
||||||
button_box_ =
|
button_box_ =
|
||||||
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
@ -426,6 +427,7 @@ auto KeyGenDialog::create_basic_info_group_box() -> QGroupBox* {
|
|||||||
gpg_contexts_combo_box_->addItem(
|
gpg_contexts_combo_box_->addItem(
|
||||||
QString("%1: %2").arg(channel).arg(database_name));
|
QString("%1: %2").arg(channel).arg(database_name));
|
||||||
}
|
}
|
||||||
|
gpg_contexts_combo_box_->setCurrentIndex(default_gpg_context_channel_);
|
||||||
|
|
||||||
for (const auto& algo : GenKeyInfo::GetSupportedKeyAlgo()) {
|
for (const auto& algo : GenKeyInfo::GetSupportedKeyAlgo()) {
|
||||||
key_type_combo_box_->addItem(std::get<0>(algo));
|
key_type_combo_box_->addItem(std::get<0>(algo));
|
||||||
|
@ -52,7 +52,7 @@ class KeyGenDialog : public GeneralDialog {
|
|||||||
* @param key The key to show details of
|
* @param key The key to show details of
|
||||||
* @param parent The parent of this widget
|
* @param parent The parent of this widget
|
||||||
*/
|
*/
|
||||||
explicit KeyGenDialog(QWidget* parent = nullptr);
|
explicit KeyGenDialog(int channel, QWidget* parent = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
@ -110,6 +110,8 @@ class KeyGenDialog : public GeneralDialog {
|
|||||||
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
|
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
|
||||||
QComboBox* gpg_contexts_combo_box_{};
|
QComboBox* gpg_contexts_combo_box_{};
|
||||||
|
|
||||||
|
int default_gpg_context_channel_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
|
@ -95,8 +95,8 @@ void KeyNewUIDDialog::slot_create_new_uid() {
|
|||||||
}
|
}
|
||||||
auto error_string = error_stream.readAll();
|
auto error_string = error_stream.readAll();
|
||||||
if (error_string.isEmpty()) {
|
if (error_string.isEmpty()) {
|
||||||
if (GpgUIDOperator::GetInstance().AddUID(
|
if (GpgUIDOperator::GetInstance(current_gpg_context_channel_)
|
||||||
m_key_, name_->text(), comment_->text(), email_->text())) {
|
.AddUID(m_key_, name_->text(), comment_->text(), email_->text())) {
|
||||||
emit finished(1);
|
emit finished(1);
|
||||||
emit SignalUIDCreated();
|
emit SignalUIDCreated();
|
||||||
} else {
|
} else {
|
||||||
|
@ -218,7 +218,8 @@ void KeyPairOperaTab::CreateOperaMenu() {
|
|||||||
|
|
||||||
void KeyPairOperaTab::slot_export_public_key() {
|
void KeyPairOperaTab::slot_export_public_key() {
|
||||||
auto [err, gf_buffer] =
|
auto [err, gf_buffer] =
|
||||||
GpgKeyImportExporter::GetInstance().ExportKey(m_key_, false, true, false);
|
GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
|
||||||
|
.ExportKey(m_key_, false, true, false);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
@ -265,7 +266,8 @@ void KeyPairOperaTab::slot_export_short_private_key() {
|
|||||||
// export key, if ok was clicked
|
// export key, if ok was clicked
|
||||||
if (ret == QMessageBox::Ok) {
|
if (ret == QMessageBox::Ok) {
|
||||||
auto [err, gf_buffer] =
|
auto [err, gf_buffer] =
|
||||||
GpgKeyImportExporter::GetInstance().ExportKey(m_key_, true, true, true);
|
GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
|
||||||
|
.ExportKey(m_key_, true, true, true);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
@ -308,8 +310,9 @@ void KeyPairOperaTab::slot_export_private_key() {
|
|||||||
|
|
||||||
// export key, if ok was clicked
|
// export key, if ok was clicked
|
||||||
if (ret == QMessageBox::Ok) {
|
if (ret == QMessageBox::Ok) {
|
||||||
auto [err, gf_buffer] = GpgKeyImportExporter::GetInstance().ExportKey(
|
auto [err, gf_buffer] =
|
||||||
m_key_, true, true, false);
|
GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
|
||||||
|
.ExportKey(m_key_, true, true, false);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
@ -386,8 +389,8 @@ void KeyPairOperaTab::slot_gen_revoke_cert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_output_file_name.isEmpty()) {
|
if (!m_output_file_name.isEmpty()) {
|
||||||
GpgKeyOpera::GetInstance().GenerateRevokeCert(
|
GpgKeyOpera::GetInstance(current_gpg_context_channel_)
|
||||||
m_key_, m_output_file_name, code, text);
|
.GenerateRevokeCert(m_key_, m_output_file_name, code, text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -395,8 +398,8 @@ void KeyPairOperaTab::slot_gen_revoke_cert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeyPairOperaTab::slot_modify_password() {
|
void KeyPairOperaTab::slot_modify_password() {
|
||||||
GpgKeyOpera::GetInstance().ModifyPassword(
|
GpgKeyOpera::GetInstance(current_gpg_context_channel_)
|
||||||
m_key_, [this](GpgError err, const DataObjectPtr&) {
|
.ModifyPassword(m_key_, [this](GpgError err, const DataObjectPtr&) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -423,7 +426,8 @@ void KeyPairOperaTab::slot_modify_tofu_policy() {
|
|||||||
} else if (item == tr("Policy Unknown")) {
|
} else if (item == tr("Policy Unknown")) {
|
||||||
tofu_policy = GPGME_TOFU_POLICY_UNKNOWN;
|
tofu_policy = GPGME_TOFU_POLICY_UNKNOWN;
|
||||||
}
|
}
|
||||||
auto err = GpgKeyOpera::GetInstance().ModifyTOFUPolicy(m_key_, tofu_policy);
|
auto err = GpgKeyOpera::GetInstance(current_gpg_context_channel_)
|
||||||
|
.ModifyTOFUPolicy(m_key_, tofu_policy);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
QMessageBox::critical(this, tr("Not Successful"),
|
QMessageBox::critical(this, tr("Not Successful"),
|
||||||
tr("Modify TOFU policy not successfully."));
|
tr("Modify TOFU policy not successfully."));
|
||||||
@ -508,8 +512,9 @@ void KeyPairOperaTab::slot_export_paper_key() {
|
|||||||
|
|
||||||
// export key, if ok was clicked
|
// export key, if ok was clicked
|
||||||
if (ret == QMessageBox::Ok) {
|
if (ret == QMessageBox::Ok) {
|
||||||
auto [err, gf_buffer] = GpgKeyImportExporter::GetInstance().ExportKey(
|
auto [err, gf_buffer] =
|
||||||
m_key_, true, false, true);
|
GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
|
||||||
|
.ExportKey(m_key_, true, false, true);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
@ -562,7 +567,8 @@ void KeyPairOperaTab::slot_import_paper_key() {
|
|||||||
if (!Module::IsModuleActivate(kPaperKeyModuleID)) return;
|
if (!Module::IsModuleActivate(kPaperKeyModuleID)) return;
|
||||||
|
|
||||||
auto [err, gf_buffer] =
|
auto [err, gf_buffer] =
|
||||||
GpgKeyImportExporter::GetInstance().ExportKey(m_key_, false, false, true);
|
GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
|
||||||
|
.ExportKey(m_key_, false, false, true);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
|
@ -389,7 +389,8 @@ void KeyPairUIDTab::slot_del_uid() {
|
|||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
for (const auto& uid : *selected_uids) {
|
for (const auto& uid : *selected_uids) {
|
||||||
if (!GpgUIDOperator::GetInstance().RevUID(m_key_, uid)) {
|
if (!GpgUIDOperator::GetInstance(current_gpg_context_channel_)
|
||||||
|
.RevUID(m_key_, uid)) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
nullptr, tr("Operation Failed"),
|
nullptr, tr("Operation Failed"),
|
||||||
tr("An error occurred during the delete %1 operation.").arg(uid));
|
tr("An error occurred during the delete %1 operation.").arg(uid));
|
||||||
@ -423,8 +424,8 @@ void KeyPairUIDTab::slot_set_primary_uid() {
|
|||||||
QMessageBox::No | QMessageBox::Yes);
|
QMessageBox::No | QMessageBox::Yes);
|
||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
if (!GpgUIDOperator::GetInstance().SetPrimaryUID(m_key_,
|
if (!GpgUIDOperator::GetInstance(current_gpg_context_channel_)
|
||||||
selected_uids->front())) {
|
.SetPrimaryUID(m_key_, selected_uids->front())) {
|
||||||
QMessageBox::critical(nullptr, tr("Operation Failed"),
|
QMessageBox::critical(nullptr, tr("Operation Failed"),
|
||||||
tr("An error occurred during the operation."));
|
tr("An error occurred during the operation."));
|
||||||
} else {
|
} else {
|
||||||
@ -520,7 +521,8 @@ void KeyPairUIDTab::slot_del_uid_single() {
|
|||||||
QMessageBox::No | QMessageBox::Yes);
|
QMessageBox::No | QMessageBox::Yes);
|
||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
if (!GpgUIDOperator::GetInstance().RevUID(m_key_, selected_uids->front())) {
|
if (!GpgUIDOperator::GetInstance(current_gpg_context_channel_)
|
||||||
|
.RevUID(m_key_, selected_uids->front())) {
|
||||||
QMessageBox::critical(nullptr, tr("Operation Failed"),
|
QMessageBox::critical(nullptr, tr("Operation Failed"),
|
||||||
tr("An error occurred during the operation."));
|
tr("An error occurred during the operation."));
|
||||||
} else {
|
} else {
|
||||||
@ -572,7 +574,8 @@ void KeyPairUIDTab::slot_del_sign() {
|
|||||||
QMessageBox::No | QMessageBox::Yes);
|
QMessageBox::No | QMessageBox::Yes);
|
||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
if (!GpgKeyManager::GetInstance().RevSign(m_key_, selected_signs)) {
|
if (!GpgKeyManager::GetInstance(current_gpg_context_channel_)
|
||||||
|
.RevSign(m_key_, selected_signs)) {
|
||||||
QMessageBox::critical(nullptr, tr("Operation Failed"),
|
QMessageBox::critical(nullptr, tr("Operation Failed"),
|
||||||
tr("An error occurred during the operation."));
|
tr("An error occurred during the operation."));
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,8 @@ void KeySetExpireDateDialog::slot_confirm() {
|
|||||||
expires = std::make_unique<QDateTime>(datetime.toLocalTime());
|
expires = std::make_unique<QDateTime>(datetime.toLocalTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto err = GpgKeyOpera::GetInstance().SetExpire(m_key_, m_subkey_, expires);
|
auto err = GpgKeyOpera::GetInstance(current_gpg_context_channel_)
|
||||||
|
.SetExpire(m_key_, m_subkey_, expires);
|
||||||
|
|
||||||
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
|
||||||
auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
|
auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
|
||||||
|
@ -116,7 +116,8 @@ void KeyUIDSignDialog::slot_sign_key(bool clicked) {
|
|||||||
|
|
||||||
for (const auto& uid : *m_uids_) {
|
for (const auto& uid : *m_uids_) {
|
||||||
// Sign For mKey
|
// Sign For mKey
|
||||||
if (!GpgKeyManager::GetInstance().SignKey(m_key_, *keys, uid, expires)) {
|
if (!GpgKeyManager::GetInstance(current_gpg_context_channel_)
|
||||||
|
.SignKey(m_key_, *keys, uid, expires)) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
nullptr, tr("Unsuccessful Operation"),
|
nullptr, tr("Unsuccessful Operation"),
|
||||||
tr("Signature operation failed for UID %1").arg(uid));
|
tr("Signature operation failed for UID %1").arg(uid));
|
||||||
|
@ -77,8 +77,8 @@ auto SetOwnerTrustLevel::Exec(int channel, const QString& key_id) -> bool {
|
|||||||
trust_level = 1;
|
trust_level = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool status =
|
bool status = GpgKeyManager::GetInstance(channel).SetOwnerTrustLevel(
|
||||||
GpgKeyManager::GetInstance().SetOwnerTrustLevel(key, trust_level);
|
key, trust_level);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
QMessageBox::critical(this, tr("Failed"),
|
QMessageBox::critical(this, tr("Failed"),
|
||||||
tr("Modify Owner Trust Level failed."));
|
tr("Modify Owner Trust Level failed."));
|
||||||
|
@ -353,7 +353,8 @@ void KeyMgmt::delete_keys_with_warning(KeyIdArgsListPtr uidList) {
|
|||||||
QMessageBox::No | QMessageBox::Yes);
|
QMessageBox::No | QMessageBox::Yes);
|
||||||
|
|
||||||
if (ret == QMessageBox::Yes) {
|
if (ret == QMessageBox::Yes) {
|
||||||
GpgKeyOpera::GetInstance().DeleteKeys(std::move(uidList));
|
GpgKeyOpera::GetInstance(key_list_->GetCurrentGpgContextChannel())
|
||||||
|
.DeleteKeys(std::move(uidList));
|
||||||
emit SignalKeyStatusUpdated();
|
emit SignalKeyStatusUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,8 +403,9 @@ void KeyMgmt::SlotExportKeyToClipboard() {
|
|||||||
.GetKey(keys_checked->front());
|
.GetKey(keys_checked->front());
|
||||||
assert(key.IsGood());
|
assert(key.IsGood());
|
||||||
|
|
||||||
auto [err, gf_buffer] =
|
auto [err, gf_buffer] = GpgKeyImportExporter::GetInstance(
|
||||||
GpgKeyImportExporter::GetInstance().ExportKey(key, false, true, false);
|
key_list_->GetCurrentGpgContextChannel())
|
||||||
|
.ExportKey(key, false, true, false);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
@ -419,40 +421,42 @@ void KeyMgmt::SlotExportKeyToClipboard() {
|
|||||||
|
|
||||||
CommonUtils::WaitForOpera(
|
CommonUtils::WaitForOpera(
|
||||||
this, tr("Exporting"), [=](const OperaWaitingHd& op_hd) {
|
this, tr("Exporting"), [=](const OperaWaitingHd& op_hd) {
|
||||||
GpgKeyImportExporter::GetInstance().ExportKeys(
|
GpgKeyImportExporter::GetInstance(
|
||||||
*keys, false, true, false, false,
|
key_list_->GetCurrentGpgContextChannel())
|
||||||
[=](GpgError err, const DataObjectPtr& data_obj) {
|
.ExportKeys(
|
||||||
// stop waiting
|
*keys, false, true, false, false,
|
||||||
op_hd();
|
[=](GpgError err, const DataObjectPtr& data_obj) {
|
||||||
|
// stop waiting
|
||||||
|
op_hd();
|
||||||
|
|
||||||
if (CheckGpgError(err) == GPG_ERR_USER_1) {
|
if (CheckGpgError(err) == GPG_ERR_USER_1) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
tr("Unknown error occurred"));
|
tr("Unknown error occurred"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
|
if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
|
||||||
FLOG_W("data object checking failed");
|
FLOG_W("data object checking failed");
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
tr("Unknown error occurred"));
|
tr("Unknown error occurred"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
|
auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
|
||||||
QApplication::clipboard()->setText(
|
QApplication::clipboard()->setText(
|
||||||
gf_buffer.ConvertToQByteArray());
|
gf_buffer.ConvertToQByteArray());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyMgmt::SlotGenerateKeyDialog() {
|
void KeyMgmt::SlotGenerateKeyDialog() {
|
||||||
(new KeyGenDialog(this))->exec();
|
(new KeyGenDialog(key_list_->GetCurrentGpgContextChannel(), this))->exec();
|
||||||
this->raise();
|
this->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,53 +512,56 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() {
|
|||||||
|
|
||||||
CommonUtils::WaitForOpera(
|
CommonUtils::WaitForOpera(
|
||||||
this, tr("Exporting"), [this, keys](const OperaWaitingHd& op_hd) {
|
this, tr("Exporting"), [this, keys](const OperaWaitingHd& op_hd) {
|
||||||
GpgKeyImportExporter::GetInstance().ExportKeys(
|
GpgKeyImportExporter::GetInstance(
|
||||||
*keys, false, true, false, true,
|
key_list_->GetCurrentGpgContextChannel())
|
||||||
[=](GpgError err, const DataObjectPtr& data_obj) {
|
.ExportKeys(
|
||||||
// stop waiting
|
*keys, false, true, false, true,
|
||||||
op_hd();
|
[=](GpgError err, const DataObjectPtr& data_obj) {
|
||||||
|
// stop waiting
|
||||||
|
op_hd();
|
||||||
|
|
||||||
if (CheckGpgError(err) == GPG_ERR_USER_1) {
|
if (CheckGpgError(err) == GPG_ERR_USER_1) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
tr("Unknown error occurred"));
|
tr("Unknown error occurred"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
|
if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
tr("Unknown error occurred"));
|
tr("Unknown error occurred"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
|
auto gf_buffer = ExtractParams<GFBuffer>(data_obj, 0);
|
||||||
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
|
||||||
CommonUtils::RaiseMessageBox(this, err);
|
CommonUtils::RaiseMessageBox(this, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gf_buffer.Empty()) {
|
if (gf_buffer.Empty()) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
this, tr("Error"),
|
this, tr("Error"),
|
||||||
tr("This key may not be able to export as OpenSSH format. "
|
tr("This key may not be able to export as OpenSSH "
|
||||||
"Please check the key-size of the subkey(s) used to "
|
"format. "
|
||||||
"sign."));
|
"Please check the key-size of the subkey(s) used to "
|
||||||
return;
|
"sign."));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString const file_name = QFileDialog::getSaveFileName(
|
QString const file_name = QFileDialog::getSaveFileName(
|
||||||
this, tr("Export OpenSSH Key To File"), "authorized_keys",
|
this, tr("Export OpenSSH Key To File"), "authorized_keys",
|
||||||
tr("OpenSSH Public Key Files") + "All Files (*)");
|
tr("OpenSSH Public Key Files") + "All Files (*)");
|
||||||
|
|
||||||
if (!file_name.isEmpty()) {
|
if (!file_name.isEmpty()) {
|
||||||
WriteFileGFBuffer(file_name, gf_buffer);
|
WriteFileGFBuffer(file_name, gf_buffer);
|
||||||
emit SignalStatusBarChanged(tr("key(s) exported"));
|
emit SignalStatusBarChanged(tr("key(s) exported"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,6 +617,7 @@ void KeyMgmt::SlotImportKeyPackage() {
|
|||||||
this, tr("Importing"), [=](const OperaWaitingHd& op_hd) {
|
this, tr("Importing"), [=](const OperaWaitingHd& op_hd) {
|
||||||
KeyPackageOperator::ImportKeyPackage(
|
KeyPackageOperator::ImportKeyPackage(
|
||||||
key_package_file_name, key_file_name,
|
key_package_file_name, key_file_name,
|
||||||
|
key_list_->GetCurrentGpgContextChannel(),
|
||||||
[=](GFError err, const DataObjectPtr& data_obj) {
|
[=](GFError err, const DataObjectPtr& data_obj) {
|
||||||
// stop waiting
|
// stop waiting
|
||||||
op_hd();
|
op_hd();
|
||||||
|
@ -523,8 +523,8 @@ void KeyList::dragEnterEvent(QDragEnterEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KeyList::import_keys(const QByteArray& in_buffer) {
|
void KeyList::import_keys(const QByteArray& in_buffer) {
|
||||||
auto result =
|
auto result = GpgKeyImportExporter::GetInstance(current_gpg_context_channel_)
|
||||||
GpgKeyImportExporter::GetInstance().ImportKey(GFBuffer(in_buffer));
|
.ImportKey(GFBuffer(in_buffer));
|
||||||
(new KeyImportDetailDialog(current_gpg_context_channel_, result, this));
|
(new KeyImportDetailDialog(current_gpg_context_channel_, result, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user