1 #ifndef _LIBRFB_DECODER_H_ 2 #define _LIBRFB_DECODER_H_ 3 4 #include <gio/gio.h> 5 6 #include <glib.h> 7 8 G_BEGIN_DECLS 9 10 enum 11 { 12 SECURITY_FAIL = 0, 13 SECURITY_NONE, 14 SECURITY_VNC, 15 }; 16 17 #define IS_VERSION(x, ma, mi) ((x->protocol_major == ma) && (x->protocol_minor == mi)) 18 #define IS_VERSION_3_3(x) IS_VERSION(x, 3, 3) 19 #define IS_VERSION_3_7(x) IS_VERSION(x, 3, 7) 20 #define IS_VERSION_3_8(x) IS_VERSION(x, 3, 8) 21 22 #define MESSAGE_TYPE_FRAMEBUFFER_UPDATE 0 23 24 #define ENCODING_TYPE_RAW 0 25 #define ENCODING_TYPE_COPYRECT 1 26 #define ENCODING_TYPE_RRE 2 27 #define ENCODING_TYPE_CORRE 4 28 #define ENCODING_TYPE_HEXTILE 5 29 30 #define SUBENCODING_RAW 1 31 #define SUBENCODING_BACKGROUND 2 32 #define SUBENCODING_FOREGROUND 4 33 #define SUBENCODING_ANYSUBRECTS 8 34 #define SUBENCODING_SUBRECTSCOLORED 16 35 36 typedef struct _RfbDecoder RfbDecoder; 37 38 struct _RfbDecoder 39 { 40 /* callbacks */ 41 gboolean (*state) (RfbDecoder * decoder); 42 43 gpointer buffer_handler_data; 44 45 GSocketClient *socket_client; 46 GSocketConnection *connection; 47 GCancellable *cancellable; 48 49 guint8 *data; 50 guint32 data_len; 51 gpointer decoder_private; 52 guint8 *frame; 53 guint8 *prev_frame; 54 55 GError *error; 56 57 /* settable properties */ 58 gboolean shared_flag; 59 60 /* readable properties */ 61 gboolean inited; 62 63 guint protocol_major; 64 guint protocol_minor; 65 guint security_type; 66 67 gchar *password; 68 gboolean use_copyrect; 69 70 guint width; 71 guint height; 72 guint bpp; 73 guint depth; 74 gboolean big_endian; 75 gboolean true_colour; 76 guint red_max; 77 guint green_max; 78 guint blue_max; 79 guint red_shift; 80 guint green_shift; 81 guint blue_shift; 82 83 gchar *name; 84 85 /* information if we don't want to update the whole screen */ 86 guint offset_x; 87 guint offset_y; 88 guint rect_width; 89 guint rect_height; 90 91 gint n_rects; 92 93 /* some many used values */ 94 guint bytespp; 95 guint line_size; 96 97 /* Seriliaze writes operations */ 98 GMutex write_lock; 99 }; 100 101 RfbDecoder *rfb_decoder_new (void); 102 void rfb_decoder_free (RfbDecoder * decoder); 103 gboolean rfb_decoder_connect_tcp (RfbDecoder * decoder, 104 gchar * host, guint port); 105 void rfb_decoder_disconnect (RfbDecoder * decoder); 106 gboolean rfb_decoder_iterate (RfbDecoder * decoder); 107 void rfb_decoder_send_update_request (RfbDecoder * decoder, 108 gboolean incremental, gint x, gint y, gint width, gint height); 109 void rfb_decoder_send_key_event (RfbDecoder * decoder, 110 guint key, gboolean down_flag); 111 void rfb_decoder_send_pointer_event (RfbDecoder * decoder, 112 gint button_mask, gint x, gint y); 113 114 G_END_DECLS 115 #endif 116