From 68710a6702db1a23d03478259c65d49a4a6324a3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 21 Dec 2019 19:36:20 -0800 Subject: [PATCH] GUACAMOLE-249: Migrate loading of RDPDR support (guacdr plugin) to abstract function. --- src/protocols/rdp/Makefile.am | 2 ++ src/protocols/rdp/rdp.c | 12 ++-------- src/protocols/rdp/rdpdr.c | 43 +++++++++++++++++++++++++++++++++++ src/protocols/rdp/rdpdr.h | 40 ++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 src/protocols/rdp/rdpdr.c create mode 100644 src/protocols/rdp/rdpdr.h diff --git a/src/protocols/rdp/Makefile.am b/src/protocols/rdp/Makefile.am index a5eb77f2..97f36535 100644 --- a/src/protocols/rdp/Makefile.am +++ b/src/protocols/rdp/Makefile.am @@ -59,6 +59,7 @@ libguac_client_rdp_la_SOURCES = \ rdp_pointer.c \ rdp_settings.c \ rdp_stream.c \ + rdpdr.c \ rdpsnd.c \ resolution.c \ svc.c \ @@ -101,6 +102,7 @@ noinst_HEADERS = \ rdp_settings.h \ rdp_status.h \ rdp_stream.h \ + rdpdr.h \ rdpsnd.h \ resolution.h \ svc.h \ diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index 17da6e6d..b42035ca 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -38,6 +38,7 @@ #include "rdp_glyph.h" #include "rdp_pointer.h" #include "rdp_stream.h" +#include "rdpdr.h" #include "rdpsnd.h" #include "svc.h" @@ -108,17 +109,8 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) { if (settings->printing_enabled || settings->drive_enabled || settings->audio_enabled) { - - /* Load RDPDR plugin */ - if (guac_freerdp_channels_load_plugin(channels, instance->settings, - "guacdr", client)) - guac_client_log(client, GUAC_LOG_WARNING, - "Failed to load guacdr plugin. Drive redirection and " - "printing will not work. Sound MAY not work."); - - /* Load RDPSND plugin */ + guac_rdpdr_load_plugin(context); guac_rdpsnd_load_plugin(context); - } /* Load RAIL plugin if RemoteApp in use */ diff --git a/src/protocols/rdp/rdpdr.c b/src/protocols/rdp/rdpdr.c new file mode 100644 index 00000000..e39d393a --- /dev/null +++ b/src/protocols/rdp/rdpdr.c @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "config.h" +#include "channels.h" +#include "rdp.h" + +#include +#include + +void guac_rdpdr_load_plugin(rdpContext* context) { + + guac_client* client = ((rdp_freerdp_context*) context)->client; + + /* Load RDPDR plugin */ + if (guac_freerdp_channels_load_plugin(context->channels, context->settings, "guacdr", client)) { + guac_client_log(client, GUAC_LOG_WARNING, "Support for the RDPDR " + "channel (device redirection) could not be loaded. Drive " + "redirection and printing will not work. Sound MAY not work."); + return; + } + + guac_client_log(client, GUAC_LOG_DEBUG, "Support for RDPDR (device " + "redirection) registered. Awaiting channel connection."); + +} + diff --git a/src/protocols/rdp/rdpdr.h b/src/protocols/rdp/rdpdr.h new file mode 100644 index 00000000..0a18a58c --- /dev/null +++ b/src/protocols/rdp/rdpdr.h @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef GUAC_RDP_RDPDR_H +#define GUAC_RDP_RDPDR_H + +#include "config.h" + +/** + * Initializes device redirection support (file transfer, printing, etc.) for + * RDP and handling of the RDPDR channel. If failures occur, messages noting + * the specifics of those failures will be logged, and the RDP side of + * device redirection support will not be functional. + * + * This MUST be called within the PreConnect callback of the freerdp instance + * for RDPDR support to be loaded. + * + * @param rdpContext + * The rdpContext associated with the FreeRDP side of the RDP connection. + */ +void guac_rdpdr_load_plugin(rdpContext* context); + +#endif +