diff options
| author | Werner Koch <[email protected]> | 2013-02-07 19:59:16 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2013-02-07 19:59:16 +0000 | 
| commit | 61a0d92b679f248505f1bf16386bc41a5bf2ba1d (patch) | |
| tree | 7f3e0358bb4f6004a395a55a2902b27940dcf79e /src/gpgme.c | |
| parent | Add public function gpgme_io_writen. (diff) | |
| download | gpgme-61a0d92b679f248505f1bf16386bc41a5bf2ba1d.tar.gz gpgme-61a0d92b679f248505f1bf16386bc41a5bf2ba1d.zip | |
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.
Diffstat (limited to 'src/gpgme.c')
| -rw-r--r-- | src/gpgme.c | 31 | 
1 files changed, 29 insertions, 2 deletions
| 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 | 
