[git] GPGME - branch, bjk/passphrase-inquire, created. gpgme-1.5.4-4-g2fe9ffe

by Ben Kibbey cvs at cvs.gnupg.org
Fri Apr 17 03:44:27 CEST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, bjk/passphrase-inquire has been created
        at  2fe9ffe0205ef44ad7318bd92474051c6176bcc4 (commit)

- Log -----------------------------------------------------------------
commit 2fe9ffe0205ef44ad7318bd92474051c6176bcc4
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Thu Apr 16 21:05:01 2015 -0400

    Parse the INQUIRE_MAXLEN status message.
    
    * src/gpgme.h.in: (gpgme_status_code_t): Add INQUIRE_MAXLEN.
    * src/status-table.c (status_table_s): Ditto.
    * src/genkey.c (genkey_status_handler): Parse INQUIRE_MAXLEN.
    * src/decrypt.c (_gpgme_decrypt_status_handler): Ditto.
    * src/sign.c (_gpgme_sign_status_handler): Ditto.
    
    This status message informs the client of the maximum length of an
    inquired line. It is sent from gpg and forwarded to the client via
    gpgme_status_cb_t.

diff --git a/src/decrypt.c b/src/decrypt.c
index 4742060..4fd92c6 100644
--- a/src/decrypt.c
+++ b/src/decrypt.c
@@ -291,6 +291,16 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
       err = _gpgme_parse_plaintext (args, &opd->result.file_name);
       if (err)
 	return err;
+      break;
+
+    case GPGME_STATUS_INQUIRE_MAXLEN:
+      if (ctx->status_cb)
+        {
+          err = ctx->status_cb (ctx->status_cb_value, "INQUIRE_MAXLEN", args);
+          if (err)
+            return err;
+        }
+      break;
 
     default:
       break;
diff --git a/src/genkey.c b/src/genkey.c
index 17009bd..18765dd 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -124,6 +124,15 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
 	return gpg_error (GPG_ERR_GENERAL);
       break;
 
+    case GPGME_STATUS_INQUIRE_MAXLEN:
+      if (ctx->status_cb)
+        {
+          err = ctx->status_cb (ctx->status_cb_value, "INQUIRE_MAXLEN", args);
+          if (err)
+            return err;
+        }
+      break;
+
     default:
       break;
     }
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 55bc568..893e11c 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -544,7 +544,8 @@ typedef enum
     GPGME_STATUS_PINENTRY_LAUNCHED = 88,
     GPGME_STATUS_ATTRIBUTE = 89,
     GPGME_STATUS_BEGIN_SIGNING = 90,
-    GPGME_STATUS_KEY_NOT_CREATED = 91
+    GPGME_STATUS_KEY_NOT_CREATED = 91,
+    GPGME_STATUS_INQUIRE_MAXLEN = 92
   }
 gpgme_status_code_t;
 
diff --git a/src/sign.c b/src/sign.c
index ffbde56..9e22fdb 100644
--- a/src/sign.c
+++ b/src/sign.c
@@ -338,6 +338,11 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
 	err = gpg_error (GPG_ERR_GENERAL);
       break;
 
+    case GPGME_STATUS_INQUIRE_MAXLEN:
+      if (ctx->status_cb)
+        err = ctx->status_cb (ctx->status_cb_value, "INQUIRE_MAXLEN", args);
+      break;
+
     default:
       break;
     }
diff --git a/src/status-table.c b/src/status-table.c
index b936997..c85fa95 100644
--- a/src/status-table.c
+++ b/src/status-table.c
@@ -80,6 +80,7 @@ static struct status_table_s status_table[] =
   { "IMPORT_PROBLEM", GPGME_STATUS_IMPORT_PROBLEM },
   { "IMPORT_RES", GPGME_STATUS_IMPORT_RES },
   { "IMPORTED", GPGME_STATUS_IMPORTED },
+  { "INQUIRE_MAXLEN", GPGME_STATUS_INQUIRE_MAXLEN },
   { "INV_RECP", GPGME_STATUS_INV_RECP },
   { "INV_SGNR", GPGME_STATUS_INV_SGNR },
   { "KEY_CREATED", GPGME_STATUS_KEY_CREATED },

commit 7e46a5e20c5e75c7a297047b5879f4a4d45e9d7c
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Thu Apr 16 20:23:38 2015 -0400

    Add gpgme_set/get_status_cb().
    
    * src/gpgme.h.in (gpgme_set_status_cb): New.
    (gpgme_get_status_cb): New.
    (gpgme_status_cb_t): New.
    * src/gpgme.c (gpgme_set_status_cb): New.
    (gpgme_get_status_cb): New.
    * src/context.h (status_cb): New.
    (status_cb_value): New.
    * src/gpgme.def: Export new symbols.
    * src/libgpgme.vers: Ditto.
    * doc/gpgme.texi: Document these new functions.
    
    --
    This callback function is used to forward status messages from gpg back
    to the client.

diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index 45c359d..a84a9d0 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -193,6 +193,7 @@ Context Attributes
 * Key Listing Mode::              Selecting key listing mode.
 * Passphrase Callback::           Getting the passphrase from the user.
 * Progress Meter Callback::       Being informed about the progress.
+* Status Message Callback::       Status messages received from gpg.
 * Locale::                        Setting the locale of a context.
 
 Key Management
@@ -2289,6 +2290,7 @@ started.  In fact, these references are accessed through the
 * Key Listing Mode::              Selecting key listing mode.
 * Passphrase Callback::           Getting the passphrase from the user.
 * Progress Meter Callback::       Being informed about the progress.
+* Status Message Callback::       Status messages received from gpg.
 * Locale::                        Setting the locale of a context.
 @end menu
 
@@ -2642,6 +2644,48 @@ the corresponding value will not be returned.
 @end deftypefun
 
 
+ at node Status Message Callback
+ at subsection Status Message Callback
+ at cindex callback, status message
+ at cindex status message callback
+
+ at deftp {Data type} {gpgme_error_t (*gpgme_status_cb_t)(void *@var{hook}, const char *@var{keyword}, const char *@var{args})}
+ at tindex gpgme_status_cb_t
+The @code{gpgme_status_cb_t} type is the type of function usable as
+a status message callback function.
+
+The argument @var{keyword} is the name of the status message while the
+ at var{args} argument contains any arguments for the status message.
+
+The status message may have come from gpg or libgpgme.
+
+If an error occurs, return the corresponding @code{gpgme_error_t}
+value. Otherwise, return @code{0}.
+ at end deftp
+
+ at deftypefun void gpgme_set_status_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_status_cb_t @var{statusfunc}}, @w{void *@var{hook_value}})
+The function @code{gpgme_set_status_cb} sets the function that is used when a
+status message is received from gpg to @var{statusfunc}. The function
+ at var{statusfunc} needs to implemented by the user, and whenever it is called,
+it is called with its first argument being @var{hook_value}.  By default, no
+status message callback function is set.
+
+The user can disable the use of a status message callback function by calling
+ at code{gpgme_set_status_cb} with @var{statusfunc} being @code{NULL}.
+ at end deftypefun
+
+ at deftypefun void gpgme_get_status_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_status_cb_t *@var{statusfunc}}, @w{void **@var{hook_value}})
+The function @code{gpgme_get_status_cb} returns the function that is used to
+process status messages from gpg in @var{*statusfunc}, and the first argument
+for this function in @var{*hook_value}.  If no status message callback is set,
+or @var{ctx} is not a valid pointer, @code{NULL} is returned in both
+variables.
+
+ at var{statusfunc} or @var{hook_value} can be @code{NULL}.  In this case,
+the corresponding value will not be returned.
+ at end deftypefun
+
+
 @node Locale
 @subsection Locale
 @cindex locale, default
diff --git a/src/context.h b/src/context.h
index 745ffa8..a2977fc 100644
--- a/src/context.h
+++ b/src/context.h
@@ -132,6 +132,10 @@ struct gpgme_context
   gpgme_progress_cb_t progress_cb;
   void *progress_cb_value;
 
+  /* The user provided status callback and its hook value.  */
+  gpgme_status_cb_t status_cb;
+  void *status_cb_value;
+
   /* A list of file descriptors in active use by the current
      operation.  */
   struct fd_table fdt;
diff --git a/src/gpgme.c b/src/gpgme.c
index 628cdae..ac2c95e 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -632,6 +632,37 @@ gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb,
 }
 
 
+/* This function sets a callback function to be used as a status
+   message forwarder.  */
+void
+gpgme_set_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t cb, void *cb_value)
+{
+  TRACE2 (DEBUG_CTX, "gpgme_set_status_cb", ctx, "status_cb=%p/%p",
+	  cb, cb_value);
+
+  if (!ctx)
+    return;
+
+  ctx->status_cb = cb;
+  ctx->status_cb_value = cb_value;
+}
+
+
+/* This function returns the callback function to be used as a
+   status message forwarder.  */
+void
+gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *r_cb,
+		       void **r_cb_value)
+{
+  TRACE2 (DEBUG_CTX, "gpgme_get_status_cb", ctx, "ctx->status_cb=%p/%p",
+	  ctx->status_cb, ctx->status_cb_value);
+  if (r_cb)
+    *r_cb = ctx->status_cb;
+  if (r_cb_value)
+    *r_cb_value = ctx->status_cb_value;
+}
+
+
 /* Set the I/O callback functions for CTX to IO_CBS.  */
 void
 gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
diff --git a/src/gpgme.def b/src/gpgme.def
index dc18948..ab1f643 100644
--- a/src/gpgme.def
+++ b/src/gpgme.def
@@ -217,5 +217,8 @@ EXPORTS
 
     gpgme_op_spawn_start                  @163
     gpgme_op_spawn                        @164
+
+    gpgme_set_status_cb                   @165
+    gpgme_get_status_cb                   @166
 ; END
 
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 15ed803..55bc568 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -839,6 +839,11 @@ typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
 				     int type, int current, int total);
 
+/* Status messages from gpg. */
+typedef gpgme_error_t (*gpgme_status_cb_t) (void *opaque, const char *keyword,
+                                            const char *args);
+
+
 /* Interact with the user about an edit operation.  */
 typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
 					  gpgme_status_code_t status,
@@ -930,6 +935,16 @@ void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
 			    void **hook_value);
 
+/* Set the status callback function in CTX to CB.  HOOK_VALUE is
+   passed as first argument to thes status callback function.  */
+void gpgme_set_status_cb (gpgme_ctx_t c, gpgme_status_cb_t cb,
+                          void *hook_value);
+
+/* Get the current status callback function in *CB and the current
+   hook value in *HOOK_VALUE.  */
+void gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *cb,
+                          void **hook_value);
+
 /* This function sets the locale for the context CTX, or the default
    locale if CTX is a null pointer.  */
 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
diff --git a/src/libgpgme.vers b/src/libgpgme.vers
index 39663c1..decfc8a 100644
--- a/src/libgpgme.vers
+++ b/src/libgpgme.vers
@@ -92,6 +92,9 @@ GPGME_1.1 {
 
     gpgme_op_spawn_start;
     gpgme_op_spawn;
+
+    gpgme_set_status_cb;
+    gpgme_get_status_cb;
 };
 
 

commit f543631aae3e52f010173926b646dba1e2b14ab9
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Tue Apr 14 18:39:26 2015 -0400

    Make use of user passphrase handler during genkey.
    
    * src/genkey.c (genkey_start): set engine passphrase command handler.
    
    This allows for inquiring a new passphrase during key generation rather
    than requiring a pinentry.

diff --git a/src/genkey.c b/src/genkey.c
index fd6685e..17009bd 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -186,6 +186,14 @@ genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms,
 
   _gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
 
+  if (ctx->passphrase_cb)
+    {
+      err = _gpgme_engine_set_command_handler
+        (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL);
+      if (err)
+        return err;
+    }
+
   return _gpgme_engine_op_genkey (ctx->engine, opd->key_parameter,
 				  ctx->use_armor, pubkey, seckey);
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list