* 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.
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)
+2003-02-06 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpgme.texi (Cancelling an Operation): Removed.
+ (Passphrase Callback): Document new type for GpgmePassphraseCb.
+
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Engine Information): Rename member part to
@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}})
@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
+2003-02-06 Marcus Brinkmann <marcus@g10code.de>
+
+ * 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 <marcus@g10code.de>
* edit.c (_gpgme_edit_status_handler): Call the progress status
int use_cms;
- /* Cancel operation requested. */
- int cancel;
-
/* The running engine process. */
EngineObject engine;
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;
}
-/* 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
/* 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,
/* 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);
{
/* 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)
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;
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,
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,
+2003-02-06 Marcus Brinkmann <marcus@g10code.de>
+
+ * 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 <marcus@g10code.de>
* t-engine-info.c: Use file_name instead path throughout.
/* 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.
}
-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)
{
-/* 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.
*
exit (1); } \
} while(0)
-static void
-print_op_info (GpgmeCtx ctx)
-{
- char *str = gpgme_get_op_info (ctx, 0);
-
- if (!str)
- puts ("<!-- no operation info available -->");
- else
- {
- puts (str);
- free (str);
- }
-}
-
-
static void
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;
}
/* 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.
*
}
-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;
}
}
-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;
}
-/* 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.
*
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;
}
/* 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.
*
}
-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;
}
/* 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.
*
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[])
{