Added clipboard CB_HUGE_FILE_SUPPORT_ENABLED flag

(cherry picked from commit f282c55c7a)
This commit is contained in:
akallabeth 2020-09-29 08:22:28 +02:00 committed by akallabeth
parent d7d16bf93c
commit ac0f0c6500
8 changed files with 41 additions and 2 deletions

View File

@ -119,6 +119,9 @@ static void cliprdr_print_general_capability_flags(UINT32 flags)
if (flags & CB_CAN_LOCK_CLIPDATA) if (flags & CB_CAN_LOCK_CLIPDATA)
WLog_INFO(TAG, "\tCB_CAN_LOCK_CLIPDATA"); WLog_INFO(TAG, "\tCB_CAN_LOCK_CLIPDATA");
if (flags & CB_HUGE_FILE_SUPPORT_ENABLED)
WLog_INFO(TAG, "\tCB_HUGE_FILE_SUPPORT_ENABLED");
WLog_INFO(TAG, "}"); WLog_INFO(TAG, "}");
} }
#endif #endif
@ -157,6 +160,7 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
cliprdr->streamFileClipEnabled = (generalFlags & CB_STREAM_FILECLIP_ENABLED); cliprdr->streamFileClipEnabled = (generalFlags & CB_STREAM_FILECLIP_ENABLED);
cliprdr->fileClipNoFilePaths = (generalFlags & CB_FILECLIP_NO_FILE_PATHS); cliprdr->fileClipNoFilePaths = (generalFlags & CB_FILECLIP_NO_FILE_PATHS);
cliprdr->canLockClipData = (generalFlags & CB_CAN_LOCK_CLIPDATA); cliprdr->canLockClipData = (generalFlags & CB_CAN_LOCK_CLIPDATA);
cliprdr->hasHugeFileSupport = (generalFlags & CB_HUGE_FILE_SUPPORT_ENABLED);
cliprdr->capabilitiesReceived = TRUE; cliprdr->capabilitiesReceived = TRUE;
if (!context->custom) if (!context->custom)
@ -571,11 +575,14 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
flags &= ~CB_FILECLIP_NO_FILE_PATHS; flags &= ~CB_FILECLIP_NO_FILE_PATHS;
if (!cliprdr->canLockClipData) if (!cliprdr->canLockClipData)
flags &= CB_CAN_LOCK_CLIPDATA; flags &= CB_CAN_LOCK_CLIPDATA;
if (!cliprdr->hasHugeFileSupport)
flags &= CB_HUGE_FILE_SUPPORT_ENABLED;
cliprdr->useLongFormatNames = flags & CB_USE_LONG_FORMAT_NAMES; cliprdr->useLongFormatNames = flags & CB_USE_LONG_FORMAT_NAMES;
cliprdr->streamFileClipEnabled = flags & CB_STREAM_FILECLIP_ENABLED; cliprdr->streamFileClipEnabled = flags & CB_STREAM_FILECLIP_ENABLED;
cliprdr->fileClipNoFilePaths = flags & CB_FILECLIP_NO_FILE_PATHS; cliprdr->fileClipNoFilePaths = flags & CB_FILECLIP_NO_FILE_PATHS;
cliprdr->canLockClipData = flags & CB_CAN_LOCK_CLIPDATA; cliprdr->canLockClipData = flags & CB_CAN_LOCK_CLIPDATA;
cliprdr->hasHugeFileSupport = flags & CB_HUGE_FILE_SUPPORT_ENABLED;
Stream_Write_UINT32(s, flags); /* generalFlags */ Stream_Write_UINT32(s, flags); /* generalFlags */
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientCapabilities"); WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientCapabilities");
@ -774,6 +781,18 @@ cliprdr_client_file_contents_request(CliprdrClientContext* context,
wStream* s; wStream* s;
cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle; cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle;
if (!cliprdr)
return ERROR_INTERNAL_ERROR;
if (!cliprdr->hasHugeFileSupport)
{
if (((UINT64)fileContentsRequest->cbRequested + fileContentsRequest->nPositionLow) >
UINT32_MAX)
return ERROR_INVALID_PARAMETER;
if (fileContentsRequest->nPositionHigh != 0)
return ERROR_INVALID_PARAMETER;
}
s = cliprdr_packet_file_contents_request_new(fileContentsRequest); s = cliprdr_packet_file_contents_request_new(fileContentsRequest);
if (!s) if (!s)

View File

@ -49,6 +49,7 @@ struct cliprdr_plugin
BOOL streamFileClipEnabled; BOOL streamFileClipEnabled;
BOOL fileClipNoFilePaths; BOOL fileClipNoFilePaths;
BOOL canLockClipData; BOOL canLockClipData;
BOOL hasHugeFileSupport;
}; };
typedef struct cliprdr_plugin cliprdrPlugin; typedef struct cliprdr_plugin cliprdrPlugin;

View File

@ -453,6 +453,10 @@ static UINT cliprdr_server_receive_general_capability(CliprdrServerContext* cont
if (context->canLockClipData) if (context->canLockClipData)
context->canLockClipData = (cap_set->generalFlags & CB_CAN_LOCK_CLIPDATA) ? TRUE : FALSE; context->canLockClipData = (cap_set->generalFlags & CB_CAN_LOCK_CLIPDATA) ? TRUE : FALSE;
if (context->hasHugeFileSupport)
context->hasHugeFileSupport =
(cap_set->generalFlags & CB_HUGE_FILE_SUPPORT_ENABLED) ? TRUE : FALSE;
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }
@ -776,6 +780,13 @@ static UINT cliprdr_server_receive_filecontents_request(CliprdrServerContext* co
if ((error = cliprdr_read_file_contents_request(s, &request))) if ((error = cliprdr_read_file_contents_request(s, &request)))
return error; return error;
if (!context->hasHugeFileSupport)
{
if (request.nPositionHigh > 0)
return ERROR_INVALID_DATA;
if ((UINT64)request.nPositionLow + request.cbRequested > UINT32_MAX)
return ERROR_INVALID_DATA;
}
IFCALLRET(context->ClientFileContentsRequest, error, context, &request); IFCALLRET(context->ClientFileContentsRequest, error, context, &request);
if (error) if (error)
@ -948,6 +959,9 @@ static UINT cliprdr_server_init(CliprdrServerContext* context)
if (context->canLockClipData) if (context->canLockClipData)
generalFlags |= CB_CAN_LOCK_CLIPDATA; generalFlags |= CB_CAN_LOCK_CLIPDATA;
if (context->hasHugeFileSupport)
generalFlags |= CB_HUGE_FILE_SUPPORT_ENABLED;
capabilities.msgType = CB_CLIP_CAPS; capabilities.msgType = CB_CLIP_CAPS;
capabilities.msgFlags = 0; capabilities.msgFlags = 0;
capabilities.dataLen = 4 + CB_CAPSTYPE_GENERAL_LEN; capabilities.dataLen = 4 + CB_CAPSTYPE_GENERAL_LEN;

View File

@ -306,7 +306,8 @@ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES; generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
if (clipboard->streams_supported && clipboard->file_formats_registered) if (clipboard->streams_supported && clipboard->file_formats_registered)
generalCapabilitySet.generalFlags |= CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS; generalCapabilitySet.generalFlags |=
CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS | CB_HUGE_FILE_SUPPORT_ENABLED;
return clipboard->context->ClientCapabilities(clipboard->context, &capabilities); return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
} }

View File

@ -1064,7 +1064,8 @@ static UINT xf_cliprdr_send_client_capabilities(xfClipboard* clipboard)
generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES; generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
if (clipboard->streams_supported && clipboard->file_formats_registered) if (clipboard->streams_supported && clipboard->file_formats_registered)
generalCapabilitySet.generalFlags |= CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS; generalCapabilitySet.generalFlags |=
CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS | CB_HUGE_FILE_SUPPORT_ENABLED;
return clipboard->context->ClientCapabilities(clipboard->context, &capabilities); return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
} }

View File

@ -70,6 +70,7 @@
#define CB_STREAM_FILECLIP_ENABLED 0x00000004 #define CB_STREAM_FILECLIP_ENABLED 0x00000004
#define CB_FILECLIP_NO_FILE_PATHS 0x00000008 #define CB_FILECLIP_NO_FILE_PATHS 0x00000008
#define CB_CAN_LOCK_CLIPDATA 0x00000010 #define CB_CAN_LOCK_CLIPDATA 0x00000010
#define CB_HUGE_FILE_SUPPORT_ENABLED 0x00000020
/* File Contents Request Flags */ /* File Contents Request Flags */
#define FILECONTENTS_SIZE 0x00000001 #define FILECONTENTS_SIZE 0x00000001

View File

@ -94,6 +94,7 @@ struct _cliprdr_server_context
BOOL streamFileClipEnabled; BOOL streamFileClipEnabled;
BOOL fileClipNoFilePaths; BOOL fileClipNoFilePaths;
BOOL canLockClipData; BOOL canLockClipData;
BOOL hasHugeFileSupport;
psCliprdrOpen Open; psCliprdrOpen Open;
psCliprdrClose Close; psCliprdrClose Close;

View File

@ -45,6 +45,7 @@ BOOL pf_server_cliprdr_init(pServerContext* ps)
cliprdr->streamFileClipEnabled = TRUE; cliprdr->streamFileClipEnabled = TRUE;
cliprdr->fileClipNoFilePaths = TRUE; cliprdr->fileClipNoFilePaths = TRUE;
cliprdr->canLockClipData = TRUE; cliprdr->canLockClipData = TRUE;
cliprdr->hasHugeFileSupport = TRUE;
/* disable initialization sequence, for caps sync */ /* disable initialization sequence, for caps sync */
cliprdr->autoInitializationSequence = FALSE; cliprdr->autoInitializationSequence = FALSE;