From f8fdc3f35ad7ca1d85bca0af31bd64f100e760a5 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 3 Sep 2012 17:54:30 -0700 Subject: [PATCH] Refactor guac_resource functions into resource.h --- libguac/include/client.h | 47 ---------------- libguac/include/protocol.h | 18 ------ libguac/include/resource.h | 110 +++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 65 deletions(-) create mode 100644 libguac/include/resource.h diff --git a/libguac/include/client.h b/libguac/include/client.h index e6abd1cc..9dc650f1 100644 --- a/libguac/include/client.h +++ b/libguac/include/client.h @@ -122,33 +122,6 @@ 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 has been accepted by the - * client. - */ -typedef int guac_client_accept_handler(guac_client* client, - guac_resource* resource, const char* mimetype); - -/** - * Handler which will be called whenever a resource has been rejected by the - * 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. */ @@ -572,26 +545,6 @@ 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); - -/** - * Frees an existing resource, re-adding it to the client's resource - * pool, such that it can be reused by a subsequent call to - * guac_client_alloc_resource(). - * - * @param client The proxy client to free the resource for. - * @oaran resource The resource to return to the resource pool. - */ -void guac_client_free_resource(guac_client* client, guac_resource* resource); - - /** * Logs an informational message in the log used by the given client. The * logger used will normally be defined by guacd (or whichever program loads diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index 3ad1dc63..6d77107d 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -170,24 +170,6 @@ 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 index of this resource. - */ - int index; - - /** - * Arbitrary data associated with this resource. - */ - void* data; - -} guac_resource; - typedef struct guac_layer guac_layer; /** diff --git a/libguac/include/resource.h b/libguac/include/resource.h new file mode 100644 index 00000000..eda0e204 --- /dev/null +++ b/libguac/include/resource.h @@ -0,0 +1,110 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +#ifndef _GUAC_RESOURCE_H +#define _GUAC_RESOURCE_H + +#include "client.h" + +/** + * Provides functions and structures required for handling resources. + * + * 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. + * + * @file resource.h + */ + +/** + * Represents a single resource which can be requested or exposed via + * the Guacamole protocol. + */ +typedef struct guac_resource { + + /** + * The index of this resource. + */ + int index; + + /** + * Arbitrary data associated with this resource. + */ + void* data; + +} guac_resource; + +/** + * Handler which will be called whenever a resource has been accepted by the + * client. + */ +typedef int guac_resource_accept_handler(guac_resource* resource, const char* mimetype); + +/** + * Handler which will be called whenever a resource has been rejected by the + * client. + */ +typedef int guac_resource_reject_handler(guac_resource* resource); + +/** + * 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); + +/** + * Frees an existing resource, re-adding it to the client's resource + * pool, such that it can be reused by a subsequent call to + * guac_client_alloc_resource(). + * + * @param client The proxy client to free the resource for. + * @oaran resource The resource to return to the resource pool. + */ +void guac_client_free_resource(guac_client* client, guac_resource* resource); + +#endif