New resource API and corresponding stubs.

This commit is contained in:
Michael Jumper 2012-08-27 12:50:09 -07:00
parent 9e2e1e4994
commit 5f1b67fb02
2 changed files with 63 additions and 41 deletions

View File

@ -123,17 +123,32 @@ typedef void guac_client_log_handler(guac_client* client, const char* format, va
typedef int guac_client_init_handler(guac_client* client, int argc, char** argv);
/**
* Handler which will be called whenever a resource is being exposed.
* Handler which will be called whenever a resource has been accepted by the
* client.
*/
typedef int guac_client_resource_handler(guac_client* client,
guac_resource* resource);
typedef int guac_client_accept_handler(guac_client* client,
guac_resource* resource, const char* mimetype);
/**
* Handler which will be called whenever a valid resource is selected.
* Handler which will be called whenever a resource has been rejected by the
* client.
*/
typedef int guac_client_stream_handler(guac_client* client,
typedef int guac_client_reject_handler(guac_client* client,
guac_resource* resource);
/*
* NOTE: The data and end instructions are currently implemented client-side
* only, and allocation of resources must ALWAYS be server-side.
*
* Each resource is mono-directional. Two resources must be allocated for
* bidirectional communication.
*
* Exposure of client-side resources to the server will be accomplished
* over the same protocol (resource -> accept/reject -> data -> end). The
* mono-directional nature of resources will allow the index spaces of
* client and server resources to be independent.
*/
/**
* The flag set in the mouse button mask when the left mouse button is down.
*/
@ -557,6 +572,14 @@ void guac_client_free_buffer(guac_client* client, guac_layer* layer);
*/
void guac_client_free_layer(guac_client* client, guac_layer* layer);
/**
* Allocates a new resource. An arbitrary index is automatically assigned
* if no existing resource index is available for use.
*
* @param client The proxy client to allocate the resource for.
* @return The next available resource, or a newly allocated resource.
*/
guac_resource* guac_client_alloc_resource(guac_client* client);
/**
* Logs an informational message in the log used by the given client. The

View File

@ -177,9 +177,9 @@ typedef enum guac_line_join_style {
typedef struct guac_resource {
/**
* The UUID of this resource.
* The index of this resource.
*/
const char* uuid;
int index;
/**
* Arbitrary data associated with this resource.
@ -315,20 +315,6 @@ guac_timestamp guac_protocol_get_timestamp();
/* CONTROL INSTRUCTIONS */
/**
* Sends an accept instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param uuid The UUID of the resource that is being accepted.
* @param mimetype The mimetype being accepted.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_accept(guac_socket* socket, const char* uuid,
const char* mimetype);
/**
* Sends an args instruction over the given guac_socket connection.
*
@ -353,6 +339,20 @@ int guac_protocol_send_args(guac_socket* socket, const char** args);
*/
int guac_protocol_send_connect(guac_socket* socket, const char** args);
/**
* Sends a data instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param resource The resource associated with the data being sent.
* @param data The data to send.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_data(guac_socket* socket, guac_resource* resource,
const unsigned char* data);
/**
* Sends a disconnect instruction over the given guac_socket connection.
*
@ -364,6 +364,18 @@ int guac_protocol_send_connect(guac_socket* socket, const char** args);
*/
int guac_protocol_send_disconnect(guac_socket* socket);
/**
* Sends an end instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param resource The resource being closed.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_end(guac_socket* socket, guac_resource* resource);
/**
* Sends an error instruction over the given guac_socket connection.
*
@ -376,18 +388,6 @@ int guac_protocol_send_disconnect(guac_socket* socket);
*/
int guac_protocol_send_error(guac_socket* socket, const char* error);
/**
* Sends a reject instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param uuid The UUID of the resource that is being rejected.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_reject(guac_socket* socket, const char* uuid);
/**
* Sends a resource instruction over the given guac_socket connection.
*
@ -395,15 +395,14 @@ int guac_protocol_send_reject(guac_socket* socket, const char* uuid);
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param uri The destination URI that this resource should be exposed through.
* @param uuid The UUID of the resource that will be exposed.
* @param mimetypes An array of strings, where each string is an available
* mimetype.
* @param length The number of elements in the array of mimetype strings.
* @param resource The resource being exposed.
* @param uri The URI this resource should be exposed to.
* @param mimetypes A NULL-terminated array of strings, where each string is
* an available mimetype.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_resource(guac_socket* socket, const char* uri,
const char* uuid, const char** mimetypes, int length);
int guac_protocol_send_resource(guac_socket* socket, guac_resource* resource,
const char* uri, const char** mimetypes);
/**
* Sends a set instruction over the given guac_socket connection.
@ -427,7 +426,7 @@ int guac_protocol_send_set(guac_socket* socket, const guac_layer* layer,
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param protocol The protocol or resource UUID to request.
* @param protocol The protocol to request.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_select(guac_socket* socket, const char* protocol);