00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
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
00056 #define GUAC_PROTOCOL_LIBRARY_PREFIX "libguac-client-"
00057
00061 #define GUAC_PROTOCOL_LIBRARY_SUFFIX ".so"
00062
00067 #define GUAC_PROTOCOL_NAME_LIMIT 256
00068
00075 #define GUAC_PROTOCOL_LIBRARY_LIMIT ( \
00076 \
00077 sizeof(GUAC_PROTOCOL_LIBRARY_PREFIX) - 1 \
00078 + GUAC_PROTOCOL_NAME_LIMIT - 1 \
00079 + sizeof(GUAC_PROTOCOL_LIBRARY_SUFFIX) - 1 \
00080 + 1 \
00081 \
00082 )
00083
00084
00085 typedef struct guac_client guac_client;
00086 typedef struct guac_client_plugin guac_client_plugin;
00087
00092 typedef int guac_client_handle_messages(guac_client* client);
00093
00097 typedef int guac_client_mouse_handler(guac_client* client, int x, int y, int button_mask);
00098
00102 typedef int guac_client_key_handler(guac_client* client, int keysym, int pressed);
00103
00107 typedef int guac_client_clipboard_handler(guac_client* client, char* copied);
00108
00113 typedef int guac_client_free_handler(guac_client* client);
00114
00118 typedef void guac_client_log_handler(guac_client* client, const char* format, va_list args);
00119
00123 typedef int guac_client_init_handler(guac_client* client, int argc, char** argv);
00124
00128 #define GUAC_CLIENT_MOUSE_LEFT 0x01
00129
00133 #define GUAC_CLIENT_MOUSE_MIDDLE 0x02
00134
00138 #define GUAC_CLIENT_MOUSE_RIGHT 0x04
00139
00147 #define GUAC_CLIENT_MOUSE_SCROLL_UP 0x08
00148
00156 #define GUAC_CLIENT_MOUSE_SCROLL_DOWN 0x10
00157
00164 #define GUAC_BUFFER_POOL_INITIAL_SIZE 1024
00165
00170 typedef enum guac_client_state {
00171
00176 GUAC_CLIENT_RUNNING,
00177
00182 GUAC_CLIENT_STOPPING
00183
00184 } guac_client_state;
00185
00191 struct guac_client_plugin {
00192
00196 void* __client_plugin_handle;
00197
00202 guac_client_init_handler* init_handler;
00203
00209 const char** args;
00210
00211 };
00212
00219 struct guac_client {
00220
00228 guac_socket* socket;
00229
00236 guac_client_state state;
00237
00242 guac_timestamp last_received_timestamp;
00243
00248 guac_timestamp last_sent_timestamp;
00249
00255 void* data;
00256
00271 guac_client_handle_messages* handle_messages;
00272
00298 guac_client_mouse_handler* mouse_handler;
00299
00316 guac_client_key_handler* key_handler;
00317
00337 guac_client_clipboard_handler* clipboard_handler;
00338
00360 guac_client_free_handler* free_handler;
00361
00384 guac_client_log_handler* log_info_handler;
00385
00386
00409 guac_client_log_handler* log_error_handler;
00410
00414 int __next_buffer_index;
00415
00420 guac_layer* __available_buffers;
00421
00425 guac_layer* __last_available_buffer;
00426
00430 int __next_layer_index;
00431
00436 guac_layer* __available_layers;
00437
00441 guac_layer* __last_available_layer;
00442
00447 guac_layer* __all_layers;
00448
00449 };
00450
00460 guac_client_plugin* guac_client_plugin_open(const char* protocol);
00461
00470 int guac_client_plugin_close(guac_client_plugin* plugin);
00471
00486 guac_client* guac_client_plugin_get_client(guac_client_plugin* plugin,
00487 guac_socket* socket, int argc, char** argv,
00488 guac_client_log_handler* log_info_handler,
00489 guac_client_log_handler* log_error_handler);
00490
00496 void guac_client_free(guac_client* client);
00497
00508 int guac_client_handle_instruction(guac_client* client, guac_instruction* instruction);
00509
00517 guac_layer* guac_client_alloc_buffer(guac_client* client);
00518
00526 guac_layer* guac_client_alloc_layer(guac_client* client);
00527
00535 void guac_client_free_buffer(guac_client* client, guac_layer* layer);
00536
00544 void guac_client_free_layer(guac_client* client, guac_layer* layer);
00545
00546
00557 void guac_client_log_info(guac_client* client, const char* format, ...);
00558
00569 void guac_client_log_error(guac_client* client, const char* format, ...);
00570
00582 void vguac_client_log_info(guac_client* client, const char* format, va_list ap);
00583
00595 void vguac_client_log_error(guac_client* client, const char* format, va_list ap);
00596
00604 void guac_client_stop(guac_client* client);
00605
00609 extern const guac_layer* GUAC_DEFAULT_LAYER;
00610
00611 #endif