From 10d987a0c3be7cb4f70201449886109b8ac126a1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 30 Jan 2014 00:04:31 -0800 Subject: [PATCH] Working RemoteApp with current FreeRDP. --- src/protocols/rdp/Makefile.am | 2 + src/protocols/rdp/guac_handlers.c | 7 +- src/protocols/rdp/rdp_rail.c | 117 ++++++++++++++++++++++++++++++ src/protocols/rdp/rdp_rail.h | 50 +++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 src/protocols/rdp/rdp_rail.c create mode 100644 src/protocols/rdp/rdp_rail.h diff --git a/src/protocols/rdp/Makefile.am b/src/protocols/rdp/Makefile.am index d47404cd..2444973a 100644 --- a/src/protocols/rdp/Makefile.am +++ b/src/protocols/rdp/Makefile.am @@ -38,6 +38,7 @@ libguac_client_rdp_la_SOURCES = \ rdp_glyph.c \ rdp_keymap.c \ rdp_pointer.c \ + rdp_rail.c \ rdp_settings.c \ unicode.c @@ -79,6 +80,7 @@ noinst_HEADERS = \ rdp_glyph.h \ rdp_keymap.h \ rdp_pointer.h \ + rdp_rail.h \ rdp_settings.h \ rdp_status.h \ unicode.h diff --git a/src/protocols/rdp/guac_handlers.c b/src/protocols/rdp/guac_handlers.c index c4a0ef40..d236030c 100644 --- a/src/protocols/rdp/guac_handlers.c +++ b/src/protocols/rdp/guac_handlers.c @@ -26,6 +26,7 @@ #include "guac_handlers.h" #include "rdp_cliprdr.h" #include "rdp_keymap.h" +#include "rdp_rail.h" #include #include @@ -210,13 +211,17 @@ int rdp_guac_client_handle_messages(guac_client* client) { event = freerdp_channels_pop_event(channels); if (event) { - /* Handle clipboard events */ + /* Handle channel events (clipboard and RAIL) */ #ifdef LEGACY_EVENT if (event->event_class == CliprdrChannel_Class) guac_rdp_process_cliprdr_event(client, event); + else if (event->event_class == RailChannel_Class) + guac_rdp_process_rail_event(client, event); #else if (GetMessageClass(event->id) == CliprdrChannel_Class) guac_rdp_process_cliprdr_event(client, event); + else if (GetMessageClass(event->id) == RailChannel_Class) + guac_rdp_process_rail_event(client, event); #endif freerdp_event_free(event); diff --git a/src/protocols/rdp/rdp_rail.c b/src/protocols/rdp/rdp_rail.c new file mode 100644 index 00000000..c38fac6d --- /dev/null +++ b/src/protocols/rdp/rdp_rail.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2013 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "config.h" + +#include "client.h" +#include "rdp_rail.h" + +#include +#include +#include +#include + +#ifdef ENABLE_WINPR +#include +#else +#include "compat/winpr-wtypes.h" +#endif + +#include + +void guac_rdp_process_rail_event(guac_client* client, wMessage* event) { + +#ifdef LEGACY_EVENT + switch (event->event_type) { +#else + switch (GetMessageType(event->id)) { +#endif + + /* Get system parameters */ + case RailChannel_GetSystemParam: + guac_rdp_process_rail_get_sysparam(client, event); + break; + + /* Currently ignored events */ + case RailChannel_ServerSystemParam: + case RailChannel_ServerExecuteResult: + case RailChannel_ServerMinMaxInfo: + case RailChannel_ServerLocalMoveSize: + case RailChannel_ServerGetAppIdResponse: + case RailChannel_ServerLanguageBarInfo: + break; + + default: +#ifdef LEGACY_EVENT + guac_client_log_info(client, + "Unknown rail event type: 0x%x", + event->event_type); +#else + guac_client_log_info(client, + "Unknown rail event type: 0x%x", + GetMessageType(event->id)); +#endif + + } + +} + +void guac_rdp_process_rail_get_sysparam(guac_client* client, wMessage* event) { + + wMessage* response; + RAIL_SYSPARAM_ORDER* sysparam; + + /* Get channels */ + rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data; + rdpChannels* channels = client_data->rdp_inst->context->channels; + + /* Get sysparam structure */ +#ifdef LEGACY_EVENT + sysparam = (RAIL_SYSPARAM_ORDER*) event->user_data; +#else + sysparam = (RAIL_SYSPARAM_ORDER*) event->wParam; +#endif + + response = freerdp_event_new(RailChannel_Class, + RailChannel_ClientSystemParam, + NULL, + sysparam); + + /* Work area */ + sysparam->workArea.left = 0; + sysparam->workArea.top = 0; + sysparam->workArea.right = client_data->settings.width; + sysparam->workArea.bottom = client_data->settings.height; + + /* Taskbar */ + sysparam->taskbarPos.left = 0; + sysparam->taskbarPos.top = 0; + sysparam->taskbarPos.right = 0; + sysparam->taskbarPos.bottom = 0; + + sysparam->dragFullWindows = FALSE; + + /* Send response */ + freerdp_channels_send_event(channels, response); + +} + diff --git a/src/protocols/rdp/rdp_rail.h b/src/protocols/rdp/rdp_rail.h new file mode 100644 index 00000000..3264b095 --- /dev/null +++ b/src/protocols/rdp/rdp_rail.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef __GUAC_RDP_RDP_RAIL_H +#define __GUAC_RDP_RDP_RAIL_H + +#include "config.h" + +#include + +#ifdef ENABLE_WINPR +#include +#else +#include "compat/winpr-stream.h" +#endif + +#include + +/** + * Dispatches a given RAIL event to the appropriate handler. + */ +void guac_rdp_process_rail_event(guac_client* client, wMessage* event); + +/** + * Handles the event sent when updating system parameters. + */ +void guac_rdp_process_rail_get_sysparam(guac_client* client, wMessage* event); + +#endif +