From f3f0900de98077209f6edf9d03315c64e63b57fc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 18 Jul 2013 11:54:22 -0700 Subject: [PATCH] Detect event interface, fix cliprdr. --- configure.ac | 26 ++++++++++++++++++++++++++ src/protocols/rdp/guac_handlers.c | 17 +++++++++++++++-- src/protocols/rdp/rdp_cliprdr.h | 10 ++++++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index ca607713..429650fd 100644 --- a/configure.ac +++ b/configure.ac @@ -218,6 +218,7 @@ have_freerdp=yes legacy_freerdp_extensions=no rdpsettings_interface=unknown freerdp_interface=unknown +event_interface=unknown RDP_LIBS= # libfreerdp-cache @@ -362,6 +363,31 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include rdpBitmap b = { .Decompress = __decompress };]])],, [AC_DEFINE([LEGACY_RDPBITMAP])]) +# +# FreeRDP: wMessage / RDP_EVENT +# + +# Check for current (as of 1.1) wMessage interface +AC_CHECK_MEMBERS([wMessage.id], + [event_interface=stable],, + [[#include ]]) + +# If not current, check for legacy (RDP_EVENT) interface +if test "x${event_interface}" = "xunknown" +then + AC_CHECK_MEMBERS([RDP_EVENT.event_class], + [event_interface=legacy],, + [[#include ]]) +fi + +# Set defines based on interface type, warn if unknown +if test "x${event_interface}" = "xlegacy"; then + AC_DEFINE([LEGACY_EVENT]) +elif test "x${event_interface}" = "xunknown"; then + have_freerdp=no +fi + + AM_CONDITIONAL([LEGACY_FREERDP_EXTENSIONS], [test "x${legacy_freerdp_extensions}" = "xyes"]) AM_CONDITIONAL([ENABLE_WINPR], [test "x${have_winpr}" = "xyes"]) AM_CONDITIONAL([ENABLE_RDP], [test "x${have_freerdp}" = "xyes"]) diff --git a/src/protocols/rdp/guac_handlers.c b/src/protocols/rdp/guac_handlers.c index f0dd244f..a0774512 100644 --- a/src/protocols/rdp/guac_handlers.c +++ b/src/protocols/rdp/guac_handlers.c @@ -118,7 +118,7 @@ int rdp_guac_client_handle_messages(guac_client* client) { int read_count = 0; int write_count = 0; fd_set rfds, wfds; - RDP_EVENT* event; + wMessage* event; struct timeval timeout = { .tv_sec = 0, @@ -200,8 +200,13 @@ int rdp_guac_client_handle_messages(guac_client* client) { if (event) { /* Handle clipboard events */ +#ifdef LEGACY_EVENT if (event->event_class == RDP_EVENT_CLASS_CLIPRDR) guac_rdp_process_cliprdr_event(client, event); +#else + if (GetMessageClass(event->id) == CliprdrChannel_Class) + guac_rdp_process_cliprdr_event(client, event); +#endif freerdp_event_free(event); @@ -422,11 +427,19 @@ int rdp_guac_client_clipboard_handler(guac_client* client, char* data) { rdpChannels* channels = ((rdp_guac_client_data*) client->data)->rdp_inst->context->channels; +#ifdef LEGACY_EVENT RDP_CB_FORMAT_LIST_EVENT* format_list = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new( RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); +#else + RDP_CB_FORMAT_LIST_EVENT* format_list = + (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new( + CliprdrChannel_Class, + CliprdrChannel_FormatList, + NULL, NULL); +#endif /* Free existing data */ free(((rdp_guac_client_data*) client->data)->clipboard); @@ -439,7 +452,7 @@ int rdp_guac_client_clipboard_handler(guac_client* client, char* data) { format_list->formats[0] = CB_FORMAT_TEXT; format_list->num_formats = 1; - freerdp_channels_send_event(channels, (RDP_EVENT*) format_list); + freerdp_channels_send_event(channels, (wMessage*) format_list); return 0; diff --git a/src/protocols/rdp/rdp_cliprdr.h b/src/protocols/rdp/rdp_cliprdr.h index be838c4a..f33d7c7f 100644 --- a/src/protocols/rdp/rdp_cliprdr.h +++ b/src/protocols/rdp/rdp_cliprdr.h @@ -38,10 +38,16 @@ #ifndef __GUAC_RDP_RDP_CLIPRDR_H #define __GUAC_RDP_RDP_CLIPRDR_H +#ifdef ENABLE_WINPR +#include +#else +#include "compat/winpr-wtypes.h" +#endif + #include -void guac_rdp_process_cliprdr_event(guac_client* client, RDP_EVENT* event); -void guac_rdp_process_cb_monitor_ready(guac_client* client, RDP_EVENT* event); +void guac_rdp_process_cliprdr_event(guac_client* client, wMessage* event); +void guac_rdp_process_cb_monitor_ready(guac_client* client, wMessage* event); void guac_rdp_process_cb_format_list(guac_client* client, RDP_CB_FORMAT_LIST_EVENT* event);