aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp/src
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2022-04-27 15:21:04 +0000
committerIngo Klöcker <[email protected]>2022-04-27 15:21:04 +0000
commitdea872f21ff77cd58bafe0966d89d6331c8d2e07 (patch)
tree9df3abcc503e3027c998cd0ee105a2496396c91c /lang/cpp/src
parentcore: Support --locate-external-keys command of gpg (diff)
downloadgpgme-dea872f21ff77cd58bafe0966d89d6331c8d2e07.tar.gz
gpgme-dea872f21ff77cd58bafe0966d89d6331c8d2e07.zip
cpp: Support new keylist modes
* lang/cpp/src/global.h (ForceExtern, LocateExternal, KeyListModeMask): New. * lang/cpp/src/context.cpp (operator<<): Add check. * lang/cpp/src/util.h (gpgme_keylist_mode_t, convert_from_gpgme_keylist_mode_t): Handle ForceExtern. * lang/cpp/tests/run-getkey.cpp (show_usage, main): Add arguments --force-extern and --locate-external. * lang/cpp/tests/run-keylist.cpp (show_usage, main): Ditto. -- GnuPG-bug-id: 5951
Diffstat (limited to 'lang/cpp/src')
-rw-r--r--lang/cpp/src/context.cpp1
-rw-r--r--lang/cpp/src/global.h8
-rw-r--r--lang/cpp/src/util.h22
3 files changed, 18 insertions, 13 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 6d840f06..89bc3fd7 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -1849,6 +1849,7 @@ std::ostream &operator<<(std::ostream &os, KeyListMode mode)
CHECK(WithTofu);
CHECK(WithKeygrip);
CHECK(WithSecret);
+ CHECK(ForceExtern);
#undef CHECK
return os << ')';
}
diff --git a/lang/cpp/src/global.h b/lang/cpp/src/global.h
index 9aafea87..1336142a 100644
--- a/lang/cpp/src/global.h
+++ b/lang/cpp/src/global.h
@@ -60,14 +60,18 @@ enum Engine { GpgEngine, GpgSMEngine, GpgConfEngine, UnknownEngine, AssuanEngine
enum KeyListMode {
Local = 0x1,
Extern = 0x2,
- Locate = 0x3,
+ Locate = Local|Extern,
Signatures = 0x4,
SignatureNotations = 0x8,
Validate = 0x10,
Ephemeral = 0x20,
WithTofu = 0x40,
WithKeygrip = 0x80,
- WithSecret = 0x100
+ WithSecret = 0x100,
+ ForceExtern = 0x200,
+ LocateExternal = Locate|ForceExtern,
+
+ KeyListModeMask = 0x3ff
};
enum SignatureMode { NormalSignatureMode, Detached, Clearsigned };
diff --git a/lang/cpp/src/util.h b/lang/cpp/src/util.h
index 423973a8..cb6df0d0 100644
--- a/lang/cpp/src/util.h
+++ b/lang/cpp/src/util.h
@@ -89,19 +89,15 @@ static inline gpgme_keylist_mode_t add_to_gpgme_keylist_mode_t(unsigned int oldm
if (newmodes & GpgME::WithSecret) {
oldmode |= GPGME_KEYLIST_MODE_WITH_SECRET;
}
+ if (newmodes & GpgME::ForceExtern) {
+ oldmode |= GPGME_KEYLIST_MODE_FORCE_EXTERN;
+ }
#ifndef NDEBUG
- if (newmodes & ~(GpgME::Local |
- GpgME::Extern |
- GpgME::Signatures |
- GpgME::SignatureNotations |
- GpgME::Validate |
- GpgME::Ephemeral |
- GpgME::WithTofu |
- GpgME::WithKeygrip |
- GpgME::WithSecret)) {
+ if (newmodes & ~(GpgME::KeyListModeMask)) {
//std::cerr << "GpgME::Context: keylist mode must be one of Local, "
//"Extern, Signatures, SignatureNotations, Validate, Ephemeral, WithTofu, "
- //"WithKeygrip, WithSecret, or a combination thereof!" << std::endl;
+ //"WithKeygrip, WithSecret, ForceExtern, or a combination thereof!"
+ //<< std::endl;
}
#endif
return static_cast<gpgme_keylist_mode_t>(oldmode);
@@ -137,6 +133,9 @@ static inline unsigned int convert_from_gpgme_keylist_mode_t(unsigned int mode)
if (mode & GPGME_KEYLIST_MODE_VALIDATE) {
result |= GpgME::Validate;
}
+ if (mode & GPGME_KEYLIST_MODE_FORCE_EXTERN) {
+ result |= GpgME::ForceExtern;
+ }
#ifndef NDEBUG
if (mode & ~(GPGME_KEYLIST_MODE_LOCAL |
GPGME_KEYLIST_MODE_EXTERN |
@@ -146,7 +145,8 @@ static inline unsigned int convert_from_gpgme_keylist_mode_t(unsigned int mode)
GPGME_KEYLIST_MODE_WITH_TOFU |
GPGME_KEYLIST_MODE_WITH_KEYGRIP |
GPGME_KEYLIST_MODE_EPHEMERAL |
- GPGME_KEYLIST_MODE_VALIDATE)) {
+ GPGME_KEYLIST_MODE_VALIDATE |
+ GPGME_KEYLIST_MODE_FORCE_EXTERN)) {
//std::cerr << "GpgME: WARNING: gpgme_get_keylist_mode() returned an unknown flag!" << std::endl;
}
#endif // NDEBUG