From 9e2e1e4994fea9a7c0eade9f6fe8692a30c80b7e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 24 Aug 2012 21:37:37 -0700 Subject: [PATCH] Define guac_resource, remove rel, use URI instead of rel. --- libguac/include/protocol.h | 42 ++++++++++++++++++++------------------ libguac/src/client.c | 6 ++++++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index df09fb17..df49a2a5 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -51,21 +51,6 @@ */ -/** - * Annotates a resource related to printing. - */ -#define GUAC_REL_PRINTER "printer" - -/** - * Annotates a resource related to file transfer. - */ -#define GUAC_REL_FILE "file" - -/** - * Annotates a resource related to audio. - */ -#define GUAC_REL_AUDIO "audio" - /** * An arbitrary timestamp denoting a relative time value in milliseconds. */ @@ -185,6 +170,24 @@ typedef enum guac_line_join_style { GUAC_LINE_JOIN_ROUND = 0x2 } guac_line_join_style; +/** + * Represents a single resource which can be requested or exposed via + * the Guacamole protocol. + */ +typedef struct guac_resource { + + /** + * The UUID of this resource. + */ + const char* uuid; + + /** + * Arbitrary data associated with this resource. + */ + void* data; + +} guac_resource; + typedef struct guac_layer guac_layer; /** @@ -198,11 +201,11 @@ struct guac_layer { int index; /** - * The string which must be passed via a resource instruction to denote + * The URI which must be passed via a resource instruction to denote * a resource related to this layer. This value is automatically set * upon allocation. */ - const char* rel; + char* uri; /** * The next allocated layer in the list of all layers. @@ -392,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 rel What this resource is related to (see the GUAC_REL_* - * constants). + * @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. * @return Zero on success, non-zero on error. */ -int guac_protocol_send_resource(guac_socket* socket, const char* rel, +int guac_protocol_send_resource(guac_socket* socket, const char* uri, const char* uuid, const char** mimetypes, int length); /** diff --git a/libguac/src/client.c b/libguac/src/client.c index 63ed56a5..3a685ec4 100644 --- a/libguac/src/client.c +++ b/libguac/src/client.c @@ -51,6 +51,7 @@ guac_layer __GUAC_DEFAULT_LAYER = { .index = 0, + .uri = "layer://0", .__next = NULL, .__next_available = NULL }; @@ -80,6 +81,8 @@ guac_layer* guac_client_alloc_layer(guac_client* client) { /* Init new layer */ allocd_layer = malloc(sizeof(guac_layer)); allocd_layer->index = client->__next_layer_index++; + allocd_layer->uri = malloc(64); + snprintf(allocd_layer->uri, 64, "layer://%i", allocd_layer->index); /* Add to __all_layers list */ allocd_layer->__next = client->__all_layers; @@ -114,6 +117,8 @@ guac_layer* guac_client_alloc_buffer(guac_client* client) { /* Init new layer */ allocd_layer = malloc(sizeof(guac_layer)); allocd_layer->index = client->__next_buffer_index--; + allocd_layer->uri = malloc(64); + snprintf(allocd_layer->uri, 64, "layer://%i", allocd_layer->index); /* Add to __all_layers list */ allocd_layer->__next = client->__all_layers; @@ -290,6 +295,7 @@ void guac_client_free(guac_client* client) { client->__all_layers = layer->__next; /* Free layer */ + free(layer->uri); free(layer); }