From: Marcus Brinkmann Date: Thu, 6 Feb 2003 20:09:24 +0000 (+0000) Subject: doc/ X-Git-Tag: gpgme-0-4-1~95 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5a37051361cd2d8c47c49f7ac3c4ae6fd0e0c206;p=gpgme.git doc/ 2003-02-06 Marcus Brinkmann * gpgme.texi (Cancelling an Operation): Removed. (Passphrase Callback): Document new type for GpgmePassphraseCb. gpgme/ 2003-02-06 Marcus Brinkmann * gpgme.h (GpgmePassphraseCb): Change type to return GpgmeError, and add argument for returning the result string. (gpgme_cancel): Remove prototype. * gpgme.c (gpgme_cancel): Remove function. * context.h (struct gpgme_context_s): Remove member cancel. * passphrase.c (_gpgme_passphrase_command_handler): Call the passphrase callback in the new way. tests/ 2003-02-06 Marcus Brinkmann * gpg/t-decrypt.c (passphrase_cb): Fix to new prototype. * gpg/t-decrypt-verify.c (passphrase_cb): Likewise. * gpg/t-edit.c (passphrase_cb): Likewise. * gpg/t-encrypt-sign.c (passphrase_cb): Likewise. * gpg/t-encrypt-sym.c (passphrase_cb): Likewise. * gpg/t-sign.c (passphrase_cb): Likewise. * gpg/t-signers.c (passphrase_cb): Likewise. --- diff --git a/NEWS b/NEWS index 331123c..d0d7266 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,11 @@ Noteworthy changes in version 0.4.1 (unreleased) * The new function gpgme_get_protocol_name can be used to convert a GpgmeProtocol value into a string. + * The GpgmePassphraseCb type now returns a GpgmeError value, and + returns the password string in a new parameter. The gpgme_cancel + function has been removed, just return GPGME_Canceled in the + passphrase callback directly. + * Interface changes relative to the 0.4.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpgmeIOCb CHANGED: Return type from void to GpgmeError. @@ -49,6 +54,8 @@ gpgme_register_idle REMOVED GpgmeEngineInfo NEW gpgme_get_engine_info CHANGED: Return info structure instead XML. gpgme_get_protocol_name NEW +GpgmePassphraseCb CHANGED: Return error value, new argument. +gpgme_cancel REMOVED: Return error in callback directly. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.0 (2002-12-23) diff --git a/doc/ChangeLog b/doc/ChangeLog index 4b695d7..37a7f08 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2003-02-06 Marcus Brinkmann + + * gpgme.texi (Cancelling an Operation): Removed. + (Passphrase Callback): Document new type for GpgmePassphraseCb. + 2003-01-30 Marcus Brinkmann * gpgme.texi (Engine Information): Rename member part to diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 88472cc..95e615c 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -1537,20 +1537,25 @@ current mode otherwise. Note that 0 is not a valid mode value. @cindex callback, passphrase @cindex passphrase callback -@deftp {Data type} {const char *(*GpgmePassphraseCb)(void *@var{hook}, const char *@var{desc}, void **@var{r_hd})} +@deftp {Data type} {GpgmeError (*GpgmePassphraseCb)(void *@var{hook}, const char *@var{desc}, void **@var{r_hd}, const char **@var{result})} @tindex GpgmePassphraseCb The @code{GpgmePassphraseCb} type is the type of functions usable as passphrase callback function. The string @var{desc} contains a text usable to be displayed to the user of the application. The function should return a passphrase for -the context when invoked with @var{desc} not being @code{NULL}. +the context when invoked with @var{desc} not being @code{NULL} in +*@var{result}. The user may store information about the resources associated with the returned passphrase in @var{*r_hd}. When the passphrase is no longer needed by @acronym{GPGME}, the passphrase callback function will be called with @var{desc} being @var{NULL}, and @var{r_hd} being the same as at the first invocation. + +If an error occurs, return the corresponding @code{GpgmeError} value. +You can use @code{GPGME_Canceled} to abort the operation. Otherwise, +return @code{0}. @end deftp @deftypefun void gpgme_set_passphrase_cb (@w{GpgmeCtx @var{ctx}}, @w{GpgmePassphraseCb @var{passfunc}}, @w{void *@var{hook_value}}) @@ -3113,22 +3118,6 @@ error occurs, @code{NULL} is returned and the error is returned in @end deftypefun -@node Cancelling an Operation -@subsection Cancelling an Operation -@cindex cancellation -@cindex cryptographic operation, cancel - -@deftypefun void gpgme_cancel (@w{GpgmeCtx @var{ctx}}) -The function @code{gpgme_cancel} tries to cancel the pending -operation. A running synchronous operation in the context or the -function @code{gpgme_wait} with this context as its @var{ctx} argument -might notice the cancellation flag and return. It is currently not -guaranteed to work under all circumstances. Its current primary -purpose is to prevent asking for a passphrase again in the passphrase -callback. -@end deftypefun - - @node Using External Event Loops @subsection Using External Event Loops @cindex event loop, external diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 53bcc45..0ab9523 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,13 @@ +2003-02-06 Marcus Brinkmann + + * gpgme.h (GpgmePassphraseCb): Change type to return GpgmeError, + and add argument for returning the result string. + (gpgme_cancel): Remove prototype. + * gpgme.c (gpgme_cancel): Remove function. + * context.h (struct gpgme_context_s): Remove member cancel. + * passphrase.c (_gpgme_passphrase_command_handler): Call the + passphrase callback in the new way. + 2003-01-30 Marcus Brinkmann * edit.c (_gpgme_edit_status_handler): Call the progress status diff --git a/gpgme/context.h b/gpgme/context.h index a46a292..d2b22d6 100644 --- a/gpgme/context.h +++ b/gpgme/context.h @@ -80,9 +80,6 @@ struct gpgme_context_s int use_cms; - /* Cancel operation requested. */ - int cancel; - /* The running engine process. */ EngineObject engine; diff --git a/gpgme/edit.c b/gpgme/edit.c index 5fbb4b4..1fa3929 100644 --- a/gpgme/edit.c +++ b/gpgme/edit.c @@ -43,7 +43,7 @@ edit_status_handler (GpgmeCtx ctx, GpgmeStatusCode status, char *args) if (err) return err; - GpgmeError err = _gpgme_progress_status_handler (ctx, status, args); + err = _gpgme_progress_status_handler (ctx, status, args); if (err) return err; diff --git a/gpgme/gpgme.c b/gpgme/gpgme.c index 02bc908..6deb627 100644 --- a/gpgme/gpgme.c +++ b/gpgme/gpgme.c @@ -102,20 +102,6 @@ _gpgme_release_result (GpgmeCtx ctx) } -/* Cancel the current operation. It is not guaranteed that it will - work for all kinds of operations. It is especially useful in a - passphrase callback to stop the system from asking another time for - the passphrase. */ -void -gpgme_cancel (GpgmeCtx ctx) -{ - if (!ctx) - return; - - ctx->cancel = 1; -} - - /** * gpgme_get_notation: * @c: the context diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index dcc1eb0..9d39595 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -334,8 +334,8 @@ typedef struct _gpgme_engine_info *GpgmeEngineInfo; /* Types for callback functions. */ /* Request a passphrase from the user. */ -typedef const char *(*GpgmePassphraseCb) (void *hook, const char *desc, - void **r_hd); +typedef GpgmeError (*GpgmePassphraseCb) (void *hook, const char *desc, + void **r_hd, const char **result); /* Inform the user about progress made. */ typedef void (*GpgmeProgressCb) (void *opaque, const char *what, @@ -487,9 +487,6 @@ void gpgme_set_io_cbs (GpgmeCtx ctx, struct GpgmeIOCbs *io_cbs); /* Get the current I/O callback functions. */ void gpgme_get_io_cbs (GpgmeCtx ctx, struct GpgmeIOCbs *io_cbs); -/* Cancel a pending operation in CTX. */ -void gpgme_cancel (GpgmeCtx ctx); - /* Process the pending operation and, if HANG is non-zero, wait for the pending operation to finish. */ GpgmeCtx gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang); diff --git a/gpgme/passphrase.c b/gpgme/passphrase.c index 67fb43b..fd492ac 100644 --- a/gpgme/passphrase.c +++ b/gpgme/passphrase.c @@ -125,13 +125,11 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, { /* We have been called for cleanup. */ if (ctx->passphrase_cb) - { - /* Fixme: Take the key in account. */ - ctx->passphrase_cb (ctx->passphrase_cb_value, NULL, - &result->last_pw_handle); - } + /* Fixme: Take the key in account. */ + err = ctx->passphrase_cb (ctx->passphrase_cb_value, NULL, + &result->last_pw_handle, NULL); *result_r = NULL; - return 0; + return err; } if (!key || !ctx->passphrase_cb) @@ -160,10 +158,10 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, bad_passphrase ? "TRY_AGAIN":"ENTER", userid_hint, passphrase_info); - *result_r = ctx->passphrase_cb (ctx->passphrase_cb_value, buf, - &result->last_pw_handle); + err = ctx->passphrase_cb (ctx->passphrase_cb_value, buf, + &result->last_pw_handle, result_r); free (buf); - return 0; + return err; } *result_r = NULL; diff --git a/gpgme/wait-global.c b/gpgme/wait-global.c index daf3209..4025d2b 100644 --- a/gpgme/wait-global.c +++ b/gpgme/wait-global.c @@ -306,8 +306,6 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang) assert (ictx); err = item->handler (item->handler_value, fdt.fds[i].fd); - if (!err && ictx->cancel) - err = GPGME_Canceled; if (err) { /* An error occured. Close all fds in this context, diff --git a/gpgme/wait-private.c b/gpgme/wait-private.c index 75d44a7..de7f535 100644 --- a/gpgme/wait-private.c +++ b/gpgme/wait-private.c @@ -110,8 +110,6 @@ _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond) item = (struct wait_item_s *) ctx->fdt.fds[i].opaque; err = item->handler (item->handler_value, ctx->fdt.fds[i].fd); - if (!err && ctx->cancel) - err = GPGME_Canceled; if (err) { /* An error occured. Close all fds in this context, diff --git a/tests/ChangeLog b/tests/ChangeLog index 2ff2aff..37d6d11 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,13 @@ +2003-02-06 Marcus Brinkmann + + * gpg/t-decrypt.c (passphrase_cb): Fix to new prototype. + * gpg/t-decrypt-verify.c (passphrase_cb): Likewise. + * gpg/t-edit.c (passphrase_cb): Likewise. + * gpg/t-encrypt-sign.c (passphrase_cb): Likewise. + * gpg/t-encrypt-sym.c (passphrase_cb): Likewise. + * gpg/t-sign.c (passphrase_cb): Likewise. + * gpg/t-signers.c (passphrase_cb): Likewise. + 2003-01-30 Marcus Brinkmann * t-engine-info.c: Use file_name instead path throughout. diff --git a/tests/gpg/t-decrypt-verify.c b/tests/gpg/t-decrypt-verify.c index 1a129a7..f7bbbbd 100644 --- a/tests/gpg/t-decrypt-verify.c +++ b/tests/gpg/t-decrypt-verify.c @@ -1,6 +1,6 @@ /* t-decrypt-verify.c - regression test Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002 g10 Code GmbH + Copyright (C) 2001, 2002, 2003 g10 Code GmbH This file is part of GPGME. @@ -58,24 +58,22 @@ print_data (GpgmeData dh) } -static const char * -passphrase_cb (void *opaque, const char *desc, void **r_hd) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; + if (!desc) + /* Cleanup by looking at *r_hd. */ + return 0; - if ( !desc ) - { - /* Cleanup by looking at *r_hd. */ - return NULL; - } - - pass = "abc"; + *result = "abc"; fprintf (stderr, "%% requesting passphrase for `%s': ", desc); - fprintf (stderr, "sending `%s'\n", pass); - - return pass; + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } + static char * mk_fname (const char *fname) { diff --git a/tests/gpg/t-decrypt.c b/tests/gpg/t-decrypt.c index 0eda6ac..39f534f 100644 --- a/tests/gpg/t-decrypt.c +++ b/tests/gpg/t-decrypt.c @@ -1,6 +1,6 @@ -/* t-encrypt.c - regression test +/* t-decrypt.c - regression test * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2003 g10 Code GmbH * * This file is part of GPGME. * @@ -41,21 +41,6 @@ struct passphrase_cb_info_s { exit (1); } \ } while(0) -static void -print_op_info (GpgmeCtx ctx) -{ - char *str = gpgme_get_op_info (ctx, 0); - - if (!str) - puts (""); - else - { - puts (str); - free (str); - } -} - - static void print_data (GpgmeData dh) { @@ -72,23 +57,19 @@ print_data (GpgmeData dh) } -static const char * -passphrase_cb ( void *opaque, const char *desc, void **r_hd ) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; - - if ( !desc ) { - /* cleanup by looking at *r_hd */ - - - return NULL; - } - - pass = "abc"; - fprintf (stderr, "%% requesting passphrase for `%s': ", desc ); - fprintf (stderr, "sending `%s'\n", pass ); + if (!desc) + /* Cleanup by looking at *r_hd. */ + return 0; - return pass; + *result = "abc"; + fprintf (stderr, "%% requesting passphrase for `%s': ", desc); + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } diff --git a/tests/gpg/t-edit.c b/tests/gpg/t-edit.c index 8117d58..b78a7fe 100644 --- a/tests/gpg/t-edit.c +++ b/tests/gpg/t-edit.c @@ -1,6 +1,6 @@ /* t-edit.c - regression test * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH + * Copyright (C) 2001, 2002, 2003 g10 Code GmbH * * This file is part of GPGME. * @@ -57,22 +57,19 @@ flush_data (GpgmeData dh) } -static const char * -passphrase_cb (void *opaque, const char *desc, void **r_hd) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; - if (!desc) - { - /* cleanup by looking at *r_hd */ - return NULL; - } + /* Cleanup by looking at *r_hd. */ + return 0; - pass = "abc"; + *result = "abc"; fprintf (stderr, "%% requesting passphrase for `%s': ", desc); - fprintf (stderr, "sending `%s'\n", pass ); - - return pass; + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } diff --git a/tests/gpg/t-encrypt-sign.c b/tests/gpg/t-encrypt-sign.c index dfd54be..36bd888 100644 --- a/tests/gpg/t-encrypt-sign.c +++ b/tests/gpg/t-encrypt-sign.c @@ -62,23 +62,19 @@ print_data (GpgmeData dh) } -static const char * -passphrase_cb ( void *opaque, const char *desc, void **r_hd ) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; - - if ( !desc ) { - /* cleanup by looking at *r_hd */ - - - return NULL; - } - - pass = "abc"; - fprintf (stderr, "%% requesting passphrase for `%s': ", desc ); - fprintf (stderr, "sending `%s'\n", pass ); + if (!desc) + /* Cleanup by looking at *r_hd. */ + return 0; - return pass; + *result = "abc"; + fprintf (stderr, "%% requesting passphrase for `%s': ", desc); + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } diff --git a/tests/gpg/t-encrypt-sym.c b/tests/gpg/t-encrypt-sym.c index db3f3e9..520005c 100644 --- a/tests/gpg/t-encrypt-sym.c +++ b/tests/gpg/t-encrypt-sym.c @@ -1,6 +1,6 @@ -/* t-encrypt.c - regression test +/* t-encrypt-sym.c - regression test * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2003 g10 Code GmbH * * This file is part of GPGME. * @@ -47,24 +47,19 @@ print_data (GpgmeData dh) fail_if_err (GPGME_File_Error); } - -static const char * -passphrase_cb ( void *opaque, const char *desc, void **r_hd ) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; - - if ( !desc ) { - /* cleanup by looking at *r_hd */ - - - return NULL; - } + if (!desc) + /* Cleanup by looking at *r_hd. */ + return 0; - pass = "abc"; - fprintf (stderr, "%% requesting passphrase for `%s': ", desc ); - fprintf (stderr, "sending `%s'\n", pass ); - - return pass; + *result = "abc"; + fprintf (stderr, "%% requesting passphrase for `%s': ", desc); + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } diff --git a/tests/gpg/t-sign.c b/tests/gpg/t-sign.c index 9caaf69..1e69930 100644 --- a/tests/gpg/t-sign.c +++ b/tests/gpg/t-sign.c @@ -1,6 +1,6 @@ /* t-sign.c - regression test * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2003 g10 Code GmbH * * This file is part of GPGME. * @@ -63,23 +63,19 @@ print_data (GpgmeData dh) } -static const char * -passphrase_cb ( void *opaque, const char *desc, void **r_hd ) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; - - if ( !desc ) { - /* cleanup by looking at *r_hd */ - - - return NULL; - } - - pass = "abc"; - fprintf (stderr, "%% requesting passphrase for `%s': ", desc ); - fprintf (stderr, "sending `%s'\n", pass ); + if (!desc) + /* Cleanup by looking at *r_hd. */ + return 0; - return pass; + *result = "abc"; + fprintf (stderr, "%% requesting passphrase for `%s': ", desc); + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } diff --git a/tests/gpg/t-signers.c b/tests/gpg/t-signers.c index 2e8d3f4..d17b397 100644 --- a/tests/gpg/t-signers.c +++ b/tests/gpg/t-signers.c @@ -1,6 +1,6 @@ /* t-signers.c - Regression tests for the Gpgme multiple signers interface. * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2003 g10 Code GmbH * * This file is part of GPGME. * @@ -62,25 +62,22 @@ print_data (GpgmeData dh) fail_if_err (GPGME_File_Error); } - -static const char * -passphrase_cb (void *opaque, const char *desc, void **r_hd) +static GpgmeError +passphrase_cb (void *opaque, const char *desc, + void **r_hd, const char **result) { - const char *pass; - if (!desc) - { - /* cleanup by looking at *r_hd */ - return NULL; - } + /* Cleanup by looking at *r_hd. */ + return 0; - pass = "abc"; + *result = "abc"; fprintf (stderr, "%% requesting passphrase for `%s': ", desc); - fprintf (stderr, "sending `%s'\n", pass); - - return pass; + fprintf (stderr, "sending `%s'\n", *result); + + return 0; } + int main (int argc, char *argv[]) {