core: Add new context flag "redraw".
* src/context.h (struct gpgme_context): New field 'redraw_suggested'. * src/op-support.c (_gpgme_op_reset): Clear REDRAW_SUGGESTED. * src/progress.c (_gpgme_progress_status_handler): Set REDRAW_SUGGESTED. * src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "redraw". * tests/run-sign.c (main): Use it. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
7bd6ab4a91
commit
752d3597ef
@ -2888,6 +2888,29 @@ by this function. The properties are identified by the following
|
|||||||
values for @var{name}:
|
values for @var{name}:
|
||||||
|
|
||||||
@table @code
|
@table @code
|
||||||
|
@item "redraw"
|
||||||
|
This flag is normally not changed by the caller because GPGME sets and
|
||||||
|
clears it automatically: The flag is cleared before an operation and
|
||||||
|
set if an operation noticed that the engine has launched a Pinentry.
|
||||||
|
A Curses based application may use this information to redraw the
|
||||||
|
screen; for example:
|
||||||
|
|
||||||
|
@example
|
||||||
|
err = gpgme_op_keylist_start (ctx, "foo@@example.org", 0);
|
||||||
|
while (!err)
|
||||||
|
@{
|
||||||
|
err = gpgme_op_keylist_next (ctx, &key);
|
||||||
|
if (err)
|
||||||
|
break;
|
||||||
|
show_key (key);
|
||||||
|
gpgme_key_release (key);
|
||||||
|
@}
|
||||||
|
if ((s = gpgme_get_ctx_flag (ctx, "redraw")) && *s)
|
||||||
|
redraw_screen ();
|
||||||
|
gpgme_release (ctx);
|
||||||
|
@end example
|
||||||
|
|
||||||
|
|
||||||
@item "full-status"
|
@item "full-status"
|
||||||
Using a @var{value} of "1" the status callback set by
|
Using a @var{value} of "1" the status callback set by
|
||||||
gpgme_set_status_cb returns all status lines with the exception of
|
gpgme_set_status_cb returns all status lines with the exception of
|
||||||
|
@ -114,10 +114,14 @@ struct gpgme_context
|
|||||||
/* True if session keys should be exported upon decryption. */
|
/* True if session keys should be exported upon decryption. */
|
||||||
unsigned int export_session_keys : 1;
|
unsigned int export_session_keys : 1;
|
||||||
|
|
||||||
|
/* True if a Pinentry was launched during the last operation. This
|
||||||
|
* flag is cleared with each operation. */
|
||||||
|
unsigned int redraw_suggested : 1;
|
||||||
|
|
||||||
/* Flags for keylist mode. */
|
/* Flags for keylist mode. */
|
||||||
gpgme_keylist_mode_t keylist_mode;
|
gpgme_keylist_mode_t keylist_mode;
|
||||||
|
|
||||||
/* The current pinnetry mode. */
|
/* The current pinentry mode. */
|
||||||
gpgme_pinentry_mode_t pinentry_mode;
|
gpgme_pinentry_mode_t pinentry_mode;
|
||||||
|
|
||||||
/* Number of certs to be included. */
|
/* Number of certs to be included. */
|
||||||
|
@ -508,6 +508,10 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
|
|||||||
|
|
||||||
if (!ctx || !name || !value)
|
if (!ctx || !name || !value)
|
||||||
err = gpg_error (GPG_ERR_INV_VALUE);
|
err = gpg_error (GPG_ERR_INV_VALUE);
|
||||||
|
else if (!strcmp (name, "redraw"))
|
||||||
|
{
|
||||||
|
ctx->redraw_suggested = abool;
|
||||||
|
}
|
||||||
else if (!strcmp (name, "full-status"))
|
else if (!strcmp (name, "full-status"))
|
||||||
{
|
{
|
||||||
ctx->full_status = abool;
|
ctx->full_status = abool;
|
||||||
@ -544,6 +548,10 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)
|
|||||||
{
|
{
|
||||||
if (!ctx || !name)
|
if (!ctx || !name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
else if (!strcmp (name, "redraw"))
|
||||||
|
{
|
||||||
|
return ctx->redraw_suggested? "1":"";
|
||||||
|
}
|
||||||
else if (!strcmp (name, "full-status"))
|
else if (!strcmp (name, "full-status"))
|
||||||
{
|
{
|
||||||
return ctx->full_status? "1":"";
|
return ctx->full_status? "1":"";
|
||||||
|
@ -94,6 +94,7 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int type)
|
|||||||
_gpgme_release_result (ctx);
|
_gpgme_release_result (ctx);
|
||||||
LOCK (ctx->lock);
|
LOCK (ctx->lock);
|
||||||
ctx->canceled = 0;
|
ctx->canceled = 0;
|
||||||
|
ctx->redraw_suggested = 0;
|
||||||
UNLOCK (ctx->lock);
|
UNLOCK (ctx->lock);
|
||||||
|
|
||||||
if (ctx->engine && no_reset)
|
if (ctx->engine && no_reset)
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* The status handler for progress status lines which also monitors
|
||||||
|
* the PINENTRY_LAUNCHED status. */
|
||||||
gpgme_error_t
|
gpgme_error_t
|
||||||
_gpgme_progress_status_handler (void *priv, gpgme_status_code_t code,
|
_gpgme_progress_status_handler (void *priv, gpgme_status_code_t code,
|
||||||
char *args)
|
char *args)
|
||||||
@ -42,6 +44,12 @@ _gpgme_progress_status_handler (void *priv, gpgme_status_code_t code,
|
|||||||
int current = 0;
|
int current = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
|
if (code == GPGME_STATUS_PINENTRY_LAUNCHED)
|
||||||
|
{
|
||||||
|
ctx->redraw_suggested = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (code != GPGME_STATUS_PROGRESS || !*args || !ctx->progress_cb)
|
if (code != GPGME_STATUS_PROGRESS || !*args || !ctx->progress_cb)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ main (int argc, char **argv)
|
|||||||
int print_status = 0;
|
int print_status = 0;
|
||||||
int use_loopback = 0;
|
int use_loopback = 0;
|
||||||
const char *sender = NULL;
|
const char *sender = NULL;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
if (argc)
|
if (argc)
|
||||||
{ argc--; argv++; }
|
{ argc--; argv++; }
|
||||||
@ -229,6 +230,9 @@ main (int argc, char **argv)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((s = gpgme_get_ctx_flag (ctx, "redraw")) && *s)
|
||||||
|
fputs ("Screen redraw suggested\n", stdout);
|
||||||
|
|
||||||
fputs ("Begin Output:\n", stdout);
|
fputs ("Begin Output:\n", stdout);
|
||||||
print_data (out);
|
print_data (out);
|
||||||
fputs ("End Output.\n", stdout);
|
fputs ("End Output.\n", stdout);
|
||||||
|
Loading…
Reference in New Issue
Block a user