GUACAMOLE-249: Remove CLIPRDR callback typecasts, relying instead on configure tests to check need for const.

This commit is contained in:
Michael Jumper 2020-01-13 16:22:50 -08:00
parent 308d7a09a8
commit e5fdda1286
2 changed files with 53 additions and 8 deletions

View File

@ -597,6 +597,36 @@ then
fi
# CLIPRDR callback variants
if test "x${have_freerdp2}" = "xyes"
then
# FreeRDP 2.0.0-rc3 and older did not use const for CLIPRDR callbacks
AC_MSG_CHECKING([whether CLIPRDR callbacks require const for their final parameter])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <freerdp/client/cliprdr.h>
#include <winpr/wtypes.h>
UINT test_monitor_ready(CliprdrClientContext* cliprdr,
const CLIPRDR_MONITOR_READY* monitor_ready);
CliprdrClientContext context = {
.MonitorReady = test_monitor_ready
};
int main() {
return (int) context.MonitorReady(NULL, NULL);
}
]])],
[AC_MSG_RESULT([yes])]
[AC_DEFINE([FREERDP_CLIPRDR_CALLBACKS_REQUIRE_CONST],,
[Whether CLIPRDR callbacks require const for the final parameter])],
[AC_MSG_RESULT([no])])
fi
AM_CONDITIONAL([ENABLE_RDP], [test "x${have_freerdp2}" = "xyes"])
#

View File

@ -21,6 +21,7 @@
#include "client.h"
#include "common/clipboard.h"
#include "common/iconv.h"
#include "config.h"
#include "plugins/channels.h"
#include "rdp.h"
@ -37,6 +38,20 @@
#include <stdlib.h>
#include <string.h>
#ifdef FREERDP_CLIPRDR_CALLBACKS_REQUIRE_CONST
/**
* FreeRDP 2.0.0-rc4 and newer requires the final argument for all CLIPRDR
* callbacks to be const.
*/
#define CLIPRDR_CONST const
#else
/**
* FreeRDP 2.0.0-rc3 and older requires the final argument for all CLIPRDR
* callbacks to NOT be const.
*/
#define CLIPRDR_CONST
#endif
/**
* Sends a Format List PDU to the RDP server containing the formats of
* clipboard data supported. This PDU is used both to indicate the general
@ -127,7 +142,7 @@ static UINT guac_rdp_cliprdr_send_capabilities(CliprdrClientContext* cliprdr) {
* (non-zero) otherwise.
*/
static UINT guac_rdp_cliprdr_monitor_ready(CliprdrClientContext* cliprdr,
const CLIPRDR_MONITOR_READY* monitor_ready) {
CLIPRDR_CONST CLIPRDR_MONITOR_READY* monitor_ready) {
/* FreeRDP-specific handlers for CLIPRDR are not assigned, and thus not
* callable, until after the relevant guac_rdp_clipboard structure is
@ -241,7 +256,7 @@ static int guac_rdp_cliprdr_format_supported(const CLIPRDR_FORMAT_LIST* format_l
* (non-zero) otherwise.
*/
static UINT guac_rdp_cliprdr_format_list(CliprdrClientContext* cliprdr,
const CLIPRDR_FORMAT_LIST* format_list) {
CLIPRDR_CONST CLIPRDR_FORMAT_LIST* format_list) {
/* FreeRDP-specific handlers for CLIPRDR are not assigned, and thus not
* callable, until after the relevant guac_rdp_clipboard structure is
@ -296,7 +311,7 @@ static UINT guac_rdp_cliprdr_format_list(CliprdrClientContext* cliprdr,
* (non-zero) otherwise.
*/
static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
const CLIPRDR_FORMAT_DATA_REQUEST* format_data_request) {
CLIPRDR_CONST CLIPRDR_FORMAT_DATA_REQUEST* format_data_request) {
/* FreeRDP-specific handlers for CLIPRDR are not assigned, and thus not
* callable, until after the relevant guac_rdp_clipboard structure is
@ -373,7 +388,7 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
* (non-zero) otherwise.
*/
static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
const CLIPRDR_FORMAT_DATA_RESPONSE* format_data_response) {
CLIPRDR_CONST CLIPRDR_FORMAT_DATA_RESPONSE* format_data_response) {
/* FreeRDP-specific handlers for CLIPRDR are not assigned, and thus not
* callable, until after the relevant guac_rdp_clipboard structure is
@ -474,10 +489,10 @@ static void guac_rdp_cliprdr_channel_connected(rdpContext* context,
cliprdr->custom = clipboard;
clipboard->cliprdr = cliprdr;
cliprdr->MonitorReady = (pcCliprdrMonitorReady) guac_rdp_cliprdr_monitor_ready;
cliprdr->ServerFormatList = (pcCliprdrServerFormatList) guac_rdp_cliprdr_format_list;
cliprdr->ServerFormatDataRequest = (pcCliprdrServerFormatDataRequest) guac_rdp_cliprdr_format_data_request;
cliprdr->ServerFormatDataResponse = (pcCliprdrServerFormatDataResponse) guac_rdp_cliprdr_format_data_response;
cliprdr->MonitorReady = guac_rdp_cliprdr_monitor_ready;
cliprdr->ServerFormatList = guac_rdp_cliprdr_format_list;
cliprdr->ServerFormatDataRequest = guac_rdp_cliprdr_format_data_request;
cliprdr->ServerFormatDataResponse = guac_rdp_cliprdr_format_data_response;
guac_client_log(client, GUAC_LOG_DEBUG, "CLIPRDR (clipboard redirection) "
"channel connected.");