aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/context.h4
-rw-r--r--src/decrypt.c10
-rw-r--r--src/genkey.c17
-rw-r--r--src/gpgme.c31
-rw-r--r--src/gpgme.def3
-rw-r--r--src/gpgme.h.in18
-rw-r--r--src/libgpgme.vers3
-rw-r--r--src/sign.c5
-rw-r--r--src/status-table.c1
9 files changed, 91 insertions, 1 deletions
diff --git a/src/context.h b/src/context.h
index 8cd86e9c..757d9b42 100644
--- a/src/context.h
+++ b/src/context.h
@@ -135,6 +135,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/decrypt.c b/src/decrypt.c
index 47420601..4fd92c61 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 fd6685ef..18765dde 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;
}
@@ -186,6 +195,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);
}
diff --git a/src/gpgme.c b/src/gpgme.c
index c24b6200..9c09827e 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -656,6 +656,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 cf167b4f..a3f5fb4a 100644
--- a/src/gpgme.def
+++ b/src/gpgme.def
@@ -220,5 +220,8 @@ EXPORTS
gpgme_set_offline @165
gpgme_get_offline @166
+
+ gpgme_set_status_cb @167
+ gpgme_get_status_cb @168
; END
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 099cc8a5..8255e637 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;
@@ -839,6 +840,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,
@@ -936,6 +942,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 fc2920f8..6687571f 100644
--- a/src/libgpgme.vers
+++ b/src/libgpgme.vers
@@ -95,6 +95,9 @@ GPGME_1.1 {
gpgme_set_offline;
gpgme_get_offline;
+
+ gpgme_set_status_cb;
+ gpgme_get_status_cb;
};
diff --git a/src/sign.c b/src/sign.c
index ffbde569..9e22fdb8 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 b9369977..c85fa951 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 },