diff options
author | Werner Koch <[email protected]> | 2016-01-25 10:20:23 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-01-25 10:20:23 +0000 |
commit | ee87c653bf4b495714e8e6b024d0a8ace3a33452 (patch) | |
tree | 3ee9f5311b62b1943615db16a9f4f02c98a51e9c /agent/command.c | |
parent | speedo: Allow use of SHA-256 checksums (diff) | |
download | gnupg-ee87c653bf4b495714e8e6b024d0a8ace3a33452.tar.gz gnupg-ee87c653bf4b495714e8e6b024d0a8ace3a33452.zip |
agent: Send PROGRESS status lines to the client.
* agent/gpg-agent.c (struct progress_dispatch_s): New.
(progress_dispatch_list): New.
(main): Register libgcrypt pogress handler.
(agent_libgcrypt_progress_cb): New.
(agent_set_progress_cb): New.
(unregister_progress_cb): New.
(agent_deinit_default_ctrl): Call unregister.
* agent/command.c (progress_cb): New.
(start_command_handler): Register progress callback.
--
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/command.c')
-rw-r--r-- | agent/command.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/agent/command.c b/agent/command.c index a09da607d..421df0044 100644 --- a/agent/command.c +++ b/agent/command.c @@ -446,6 +446,23 @@ agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid) } +/* An agent progress callback for Libgcrypt. This has been registered + * to be called via the progress dispatcher mechanism from + * gpg-agent.c */ +static void +progress_cb (ctrl_t ctrl, const char *what, int printchar, + int current, int total) +{ + if (!ctrl || !ctrl->server_local || !ctrl->server_local->assuan_ctx) + ; + else if (printchar == '\n' && what && !strcmp (what, "primegen")) + agent_print_status (ctrl, "PROGRESS", "%.20s X 100 100", what); + else + agent_print_status (ctrl, "PROGRESS", "%.20s %c %d %d", + what, printchar=='\n'?'X':printchar, current, total); +} + + /* Helper to print a message while leaving a command. */ static gpg_error_t leave_cmd (assuan_context_t ctx, gpg_error_t err) @@ -3205,6 +3222,7 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd) ctrl->digest.raw_value = 0; assuan_set_io_monitor (ctx, io_monitor, NULL); + agent_set_progress_cb (progress_cb, ctrl); for (;;) { |