diff --git a/protocols/rdp/Makefile.am b/protocols/rdp/Makefile.am index 109d801c..c4e42dc4 100644 --- a/protocols/rdp/Makefile.am +++ b/protocols/rdp/Makefile.am @@ -41,7 +41,7 @@ AM_CFLAGS = -Werror -Wall -pedantic -Iinclude lib_LTLIBRARIES = libguac-client-rdp.la -libguac_client_rdp_la_SOURCES = src/rdp_client.c src/rdp_handlers.c src/rdp_keymap.c +libguac_client_rdp_la_SOURCES = src/client.c src/rdp_handlers.c src/rdp_keymap.c libguac_client_rdp_la_LDFLAGS = -version-info 0:0:0 diff --git a/protocols/rdp/configure.in b/protocols/rdp/configure.in index 076567fd..48d1c20c 100644 --- a/protocols/rdp/configure.in +++ b/protocols/rdp/configure.in @@ -34,7 +34,7 @@ # # ***** END LICENSE BLOCK ***** -AC_INIT(src/rdp_client.c) +AC_INIT(src/client.c) AM_INIT_AUTOMAKE([libguac-client-rdp], 0.5.0) AC_CONFIG_MACRO_DIR([m4]) @@ -47,7 +47,7 @@ AC_PROG_LIBTOOL AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first")) AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([freerdp-core], [freerdp_new],, AC_MSG_ERROR("libfreerdp is required")) -AC_CHECK_LIB([freerdp-chanman], [freerdp_chanman_new],, AC_MSG_ERROR("libfreerdp is required")) +AC_CHECK_LIB([freerdp-channels], [freerdp_channels_new],, AC_MSG_ERROR("libfreerdp is required")) # Checks for header files. AC_CHECK_HEADERS([guacamole/client.h guacamole/guacio.h guacamole/protocol.h]) diff --git a/protocols/rdp/include/rdp_client.h b/protocols/rdp/include/client.h similarity index 82% rename from protocols/rdp/include/rdp_client.h rename to protocols/rdp/include/client.h index be0dc8d2..42a0a177 100644 --- a/protocols/rdp/include/rdp_client.h +++ b/protocols/rdp/include/client.h @@ -35,15 +35,14 @@ * * ***** END LICENSE BLOCK ***** */ -#ifndef _GUAC_CLIENT_RDP_CLIENT -#define _GUAC_CLIENT_RDP_CLIENT +#ifndef _GUAC_RDP_CLIENT_H +#define _GUAC_RDP_CLIENT_H #include -#include +#include #include - #define RDP_DEFAULT_PORT 3389 typedef struct guac_rdp_color { @@ -54,9 +53,9 @@ typedef struct guac_rdp_color { typedef struct rdp_guac_client_data { - rdpInst* rdp_inst; - rdpChanMan* chanman; - rdpSet* settings; + freerdp* rdp_inst; + rdpChannels* channels; + rdpSettings* settings; int mouse_button_mask; @@ -67,10 +66,13 @@ typedef struct rdp_guac_client_data { } rdp_guac_client_data; -int rdp_guac_client_free_handler(guac_client* client); -int rdp_guac_client_handle_messages(guac_client* client); -int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask); -int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed); +typedef struct rdp_freerdp_context { + + rdpContext _p; + + guac_client* client; + +} rdp_freerdp_context; #endif diff --git a/protocols/rdp/include/guac_handlers.h b/protocols/rdp/include/guac_handlers.h new file mode 100644 index 00000000..e7914fac --- /dev/null +++ b/protocols/rdp/include/guac_handlers.h @@ -0,0 +1,49 @@ + +/* ***** 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-client-rdp. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * 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_RDP_GUAC_HANDLERS_H +#define _GUAC_RDP_GUAC_HANDLERS_H + +#include + +int rdp_guac_client_free_handler(guac_client* client); +int rdp_guac_client_handle_messages(guac_client* client); +int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask); +int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed); + +#endif + diff --git a/protocols/rdp/include/rdp_handlers.h b/protocols/rdp/include/rdp_handlers.h index 3b78392b..67cb27ef 100644 --- a/protocols/rdp/include/rdp_handlers.h +++ b/protocols/rdp/include/rdp_handlers.h @@ -35,56 +35,48 @@ * * ***** END LICENSE BLOCK ***** */ -#ifndef _GUAC_CLIENT_RDP_HANDLERS -#define _GUAC_CLIENT_RDP_HANDLERS +#ifndef _GUAC_RDP_RDP_HANDLERS_H +#define _GUAC_RDP_RDP_HANDLERS_H #include +#include -void guac_rdp_ui_error(rdpInst* inst, const char* text); -void guac_rdp_ui_warning(rdpInst* inst, const char* text); -void guac_rdp_ui_unimpl(rdpInst* inst, const char* text); -void guac_rdp_ui_begin_update(rdpInst* inst); -void guac_rdp_ui_end_update(rdpInst* inst); -void guac_rdp_ui_desktop_save(rdpInst* inst, int offset, int x, int y, int cx, int cy); -void guac_rdp_ui_desktop_restore(rdpInst* inst, int offset, int x, int y, int cx, int cy); -RD_HBITMAP guac_rdp_ui_create_bitmap(rdpInst* inst, int width, int height, uint8* data); -void guac_rdp_ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int width, int height, uint8* data); -void guac_rdp_ui_destroy_bitmap(rdpInst* inst, RD_HBITMAP bmp); -void guac_rdp_ui_line(rdpInst* inst, uint8 opcode, int startx, int starty, int endx, int endy, RD_PEN* pen); -void guac_rdp_ui_rect(rdpInst* inst, int x, int y, int cx, int cy, uint32 colour); -void guac_rdp_ui_polygon(rdpInst* inst, uint8 opcode, uint8 fillmode, RD_POINT* point, int npoints, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor); -void guac_rdp_ui_polyline(rdpInst* inst, uint8 opcode, RD_POINT* points, int npoints, RD_PEN* pen); -void guac_rdp_ui_ellipse(rdpInst* inst, uint8 opcode, uint8 fillmode, int x, int y, int cx, int cy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor); -void guac_rdp_ui_start_draw_glyphs(rdpInst* inst, uint32 bgcolor, uint32 fgcolor); -void guac_rdp_ui_draw_glyph(rdpInst* inst, int x, int y, int cx, int cy, RD_HGLYPH glyph); -void guac_rdp_ui_end_draw_glyphs(rdpInst* inst, int x, int y, int cx, int cy); -uint32 guac_rdp_ui_get_toggle_keys_state(rdpInst* inst); -void guac_rdp_ui_bell(rdpInst* inst); -void guac_rdp_ui_destblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy); -void guac_rdp_ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor); -void guac_rdp_ui_screenblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy); -void guac_rdp_ui_memblt(rdpInst* inst, uint8 opcode, int x, int y, int width, int height, RD_HBITMAP src, int srcx, int srcy); -void guac_rdp_ui_triblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy, RD_HBITMAP src, int srcx, int srcy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor); -RD_HGLYPH guac_rdp_ui_create_glyph(rdpInst* inst, int width, int height, uint8* data); -void guac_rdp_ui_destroy_glyph(rdpInst* inst, RD_HGLYPH glyph); -int guac_rdp_ui_select(rdpInst* inst, int rdp_socket); -void guac_rdp_ui_set_clip(rdpInst* inst, int x, int y, int cx, int cy); -void guac_rdp_ui_reset_clip(rdpInst* inst); -void guac_rdp_ui_resize_window(rdpInst* inst); -void guac_rdp_ui_set_cursor(rdpInst* inst, RD_HCURSOR cursor); -void guac_rdp_ui_destroy_cursor(rdpInst* inst, RD_HCURSOR cursor); -RD_HCURSOR guac_rdp_ui_create_cursor(rdpInst* inst, unsigned int x, unsigned int y, int width, int height, uint8* andmask, uint8* xormask, int bpp); -void guac_rdp_ui_set_null_cursor(rdpInst* inst); -void guac_rdp_ui_set_default_cursor(rdpInst* inst); -void guac_rdp_ui_move_pointer(rdpInst* inst, int x, int y); -RD_HBITMAP guac_rdp_ui_create_surface(rdpInst* inst, int width, int height, RD_HBITMAP old); -void guac_rdp_ui_set_surface(rdpInst* inst, RD_HBITMAP surface); -void guac_rdp_ui_destroy_surface(rdpInst* inst, RD_HBITMAP surface); -void guac_rdp_ui_channel_data(rdpInst* inst, int chan_id, char* data, int data_size, int flags, int total_size); -RD_HPALETTE guac_rdp_ui_create_palette(rdpInst* inst, RD_PALETTE* colours); -void guac_rdp_ui_set_palette(rdpInst* inst, RD_HPALETTE map); +int guac_rdp_ui_select(freerdp* inst, int rdp_socket); -extern const int guac_rdp_letter_scancodes[]; +void guac_rdp_ui_resize_window(freerdp* inst); + +void guac_rdp_ui_move_pointer(freerdp* inst, int x, int y); + +void guac_rdp_ui_set_clip(freerdp* inst, int x, int y, int cx, int cy); +void guac_rdp_ui_reset_clip(freerdp* inst); + +void guac_rdp_ui_rect(freerdp* inst, int x, int y, int cx, int cy, uint32 colour); + +rdpBitmap* guac_rdp_ui_create_bitmap(freerdp* inst, int width, int height, uint8* data); +void guac_rdp_ui_paint_bitmap(freerdp* inst, int x, int y, int cx, int cy, int width, int height, uint8* data); +void guac_rdp_ui_destroy_bitmap(freerdp* inst, rdpBitmap* bmp); + +void guac_rdp_ui_destblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy); +void guac_rdp_ui_patblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy, rdpBrush* brush, uint32 bgcolor, uint32 fgcolor); +void guac_rdp_ui_screenblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy); +void guac_rdp_ui_memblt(freerdp* inst, uint8 opcode, int x, int y, int width, int height, rdpBitmap* src, int srcx, int srcy); +void guac_rdp_ui_triblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy, rdpBitmap* src, int srcx, int srcy, rdpBrush* brush, uint32 bgcolor, uint32 fgcolor); + +void guac_rdp_ui_start_draw_glyphs(freerdp* inst, uint32 bgcolor, uint32 fgcolor); +void guac_rdp_ui_draw_glyph(freerdp* inst, int x, int y, int cx, int cy, rdpGlyph* glyph); +void guac_rdp_ui_end_draw_glyphs(freerdp* inst, int x, int y, int cx, int cy); +rdpGlyph* guac_rdp_ui_create_glyph(freerdp* inst, int width, int height, uint8* data); +void guac_rdp_ui_destroy_glyph(freerdp* inst, rdpGlyph* glyph); + +void guac_rdp_ui_set_pointer(freerdp* inst, rdpPointer pointer); +void guac_rdp_ui_destroy_pointer(freerdp* inst, rdpPointer pointer); +rdpPointer guac_rdp_ui_create_pointer(freerdp* inst, unsigned int x, unsigned int y, int width, int height, uint8* andmask, uint8* xormask, int bpp); +void guac_rdp_ui_set_null_pointer(freerdp* inst); +void guac_rdp_ui_set_default_pointer(freerdp* inst); + +rdpBitmap* guac_rdp_ui_create_surface(freerdp* inst, int width, int height, rdpBitmap* old); +void guac_rdp_ui_set_surface(freerdp* inst, rdpBitmap* surface); +void guac_rdp_ui_destroy_surface(freerdp* inst, rdpBitmap* surface); #endif diff --git a/protocols/rdp/include/rdp_keymap.h b/protocols/rdp/include/rdp_keymap.h index a97502ac..23c93679 100644 --- a/protocols/rdp/include/rdp_keymap.h +++ b/protocols/rdp/include/rdp_keymap.h @@ -35,8 +35,8 @@ * * ***** END LICENSE BLOCK ***** */ -#ifndef _GUAC_CLIENT_RDP_KEYMAP -#define _GUAC_CLIENT_RDP_KEYMAP +#ifndef _GUAC_RDP_RDP_KEYMAP_H +#define _GUAC_RDP_RDP_KEYMAP_H typedef struct guac_rdp_keymap { int scancode; diff --git a/protocols/rdp/src/client.c b/protocols/rdp/src/client.c new file mode 100644 index 00000000..8a71ff6b --- /dev/null +++ b/protocols/rdp/src/client.c @@ -0,0 +1,173 @@ + +/* ***** 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-client-rdp. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * 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 ***** */ + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "client.h" +#include "guac_handlers.h" +#include "rdp_handlers.h" +#include "rdp_keymap.h" + +/* Client plugin arguments */ +const char* GUAC_CLIENT_ARGS[] = { + "hostname", + "port", + NULL +}; + +void rdp_freerdp_context_new(freerdp* instance, rdpContext* context) { + /* EMPTY */ +} + +void rdp_freerdp_context_free(freerdp* instance, rdpContext* context) { + /* EMPTY */ +} + +int guac_client_init(guac_client* client, int argc, char** argv) { + + rdp_guac_client_data* guac_client_data; + + freerdp* rdp_inst; + rdpChannels* channels; + rdpSettings* settings; + + char* hostname; + int port = RDP_DEFAULT_PORT; + + if (argc < 2) { + guac_protocol_send_error(client->socket, "Wrong argument count received."); + guac_socket_flush(client->socket); + return 1; + } + + /* If port specified, use it */ + if (argv[1][0] != '\0') + port = atoi(argv[1]); + + hostname = argv[0]; + + /* Allocate client data */ + guac_client_data = malloc(sizeof(rdp_guac_client_data)); + + /* Get channel manager */ + channels = freerdp_channels_new(); + guac_client_data->channels = channels; + + /* INIT SETTINGS */ + settings = malloc(sizeof(rdpSettings)); + memset(settings, 0, sizeof(rdpSettings)); + guac_client_data->settings = settings; + + /* Set hostname */ + strncpy(settings->hostname, hostname, sizeof(settings->hostname) - 1); + + /* Default size */ + settings->width = 1024; + settings->height = 768; + + strncpy(settings->window_title, hostname, sizeof(settings->window_title)); + strcpy(settings->username, "guest"); + + /* FIXME: Set RDP settings->* */ + + /* Init client */ + rdp_inst = freerdp_new(settings); + if (rdp_inst == NULL) { + guac_protocol_send_error(client->socket, "Error initializing RDP client"); + guac_socket_flush(client->socket); + return 1; + } + guac_client_data->rdp_inst = rdp_inst; + guac_client_data->mouse_button_mask = 0; + guac_client_data->current_surface = GUAC_DEFAULT_LAYER; + + /* Allocate FreeRDP context */ + rdp_inst->context_size = sizeof(rdp_freerdp_context); + rdp_inst->ContextNew = (pContextNew) rdp_freerdp_context_new; + rdp_inst->ContextFree = (pContextFree) rdp_freerdp_context_free; + freerdp_context_new(rdp_inst); + + /* Store client data */ + ((rdp_freerdp_context*) rdp_inst->context)->client = client; + client->data = guac_client_data; + + /* FIXME: Set RDP handlers */ + + /* Init channels (pre-connect) */ + if (freerdp_channels_pre_connect(channels, rdp_inst)) { + guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager"); + guac_socket_flush(client->socket); + return 1; + } + + /* Connect to RDP server */ + if (!freerdp_connect(rdp_inst)) { + guac_protocol_send_error(client->socket, "Error connecting to RDP server"); + guac_socket_flush(client->socket); + return 1; + } + + /* Init channels (post-connect) */ + if (freerdp_channels_post_connect(channels, rdp_inst)) { + guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager"); + guac_socket_flush(client->socket); + return 1; + } + + /* Client handlers */ + client->free_handler = rdp_guac_client_free_handler; + client->handle_messages = rdp_guac_client_handle_messages; + client->mouse_handler = rdp_guac_client_mouse_handler; + client->key_handler = rdp_guac_client_key_handler; + + /* Success */ + return 0; + +} + diff --git a/protocols/rdp/src/rdp_client.c b/protocols/rdp/src/guac_handlers.c similarity index 50% rename from protocols/rdp/src/rdp_client.c rename to protocols/rdp/src/guac_handlers.c index 33d575a4..357b5725 100644 --- a/protocols/rdp/src/rdp_client.c +++ b/protocols/rdp/src/guac_handlers.c @@ -42,24 +42,17 @@ #include #include -#include -#include +#include +#include #include #include #include +#include "client.h" #include "rdp_handlers.h" -#include "rdp_client.h" #include "rdp_keymap.h" -/* Client plugin arguments */ -const char* GUAC_CLIENT_ARGS[] = { - "hostname", - "port", - NULL -}; - int rdp_guac_client_free_handler(guac_client* client) { rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; @@ -69,7 +62,7 @@ int rdp_guac_client_free_handler(guac_client* client) { /* Free RDP client */ freerdp_free(guac_client_data->rdp_inst); - freerdp_chanman_free(guac_client_data->chanman); + freerdp_channels_free(guac_client_data->channels); free(guac_client_data->settings); /* Free guac client data */ @@ -83,7 +76,7 @@ int rdp_guac_client_handle_messages(guac_client* client) { rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; rdpInst* rdp_inst = guac_client_data->rdp_inst; - rdpChanMan* chanman = guac_client_data->chanman; + rdpChannels* channels = guac_client_data->channels; int index; int max_fd, fd; @@ -101,7 +94,7 @@ int rdp_guac_client_handle_messages(guac_client* client) { } /* get channel fds */ - if (freerdp_chanman_get_fds(chanman, rdp_inst, read_fds, &read_count, write_fds, &write_count) != 0) { + if (freerdp_channels_get_fds(channels, rdp_inst, read_fds, &read_count, write_fds, &write_count) != 0) { guac_client_log_error(client, "Unable to read RDP channel file descriptors."); return 1; } @@ -151,7 +144,7 @@ int rdp_guac_client_handle_messages(guac_client* client) { } /* check channel fds */ - if (freerdp_chanman_check_fds(chanman, rdp_inst) != 0) { + if (freerdp_channels_check_fds(channels, rdp_inst) != 0) { guac_client_log_error(client, "Error handling RDP channel file descriptors."); return 1; } @@ -161,163 +154,6 @@ int rdp_guac_client_handle_messages(guac_client* client) { } -int guac_client_init(guac_client* client, int argc, char** argv) { - - rdp_guac_client_data* guac_client_data; - - rdpInst* rdp_inst; - rdpChanMan* chanman; - rdpSet* settings; - - char* hostname; - int port = RDP_DEFAULT_PORT; - - if (argc < 2) { - guac_protocol_send_error(client->socket, "Wrong argument count received."); - guac_socket_flush(client->socket); - return 1; - } - - /* If port specified, use it */ - if (argv[1][0] != '\0') - port = atoi(argv[1]); - - hostname = argv[0]; - - /* Allocate client data */ - guac_client_data = malloc(sizeof(rdp_guac_client_data)); - - /* Get channel manager */ - chanman = freerdp_chanman_new(); - guac_client_data->chanman = chanman; - - /* INIT SETTINGS */ - settings = malloc(sizeof(rdpSet)); - memset(settings, 0, sizeof(rdpSet)); - guac_client_data->settings = settings; - - /* Set hostname */ - strncpy(settings->hostname, hostname, sizeof(settings->hostname) - 1); - - /* Default size */ - settings->width = 1024; - settings->height = 768; - - strncpy(settings->server, hostname, sizeof(settings->server)); - strcpy(settings->username, "guest"); - - settings->tcp_port_rdp = port; - settings->encryption = 1; - settings->server_depth = 16; - settings->bitmap_cache = 1; - settings->bitmap_compression = 1; - settings->desktop_save = 0; - settings->performanceflags = - PERF_DISABLE_WALLPAPER - | PERF_DISABLE_FULLWINDOWDRAG - | PERF_DISABLE_MENUANIMATIONS; - settings->mouse_motion = 1; - settings->off_screen_bitmaps = 1; - settings->triblt = 0; - settings->software_gdi = 0; - settings->new_cursors = 1; - settings->rdp_version = 5; - settings->rdp_security = 1; - - /* Init client */ - rdp_inst = freerdp_new(settings); - if (rdp_inst == NULL) { - guac_protocol_send_error(client->socket, "Error initializing RDP client"); - guac_socket_flush(client->socket); - return 1; - } - guac_client_data->rdp_inst = rdp_inst; - guac_client_data->mouse_button_mask = 0; - guac_client_data->current_surface = GUAC_DEFAULT_LAYER; - - - /* Store client data */ - rdp_inst->param1 = client; - client->data = guac_client_data; - - - /* RDP handlers */ - rdp_inst->ui_error = guac_rdp_ui_error; - rdp_inst->ui_warning = guac_rdp_ui_warning; - rdp_inst->ui_unimpl = guac_rdp_ui_unimpl; - rdp_inst->ui_begin_update = guac_rdp_ui_begin_update; - rdp_inst->ui_end_update = guac_rdp_ui_end_update; - rdp_inst->ui_desktop_save = guac_rdp_ui_desktop_save; - rdp_inst->ui_desktop_restore = guac_rdp_ui_desktop_restore; - rdp_inst->ui_create_bitmap = guac_rdp_ui_create_bitmap; - rdp_inst->ui_paint_bitmap = guac_rdp_ui_paint_bitmap; - rdp_inst->ui_destroy_bitmap = guac_rdp_ui_destroy_bitmap; - rdp_inst->ui_line = guac_rdp_ui_line; - rdp_inst->ui_rect = guac_rdp_ui_rect; - rdp_inst->ui_polygon = guac_rdp_ui_polygon; - rdp_inst->ui_polyline = guac_rdp_ui_polyline; - rdp_inst->ui_ellipse = guac_rdp_ui_ellipse; - rdp_inst->ui_start_draw_glyphs = guac_rdp_ui_start_draw_glyphs; - rdp_inst->ui_draw_glyph = guac_rdp_ui_draw_glyph; - rdp_inst->ui_end_draw_glyphs = guac_rdp_ui_end_draw_glyphs; - rdp_inst->ui_get_toggle_keys_state = guac_rdp_ui_get_toggle_keys_state; - rdp_inst->ui_bell = guac_rdp_ui_bell; - rdp_inst->ui_destblt = guac_rdp_ui_destblt; - rdp_inst->ui_patblt = guac_rdp_ui_patblt; - rdp_inst->ui_screenblt = guac_rdp_ui_screenblt; - rdp_inst->ui_memblt = guac_rdp_ui_memblt; - rdp_inst->ui_triblt = guac_rdp_ui_triblt; - rdp_inst->ui_create_glyph = guac_rdp_ui_create_glyph; - rdp_inst->ui_destroy_glyph = guac_rdp_ui_destroy_glyph; - rdp_inst->ui_select = guac_rdp_ui_select; - rdp_inst->ui_set_clip = guac_rdp_ui_set_clip; - rdp_inst->ui_reset_clip = guac_rdp_ui_reset_clip; - rdp_inst->ui_resize_window = guac_rdp_ui_resize_window; - rdp_inst->ui_set_cursor = guac_rdp_ui_set_cursor; - rdp_inst->ui_destroy_cursor = guac_rdp_ui_destroy_cursor; - rdp_inst->ui_create_cursor = guac_rdp_ui_create_cursor; - rdp_inst->ui_set_null_cursor = guac_rdp_ui_set_null_cursor; - rdp_inst->ui_set_default_cursor = guac_rdp_ui_set_default_cursor; - rdp_inst->ui_create_palette = guac_rdp_ui_create_palette; - rdp_inst->ui_move_pointer = guac_rdp_ui_move_pointer; - rdp_inst->ui_set_palette = guac_rdp_ui_set_palette; - rdp_inst->ui_create_surface = guac_rdp_ui_create_surface; - rdp_inst->ui_set_surface = guac_rdp_ui_set_surface; - rdp_inst->ui_destroy_surface = guac_rdp_ui_destroy_surface; - rdp_inst->ui_channel_data = guac_rdp_ui_channel_data; - - /* Init chanman (pre-connect) */ - if (freerdp_chanman_pre_connect(chanman, rdp_inst)) { - guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager"); - guac_socket_flush(client->socket); - return 1; - } - - /* Connect to RDP server */ - if (rdp_inst->rdp_connect(rdp_inst)) { - guac_protocol_send_error(client->socket, "Error connecting to RDP server"); - guac_socket_flush(client->socket); - return 1; - } - - /* Init chanman (post-connect) */ - if (freerdp_chanman_post_connect(chanman, rdp_inst)) { - guac_protocol_send_error(client->socket, "Error initializing RDP client channel manager"); - guac_socket_flush(client->socket); - return 1; - } - - /* Client handlers */ - client->free_handler = rdp_guac_client_free_handler; - client->handle_messages = rdp_guac_client_handle_messages; - client->mouse_handler = rdp_guac_client_mouse_handler; - client->key_handler = rdp_guac_client_key_handler; - - /* Success */ - return 0; - -} - int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; @@ -325,7 +161,7 @@ int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { /* If button mask unchanged, just send move event */ if (mask == guac_client_data->mouse_button_mask) - rdp_inst->rdp_send_input_mouse(rdp_inst, PTRFLAGS_MOVE, x, y); + rdp_inst->rdp_send_input_mouse(rdp_inst, PTR_FLAGS_MOVE, x, y); /* Otherwise, send events describing button change */ else { @@ -341,9 +177,9 @@ int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { /* Calculate flags */ int flags = 0; - if (released_mask & 0x01) flags |= PTRFLAGS_BUTTON1; - if (released_mask & 0x02) flags |= PTRFLAGS_BUTTON3; - if (released_mask & 0x04) flags |= PTRFLAGS_BUTTON2; + if (released_mask & 0x01) flags |= PTR_FLAGS_BUTTON1; + if (released_mask & 0x02) flags |= PTR_FLAGS_BUTTON3; + if (released_mask & 0x04) flags |= PTR_FLAGS_BUTTON2; rdp_inst->rdp_send_input_mouse(rdp_inst, flags, x, y); @@ -353,12 +189,12 @@ int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { if (pressed_mask & 0x07) { /* Calculate flags */ - int flags = PTRFLAGS_DOWN; - if (pressed_mask & 0x01) flags |= PTRFLAGS_BUTTON1; - if (pressed_mask & 0x02) flags |= PTRFLAGS_BUTTON3; - if (pressed_mask & 0x04) flags |= PTRFLAGS_BUTTON2; - if (pressed_mask & 0x08) flags |= PTRFLAGS_WHEEL | 0x78; - if (pressed_mask & 0x10) flags |= PTRFLAGS_WHEEL | PTRFLAGS_WHEEL_NEGATIVE | 0x88; + int flags = PTR_FLAGS_DOWN; + if (pressed_mask & 0x01) flags |= PTR_FLAGS_BUTTON1; + if (pressed_mask & 0x02) flags |= PTR_FLAGS_BUTTON3; + if (pressed_mask & 0x04) flags |= PTR_FLAGS_BUTTON2; + if (pressed_mask & 0x08) flags |= PTR_FLAGS_WHEEL | 0x78; + if (pressed_mask & 0x10) flags |= PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x88; /* Send event */ rdp_inst->rdp_send_input_mouse(rdp_inst, flags, x, y); @@ -372,14 +208,14 @@ int rdp_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { if (pressed_mask & 0x08) rdp_inst->rdp_send_input_mouse( rdp_inst, - PTRFLAGS_WHEEL | 0x78, + PTR_FLAGS_WHEEL | 0x78, x, y); /* Up */ if (pressed_mask & 0x10) rdp_inst->rdp_send_input_mouse( rdp_inst, - PTRFLAGS_WHEEL | PTRFLAGS_WHEEL_NEGATIVE | 0x88, + PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x88, x, y); } @@ -408,7 +244,7 @@ int rdp_guac_client_key_handler(guac_client* client, int keysym, int pressed) { rdp_inst->rdp_send_input_scancode( rdp_inst, !pressed, - keymap->flags & KBDFLAGS_EXTENDED, + keymap->flags & KBD_FLAGS_EXTENDED, keymap->scancode); else guac_client_log_info(client, "unmapped keysym: 0x%x", keysym); diff --git a/protocols/rdp/src/rdp_handlers.c b/protocols/rdp/src/rdp_handlers.c index ee1304e4..dc0a3a8e 100644 --- a/protocols/rdp/src/rdp_handlers.c +++ b/protocols/rdp/src/rdp_handlers.c @@ -46,8 +46,8 @@ #include +#include "client.h" #include "rdp_handlers.h" -#include "rdp_client.h" void guac_rdp_convert_color(int depth, int color, guac_rdp_color* comp) { @@ -73,9 +73,9 @@ void guac_rdp_convert_color(int depth, int color, guac_rdp_color* comp) { } -void guac_rdp_ui_error(rdpInst* inst, const char* text) { +void guac_rdp_ui_error(freerdp* inst, const char* text) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_socket* socket = client->socket; guac_protocol_send_error(socket, text); @@ -83,41 +83,30 @@ void guac_rdp_ui_error(rdpInst* inst, const char* text) { } -void guac_rdp_ui_warning(rdpInst* inst, const char* text) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_warning(freerdp* inst, const char* text) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_warning: %s\n", text); } -void guac_rdp_ui_unimpl(rdpInst* inst, const char* text) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_unimpl(freerdp* inst, const char* text) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_unimpl: %s\n", text); } -void guac_rdp_ui_begin_update(rdpInst* inst) { +void guac_rdp_ui_begin_update(freerdp* inst) { /* UNUSED */ } -void guac_rdp_ui_end_update(rdpInst* inst) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_end_update(freerdp* inst) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_socket* socket = client->socket; guac_socket_flush(socket); } -void guac_rdp_ui_desktop_save(rdpInst* inst, int offset, int x, int y, int cx, int cy) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_desktop_save: STUB\n"); -} - -void guac_rdp_ui_desktop_restore(rdpInst* inst, int offset, int x, int y, int cx, int cy) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_desktop_restore: STUB\n"); -} - - -RD_HBITMAP guac_rdp_ui_create_bitmap(rdpInst* inst, int width, int height, uint8* data) { +rdpBitmap* guac_rdp_ui_create_bitmap(freerdp* inst, int width, int height, uint8* data) { /* Allocate buffer */ - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_socket* socket = client->socket; guac_layer* buffer = guac_client_alloc_buffer(client); @@ -184,13 +173,13 @@ RD_HBITMAP guac_rdp_ui_create_bitmap(rdpInst* inst, int width, int height, uint8 cairo_surface_destroy(surface); free(image_buffer); - return (RD_HBITMAP) buffer; + return (rdpBitmap*) buffer; } -void guac_rdp_ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int width, int height, uint8* data) { +void guac_rdp_ui_paint_bitmap(freerdp* inst, int x, int y, int cx, int cy, int width, int height, uint8* data) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -268,22 +257,17 @@ void guac_rdp_ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int w } -void guac_rdp_ui_destroy_bitmap(rdpInst* inst, RD_HBITMAP bmp) { +void guac_rdp_ui_destroy_bitmap(freerdp* inst, rdpBitmap* bmp) { /* Free buffer */ - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_free_buffer(client, (guac_layer*) bmp); } -void guac_rdp_ui_line(rdpInst* inst, uint8 opcode, int startx, int starty, int endx, int endy, RD_PEN* pen) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_line: STUB\n"); -} +void guac_rdp_ui_rect(freerdp* inst, int x, int y, int cx, int cy, uint32 color) { -void guac_rdp_ui_rect(rdpInst* inst, int x, int y, int cx, int cy, uint32 color) { - - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -316,24 +300,9 @@ void guac_rdp_ui_rect(rdpInst* inst, int x, int y, int cx, int cy, uint32 color) } -void guac_rdp_ui_polygon(rdpInst* inst, uint8 opcode, uint8 fillmode, RD_POINT* point, int npoints, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_polygon: STUB\n"); -} +void guac_rdp_ui_start_draw_glyphs(freerdp* inst, uint32 bgcolor, uint32 fgcolor) { -void guac_rdp_ui_polyline(rdpInst* inst, uint8 opcode, RD_POINT* points, int npoints, RD_PEN* pen) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_polyline: STUB\n"); -} - -void guac_rdp_ui_ellipse(rdpInst* inst, uint8 opcode, uint8 fillmode, int x, int y, int cx, int cy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_ellipse: STUB\n"); -} - -void guac_rdp_ui_start_draw_glyphs(rdpInst* inst, uint32 bgcolor, uint32 fgcolor) { - - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; guac_rdp_convert_color( @@ -348,9 +317,9 @@ void guac_rdp_ui_start_draw_glyphs(rdpInst* inst, uint32 bgcolor, uint32 fgcolor } -void guac_rdp_ui_draw_glyph(rdpInst* inst, int x, int y, int width, int height, RD_HGLYPH glyph) { +void guac_rdp_ui_draw_glyph(freerdp* inst, int x, int y, int width, int height, rdpGlyph* glyph) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -359,7 +328,7 @@ void guac_rdp_ui_draw_glyph(rdpInst* inst, int x, int y, int width, int height, /* Temporarily removed BG drawing... */ /* Foreground */ - guac_protocol_send_rect(socket, GUAC_COMP_ATOP, glyph, + guac_protocol_send_rect(socket, GUAC_COMP_ATOP, (guac_layer*) glyph, 0, 0, width, height, guac_client_data->foreground.red, guac_client_data->foreground.green, @@ -381,34 +350,23 @@ void guac_rdp_ui_draw_glyph(rdpInst* inst, int x, int y, int width, int height, } -void guac_rdp_ui_end_draw_glyphs(rdpInst* inst, int x, int y, int cx, int cy) { +void guac_rdp_ui_end_draw_glyphs(freerdp* inst, int x, int y, int cx, int cy) { /* UNUSED */ } -uint32 guac_rdp_ui_get_toggle_keys_state(rdpInst* inst) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_get_toggle_keys_state: STUB\n"); - return 0; -} - -void guac_rdp_ui_bell(rdpInst* inst) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_bell: STUB\n"); -} - -void guac_rdp_ui_destblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_destblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_destblt: STUB\n"); } -void guac_rdp_ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_patblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy, rdpBrush* brush, uint32 bgcolor, uint32 fgcolor) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_patblt: STUB\n"); } -void guac_rdp_ui_screenblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy) { +void guac_rdp_ui_screenblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -419,9 +377,9 @@ void guac_rdp_ui_screenblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, in } -void guac_rdp_ui_memblt(rdpInst* inst, uint8 opcode, int x, int y, int width, int height, RD_HBITMAP src, int srcx, int srcy) { +void guac_rdp_ui_memblt(freerdp* inst, uint8 opcode, int x, int y, int width, int height, rdpBitmap* src, int srcx, int srcy) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -437,15 +395,15 @@ void guac_rdp_ui_memblt(rdpInst* inst, uint8 opcode, int x, int y, int width, in } -void guac_rdp_ui_triblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy, RD_HBITMAP src, int srcx, int srcy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_triblt(freerdp* inst, uint8 opcode, int x, int y, int cx, int cy, rdpBitmap* src, int srcx, int srcy, rdpBrush* brush, uint32 bgcolor, uint32 fgcolor) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_triblt: STUB\n"); } -RD_HGLYPH guac_rdp_ui_create_glyph(rdpInst* inst, int width, int height, uint8* data) { +rdpGlyph* guac_rdp_ui_create_glyph(freerdp* inst, int width, int height, uint8* data) { /* Allocate buffer */ - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_socket* socket = client->socket; guac_layer* glyph = guac_client_alloc_buffer(client); @@ -501,25 +459,25 @@ RD_HGLYPH guac_rdp_ui_create_glyph(rdpInst* inst, int width, int height, uint8* free(image_buffer); - return (RD_HGLYPH) glyph; + return (rdpGlyph*) glyph; } -void guac_rdp_ui_destroy_glyph(rdpInst* inst, RD_HGLYPH glyph) { +void guac_rdp_ui_destroy_glyph(freerdp* inst, rdpGlyph* glyph) { /* Free buffer */ - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_free_buffer(client, (guac_layer*) glyph); } -int guac_rdp_ui_select(rdpInst* inst, int rdp_socket) { +int guac_rdp_ui_select(freerdp* inst, int rdp_socket) { return 1; } -void guac_rdp_ui_set_clip(rdpInst* inst, int x, int y, int cx, int cy) { +void guac_rdp_ui_set_clip(freerdp* inst, int x, int y, int cx, int cy) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -528,9 +486,9 @@ void guac_rdp_ui_set_clip(rdpInst* inst, int x, int y, int cx, int cy) { } -void guac_rdp_ui_reset_clip(rdpInst* inst) { +void guac_rdp_ui_reset_clip(freerdp* inst) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; const guac_layer* current_surface = guac_client_data->current_surface; guac_socket* socket = client->socket; @@ -539,56 +497,45 @@ void guac_rdp_ui_reset_clip(rdpInst* inst) { } -void guac_rdp_ui_resize_window(rdpInst* inst) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_resize_window(freerdp* inst) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_resize_window: %ix%i\n", inst->settings->width, inst->settings->height); } -void guac_rdp_ui_set_cursor(rdpInst* inst, RD_HCURSOR cursor) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_set_cursor(freerdp* inst, rdpPointer* cursor) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_set_cursor: STUB\n"); } -void guac_rdp_ui_destroy_cursor(rdpInst* inst, RD_HCURSOR cursor) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_destroy_cursor(freerdp* inst, rdpPointer* cursor) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_destroy_cursor: STUB\n"); } -RD_HCURSOR guac_rdp_ui_create_cursor(rdpInst* inst, unsigned int x, unsigned int y, int width, int height, uint8* andmask, uint8* xormask, int bpp) { +rdpPointer* guac_rdp_ui_create_cursor(freerdp* inst, unsigned int x, unsigned int y, int width, int height, uint8* andmask, uint8* xormask, int bpp) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_create_cursor: STUB\n"); - return guac_client_alloc_buffer(client); + return (rdpPointer*) guac_client_alloc_buffer(client); } -void guac_rdp_ui_set_null_cursor(rdpInst* inst) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_set_null_cursor(freerdp* inst) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_set_null_cursor: STUB\n"); } -void guac_rdp_ui_set_default_cursor(rdpInst* inst) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_set_default_cursor(freerdp* inst) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_set_default_cursor: STUB\n"); } -RD_HPALETTE guac_rdp_ui_create_colormap(rdpInst* inst, RD_PALETTE* colors) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_create_colormap: STUB\n"); - return NULL; -} - -void guac_rdp_ui_move_pointer(rdpInst* inst, int x, int y) { - guac_client* client = (guac_client*) inst->param1; +void guac_rdp_ui_move_pointer(freerdp* inst, int x, int y) { + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_log_info(client, "guac_rdp_ui_move_pointer: STUB\n"); } -void guac_rdp_ui_set_colormap(rdpInst* inst, RD_HPALETTE map) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_set_colormap: STUB\n"); -} - -RD_HBITMAP guac_rdp_ui_create_surface(rdpInst* inst, int width, int height, RD_HBITMAP old) { +rdpBitmap* guac_rdp_ui_create_surface(freerdp* inst, int width, int height, rdpBitmap* old) { /* If old provided, just return that one ... */ if (old != NULL) @@ -596,15 +543,15 @@ RD_HBITMAP guac_rdp_ui_create_surface(rdpInst* inst, int width, int height, RD_H /* Otherwise allocate and return new buffer */ else { - guac_client* client = (guac_client*) inst->param1; - return (RD_HBITMAP) guac_client_alloc_buffer(client); + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; + return (rdpBitmap*) guac_client_alloc_buffer(client); } } -void guac_rdp_ui_set_surface(rdpInst* inst, RD_HBITMAP surface) { +void guac_rdp_ui_set_surface(freerdp* inst, rdpBitmap* surface) { - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; guac_socket* socket = client->socket; @@ -620,32 +567,16 @@ void guac_rdp_ui_set_surface(rdpInst* inst, RD_HBITMAP surface) { guac_client_data->current_surface = GUAC_DEFAULT_LAYER; } else { - guac_client_data->current_surface = surface; + guac_client_data->current_surface = (guac_layer*) surface; } } -void guac_rdp_ui_destroy_surface(rdpInst* inst, RD_HBITMAP surface) { +void guac_rdp_ui_destroy_surface(freerdp* inst, rdpBitmap* surface) { /* Free buffer */ - guac_client* client = (guac_client*) inst->param1; + guac_client* client = ((rdp_freerdp_context*) inst->context)->client; guac_client_free_buffer(client, (guac_layer*) surface); } -void guac_rdp_ui_channel_data(rdpInst* inst, int chan_id, char* data, int data_size, int flags, int total_size) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_channel_data: STUB\n"); -} - -RD_HPALETTE guac_rdp_ui_create_palette(rdpInst* inst, RD_PALETTE* colours) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_create_palette: STUB\n"); - return NULL; -} - -void guac_rdp_ui_set_palette(rdpInst* inst, RD_HPALETTE map) { - guac_client* client = (guac_client*) inst->param1; - guac_client_log_info(client, "guac_rdp_ui_set_palette: STUB\n"); -} -