aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp/src/context.cpp
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2016-07-04 09:25:40 +0000
committerAndre Heinecke <[email protected]>2016-07-04 09:44:38 +0000
commitd75c118aae18e20f08dbbb69c7998e1f3694ccd0 (patch)
tree9e6ab4bad147506d1594c459e28186ac5f378b41 /lang/cpp/src/context.cpp
parentQt: Add test for TofuInfo (diff)
downloadgpgme-d75c118aae18e20f08dbbb69c7998e1f3694ccd0.tar.gz
gpgme-d75c118aae18e20f08dbbb69c7998e1f3694ccd0.zip
Cpp: Add support for pinentry_mode
* lang/cpp/src/context.cpp (Context::pinentryMode): Return mode. (Context::setPinentryMode): Set mode. * lang/cpp/src/context.h (PinentryMode): Add enum.
Diffstat (limited to 'lang/cpp/src/context.cpp')
-rw-r--r--lang/cpp/src/context.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 085b835f..9e31b6a9 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -1255,6 +1255,46 @@ Error Context::lastError() const
return Error(d->lasterr);
}
+Context::PinentryMode Context::pinentryMode() const
+{
+ switch (gpgme_get_pinentry_mode (d->ctx)) {
+ case GPGME_PINENTRY_MODE_ASK:
+ return PinentryAsk;
+ case GPGME_PINENTRY_MODE_CANCEL:
+ return PinentryCancel;
+ case GPGME_PINENTRY_MODE_ERROR:
+ return PinentryError;
+ case GPGME_PINENTRY_MODE_LOOPBACK:
+ return PinentryLoopback;
+ case GPGME_PINENTRY_MODE_DEFAULT:
+ default:
+ return PinentryDefault;
+ }
+}
+
+Error Context::setPinentryMode(PinentryMode which)
+{
+ gpgme_pinentry_mode_t mode;
+ switch (which) {
+ case PinentryAsk:
+ mode = GPGME_PINENTRY_MODE_ASK;
+ break;
+ case PinentryCancel:
+ mode = GPGME_PINENTRY_MODE_CANCEL;
+ break;
+ case PinentryError:
+ mode = GPGME_PINENTRY_MODE_ERROR;
+ break;
+ case PinentryLoopback:
+ mode = GPGME_PINENTRY_MODE_LOOPBACK;
+ break;
+ case PinentryDefault:
+ default:
+ mode = GPGME_PINENTRY_MODE_DEFAULT;
+ }
+ return Error(d->lasterr = gpgme_set_pinentry_mode(d->ctx, mode));
+}
+
std::ostream &operator<<(std::ostream &os, Protocol proto)
{
os << "GpgME::Protocol(";