core: Minor change of the gpgme_op_edit semantics.
* src/edit.c (command_handler): Handle special error code. * src/engine-gpg.c (read_status): Ditto. * src/engine-gpgsm.c (status_handler): Ditto. * src/engine-uiserver.c (status_handler): Ditto. * src/util.h (GPG_ERR_FALSE): Define for older libgpg-error versions. -- An edit callback may now simply return GPG_ERR_FALSE to indicate that it did not handled the status code. GPGME will the do the appropriate action, which is to send an empty line. Note that it is highly unlikely that GPG_ERR_FALSE has ever been used by an application as return value from an edit interactor. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
7c37719d79
commit
d2b72d3cc1
@ -4312,7 +4312,8 @@ indicates a command rather than a status message, the response to the
|
|||||||
command should be written to @var{fd}. The @var{handle} is provided
|
command should be written to @var{fd}. The @var{handle} is provided
|
||||||
by the user at start of operation.
|
by the user at start of operation.
|
||||||
|
|
||||||
The function should return @code{GPG_ERR_NO_ERROR} or an error value.
|
The function should return @code{GPG_ERR_FALSE} if it did not handle
|
||||||
|
the status code, @code{0} for success, or any other error value.
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
@deftypefun gpgme_error_t gpgme_op_edit (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}})
|
@deftypefun gpgme_error_t gpgme_op_edit (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}})
|
||||||
|
15
src/edit.c
15
src/edit.c
@ -77,6 +77,8 @@ command_handler (void *priv, gpgme_status_code_t status, const char *args,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
err = 0;
|
||||||
|
|
||||||
if (!processed)
|
if (!processed)
|
||||||
{
|
{
|
||||||
@ -88,16 +90,15 @@ command_handler (void *priv, gpgme_status_code_t status, const char *args,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* FIXME: We expect the user to handle _all_ status codes.
|
err = (*opd->fnc) (opd->fnc_value, status, args, fd);
|
||||||
Later, we may fix the callback interface to allow the user
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
indicate if it processed the status code or not. */
|
err = 0;
|
||||||
*processed_r = 1;
|
else
|
||||||
|
processed = 1;
|
||||||
return (*opd->fnc) (opd->fnc_value, status, args, fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*processed_r = processed;
|
*processed_r = processed;
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1102,6 +1102,8 @@ read_status (engine_gpg_t gpg)
|
|||||||
char emptystring[1] = {0};
|
char emptystring[1] = {0};
|
||||||
err = gpg->status.fnc (gpg->status.fnc_value,
|
err = gpg->status.fnc (gpg->status.fnc_value,
|
||||||
GPGME_STATUS_EOF, emptystring);
|
GPGME_STATUS_EOF, emptystring);
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
|
err = 0; /* Drop special error code. */
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@ -1169,6 +1171,8 @@ read_status (engine_gpg_t gpg)
|
|||||||
{
|
{
|
||||||
err = gpg->status.fnc (gpg->status.fnc_value,
|
err = gpg->status.fnc (gpg->status.fnc_value,
|
||||||
r, rest);
|
r, rest);
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
|
err = 0; /* Drop special error code. */
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -827,6 +827,8 @@ status_handler (void *opaque, int fd)
|
|||||||
char emptystring[1] = {0};
|
char emptystring[1] = {0};
|
||||||
err = gpgsm->status.fnc (gpgsm->status.fnc_value,
|
err = gpgsm->status.fnc (gpgsm->status.fnc_value,
|
||||||
GPGME_STATUS_EOF, emptystring);
|
GPGME_STATUS_EOF, emptystring);
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
|
err = 0; /* Drop special error code. */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!err && gpgsm->colon.fnc && gpgsm->colon.any)
|
if (!err && gpgsm->colon.fnc && gpgsm->colon.any)
|
||||||
@ -978,7 +980,11 @@ status_handler (void *opaque, int fd)
|
|||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
{
|
{
|
||||||
if (gpgsm->status.fnc)
|
if (gpgsm->status.fnc)
|
||||||
err = gpgsm->status.fnc (gpgsm->status.fnc_value, r, rest);
|
{
|
||||||
|
err = gpgsm->status.fnc (gpgsm->status.fnc_value, r, rest);
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
|
err = 0; /* Drop special error code. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest);
|
fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest);
|
||||||
|
@ -676,6 +676,8 @@ status_handler (void *opaque, int fd)
|
|||||||
char emptystring[1] = {0};
|
char emptystring[1] = {0};
|
||||||
err = uiserver->status.fnc (uiserver->status.fnc_value,
|
err = uiserver->status.fnc (uiserver->status.fnc_value,
|
||||||
GPGME_STATUS_EOF, emptystring);
|
GPGME_STATUS_EOF, emptystring);
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
|
err = 0; /* Drop special error code. */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!err && uiserver->colon.fnc && uiserver->colon.any)
|
if (!err && uiserver->colon.fnc && uiserver->colon.any)
|
||||||
@ -827,7 +829,12 @@ status_handler (void *opaque, int fd)
|
|||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
{
|
{
|
||||||
if (uiserver->status.fnc)
|
if (uiserver->status.fnc)
|
||||||
err = uiserver->status.fnc (uiserver->status.fnc_value, r, rest);
|
{
|
||||||
|
err = uiserver->status.fnc (uiserver->status.fnc_value,
|
||||||
|
r, rest);
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_FALSE)
|
||||||
|
err = 0; /* Drop special error code. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest);
|
fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest);
|
||||||
|
@ -45,6 +45,11 @@
|
|||||||
|
|
||||||
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
|
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
|
||||||
|
|
||||||
|
#if GPG_ERROR_VERSION_NUMBER < 0x011500 /* 1.21 */
|
||||||
|
# define GPG_ERR_FALSE 256
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-- {posix,w32}-util.c --*/
|
/*-- {posix,w32}-util.c --*/
|
||||||
int _gpgme_get_conf_int (const char *key, int *value);
|
int _gpgme_get_conf_int (const char *key, int *value);
|
||||||
|
Loading…
Reference in New Issue
Block a user