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.
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;
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;
"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'
{
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] == ' ')
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,
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;
}
+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,
}
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;