libguac  0.7.0
client.h
Go to the documentation of this file.
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 "instruction.h"
00045 #include "layer.h"
00046 #include "pool.h"
00047 #include "socket.h"
00048 #include "stream.h"
00049 #include "timestamp.h"
00050 
00057 typedef struct guac_client guac_client;
00058 
00063 typedef int guac_client_handle_messages(guac_client* client);
00064 
00068 typedef int guac_client_mouse_handler(guac_client* client, int x, int y, int button_mask);
00069 
00073 typedef int guac_client_key_handler(guac_client* client, int keysym, int pressed);
00074 
00078 typedef int guac_client_clipboard_handler(guac_client* client, char* copied);
00079 
00083 typedef int guac_client_size_handler(guac_client* client,
00084         int width, int height);
00085 
00089 typedef int guac_client_audio_handler(guac_client* client, char* mimetype);
00090 
00094 typedef int guac_client_video_handler(guac_client* client, char* mimetype);
00095 
00100 typedef int guac_client_free_handler(guac_client* client);
00101 
00105 typedef void guac_client_log_handler(guac_client* client, const char* format, va_list args); 
00106 
00110 typedef int guac_client_init_handler(guac_client* client, int argc, char** argv);
00111 
00115 #define GUAC_CLIENT_MOUSE_LEFT        0x01
00116 
00120 #define GUAC_CLIENT_MOUSE_MIDDLE      0x02
00121 
00125 #define GUAC_CLIENT_MOUSE_RIGHT       0x04
00126 
00134 #define GUAC_CLIENT_MOUSE_SCROLL_UP   0x08
00135 
00143 #define GUAC_CLIENT_MOUSE_SCROLL_DOWN 0x10
00144 
00151 #define GUAC_BUFFER_POOL_INITIAL_SIZE 1024
00152 
00157 typedef enum guac_client_state {
00158 
00163     GUAC_CLIENT_RUNNING,
00164 
00169     GUAC_CLIENT_STOPPING
00170 
00171 } guac_client_state;
00172 
00177 typedef struct guac_client_info {
00178 
00185     int optimal_width;
00186 
00193     int optimal_height;
00194 
00199     const char** audio_mimetypes;
00200 
00205     const char** video_mimetypes;
00206 
00207 } guac_client_info;
00208 
00215 struct guac_client {
00216 
00224     guac_socket* socket;
00225 
00232     guac_client_state state;
00233 
00238     guac_timestamp last_received_timestamp;
00239 
00244     guac_timestamp last_sent_timestamp;
00245 
00250     guac_client_info info;
00251 
00257     void* data;
00258 
00273     guac_client_handle_messages* handle_messages;
00274 
00300     guac_client_mouse_handler* mouse_handler;
00301 
00318     guac_client_key_handler* key_handler;
00319 
00339     guac_client_clipboard_handler* clipboard_handler;
00340 
00356     guac_client_size_handler* size_handler;
00357 
00379     guac_client_free_handler* free_handler;
00380 
00403     guac_client_log_handler* log_info_handler;
00404 
00405 
00428     guac_client_log_handler* log_error_handler;
00429 
00435     guac_pool* __buffer_pool;
00436 
00442     guac_pool* __layer_pool;
00443 
00447     guac_pool* __stream_pool;
00448 
00449 };
00450 
00457 guac_client* guac_client_alloc();
00458 
00464 void guac_client_free(guac_client* client);
00465 
00476 int guac_client_handle_instruction(guac_client* client, guac_instruction* instruction);
00477 
00488 void guac_client_log_info(guac_client* client, const char* format, ...);
00489 
00500 void guac_client_log_error(guac_client* client, const char* format, ...);
00501 
00513 void vguac_client_log_info(guac_client* client, const char* format, va_list ap);
00514 
00526 void vguac_client_log_error(guac_client* client, const char* format, va_list ap);
00527 
00535 void guac_client_stop(guac_client* client);
00536 
00544 guac_layer* guac_client_alloc_buffer(guac_client* client);
00545 
00553 guac_layer* guac_client_alloc_layer(guac_client* client);
00554 
00562 void guac_client_free_buffer(guac_client* client, guac_layer* layer);
00563 
00571 void guac_client_free_layer(guac_client* client, guac_layer* layer);
00572 
00580 guac_stream* guac_client_alloc_stream(guac_client* client);
00581 
00589 void guac_client_free_stream(guac_client* client, guac_stream* stream);
00590 
00591 
00595 extern const guac_layer* GUAC_DEFAULT_LAYER;
00596 
00597 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines