aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-05-26 14:53:51 +0000
committerSaturneric <[email protected]>2021-05-26 14:53:51 +0000
commit0739199b9e5a5bb0dc95efd309cc209a16ccea18 (patch)
tree1b9d87c3b4b57d3afef6353d2e2b79ccbf4fa3af
parentRemove the self-compiled GpgME package (diff)
downloadGpgFrontend-0739199b9e5a5bb0dc95efd309cc209a16ccea18.tar.gz
GpgFrontend-0739199b9e5a5bb0dc95efd309cc209a16ccea18.zip
Fix the error and adjust the way the pop-up window pops up after the key is generated.
Diffstat (limited to '')
-rw-r--r--include/ui/KeygenDialog.h2
-rw-r--r--src/gpg/GpgContext.cpp12
-rw-r--r--src/ui/KeygenDialog.cpp8
-rw-r--r--src/ui/KeygenThread.cpp6
4 files changed, 24 insertions, 4 deletions
diff --git a/include/ui/KeygenDialog.h b/include/ui/KeygenDialog.h
index 08193fd5..bcc2deb9 100644
--- a/include/ui/KeygenDialog.h
+++ b/include/ui/KeygenDialog.h
@@ -108,6 +108,8 @@ private slots:
void slotActivatedKeyType(int index);
+ void slotKeyGenResult(bool success);
+
};
#endif // __KEYGENDIALOG_H__
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index e665fdea..c73d3d65 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -263,12 +263,16 @@ namespace GpgME {
gpgme_key_t key;
+ qDebug() << "Clear List and Map";
+
mKeyList.clear();
mKeyMap.clear();
auto &keys = mKeyList;
auto &keys_map = mKeyMap;
+ qDebug() << "Set Keylist Mode";
+
gpgmeError = gpgme_set_keylist_mode(mCtx,
GPGME_KEYLIST_MODE_LOCAL
| GPGME_KEYLIST_MODE_WITH_SECRET
@@ -280,16 +284,22 @@ namespace GpgME {
return;
}
+ qDebug() << "Operate KeyList Start";
+
gpgmeError = gpgme_op_keylist_start(mCtx, nullptr, 0);
if (gpg_err_code(gpgmeError) != GPG_ERR_NO_ERROR) {
checkErr(gpgmeError);
return;
}
+ qDebug() << "Start Loop";
+
while ((gpgmeError = gpgme_op_keylist_next(mCtx, &key)) == GPG_ERR_NO_ERROR) {
if (!key->subkeys)
continue;
+ qDebug() << "Append Key" << key->subkeys->keyid;
+
keys.append(GpgKey(key));
keys_map.insert(keys.back().id, &keys.back());
gpgme_key_unref(key);
@@ -301,6 +311,8 @@ namespace GpgME {
return;
}
+ qDebug() << "Operate KeyList End";
+
gpgmeError = gpgme_op_keylist_end(mCtx);
if (gpg_err_code(gpgmeError) != GPG_ERR_NO_ERROR) {
checkErr(gpgmeError);
diff --git a/src/ui/KeygenDialog.cpp b/src/ui/KeygenDialog.cpp
index 2b9fb88e..435194e1 100644
--- a/src/ui/KeygenDialog.cpp
+++ b/src/ui/KeygenDialog.cpp
@@ -143,6 +143,8 @@ void KeyGenDialog::slotKeyGenAccept() {
kg = new KeyGenThread(&genKeyInfo, mCtx);
+ connect(kg, SIGNAL(signalKeyGenerated(bool)), this, SLOT(slotKeyGenResult(bool)));
+
kg->start();
this->accept();
@@ -358,3 +360,9 @@ bool KeyGenDialog::check_email_address(const QString &str) {
return re_email.match(str).hasMatch();
}
+void KeyGenDialog::slotKeyGenResult(bool success) {
+ if(success)
+ QMessageBox::information(nullptr, tr("Success"), tr("The new key pair has been generated."));
+ else
+ QMessageBox::critical(nullptr, tr("Failure"), tr("An error occurred during key generation."));
+}
diff --git a/src/ui/KeygenThread.cpp b/src/ui/KeygenThread.cpp
index 20e37bb4..dcd8dd77 100644
--- a/src/ui/KeygenThread.cpp
+++ b/src/ui/KeygenThread.cpp
@@ -32,9 +32,7 @@ KeyGenThread::KeyGenThread(GenKeyInfo* keyGenParams, GpgME::GpgContext *ctx) {
void KeyGenThread::run() {
bool success = mCtx->generateKey(keyGenParams);
- if(success)
- QMessageBox::information(nullptr, tr("Success"), tr("New key created"));
- else
- QMessageBox::critical(nullptr, tr("Failure"), tr("Key generation failed"));
+
+ emit signalKeyGenerated(success);
}