2009-11-05 Marcus Brinkmann <marcus@g10code.de>

* engine-g13.c (struct engine_g13): Remove members RESULT_CB and
	RESULT_CB_VALUE.
	(g13_assuan_simple_command, status_handler): Don't use those anymore.
	(g13_transact): Remove them from argument list, too.
	* vfs-mount.c (_gpgme_vfs_mount_status_handler): New function.
	(_gpgme_op_vfs_mount): Pass it to transact.
This commit is contained in:
Marcus Brinkmann 2009-11-06 00:12:59 +00:00
parent 4babea46e7
commit 8acf819d40
3 changed files with 43 additions and 30 deletions

View File

@ -1,5 +1,12 @@
2009-11-05 Marcus Brinkmann <marcus@g10code.de>
* engine-g13.c (struct engine_g13): Remove members RESULT_CB and
RESULT_CB_VALUE.
(g13_assuan_simple_command, status_handler): Don't use those anymore.
(g13_transact): Remove them from argument list, too.
* vfs-mount.c (_gpgme_vfs_mount_status_handler): New function.
(_gpgme_op_vfs_mount): Pass it to transact.
* engine-assuan.c (llass_new): Update use of assuan_socket_connect.
* engine-gpgsm.c (gpgsm_new): Update use of assuan_pipe_connect.
* engine-g13.c (g13_new): Likewise.

View File

@ -69,10 +69,6 @@ struct engine_g13
struct gpgme_io_cbs io_cbs;
/* Internal callbacks. */
engine_assuan_result_cb_t result_cb;
void *result_cb_value;
/* User provided callbacks. */
struct {
gpgme_assuan_data_cb_t data_cb;
@ -398,8 +394,8 @@ g13_set_locale (void *engine, int category, const char *value)
static gpgme_error_t
g13_assuan_simple_command (assuan_context_t ctx, char *cmd,
engine_status_handler_t status_fnc,
void *status_fnc_value)
engine_status_handler_t status_fnc,
void *status_fnc_value)
{
gpg_error_t err;
char *line;
@ -480,17 +476,13 @@ status_handler (void *opaque, int fd)
"fd 0x%x: ERR line: %s",
fd, err ? gpg_strerror (err) : "ok");
/* In g13, command execution errors are not fatal, as we use
/* Command execution errors are not fatal, as we use
a session based protocol. */
if (g13->result_cb)
err = g13->result_cb (g13->result_cb_value, err);
else
err = 0;
if (!err)
{
_gpgme_io_close (g13->status_cb.fd);
return 0;
}
data->op_err = err;
/* The caller will do the rest (namely, call cancel_op,
which closes status_fd). */
return 0;
}
else if (linelen >= 2
&& line[0] == 'O' && line[1] == 'K'
@ -498,15 +490,9 @@ status_handler (void *opaque, int fd)
{
TRACE1 (DEBUG_CTX, "gpgme:status_handler", g13,
"fd 0x%x: OK line", fd);
if (g13->result_cb)
err = g13->result_cb (g13->result_cb_value, 0);
else
err = 0;
if (!err)
{
_gpgme_io_close (g13->status_cb.fd);
return 0;
}
_gpgme_io_close (g13->status_cb.fd);
return 0;
}
else if (linelen > 2
&& line[0] == 'D' && line[1] == ' ')
@ -704,8 +690,6 @@ g13_reset (void *engine)
static gpgme_error_t
g13_transact (void *engine,
const char *command,
engine_assuan_result_cb_t result_cb,
void *result_cb_value,
gpgme_assuan_data_cb_t data_cb,
void *data_cb_value,
gpgme_assuan_inquire_cb_t inq_cb,
@ -719,8 +703,6 @@ g13_transact (void *engine,
if (!g13 || !command || !*command)
return gpg_error (GPG_ERR_INV_VALUE);
g13->result_cb = result_cb;
g13->result_cb_value = result_cb_value;
g13->user.data_cb = data_cb;
g13->user.data_cb_value = data_cb_value;
g13->user.inq_cb = inq_cb;

View File

@ -55,6 +55,30 @@ gpgme_op_vfs_mount_result (gpgme_ctx_t ctx)
}
static gpgme_error_t
_gpgme_vfs_mount_status_handler (void *priv, const char *code, const char *args)
{
gpgme_ctx_t ctx = (gpgme_ctx_t) priv;
gpgme_error_t err;
void *hook;
op_data_t opd;
err = _gpgme_op_data_lookup (ctx, OPDATA_VFS_MOUNT, &hook, -1, NULL);
opd = hook;
if (err)
return err;
if (! strcasecmp ("MOUNTPOINT", code))
{
if (opd->result.mount_dir)
free (opd->result.mount_dir);
opd->result.mount_dir = strdup (args);
}
return 0;
}
static gpgme_error_t
vfs_start (gpgme_ctx_t ctx, int synchronous,
const char *command,
@ -190,7 +214,7 @@ _gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file,
}
err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL,
NULL, NULL, op_err);
_gpgme_vfs_mount_status_handler, ctx, op_err);
free (cmd);
return err;