aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/function/GpgKeyGetter.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-09-05 15:02:19 +0000
committerSaturneric <[email protected]>2021-09-05 15:02:19 +0000
commit39440522111abf3adeef6b56cb23722119fbf3c2 (patch)
tree5979b3808d58c8c576e288004877d826556b4cda /src/gpg/function/GpgKeyGetter.cpp
parentModified ResultAnalyse. (diff)
downloadGpgFrontend-39440522111abf3adeef6b56cb23722119fbf3c2.tar.gz
GpgFrontend-39440522111abf3adeef6b56cb23722119fbf3c2.zip
Rewrite the core.
Adjust the structure.
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;
}