static void write_dsi_header_cb (GObject *object, GAsyncResult *res, gpointer user_data) { GOutputStream *output = G_OUTPUT_STREAM (object); GVfsAfpConnection *afp_conn = G_VFS_AFP_CONNECTION (user_data); GVfsAfpConnectionPrivate *priv = afp_conn->priv; RequestData *req_data; char *data; gsize size; req_data = g_queue_peek_head (priv->request_queue); HANDLE_RES (); if (req_data->type == REQUEST_TYPE_TICKLE) { remove_first (priv->request_queue); send_request (afp_conn); return; } data = g_vfs_afp_command_get_data (req_data->command); size = g_vfs_afp_command_get_size (req_data->command); write_all_async (output, data, size, 0, NULL, write_command_cb, afp_conn); }
static void write_dsi_header_cb (GObject *object, GAsyncResult *res, gpointer user_data) { GOutputStream *output = G_OUTPUT_STREAM (object); RequestData *req_data = user_data; GVfsAfpConnection *afp_conn = req_data->conn; GVfsAfpConnectionPrivate *priv = afp_conn->priv; char *data; gsize size; HANDLE_RES (); if (req_data->type == REQUEST_TYPE_TICKLE) { g_mutex_lock (&priv->mutex); send_request_unlocked (afp_conn); g_mutex_unlock (&priv->mutex); return; } data = g_vfs_afp_command_get_data (req_data->command); size = g_vfs_afp_command_get_size (req_data->command); write_all_async (output, data, size, 0, NULL, write_command_cb, req_data); }
gboolean g_vfs_afp_connection_send_command_sync (GVfsAfpConnection *afp_connection, GVfsAfpCommand *afp_command, GCancellable *cancellable, GError **error) { GVfsAfpConnectionPrivate *priv = afp_connection->priv; DsiCommand dsi_command; guint16 req_id; guint32 writeOffset; /* set dsi_command */ switch (afp_command->type) { case AFP_COMMAND_WRITE: writeOffset = 8; dsi_command = DSI_WRITE; break; case AFP_COMMAND_WRITE_EXT: writeOffset = 20; dsi_command = DSI_WRITE; break; default: writeOffset = 0; dsi_command = DSI_COMMAND; break; } req_id = get_request_id (afp_connection); return send_request_sync (g_io_stream_get_output_stream (priv->conn), dsi_command, req_id, writeOffset, g_vfs_afp_command_get_size (afp_command), g_vfs_afp_command_get_data (afp_command), cancellable, error); }