From 61a0d92b679f248505f1bf16386bc41a5bf2ba1d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 7 Feb 2013 20:59:16 +0100 Subject: Add public function gpgme_set_pinentry_mode. * src/gpgme.c (gpgme_set_pinentry_mode): New. * src/gpgme.h.in (gpgme_pinentry_t): New. (gpgme_set_pinentry_mode): New. * src/context.h (struct gpgme_context): Add field pinentry_mode. * src/engine-backend.h (struct engine_ops): Add field set_pinentry_mode. * src/engine-gpg.c (struct engine_gpg): Add field pinentry_mode. (build_argv): Implement pinentry_mode. (gpg_set_pinentry_mode): New. (_gpgme_engine_ops_gpg): Register gpg_set_pinentry_mode. -- Note that this new fucntion may only be used with gpg 2.1. --- src/gpgme.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/gpgme.c') diff --git a/src/gpgme.c b/src/gpgme.c index 79895db2..76c13b16 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -53,8 +53,8 @@ DEFINE_STATIC_LOCK (result_ref_lock); /* Set the global flag NAME to VALUE. Return 0 on success. Note that - this function does use gpgme_error and thus a non-zero return value - merely means "error". Certain flags may be set before + this function does not use gpgme_error and thus a non-zero return + value merely means "error". Certain flags may be set before gpgme_check_version is called. See the manual for a description of supported flags. The caller must assure that this function is called only by one thread at a time. */ @@ -512,6 +512,33 @@ gpgme_get_keylist_mode (gpgme_ctx_t ctx) } +/* Set the pinentry mode for CTX to MODE. */ +gpgme_error_t +gpgme_set_pinentry_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode) +{ + TRACE1 (DEBUG_CTX, "gpgme_set_pinentry_mode", ctx, "pinentry_mode=%u", + (unsigned int)mode); + + if (!ctx) + return gpg_error (GPG_ERR_INV_VALUE); + + switch (mode) + { + case GPGME_PINENTRY_MODE_DEFAULT: + case GPGME_PINENTRY_MODE_ASK: + case GPGME_PINENTRY_MODE_CANCEL: + case GPGME_PINENTRY_MODE_ERROR: + case GPGME_PINENTRY_MODE_LOOPBACK: + break; + default: + return gpg_error (GPG_ERR_INV_VALUE); + } + + ctx->pinentry_mode = mode; + return 0; +} + + /* This function sets a callback function to be used to pass a passphrase to gpg. */ void -- cgit v1.2.3