/* ***** 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_CLIENT_H #define _GUAC_CLIENT_H #include "guacio.h" #include "protocol.h" /** * Provides functions and structures required for defining (and handling) a proxy client. * * @file client.h */ /** * The time to allow between sync responses in milliseconds. If a sync * instruction is sent to the client and no response is received within this * timeframe, server messages will not be handled until a sync instruction is * received from the client. */ #define GUAC_SYNC_THRESHOLD 500 /** * The time to allow between server sync messages in milliseconds. A sync * message from the server will be sent every GUAC_SYNC_FREQUENCY milliseconds. * As this will induce a response from a client that is not malfunctioning, * this is used to detect when a client has died. This must be set to a * reasonable value to avoid clients being disconnected unnecessarily due * to timeout. */ #define GUAC_SYNC_FREQUENCY 5000 /** * The amount of time to wait after handling server messages. If a client * plugin has a message handler, and sends instructions when server messages * are being handled, there will be a pause of this many milliseconds before * the next call to the message handler. */ #define GUAC_SERVER_MESSAGE_HANDLE_FREQUENCY 50 typedef struct guac_client guac_client; /** * Handler for server messages (where "server" refers to the server that * the proxy client is connected to). */ typedef int guac_client_handle_messages(guac_client* client); /** * Handler for Guacamole mouse events. */ typedef int guac_client_mouse_handler(guac_client* client, int x, int y, int button_mask); /** * Handler for Guacamole key events. */ typedef int guac_client_key_handler(guac_client* client, int keysym, int pressed); /** * Handler for Guacamole clipboard events. */ typedef int guac_client_clipboard_handler(guac_client* client, char* copied); /** * Handler for freeing up any extra data allocated by the client * implementation. */ typedef int guac_client_free_handler(guac_client* client); /** * Possible current states of the Guacamole client. Currently, the only * two states are RUNNING and STOPPING. */ typedef enum guac_client_state { /** * The state of the client from when it has been allocated by the main * daemon until it is killed or disconnected. */ RUNNING, /** * The state of the client when a stop has been requested, signalling the * I/O threads to shutdown. */ STOPPING } guac_client_state; /** * Guacamole proxy client. * * Represents a Guacamole proxy client (the client which communicates to * a server on behalf of Guacamole, on behalf of the web-client). */ struct guac_client { /** * The GUACIO structure to be used to communicate with the web-client. It is * expected that the implementor of any Guacamole proxy client will provide * their own mechanism of I/O for their protocol. The GUACIO structure is * used only to communicate conveniently with the Guacamole web-client. */ GUACIO* io; /** * The current state of the client. When the client is first allocated, * this will be initialized to RUNNING. It will remain at RUNNING until * an event occurs which requires the client to shutdown, at which point * the state becomes STOPPING. */ guac_client_state state; /** * The time (in milliseconds) of receipt of the last sync message from * the client. */ guac_timestamp_t last_received_timestamp; /** * The time (in milliseconds) that the last sync message was sent to the * client. */ guac_timestamp_t last_sent_timestamp; /** * Reference to dlopen'd client plugin. */ void* client_plugin_handle; /** * Arbitrary reference to proxy client-specific data. Implementors of a * Guacamole proxy client can store any data they want here, which can then * be retrieved as necessary in the message handlers. */ void* data; /** * Handler for server messages. If set, this function will be called * occasionally by the Guacamole proxy to give the client a chance to * handle messages from whichever server it is connected to. * * Example: * @code * void handle_messages(guac_client* client); * * int guac_client_init(guac_client* client, int argc, char** argv) { * client->handle_messages = handle_messages; * } * @endcode */ guac_client_handle_messages* handle_messages; /** * Handler for mouse events sent by the Gaucamole web-client. * * The handler takes the integer mouse X and Y coordinates, as well as * a button mask containing the bitwise OR of all button values currently * being pressed. Those values are: * *
Button | Value |
---|---|
Left | 1 |
Middle | 2 |
Right | 4 |
Scrollwheel Up | 8 |
Scrollwheel Down | 16 |