diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpg/GpgContext.cpp | 12 | ||||
-rw-r--r-- | src/ui/KeygenDialog.cpp | 8 | ||||
-rw-r--r-- | src/ui/KeygenThread.cpp | 6 |
3 files changed, 22 insertions, 4 deletions
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); } |