mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* ccid-driver.c (struct ccid_driver_s): Add fields last_progress,
progress_cb and progress_cb_arg. (ccid_set_progress_cb): New. (print_progress): New. (ccid_transceive): Call print_progress for wait time extensions. * apdu.c (struct reader_table_s): Add field set_progress_cb. (new_reader_slot): Clear that field. (open_ccid_reader): Set it to .. (set_progress_cb_ccid_reader): ... new fucntion. * app.c (print_progress_line): New. (lock_reader): Add arg CTRL to set a progress callback and change all callers to provide it. (unlock_reader): Remove the progress callback.
This commit is contained in:
parent
806b0acad7
commit
d0d4931e00
4 changed files with 126 additions and 20 deletions
|
@ -254,6 +254,12 @@ struct ccid_driver_s
|
|||
int apdu_level; /* Reader supports short APDU level exchange.
|
||||
With a value of 2 short and extended level is
|
||||
supported.*/
|
||||
time_t last_progress; /* Last time we sent progress line. */
|
||||
|
||||
/* The progress callback and its first arg as supplied to
|
||||
ccid_set_progress_cb. */
|
||||
void (*progress_cb)(void *, const char *, int, int, int);
|
||||
void *progress_cb_arg;
|
||||
};
|
||||
|
||||
|
||||
|
@ -302,6 +308,23 @@ set_msg_len (unsigned char *msg, unsigned int length)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
print_progress (ccid_driver_t handle)
|
||||
{
|
||||
time_t ct = time (NULL);
|
||||
|
||||
/* We don't want to print progress lines too often. */
|
||||
if (ct == handle->last_progress)
|
||||
return;
|
||||
|
||||
if (handle->progress_cb)
|
||||
handle->progress_cb (handle->progress_cb_arg, "card_busy", 'w', 0, 0);
|
||||
|
||||
handle->last_progress = ct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Pint an error message for a failed CCID command including a textual
|
||||
error code. MSG shall be the CCID message at a minimum of 10 bytes. */
|
||||
static void
|
||||
|
@ -1670,6 +1693,20 @@ ccid_shutdown_reader (ccid_driver_t handle)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
ccid_set_progress_cb (ccid_driver_t handle,
|
||||
void (*cb)(void *, const char *, int, int, int),
|
||||
void *cb_arg)
|
||||
{
|
||||
if (!handle || !handle->rid)
|
||||
return CCID_DRIVER_ERR_INV_VALUE;
|
||||
|
||||
handle->progress_cb = cb;
|
||||
handle->progress_cb_arg = cb_arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Close the reader HANDLE. */
|
||||
int
|
||||
ccid_close_reader (ccid_driver_t handle)
|
||||
|
@ -2894,6 +2931,7 @@ ccid_transceive (ccid_driver_t handle,
|
|||
tpdu[tpdulen++] = (edc >> 8);
|
||||
tpdu[tpdulen++] = edc;
|
||||
DEBUGOUT_1 ("T=1: waittime extension of bwi=%d\n", bwi);
|
||||
print_progress (handle);
|
||||
}
|
||||
else if ( (tpdu[1] & 0x20) && (tpdu[1] & 0x1f) == 0 && !tpdu[2])
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue