libguac
0.5.0
|
00001 00002 /* ***** BEGIN LICENSE BLOCK ***** 00003 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00004 * 00005 * The contents of this file are subject to the Mozilla Public License Version 00006 * 1.1 (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * http://www.mozilla.org/MPL/ 00009 * 00010 * Software distributed under the License is distributed on an "AS IS" basis, 00011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 * for the specific language governing rights and limitations under the 00013 * License. 00014 * 00015 * The Original Code is libguac. 00016 * 00017 * The Initial Developer of the Original Code is 00018 * Michael Jumper. 00019 * Portions created by the Initial Developer are Copyright (C) 2010 00020 * the Initial Developer. All Rights Reserved. 00021 * 00022 * Contributor(s): 00023 * 00024 * Alternatively, the contents of this file may be used under the terms of 00025 * either the GNU General Public License Version 2 or later (the "GPL"), or 00026 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00027 * in which case the provisions of the GPL or the LGPL are applicable instead 00028 * of those above. If you wish to allow use of your version of this file only 00029 * under the terms of either the GPL or the LGPL, and not to allow others to 00030 * use your version of this file under the terms of the MPL, indicate your 00031 * decision by deleting the provisions above and replace them with the notice 00032 * and other provisions required by the GPL or the LGPL. If you do not delete 00033 * the provisions above, a recipient may use your version of this file under 00034 * the terms of any one of the MPL, the GPL or the LGPL. 00035 * 00036 * ***** END LICENSE BLOCK ***** */ 00037 00038 00039 #ifndef _GUAC_CLIENT_H 00040 #define _GUAC_CLIENT_H 00041 00042 #include <stdarg.h> 00043 00044 #include "socket.h" 00045 #include "protocol.h" 00046 00053 typedef struct guac_client guac_client; 00054 typedef struct guac_client_plugin guac_client_plugin; 00055 00060 typedef int guac_client_handle_messages(guac_client* client); 00061 00065 typedef int guac_client_mouse_handler(guac_client* client, int x, int y, int button_mask); 00066 00070 typedef int guac_client_key_handler(guac_client* client, int keysym, int pressed); 00071 00075 typedef int guac_client_clipboard_handler(guac_client* client, char* copied); 00076 00081 typedef int guac_client_free_handler(guac_client* client); 00082 00086 typedef void guac_client_log_handler(guac_client* client, const char* format, va_list args); 00087 00091 typedef int guac_client_init_handler(guac_client* client, int argc, char** argv); 00092 00096 #define GUAC_CLIENT_MOUSE_LEFT 0x01 00097 00101 #define GUAC_CLIENT_MOUSE_MIDDLE 0x02 00102 00106 #define GUAC_CLIENT_MOUSE_RIGHT 0x04 00107 00115 #define GUAC_CLIENT_MOUSE_SCROLL_UP 0x08 00116 00124 #define GUAC_CLIENT_MOUSE_SCROLL_DOWN 0x10 00125 00132 #define GUAC_BUFFER_POOL_INITIAL_SIZE 1024 00133 00138 typedef enum guac_client_state { 00139 00144 GUAC_CLIENT_RUNNING, 00145 00150 GUAC_CLIENT_STOPPING 00151 00152 } guac_client_state; 00153 00159 struct guac_client_plugin { 00160 00164 void* __client_plugin_handle; 00165 00170 guac_client_init_handler* init_handler; 00171 00177 const char** args; 00178 00179 }; 00180 00187 struct guac_client { 00188 00196 guac_socket* socket; 00197 00204 guac_client_state state; 00205 00210 guac_timestamp last_received_timestamp; 00211 00216 guac_timestamp last_sent_timestamp; 00217 00223 void* data; 00224 00239 guac_client_handle_messages* handle_messages; 00240 00266 guac_client_mouse_handler* mouse_handler; 00267 00284 guac_client_key_handler* key_handler; 00285 00305 guac_client_clipboard_handler* clipboard_handler; 00306 00328 guac_client_free_handler* free_handler; 00329 00352 guac_client_log_handler* log_info_handler; 00353 00354 00377 guac_client_log_handler* log_error_handler; 00378 00382 int __next_buffer_index; 00383 00388 guac_layer* __available_buffers; 00389 00393 guac_layer* __last_available_buffer; 00394 00398 int __next_layer_index; 00399 00404 guac_layer* __available_layers; 00405 00409 guac_layer* __last_available_layer; 00410 00415 guac_layer* __all_layers; 00416 00417 }; 00418 00428 guac_client_plugin* guac_client_plugin_open(const char* protocol); 00429 00438 int guac_client_plugin_close(guac_client_plugin* plugin); 00439 00454 guac_client* guac_client_plugin_get_client(guac_client_plugin* plugin, 00455 guac_socket* socket, int argc, char** argv, 00456 guac_client_log_handler* log_info_handler, 00457 guac_client_log_handler* log_error_handler); 00458 00464 void guac_client_free(guac_client* client); 00465 00476 int guac_client_handle_instruction(guac_client* client, guac_instruction* instruction); 00477 00485 guac_layer* guac_client_alloc_buffer(guac_client* client); 00486 00494 guac_layer* guac_client_alloc_layer(guac_client* client); 00495 00503 void guac_client_free_buffer(guac_client* client, guac_layer* layer); 00504 00512 void guac_client_free_layer(guac_client* client, guac_layer* layer); 00513 00514 00525 void guac_client_log_info(guac_client* client, const char* format, ...); 00526 00537 void guac_client_log_error(guac_client* client, const char* format, ...); 00538 00550 void vguac_client_log_info(guac_client* client, const char* format, va_list ap); 00551 00563 void vguac_client_log_error(guac_client* client, const char* format, va_list ap); 00564 00572 void guac_client_stop(guac_client* client); 00573 00577 extern const guac_layer* GUAC_DEFAULT_LAYER; 00578 00579 #endif