From 8ccf61e6b1d9198b073b17f5bafe96e12ca65c06 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 9 May 2016 22:23:46 -0700 Subject: [PATCH] GUACAMOLE-25: Support FreeRDP stable-1.0 and compatible. --- configure.ac | 9 +++++++ src/protocols/rdp/dvc.c | 33 ++++++++++++++++++++++++-- src/protocols/rdp/guac_ai/ai_service.c | 6 +++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 7dec629a..446a36e5 100644 --- a/configure.ac +++ b/configure.ac @@ -579,6 +579,15 @@ then [#include ]) fi +# Availability of ADDIN_ARGV structure for configuring plugins +if test "x${have_freerdp}" = "xyes" +then + AC_CHECK_TYPE([ADDIN_ARGV], + [AC_DEFINE([HAVE_ADDIN_ARGV],, + [Whether the ADDIN_ARGV type is available])],, + [#include ]) +fi + # # FreeRDP: WinPR # diff --git a/src/protocols/rdp/dvc.c b/src/protocols/rdp/dvc.c index 0f0e835a..10c65d7f 100644 --- a/src/protocols/rdp/dvc.c +++ b/src/protocols/rdp/dvc.c @@ -117,6 +117,14 @@ int guac_rdp_load_drdynvc(rdpContext* context, guac_rdp_dvc_list* list) { if (list->channel_count == 0) return 0; +#ifndef HAVE_ADDIN_ARGV + /* Allocate plugin data array */ + RDP_PLUGIN_DATA* all_plugin_data = + calloc(list->channel_count + 1, sizeof(RDP_PLUGIN_DATA)); + + RDP_PLUGIN_DATA* current_plugin_data = all_plugin_data; +#endif + /* For each channel */ guac_common_list_element* current = list->channels->head; while (current != NULL) { @@ -135,20 +143,41 @@ int guac_rdp_load_drdynvc(rdpContext* context, guac_rdp_dvc_list* list) { guac_client_log(client, GUAC_LOG_DEBUG, "Registering DVC plugin \"%s\"", dvc->argv[0]); +#ifdef HAVE_ADDIN_ARGV /* Register plugin with FreeRDP */ ADDIN_ARGV* args = malloc(sizeof(ADDIN_ARGV)); args->argc = dvc->argc; args->argv = dvc->argv; freerdp_dynamic_channel_collection_add(context->settings, args); +#else + /* Copy all arguments */ + for (int i = 0; i < dvc->argc; i++) + current_plugin_data->data[i] = dvc->argv[i]; + + /* Store size of entry */ + current_plugin_data->size = sizeof(*current_plugin_data); + + /* Advance to next set of plugin data */ + current_plugin_data++; +#endif /* Rely on FreeRDP to free argv storage */ dvc->argv = NULL; } +#ifdef HAVE_ADDIN_ARGV /* Load virtual channel management plugin */ - return freerdp_channels_load_plugin(channels, context->settings, - "drdynvc", context->settings); + return freerdp_channels_load_plugin(channels, context->instance->settings, + "drdynvc", context->instance->settings); +#else + /* Terminate with empty RDP_PLUGIN_DATA element */ + current_plugin_data->size = 0; + + /* Load virtual channel management plugin */ + return freerdp_channels_load_plugin(channels, context->instance->settings, + "drdynvc", all_plugin_data); +#endif } diff --git a/src/protocols/rdp/guac_ai/ai_service.c b/src/protocols/rdp/guac_ai/ai_service.c index 2fbf2aca..5058ea0a 100644 --- a/src/protocols/rdp/guac_ai/ai_service.c +++ b/src/protocols/rdp/guac_ai/ai_service.c @@ -314,8 +314,14 @@ static int guac_rdp_ai_terminated(IWTSPlugin* plugin) { */ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) { + /* Pull guac_client from arguments */ +#ifdef HAVE_ADDIN_ARGV ADDIN_ARGV* args = pEntryPoints->GetPluginData(pEntryPoints); guac_client* client = (guac_client*) guac_rdp_string_to_ptr(args->argv[1]); +#else + RDP_PLUGIN_DATA* data = pEntryPoints->GetPluginData(pEntryPoints); + guac_client* client = (guac_client*) guac_rdp_string_to_ptr(data->data[1]); +#endif /* Pull previously-allocated plugin */ guac_rdp_ai_plugin* ai_plugin = (guac_rdp_ai_plugin*)