Define guac_resource, remove rel, use URI instead of rel.

This commit is contained in:
Michael Jumper 2012-08-24 21:37:37 -07:00
parent 376fbe64ab
commit 9e2e1e4994
2 changed files with 28 additions and 20 deletions

View File

@ -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. * 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_ROUND = 0x2
} guac_line_join_style; } 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; typedef struct guac_layer guac_layer;
/** /**
@ -198,11 +201,11 @@ struct guac_layer {
int index; 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 * a resource related to this layer. This value is automatically set
* upon allocation. * upon allocation.
*/ */
const char* rel; char* uri;
/** /**
* The next allocated layer in the list of all layers. * 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. * returned, and guac_error is set appropriately.
* *
* @param socket The guac_socket connection to use. * @param socket The guac_socket connection to use.
* @param rel What this resource is related to (see the GUAC_REL_* * @param uri The destination URI that this resource should be exposed through.
* constants).
* @param uuid The UUID of the resource that will be exposed. * @param uuid The UUID of the resource that will be exposed.
* @param mimetypes An array of strings, where each string is an available * @param mimetypes An array of strings, where each string is an available
* mimetype. * mimetype.
* @param length The number of elements in the array of mimetype strings. * @param length The number of elements in the array of mimetype strings.
* @return Zero on success, non-zero on error. * @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); const char* uuid, const char** mimetypes, int length);
/** /**

View File

@ -51,6 +51,7 @@
guac_layer __GUAC_DEFAULT_LAYER = { guac_layer __GUAC_DEFAULT_LAYER = {
.index = 0, .index = 0,
.uri = "layer://0",
.__next = NULL, .__next = NULL,
.__next_available = NULL .__next_available = NULL
}; };
@ -80,6 +81,8 @@ guac_layer* guac_client_alloc_layer(guac_client* client) {
/* Init new layer */ /* Init new layer */
allocd_layer = malloc(sizeof(guac_layer)); allocd_layer = malloc(sizeof(guac_layer));
allocd_layer->index = client->__next_layer_index++; 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 */ /* Add to __all_layers list */
allocd_layer->__next = client->__all_layers; allocd_layer->__next = client->__all_layers;
@ -114,6 +117,8 @@ guac_layer* guac_client_alloc_buffer(guac_client* client) {
/* Init new layer */ /* Init new layer */
allocd_layer = malloc(sizeof(guac_layer)); allocd_layer = malloc(sizeof(guac_layer));
allocd_layer->index = client->__next_buffer_index--; 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 */ /* Add to __all_layers list */
allocd_layer->__next = client->__all_layers; allocd_layer->__next = client->__all_layers;
@ -290,6 +295,7 @@ void guac_client_free(guac_client* client) {
client->__all_layers = layer->__next; client->__all_layers = layer->__next;
/* Free layer */ /* Free layer */
free(layer->uri);
free(layer); free(layer);
} }