aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/function/GpgKeyGetter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpg/function/GpgKeyGetter.cpp')
-rw-r--r--src/gpg/function/GpgKeyGetter.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/gpg/function/GpgKeyGetter.cpp
index e4572290..4bea83f3 100644
--- a/src/gpg/function/GpgKeyGetter.cpp
+++ b/src/gpg/function/GpgKeyGetter.cpp
@@ -24,15 +24,46 @@
#include "gpg/function/GpgKeyGetter.h"
+GpgFrontend::GpgKey &&
+GpgFrontend::GpgKeyGetter::GetKey(const std::string &fpr) {
+ gpgme_key_t _p_key;
+ gpgme_get_key(ctx, fpr.c_str(), &_p_key, 1);
+ return std::move(GpgKey(std::move(_p_key)));
+}
-GpgFrontend::GpgKey &&GpgFrontend::GpgKeyGetter::getKey(const std::string &fpr) {
- gpgme_key_t _p_key;
- gpgme_get_key(ctx, fpr.c_str(), &_p_key, 1);
- return std::move(GpgKey(std::move(_p_key)));
+GpgFrontend::GpgKey &&
+GpgFrontend::GpgKeyGetter::GetPubkey(const std::string &fpr) {
+ gpgme_key_t _p_key;
+ gpgme_get_key(ctx, fpr.c_str(), &_p_key, 0);
+ return std::move(GpgKey(std::move(_p_key)));
}
-GpgFrontend::GpgKey &&GpgFrontend::GpgKeyGetter::getPubkey(const std::string &fpr) {
- gpgme_key_t _p_key;
- gpgme_get_key(ctx, fpr.c_str(), &_p_key, 0);
- return std::move(GpgKey(std::move(_p_key)));
+GpgFrontend::KeyListPtr GpgFrontend::GpgKeyGetter::FetchKey() {
+
+ gpgme_error_t err;
+
+ qDebug() << "Clear List and Map";
+
+ KeyListPtr keys_list = std::make_unique<std::vector<GpgKey>>();
+
+ qDebug() << "Operate KeyList Start";
+
+ err = gpgme_op_keylist_start(ctx, nullptr, 0);
+ assert(gpg_err_code(err) != GPG_ERR_NO_ERROR);
+
+ qDebug() << "Start Loop";
+
+ gpgme_key_t key;
+ while ((err = gpgme_op_keylist_next(ctx, &key)) == GPG_ERR_NO_ERROR) {
+ keys_list->push_back(GpgKey(std::move(key)));
+ qDebug() << "Append Key" << keys_list->back().id().c_str();
+ }
+
+ assert(gpg_err_code(err) != GPG_ERR_NO_ERROR);
+
+ err = gpgme_op_keylist_end(ctx);
+
+ qDebug() << "Operate KeyList End";
+
+ return keys_list;
}