cpp: Add keylist mode WithSecret

* lang/cpp/src/global.h (WithSecret): New.
* lang/cpp/src/context.cpp (operator<<): Handle WithSecret.
* lang/cpp/src/util.h (add_to_gpgme_keylist_mode_t,
convert_from_gpgme_keylist_mode_t): Ditto.
--

GnuPG-bug-id: 4794
This commit is contained in:
Ingo Klöcker 2020-09-07 11:55:07 +02:00
parent b714a6bbc8
commit 188cc9e9b5
3 changed files with 13 additions and 3 deletions

View File

@ -1695,6 +1695,7 @@ std::ostream &operator<<(std::ostream &os, KeyListMode mode)
CHECK(Ephemeral);
CHECK(WithTofu);
CHECK(WithKeygrip);
CHECK(WithSecret);
#undef CHECK
return os << ')';
}

View File

@ -66,7 +66,8 @@ enum KeyListMode {
Validate = 0x10,
Ephemeral = 0x20,
WithTofu = 0x40,
WithKeygrip = 0x80
WithKeygrip = 0x80,
WithSecret = 0x100
};
enum SignatureMode { NormalSignatureMode, Detached, Clearsigned };

View File

@ -84,6 +84,9 @@ static inline gpgme_keylist_mode_t add_to_gpgme_keylist_mode_t(unsigned int oldm
if (newmodes & GpgME::WithKeygrip) {
oldmode |= GPGME_KEYLIST_MODE_WITH_KEYGRIP;
}
if (newmodes & GpgME::WithSecret) {
oldmode |= GPGME_KEYLIST_MODE_WITH_SECRET;
}
#ifndef NDEBUG
if (newmodes & ~(GpgME::Local |
GpgME::Extern |
@ -92,10 +95,11 @@ static inline gpgme_keylist_mode_t add_to_gpgme_keylist_mode_t(unsigned int oldm
GpgME::Validate |
GpgME::Ephemeral |
GpgME::WithTofu |
GpgME::WithKeygrip)) {
GpgME::WithKeygrip |
GpgME::WithSecret)) {
//std::cerr << "GpgME::Context: keylist mode must be one of Local, "
//"Extern, Signatures, SignatureNotations, Validate, Ephemeral, WithTofu, "
//"WithKeygrip, or a combination thereof!" << std::endl;
//"WithKeygrip, WithSecret, or a combination thereof!" << std::endl;
}
#endif
return static_cast<gpgme_keylist_mode_t>(oldmode);
@ -116,6 +120,9 @@ static inline unsigned int convert_from_gpgme_keylist_mode_t(unsigned int mode)
if (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS) {
result |= GpgME::SignatureNotations;
}
if (mode & GPGME_KEYLIST_MODE_WITH_SECRET) {
result |= GpgME::WithSecret;
}
if (mode & GPGME_KEYLIST_MODE_WITH_TOFU) {
result |= GpgME::WithTofu;
}
@ -133,6 +140,7 @@ static inline unsigned int convert_from_gpgme_keylist_mode_t(unsigned int mode)
GPGME_KEYLIST_MODE_EXTERN |
GPGME_KEYLIST_MODE_SIGS |
GPGME_KEYLIST_MODE_SIG_NOTATIONS |
GPGME_KEYLIST_MODE_WITH_SECRET |
GPGME_KEYLIST_MODE_WITH_TOFU |
GPGME_KEYLIST_MODE_WITH_KEYGRIP |
GPGME_KEYLIST_MODE_EPHEMERAL |