aboutsummaryrefslogtreecommitdiffstats
path: root/agent/call-pinentry.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-06-17 10:19:50 +0000
committerWerner Koch <[email protected]>2009-06-17 10:19:50 +0000
commitaa03d8f184dd6acbf75c316b44bccc0325af35a3 (patch)
tree9bd764140f9fa712bdf9786781b7cec6b8159345 /agent/call-pinentry.c
parentAdd readcert command. (diff)
downloadgnupg-aa03d8f184dd6acbf75c316b44bccc0325af35a3.tar.gz
gnupg-aa03d8f184dd6acbf75c316b44bccc0325af35a3.zip
Use cancel button in confirmation only if requested.
Diffstat (limited to '')
-rw-r--r--agent/call-pinentry.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index 41fe6f409..b956ef463 100644
--- a/agent/call-pinentry.c
+++ b/agent/call-pinentry.c
@@ -850,10 +850,14 @@ agent_get_passphrase (ctrl_t ctrl,
/* Pop up the PIN-entry, display the text and the prompt and ask the
user to confirm this. We return 0 for success, ie. the user
confirmed it, GPG_ERR_NOT_CONFIRMED for what the text says or an
- other error. */
+ other error. If WITH_CANCEL it true an extra cancel button is
+ displayed to allow the user to easily return a GPG_ERR_CANCELED.
+ if the Pinentry does not support this, the user can still cancel by
+ closing the Pinentry window. */
int
agent_get_confirmation (ctrl_t ctrl,
- const char *desc, const char *ok, const char *cancel)
+ const char *desc, const char *ok,
+ const char *notok, int with_cancel)
{
int rc;
char line[ASSUAN_LINELENGTH];
@@ -881,26 +885,39 @@ agent_get_confirmation (ctrl_t ctrl,
{
snprintf (line, DIM(line)-1, "SETOK %s", ok);
line[DIM(line)-1] = 0;
- rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = assuan_transact (entry_ctx,
+ line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (rc);
}
- if (cancel)
+ if (notok)
{
- snprintf (line, DIM(line)-1, "SETNOTOK %s", cancel);
- line[DIM(line)-1] = 0;
- rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
+ /* Try to use the newer NOTOK feature if a cancel button is
+ requested. If no cacnel button is requested we keep on using
+ the standard cancel. */
+ if (with_cancel)
+ {
+ snprintf (line, DIM(line)-1, "SETNOTOK %s", notok);
+ line[DIM(line)-1] = 0;
+ rc = assuan_transact (entry_ctx,
+ line, NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+ else
+ rc = GPG_ERR_ASS_UNKNOWN_CMD;
+
if (gpg_err_code (rc) == GPG_ERR_ASS_UNKNOWN_CMD)
{
- snprintf (line, DIM(line)-1, "SETCANCEL %s", cancel);
+ snprintf (line, DIM(line)-1, "SETCANCEL %s", notok);
line[DIM(line)-1] = 0;
- rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = assuan_transact (entry_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL);
}
if (rc)
return unlock_pinentry (rc);
}
- rc = assuan_transact (entry_ctx, "CONFIRM", NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = assuan_transact (entry_ctx, "CONFIRM",
+ NULL, NULL, NULL, NULL, NULL, NULL);
if (rc && gpg_err_source (rc) && gpg_err_code (rc) == GPG_ERR_ASS_CANCELED)
rc = gpg_err_make (gpg_err_source (rc), GPG_ERR_CANCELED);