GVfsAfpReply * g_vfs_afp_connection_read_reply_sync (GVfsAfpConnection *afp_connection, GCancellable *cancellable, GError **error) { GVfsAfpConnectionPrivate *priv = afp_connection->priv; gboolean res; char *data; DSIHeader dsi_header; res = read_reply_sync (g_io_stream_get_input_stream (priv->conn), &dsi_header, &data, cancellable, error); if (!res) return NULL; return g_vfs_afp_reply_new (dsi_header.errorCode, data, dsi_header.totalDataLength, TRUE); }
GVfsAfpReply * g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection, GCancellable *cancellable, GError **error) { GVfsAfpConnectionPrivate *priv = afp_connection->priv; GSocketClient *client; GIOStream *conn; gboolean res; DSIHeader dsi_header; char *data; client = g_socket_client_new (); conn = G_IO_STREAM (g_socket_client_connect (client, priv->addr, cancellable, error)); g_object_unref (client); if (!conn) return NULL; res = send_request_sync (g_io_stream_get_output_stream (conn), DSI_GET_STATUS, 0, 0, 0, NULL, cancellable, error); if (!res) { g_object_unref (conn); return NULL; } res = read_reply_sync (g_io_stream_get_input_stream (conn), &dsi_header, &data, cancellable, error); if (!res) { g_object_unref (conn); return NULL; } g_object_unref (conn); return g_vfs_afp_reply_new (dsi_header.errorCode, data, dsi_header.totalDataLength, TRUE); }
static void dispatch_reply (GVfsAfpConnection *afp_connection) { GVfsAfpConnectionPrivate *priv = afp_connection->priv; DSIHeader *dsi_header = &priv->read_dsi_header; switch (dsi_header->command) { case DSI_CLOSE_SESSION: { g_warning ("Server closed session\n"); break; } case DSI_TICKLE: { RequestData *req_data; /* Send back a tickle message */ req_data = g_slice_new0 (RequestData); req_data->type = REQUEST_TYPE_TICKLE; g_queue_push_head (priv->request_queue, req_data); run_loop (afp_connection); break; } case DSI_ATTENTION: { guint8 attention_code; attention_code = priv->reply_buf[0] >> 4; g_signal_emit (afp_connection, signals[ATTENTION], 0, attention_code); break; } case DSI_COMMAND: case DSI_WRITE: { RequestData *req_data; req_data = g_hash_table_lookup (priv->request_hash, GUINT_TO_POINTER ((guint)dsi_header->requestID)); if (req_data) { GVfsAfpReply *reply; reply = g_vfs_afp_reply_new (dsi_header->errorCode, priv->reply_buf, dsi_header->totalDataLength, priv->free_reply_buf); priv->free_reply_buf = FALSE; g_simple_async_result_set_op_res_gpointer (req_data->simple, reply, g_object_unref); g_simple_async_result_complete (req_data->simple); g_hash_table_remove (priv->request_hash, GUINT_TO_POINTER ((guint)dsi_header->requestID)); } break; } default: g_assert_not_reached (); } }