diff options
Diffstat (limited to 'src/gpg/function/GpgKeyGetter.cpp')
-rw-r--r-- | src/gpg/function/GpgKeyGetter.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/gpg/function/GpgKeyGetter.cpp index 88f80fbf..6d80088a 100644 --- a/src/gpg/function/GpgKeyGetter.cpp +++ b/src/gpg/function/GpgKeyGetter.cpp @@ -23,49 +23,50 @@ */ #include "gpg/function/GpgKeyGetter.h" +#include <gpg-error.h> +#include "GpgConstants.h" -GpgFrontend::GpgKey GpgFrontend::GpgKeyGetter::GetKey(const std::string &fpr) { - LOG(INFO) << "GpgKeyGetter GetKey Fpr " << fpr; +GpgFrontend::GpgKey GpgFrontend::GpgKeyGetter::GetKey(const std::string& fpr) { + DLOG(INFO) << "GpgKeyGetter GetKey Fpr " << fpr; gpgme_key_t _p_key; gpgme_get_key(ctx, fpr.c_str(), &_p_key, 1); if (_p_key == nullptr) - LOG(WARNING) << "GpgKeyGetter GetKey _p_key Null"; + DLOG(WARNING) << "GpgKeyGetter GetKey _p_key Null"; return GpgKey(std::move(_p_key)); } -GpgFrontend::GpgKey -GpgFrontend::GpgKeyGetter::GetPubkey(const std::string &fpr) { +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 GpgKey(std::move(_p_key)); } GpgFrontend::KeyListPtr GpgFrontend::GpgKeyGetter::FetchKey() { - gpgme_error_t err; - LOG(INFO) << "Clear List and Map"; + DLOG(INFO) << "Clear List and Map"; KeyListPtr keys_list = std::make_unique<std::vector<GpgKey>>(); - LOG(INFO) << "Operate KeyList Start"; + DLOG(INFO) << "Operate KeyList Start"; err = gpgme_op_keylist_start(ctx, nullptr, 0); - assert(gpg_err_code(err) != GPG_ERR_NO_ERROR); + assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR); - LOG(INFO) << "Start Loop"; + DLOG(INFO) << "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))); - LOG(INFO) << "Append Key" << keys_list->back().id().c_str(); + DLOG(INFO) << "Append Key" << keys_list->back().id().c_str(); } - assert(gpg_err_code(err) != GPG_ERR_NO_ERROR); + assert(check_gpg_error_2_err_code(err, GPG_ERR_EOF) == GPG_ERR_EOF); err = gpgme_op_keylist_end(ctx); - LOG(INFO) << "Operate KeyList End"; + DLOG(INFO) << "Operate KeyList End"; return keys_list; } |