From f3de3ee16b55cbb625c635bd5f30f3f8f109bef1 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 20 Apr 2020 15:26:33 +0200 Subject: [PATCH] Fix short format name configuration and format list return. --- channels/cliprdr/client/cliprdr_main.c | 28 +++++++++++++++++++++----- channels/cliprdr/cliprdr_common.c | 4 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 4509591c5..8541cabcc 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -539,8 +539,10 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context, const CLIPRDR_CAPABILITIES* capabilities) { wStream* s; + UINT32 flags; const CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet; cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle; + s = cliprdr_packet_new(CB_CLIP_CAPS, 0, 4 + CB_CAPSTYPE_GENERAL_LEN); if (!s) @@ -555,7 +557,27 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context, Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetType); /* capabilitySetType */ Stream_Write_UINT16(s, generalCapabilitySet->capabilitySetLength); /* lengthCapability */ Stream_Write_UINT32(s, generalCapabilitySet->version); /* version */ - Stream_Write_UINT32(s, generalCapabilitySet->generalFlags); /* generalFlags */ + flags = generalCapabilitySet->generalFlags; + + /* Client capabilities are sent in response to server capabilities. + * -> Do not request features the server does not support. + * -> Update clipboard context feature state to what was agreed upon. + */ + if (!cliprdr->useLongFormatNames) + flags &= ~CB_USE_LONG_FORMAT_NAMES; + if (!cliprdr->streamFileClipEnabled) + flags &= ~CB_STREAM_FILECLIP_ENABLED; + if (!cliprdr->fileClipNoFilePaths) + flags &= ~CB_FILECLIP_NO_FILE_PATHS; + if (!cliprdr->canLockClipData) + flags &= CB_CAN_LOCK_CLIPDATA; + + cliprdr->useLongFormatNames = flags & CB_USE_LONG_FORMAT_NAMES; + cliprdr->streamFileClipEnabled = flags & CB_STREAM_FILECLIP_ENABLED; + cliprdr->fileClipNoFilePaths = flags & CB_FILECLIP_NO_FILE_PATHS; + cliprdr->canLockClipData = flags & CB_CAN_LOCK_CLIPDATA; + + Stream_Write_UINT32(s, flags); /* generalFlags */ WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientCapabilities"); return cliprdr_packet_send(cliprdr, s); } @@ -1139,10 +1161,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p } cliprdr->log = WLog_Get("com.freerdp.channels.cliprdr.client"); - cliprdr->useLongFormatNames = TRUE; - cliprdr->streamFileClipEnabled = FALSE; - cliprdr->fileClipNoFilePaths = TRUE; - cliprdr->canLockClipData = FALSE; WLog_Print(cliprdr->log, WLOG_DEBUG, "VirtualChannelEntryEx"); CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)); diff --git a/channels/cliprdr/cliprdr_common.c b/channels/cliprdr/cliprdr_common.c index c35f11993..a699852b6 100644 --- a/channels/cliprdr/cliprdr_common.c +++ b/channels/cliprdr/cliprdr_common.c @@ -402,7 +402,7 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL WCHAR* wszFormatName; wStream sub1, sub2; CLIPRDR_FORMAT* formats = NULL; - UINT error = CHANNEL_RC_OK; + UINT error = ERROR_INTERNAL_ERROR; asciiNames = (formatList->msgFlags & CB_ASCII_NAMES) ? TRUE : FALSE; @@ -551,7 +551,7 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL } } - return error; + return CHANNEL_RC_OK; error_out: cliprdr_free_format_list(formatList);