[PATCH 1/5] cpp: expose minimal key export flag from C

thb at libreoffice.org thb at libreoffice.org
Tue Jan 30 15:18:06 CET 2018


From: Thorsten Behrens <Thorsten.Behrens at CIB.de>

* lang/cpp/src/context.h: add bool parameter
* lang/cpp/src/context.cpp: run gpgme_op_export with
  GPGME_EXPORT_MODE_MINIMAL if flag is set

Signed-off-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
---
 lang/cpp/src/context.cpp | 16 ++++++++--------
 lang/cpp/src/context.h   |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 135e4d56..dbc98156 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -557,14 +557,14 @@ KeyGenerationResult Context::keyGenerationResult() const
     }
 }
 
-Error Context::exportPublicKeys(const char *pattern, Data &keyData)
+Error Context::exportPublicKeys(const char *pattern, Data &keyData, bool minimal)
 {
     d->lastop = Private::Export;
     Data::Private *const dp = keyData.impl();
-    return Error(d->lasterr = gpgme_op_export(d->ctx, pattern, 0, dp ? dp->data : 0));
+    return Error(d->lasterr = gpgme_op_export(d->ctx, pattern, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
 }
 
-Error Context::exportPublicKeys(const char *patterns[], Data &keyData)
+Error Context::exportPublicKeys(const char *patterns[], Data &keyData, bool minimal)
 {
     d->lastop = Private::Export;
 #ifndef HAVE_GPGME_EXT_KEYLIST_MODE_EXTERNAL_NONBROKEN
@@ -574,17 +574,17 @@ Error Context::exportPublicKeys(const char *patterns[], Data &keyData)
     }
 #endif
     Data::Private *const dp = keyData.impl();
-    return Error(d->lasterr = gpgme_op_export_ext(d->ctx, patterns, 0, dp ? dp->data : 0));
+    return Error(d->lasterr = gpgme_op_export_ext(d->ctx, patterns, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
 }
 
-Error Context::startPublicKeyExport(const char *pattern, Data &keyData)
+Error Context::startPublicKeyExport(const char *pattern, Data &keyData, bool minimal)
 {
     d->lastop = Private::Export;
     Data::Private *const dp = keyData.impl();
-    return Error(d->lasterr = gpgme_op_export_start(d->ctx, pattern, 0, dp ? dp->data : 0));
+    return Error(d->lasterr = gpgme_op_export_start(d->ctx, pattern, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
 }
 
-Error Context::startPublicKeyExport(const char *patterns[], Data &keyData)
+Error Context::startPublicKeyExport(const char *patterns[], Data &keyData, bool minimal)
 {
     d->lastop = Private::Export;
 #ifndef HAVE_GPGME_EXT_KEYLIST_MODE_EXTERNAL_NONBROKEN
@@ -594,7 +594,7 @@ Error Context::startPublicKeyExport(const char *patterns[], Data &keyData)
     }
 #endif
     Data::Private *const dp = keyData.impl();
-    return Error(d->lasterr = gpgme_op_export_ext_start(d->ctx, patterns, 0, dp ? dp->data : 0));
+    return Error(d->lasterr = gpgme_op_export_ext_start(d->ctx, patterns, minimal ? GPGME_EXPORT_MODE_MINIMAL : 0, dp ? dp->data : 0));
 }
 
 ImportResult Context::importKeys(const Data &data)
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index 4cd5b307..d97d7dd8 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -178,10 +178,10 @@ public:
     // Key Export
     //
 
-    GpgME::Error exportPublicKeys(const char *pattern, Data &keyData);
-    GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData);
-    GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData);
-    GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData);
+    GpgME::Error exportPublicKeys(const char *pattern, Data &keyData, bool minimal=false);
+    GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData, bool minimal=false);
+    GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData, bool minimal=false);
+    GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData, bool minimal=false);
 
     //
     // Key Import
-- 
2.13.6




More information about the Gnupg-devel mailing list