Refactored clipboard structs
This commit is contained in:
parent
05b339b0b1
commit
9a2a37786e
@ -45,9 +45,9 @@ UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
formatList.msgFlags = msgFlags;
|
||||
formatList.dataLen = dataLen;
|
||||
formatList.common.msgType = CB_FORMAT_LIST;
|
||||
formatList.common.msgFlags = msgFlags;
|
||||
formatList.common.dataLen = dataLen;
|
||||
|
||||
if ((error = cliprdr_read_format_list(s, &formatList, cliprdr->useLongFormatNames)))
|
||||
goto error_out;
|
||||
@ -80,9 +80,9 @@ UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatListResponse");
|
||||
|
||||
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.msgFlags = msgFlags;
|
||||
formatListResponse.dataLen = dataLen;
|
||||
formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.common.msgFlags = msgFlags;
|
||||
formatListResponse.common.dataLen = dataLen;
|
||||
|
||||
IFCALLRET(context->ServerFormatListResponse, error, context, &formatListResponse);
|
||||
if (error)
|
||||
@ -99,15 +99,15 @@ UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
|
||||
UINT16 msgFlags)
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
|
||||
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatDataRequest");
|
||||
|
||||
formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.msgFlags = msgFlags;
|
||||
formatDataRequest.dataLen = dataLen;
|
||||
formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.common.msgFlags = msgFlags;
|
||||
formatDataRequest.common.dataLen = dataLen;
|
||||
|
||||
if ((error = cliprdr_read_format_data_request(s, &formatDataRequest)))
|
||||
return error;
|
||||
@ -128,15 +128,15 @@ UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UIN
|
||||
UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen,
|
||||
UINT16 msgFlags)
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse;
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerFormatDataResponse");
|
||||
|
||||
formatDataResponse.msgType = CB_FORMAT_DATA_RESPONSE;
|
||||
formatDataResponse.msgFlags = msgFlags;
|
||||
formatDataResponse.dataLen = dataLen;
|
||||
formatDataResponse.common.msgType = CB_FORMAT_DATA_RESPONSE;
|
||||
formatDataResponse.common.msgFlags = msgFlags;
|
||||
formatDataResponse.common.dataLen = dataLen;
|
||||
|
||||
if ((error = cliprdr_read_format_data_response(s, &formatDataResponse)))
|
||||
return error;
|
||||
|
@ -160,8 +160,8 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
|
||||
{
|
||||
UINT32 version;
|
||||
UINT32 generalFlags;
|
||||
CLIPRDR_CAPABILITIES capabilities;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
|
||||
CLIPRDR_CAPABILITIES capabilities = { 0 };
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -191,7 +191,7 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
|
||||
cliprdr->hasHugeFileSupport = (generalFlags & CB_HUGE_FILE_SUPPORT_ENABLED);
|
||||
cliprdr->capabilitiesReceived = TRUE;
|
||||
|
||||
capabilities.msgType = CB_CLIP_CAPS;
|
||||
capabilities.common.msgType = CB_CLIP_CAPS;
|
||||
capabilities.cCapabilitiesSets = 1;
|
||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
|
||||
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
||||
@ -272,7 +272,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32
|
||||
static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
|
||||
UINT16 flags)
|
||||
{
|
||||
CLIPRDR_MONITOR_READY monitorReady;
|
||||
CLIPRDR_MONITOR_READY monitorReady = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -295,9 +295,9 @@ static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
cliprdr->canLockClipData = FALSE;
|
||||
}
|
||||
|
||||
monitorReady.msgType = CB_MONITOR_READY;
|
||||
monitorReady.msgFlags = flags;
|
||||
monitorReady.dataLen = length;
|
||||
monitorReady.common.msgType = CB_MONITOR_READY;
|
||||
monitorReady.common.msgFlags = flags;
|
||||
monitorReady.common.dataLen = length;
|
||||
IFCALLRET(context->MonitorReady, error, context, &monitorReady);
|
||||
|
||||
if (error)
|
||||
@ -314,7 +314,7 @@ static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
|
||||
UINT16 flags)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST request;
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST request = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -323,9 +323,9 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream
|
||||
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "FileContentsRequest");
|
||||
|
||||
request.msgType = CB_FILECONTENTS_REQUEST;
|
||||
request.msgFlags = flags;
|
||||
request.dataLen = length;
|
||||
request.common.msgType = CB_FILECONTENTS_REQUEST;
|
||||
request.common.msgFlags = flags;
|
||||
request.common.dataLen = length;
|
||||
|
||||
if ((error = cliprdr_read_file_contents_request(s, &request)))
|
||||
return error;
|
||||
@ -346,7 +346,7 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr, wStream
|
||||
static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
|
||||
UINT16 flags)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response;
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -355,9 +355,9 @@ static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStrea
|
||||
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "FileContentsResponse");
|
||||
|
||||
response.msgType = CB_FILECONTENTS_RESPONSE;
|
||||
response.msgFlags = flags;
|
||||
response.dataLen = length;
|
||||
response.common.msgType = CB_FILECONTENTS_RESPONSE;
|
||||
response.common.msgFlags = flags;
|
||||
response.common.dataLen = length;
|
||||
|
||||
if ((error = cliprdr_read_file_contents_response(s, &response)))
|
||||
return error;
|
||||
@ -378,7 +378,7 @@ static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr, wStrea
|
||||
static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
|
||||
UINT16 flags)
|
||||
{
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData;
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -390,9 +390,9 @@ static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
lockClipboardData.msgType = CB_LOCK_CLIPDATA;
|
||||
lockClipboardData.msgFlags = flags;
|
||||
lockClipboardData.dataLen = length;
|
||||
lockClipboardData.common.msgType = CB_LOCK_CLIPDATA;
|
||||
lockClipboardData.common.msgFlags = flags;
|
||||
lockClipboardData.common.dataLen = length;
|
||||
Stream_Read_UINT32(s, lockClipboardData.clipDataId); /* clipDataId (4 bytes) */
|
||||
IFCALLRET(context->ServerLockClipboardData, error, context, &lockClipboardData);
|
||||
|
||||
@ -410,7 +410,7 @@ static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UI
|
||||
static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
|
||||
UINT16 flags)
|
||||
{
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData;
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData = { 0 };
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -422,9 +422,9 @@ static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
|
||||
if ((error = cliprdr_read_unlock_clipdata(s, &unlockClipboardData)))
|
||||
return error;
|
||||
|
||||
unlockClipboardData.msgType = CB_UNLOCK_CLIPDATA;
|
||||
unlockClipboardData.msgFlags = flags;
|
||||
unlockClipboardData.dataLen = length;
|
||||
unlockClipboardData.common.msgType = CB_UNLOCK_CLIPDATA;
|
||||
unlockClipboardData.common.msgFlags = flags;
|
||||
unlockClipboardData.common.dataLen = length;
|
||||
|
||||
IFCALLRET(context->ServerUnlockClipboardData, error, context, &unlockClipboardData);
|
||||
|
||||
@ -701,7 +701,7 @@ cliprdr_client_format_list_response(CliprdrClientContext* context,
|
||||
cliprdr = (cliprdrPlugin*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->msgFlags, 0);
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->common.msgFlags, 0);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -822,8 +822,8 @@ cliprdr_client_format_data_response(CliprdrClientContext* context,
|
||||
cliprdr = (cliprdrPlugin*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->msgFlags,
|
||||
formatDataResponse->dataLen);
|
||||
s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->common.msgFlags,
|
||||
formatDataResponse->common.dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -831,7 +831,7 @@ cliprdr_client_format_data_response(CliprdrClientContext* context,
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
|
||||
Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->common.dataLen);
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatDataResponse");
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
|
@ -170,7 +170,8 @@ wStream* cliprdr_packet_file_contents_response_new(const CLIPRDR_FILE_CONTENTS_R
|
||||
if (!response)
|
||||
return NULL;
|
||||
|
||||
s = cliprdr_packet_new(CB_FILECONTENTS_RESPONSE, response->msgFlags, 4 + response->cbRequested);
|
||||
s = cliprdr_packet_new(CB_FILECONTENTS_RESPONSE, response->common.msgFlags,
|
||||
4 + response->cbRequested);
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
@ -193,9 +194,9 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
|
||||
CLIPRDR_FORMAT* format;
|
||||
UINT32 length;
|
||||
|
||||
if (formatList->msgType != CB_FORMAT_LIST)
|
||||
if (formatList->common.msgType != CB_FORMAT_LIST)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
formatList->msgType);
|
||||
formatList->common.msgType);
|
||||
|
||||
if (!useLongFormatNames)
|
||||
{
|
||||
@ -342,10 +343,10 @@ UINT cliprdr_read_format_data_response(wStream* s, CLIPRDR_FORMAT_DATA_RESPONSE*
|
||||
{
|
||||
response->requestedFormatData = NULL;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, response->dataLen))
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, response->common.dataLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
if (response->dataLen)
|
||||
if (response->common.dataLen)
|
||||
response->requestedFormatData = Stream_Pointer(s);
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
@ -383,7 +384,9 @@ UINT cliprdr_read_file_contents_response(wStream* s, CLIPRDR_FILE_CONTENTS_RESPO
|
||||
|
||||
Stream_Read_UINT32(s, response->streamId); /* streamId (4 bytes) */
|
||||
response->requestedData = Stream_Pointer(s); /* requestedFileContentsData */
|
||||
response->cbRequested = response->dataLen - 4;
|
||||
|
||||
WINPR_ASSERT(response->common.dataLen >= 4);
|
||||
response->cbRequested = response->common.dataLen - 4;
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
|
||||
@ -399,18 +402,18 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
UINT error = ERROR_INTERNAL_ERROR;
|
||||
|
||||
asciiNames = (formatList->msgFlags & CB_ASCII_NAMES) ? TRUE : FALSE;
|
||||
asciiNames = (formatList->common.msgFlags & CB_ASCII_NAMES) ? TRUE : FALSE;
|
||||
|
||||
index = 0;
|
||||
/* empty format list */
|
||||
formatList->formats = NULL;
|
||||
formatList->numFormats = 0;
|
||||
|
||||
sub1 = Stream_StaticInit(&sub1buffer, Stream_Pointer(s), formatList->dataLen);
|
||||
if (!Stream_SafeSeek(s, formatList->dataLen))
|
||||
sub1 = Stream_StaticInit(&sub1buffer, Stream_Pointer(s), formatList->common.dataLen);
|
||||
if (!Stream_SafeSeek(s, formatList->common.dataLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
if (!formatList->dataLen)
|
||||
if (!formatList->common.dataLen)
|
||||
{
|
||||
}
|
||||
else if (!useLongFormatNames)
|
||||
@ -437,9 +440,9 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
|
||||
while (Stream_GetRemainingLength(sub1) >= 4)
|
||||
{
|
||||
Stream_Read_UINT32(sub1, formats[index].formatId); /* formatId (4 bytes) */
|
||||
CLIPRDR_FORMAT* format = &formats[index];
|
||||
|
||||
formats[index].formatName = NULL;
|
||||
Stream_Read_UINT32(sub1, format->formatId); /* formatId (4 bytes) */
|
||||
|
||||
/* According to MS-RDPECLIP 2.2.3.1.1.1 formatName is "a 32-byte block containing
|
||||
* the *null-terminated* name assigned to the Clipboard Format: (32 ASCII 8 characters
|
||||
@ -453,20 +456,22 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
wszFormatName = (WCHAR*)Stream_Pointer(sub1);
|
||||
if (!Stream_SafeSeek(sub1, 32))
|
||||
goto error_out;
|
||||
|
||||
free(format->formatName);
|
||||
format->formatName = NULL;
|
||||
|
||||
if (asciiNames)
|
||||
{
|
||||
if (szFormatName[0])
|
||||
{
|
||||
/* ensure null termination */
|
||||
formats[index].formatName = (char*)malloc(32 + 1);
|
||||
if (!formats[index].formatName)
|
||||
format->formatName = strndup(szFormatName, 31);
|
||||
if (!format->formatName)
|
||||
{
|
||||
WLog_ERR(TAG, "malloc failed!");
|
||||
error = CHANNEL_RC_NO_MEMORY;
|
||||
goto error_out;
|
||||
}
|
||||
CopyMemory(formats[index].formatName, szFormatName, 32);
|
||||
formats[index].formatName[32] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -523,9 +528,12 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
while (Stream_GetRemainingLength(sub2) >= 4)
|
||||
{
|
||||
size_t rest;
|
||||
Stream_Read_UINT32(sub2, formats[index].formatId); /* formatId (4 bytes) */
|
||||
CLIPRDR_FORMAT* format = &formats[index];
|
||||
|
||||
formats[index].formatName = NULL;
|
||||
Stream_Read_UINT32(sub2, format->formatId); /* formatId (4 bytes) */
|
||||
|
||||
free(format->formatName);
|
||||
format->formatName = NULL;
|
||||
|
||||
wszFormatName = (WCHAR*)Stream_Pointer(sub2);
|
||||
rest = Stream_GetRemainingLength(sub2);
|
||||
@ -536,7 +544,7 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
if (formatNameLength)
|
||||
{
|
||||
if (ConvertFromUnicode(CP_UTF8, 0, wszFormatName, formatNameLength,
|
||||
&(formats[index].formatName), 0, NULL, NULL) < 1)
|
||||
&format->formatName, 0, NULL, NULL) < 1)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to convert long clipboard format name");
|
||||
error = ERROR_INTERNAL_ERROR;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/print.h>
|
||||
#include <winpr/stream.h>
|
||||
|
||||
@ -81,6 +82,9 @@ static UINT cliprdr_server_packet_send(CliprdrServerPrivate* cliprdr, wStream* s
|
||||
BOOL status;
|
||||
UINT32 dataLen;
|
||||
ULONG written;
|
||||
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
pos = Stream_GetPosition(s);
|
||||
if ((pos < 8) || (pos > UINT32_MAX))
|
||||
{
|
||||
@ -118,11 +122,16 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
|
||||
size_t offset = 0;
|
||||
UINT32 x;
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
if (capabilities->msgType != CB_CLIP_CAPS)
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(capabilities);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
|
||||
if (capabilities->common.msgType != CB_CLIP_CAPS)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
capabilities->msgType);
|
||||
capabilities->common.msgType);
|
||||
|
||||
if (capabilities->cCapabilitiesSets > UINT16_MAX)
|
||||
{
|
||||
@ -186,13 +195,19 @@ static UINT cliprdr_server_monitor_ready(CliprdrServerContext* context,
|
||||
const CLIPRDR_MONITOR_READY* monitorReady)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
if (monitorReady->msgType != CB_MONITOR_READY)
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(monitorReady);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
|
||||
if (monitorReady->common.msgType != CB_MONITOR_READY)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
monitorReady->msgType);
|
||||
monitorReady->common.msgType);
|
||||
|
||||
s = cliprdr_packet_new(CB_MONITOR_READY, monitorReady->msgFlags, monitorReady->dataLen);
|
||||
s = cliprdr_packet_new(CB_MONITOR_READY, monitorReady->common.msgFlags,
|
||||
monitorReady->common.dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -213,7 +228,12 @@ static UINT cliprdr_server_format_list(CliprdrServerContext* context,
|
||||
const CLIPRDR_FORMAT_LIST* formatList)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(formatList);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
|
||||
s = cliprdr_packet_format_list_new(formatList, context->useLongFormatNames);
|
||||
if (!s)
|
||||
@ -236,13 +256,18 @@ cliprdr_server_format_list_response(CliprdrServerContext* context,
|
||||
const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (formatListResponse->msgType != CB_FORMAT_LIST_RESPONSE)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
formatListResponse->msgType);
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->msgFlags,
|
||||
formatListResponse->dataLen);
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(formatListResponse);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (formatListResponse->common.msgType != CB_FORMAT_LIST_RESPONSE)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
formatListResponse->common.msgType);
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST_RESPONSE, formatListResponse->common.msgFlags,
|
||||
formatListResponse->common.dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -263,10 +288,15 @@ static UINT cliprdr_server_lock_clipboard_data(CliprdrServerContext* context,
|
||||
const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (lockClipboardData->msgType != CB_LOCK_CLIPDATA)
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(lockClipboardData);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (lockClipboardData->common.msgType != CB_LOCK_CLIPDATA)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
lockClipboardData->msgType);
|
||||
lockClipboardData->common.msgType);
|
||||
|
||||
s = cliprdr_packet_lock_clipdata_new(lockClipboardData);
|
||||
if (!s)
|
||||
@ -290,10 +320,15 @@ cliprdr_server_unlock_clipboard_data(CliprdrServerContext* context,
|
||||
const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (unlockClipboardData->msgType != CB_UNLOCK_CLIPDATA)
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(unlockClipboardData);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (unlockClipboardData->common.msgType != CB_UNLOCK_CLIPDATA)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
unlockClipboardData->msgType);
|
||||
unlockClipboardData->common.msgType);
|
||||
|
||||
s = cliprdr_packet_unlock_clipdata_new(unlockClipboardData);
|
||||
|
||||
@ -317,13 +352,18 @@ static UINT cliprdr_server_format_data_request(CliprdrServerContext* context,
|
||||
const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (formatDataRequest->msgType != CB_FORMAT_DATA_REQUEST)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
formatDataRequest->msgType);
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST, formatDataRequest->msgFlags,
|
||||
formatDataRequest->dataLen);
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(formatDataRequest);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
if (formatDataRequest->common.msgType != CB_FORMAT_DATA_REQUEST)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
formatDataRequest->common.msgType);
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST, formatDataRequest->common.msgFlags,
|
||||
formatDataRequest->common.dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -346,14 +386,19 @@ cliprdr_server_format_data_response(CliprdrServerContext* context,
|
||||
const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
if (formatDataResponse->msgType != CB_FORMAT_DATA_RESPONSE)
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(formatDataResponse);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
|
||||
if (formatDataResponse->common.msgType != CB_FORMAT_DATA_RESPONSE)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
formatDataResponse->msgType);
|
||||
formatDataResponse->common.msgType);
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->msgFlags,
|
||||
formatDataResponse->dataLen);
|
||||
s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->common.msgFlags,
|
||||
formatDataResponse->common.dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -361,7 +406,7 @@ cliprdr_server_format_data_response(CliprdrServerContext* context,
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
|
||||
Stream_Write(s, formatDataResponse->requestedFormatData, formatDataResponse->common.dataLen);
|
||||
WLog_DBG(TAG, "ServerFormatDataResponse");
|
||||
return cliprdr_server_packet_send(cliprdr, s);
|
||||
}
|
||||
@ -376,11 +421,16 @@ cliprdr_server_file_contents_request(CliprdrServerContext* context,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
if (fileContentsRequest->msgType != CB_FILECONTENTS_REQUEST)
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
|
||||
if (fileContentsRequest->common.msgType != CB_FILECONTENTS_REQUEST)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
fileContentsRequest->msgType);
|
||||
fileContentsRequest->common.msgType);
|
||||
|
||||
s = cliprdr_packet_file_contents_request_new(fileContentsRequest);
|
||||
if (!s)
|
||||
@ -404,11 +454,16 @@ cliprdr_server_file_contents_response(CliprdrServerContext* context,
|
||||
const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
|
||||
{
|
||||
wStream* s;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
if (fileContentsResponse->msgType != CB_FILECONTENTS_RESPONSE)
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(fileContentsResponse);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
|
||||
if (fileContentsResponse->common.msgType != CB_FILECONTENTS_RESPONSE)
|
||||
WLog_WARN(TAG, "[%s] called with invalid type %08" PRIx32, __FUNCTION__,
|
||||
fileContentsResponse->msgType);
|
||||
fileContentsResponse->common.msgType);
|
||||
|
||||
s = cliprdr_packet_file_contents_response_new(fileContentsResponse);
|
||||
if (!s)
|
||||
@ -430,6 +485,9 @@ cliprdr_server_file_contents_response(CliprdrServerContext* context,
|
||||
static UINT cliprdr_server_receive_general_capability(CliprdrServerContext* context, wStream* s,
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET* cap_set)
|
||||
{
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(cap_set);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
@ -474,6 +532,7 @@ static UINT cliprdr_server_receive_capabilities(CliprdrServerContext* context, w
|
||||
CLIPRDR_CAPABILITIES capabilities = { 0 };
|
||||
CLIPRDR_CAPABILITY_SET* capSet;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_UNUSED(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientCapabilities");
|
||||
@ -547,13 +606,17 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* con
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
size_t length;
|
||||
WCHAR* wszTempDir;
|
||||
CLIPRDR_TEMP_DIRECTORY tempDirectory;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
const WCHAR* wszTempDir;
|
||||
CLIPRDR_TEMP_DIRECTORY tempDirectory = { 0 };
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_UNUSED(header);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 260 * sizeof(WCHAR)))
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
|
||||
@ -565,17 +628,16 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* con
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
free(cliprdr->temporaryDirectory);
|
||||
cliprdr->temporaryDirectory = NULL;
|
||||
memset(cliprdr->temporaryDirectory, 0, ARRAYSIZE(cliprdr->temporaryDirectory));
|
||||
|
||||
if (ConvertFromUnicode(CP_UTF8, 0, wszTempDir, -1, &(cliprdr->temporaryDirectory), 0, NULL,
|
||||
NULL) < 1)
|
||||
if (ConvertFromUnicode(CP_UTF8, 0, wszTempDir, -1, &(cliprdr->temporaryDirectory),
|
||||
ARRAYSIZE(cliprdr->temporaryDirectory), NULL, NULL) < 1)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to convert temporary directory name");
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
length = strnlen(cliprdr->temporaryDirectory, 260);
|
||||
length = strnlen(cliprdr->temporaryDirectory, ARRAYSIZE(cliprdr->temporaryDirectory));
|
||||
|
||||
if (length >= 260)
|
||||
length = 259;
|
||||
@ -599,12 +661,15 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* con
|
||||
static UINT cliprdr_server_receive_format_list(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_FORMAT_LIST formatList;
|
||||
CLIPRDR_FORMAT_LIST formatList = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
formatList.msgFlags = header->msgFlags;
|
||||
formatList.dataLen = header->dataLen;
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
formatList.common.msgType = CB_FORMAT_LIST;
|
||||
formatList.common.msgFlags = header->msgFlags;
|
||||
formatList.common.dataLen = header->dataLen;
|
||||
|
||||
if ((error = cliprdr_read_format_list(s, &formatList, context->useLongFormatNames)))
|
||||
goto out;
|
||||
@ -628,14 +693,17 @@ out:
|
||||
static UINT cliprdr_server_receive_format_list_response(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WINPR_UNUSED(s);
|
||||
WLog_DBG(TAG, "CliprdrClientFormatListResponse");
|
||||
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.msgFlags = header->msgFlags;
|
||||
formatListResponse.dataLen = header->dataLen;
|
||||
formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.common.msgFlags = header->msgFlags;
|
||||
formatListResponse.common.dataLen = header->dataLen;
|
||||
IFCALLRET(context->ClientFormatListResponse, error, context, &formatListResponse);
|
||||
|
||||
if (error)
|
||||
@ -652,16 +720,20 @@ static UINT cliprdr_server_receive_format_list_response(CliprdrServerContext* co
|
||||
static UINT cliprdr_server_receive_lock_clipdata(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData;
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientLockClipData");
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
lockClipboardData.msgType = CB_LOCK_CLIPDATA;
|
||||
lockClipboardData.msgFlags = header->msgFlags;
|
||||
lockClipboardData.dataLen = header->dataLen;
|
||||
lockClipboardData.common.msgType = CB_LOCK_CLIPDATA;
|
||||
lockClipboardData.common.msgFlags = header->msgFlags;
|
||||
lockClipboardData.common.dataLen = header->dataLen;
|
||||
Stream_Read_UINT32(s, lockClipboardData.clipDataId); /* clipDataId (4 bytes) */
|
||||
IFCALLRET(context->ClientLockClipboardData, error, context, &lockClipboardData);
|
||||
|
||||
@ -679,13 +751,17 @@ static UINT cliprdr_server_receive_lock_clipdata(CliprdrServerContext* context,
|
||||
static UINT cliprdr_server_receive_unlock_clipdata(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData;
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientUnlockClipData");
|
||||
|
||||
unlockClipboardData.msgType = CB_UNLOCK_CLIPDATA;
|
||||
unlockClipboardData.msgFlags = header->msgFlags;
|
||||
unlockClipboardData.dataLen = header->dataLen;
|
||||
unlockClipboardData.common.msgType = CB_UNLOCK_CLIPDATA;
|
||||
unlockClipboardData.common.msgFlags = header->msgFlags;
|
||||
unlockClipboardData.common.dataLen = header->dataLen;
|
||||
|
||||
if ((error = cliprdr_read_unlock_clipdata(s, &unlockClipboardData)))
|
||||
return error;
|
||||
@ -706,12 +782,16 @@ static UINT cliprdr_server_receive_unlock_clipdata(CliprdrServerContext* context
|
||||
static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
|
||||
CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientFormatDataRequest");
|
||||
formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.msgFlags = header->msgFlags;
|
||||
formatDataRequest.dataLen = header->dataLen;
|
||||
formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.common.msgFlags = header->msgFlags;
|
||||
formatDataRequest.common.dataLen = header->dataLen;
|
||||
|
||||
if ((error = cliprdr_read_format_data_request(s, &formatDataRequest)))
|
||||
return error;
|
||||
@ -733,13 +813,16 @@ static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext* con
|
||||
static UINT cliprdr_server_receive_format_data_response(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse;
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientFormatDataResponse");
|
||||
formatDataResponse.msgType = CB_FORMAT_DATA_RESPONSE;
|
||||
formatDataResponse.msgFlags = header->msgFlags;
|
||||
formatDataResponse.dataLen = header->dataLen;
|
||||
formatDataResponse.common.msgType = CB_FORMAT_DATA_RESPONSE;
|
||||
formatDataResponse.common.msgFlags = header->msgFlags;
|
||||
formatDataResponse.common.dataLen = header->dataLen;
|
||||
|
||||
if ((error = cliprdr_read_format_data_response(s, &formatDataResponse)))
|
||||
return error;
|
||||
@ -760,12 +843,16 @@ static UINT cliprdr_server_receive_format_data_response(CliprdrServerContext* co
|
||||
static UINT cliprdr_server_receive_filecontents_request(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST request;
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST request = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientFileContentsRequest");
|
||||
request.msgType = CB_FILECONTENTS_REQUEST;
|
||||
request.msgFlags = header->msgFlags;
|
||||
request.dataLen = header->dataLen;
|
||||
request.common.msgType = CB_FILECONTENTS_REQUEST;
|
||||
request.common.msgFlags = header->msgFlags;
|
||||
request.common.dataLen = header->dataLen;
|
||||
|
||||
if ((error = cliprdr_read_file_contents_request(s, &request)))
|
||||
return error;
|
||||
@ -793,13 +880,17 @@ static UINT cliprdr_server_receive_filecontents_request(CliprdrServerContext* co
|
||||
static UINT cliprdr_server_receive_filecontents_response(CliprdrServerContext* context, wStream* s,
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response;
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG, "CliprdrClientFileContentsResponse");
|
||||
|
||||
response.msgType = CB_FILECONTENTS_RESPONSE;
|
||||
response.msgFlags = header->msgFlags;
|
||||
response.dataLen = header->dataLen;
|
||||
response.common.msgType = CB_FILECONTENTS_RESPONSE;
|
||||
response.common.msgFlags = header->msgFlags;
|
||||
response.common.dataLen = header->dataLen;
|
||||
|
||||
if ((error = cliprdr_read_file_contents_response(s, &response)))
|
||||
return error;
|
||||
@ -821,6 +912,10 @@ static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context, wStream* s
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
UINT error;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(header);
|
||||
|
||||
WLog_DBG(TAG,
|
||||
"CliprdrServerReceivePdu: msgType: %" PRIu16 " msgFlags: 0x%04" PRIX16
|
||||
" dataLen: %" PRIu32 "",
|
||||
@ -927,15 +1022,16 @@ static UINT cliprdr_server_receive_pdu(CliprdrServerContext* context, wStream* s
|
||||
*/
|
||||
static UINT cliprdr_server_init(CliprdrServerContext* context)
|
||||
{
|
||||
UINT32 generalFlags;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
|
||||
UINT error;
|
||||
UINT32 generalFlags = 0;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = { 0 };
|
||||
UINT error = 0;
|
||||
CLIPRDR_MONITOR_READY monitorReady = { 0 };
|
||||
CLIPRDR_CAPABILITIES capabilities = { 0 };
|
||||
|
||||
generalFlags = 0;
|
||||
monitorReady.msgType = CB_MONITOR_READY;
|
||||
capabilities.msgType = CB_CLIP_CAPS;
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
monitorReady.common.msgType = CB_MONITOR_READY;
|
||||
capabilities.common.msgType = CB_CLIP_CAPS;
|
||||
|
||||
if (context->useLongFormatNames)
|
||||
generalFlags |= CB_USE_LONG_FORMAT_NAMES;
|
||||
@ -952,9 +1048,9 @@ static UINT cliprdr_server_init(CliprdrServerContext* context)
|
||||
if (context->hasHugeFileSupport)
|
||||
generalFlags |= CB_HUGE_FILE_SUPPORT_ENABLED;
|
||||
|
||||
capabilities.msgType = CB_CLIP_CAPS;
|
||||
capabilities.msgFlags = 0;
|
||||
capabilities.dataLen = 4 + CB_CAPSTYPE_GENERAL_LEN;
|
||||
capabilities.common.msgType = CB_CLIP_CAPS;
|
||||
capabilities.common.msgFlags = 0;
|
||||
capabilities.common.dataLen = 4 + CB_CAPSTYPE_GENERAL_LEN;
|
||||
capabilities.cCapabilitiesSets = 1;
|
||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&generalCapabilitySet;
|
||||
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
||||
@ -988,10 +1084,16 @@ static UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
size_t position;
|
||||
DWORD BytesToRead;
|
||||
DWORD BytesReturned;
|
||||
CLIPRDR_HEADER header;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CLIPRDR_HEADER header = { 0 };
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
UINT error;
|
||||
DWORD status;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
s = cliprdr->s;
|
||||
|
||||
if (Stream_GetPosition(s) < CLIPRDR_HEADER_LENGTH)
|
||||
@ -1123,16 +1225,21 @@ static UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
|
||||
static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
|
||||
{
|
||||
DWORD status;
|
||||
DWORD nCount;
|
||||
HANDLE events[8];
|
||||
DWORD status = 0;
|
||||
DWORD nCount = 0;
|
||||
HANDLE events[MAXIMUM_WAIT_OBJECTS] = { 0 };
|
||||
HANDLE ChannelEvent;
|
||||
CliprdrServerContext* context = (CliprdrServerContext*)arg;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
ChannelEvent = context->GetEventHandle(context);
|
||||
nCount = 0;
|
||||
|
||||
events[nCount++] = cliprdr->StopEvent;
|
||||
events[nCount++] = ChannelEvent;
|
||||
|
||||
@ -1205,7 +1312,13 @@ static UINT cliprdr_server_open(CliprdrServerContext* context)
|
||||
{
|
||||
void* buffer = NULL;
|
||||
DWORD BytesReturned = 0;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
cliprdr->ChannelHandle =
|
||||
WTSVirtualChannelOpen(cliprdr->vcm, WTS_CURRENT_SESSION, CLIPRDR_SVC_CHANNEL_NAME);
|
||||
|
||||
@ -1246,7 +1359,12 @@ static UINT cliprdr_server_open(CliprdrServerContext* context)
|
||||
*/
|
||||
static UINT cliprdr_server_close(CliprdrServerContext* context)
|
||||
{
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
if (cliprdr->ChannelHandle)
|
||||
{
|
||||
@ -1264,8 +1382,13 @@ static UINT cliprdr_server_close(CliprdrServerContext* context)
|
||||
*/
|
||||
static UINT cliprdr_server_start(CliprdrServerContext* context)
|
||||
{
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
UINT error;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
if (!cliprdr->ChannelHandle)
|
||||
{
|
||||
@ -1301,7 +1424,12 @@ static UINT cliprdr_server_start(CliprdrServerContext* context)
|
||||
static UINT cliprdr_server_stop(CliprdrServerContext* context)
|
||||
{
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
if (cliprdr->StopEvent)
|
||||
{
|
||||
@ -1326,7 +1454,12 @@ static UINT cliprdr_server_stop(CliprdrServerContext* context)
|
||||
|
||||
static HANDLE cliprdr_server_get_event_handle(CliprdrServerContext* context)
|
||||
{
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
cliprdr = (CliprdrServerPrivate*)context->handle;
|
||||
WINPR_ASSERT(cliprdr);
|
||||
return cliprdr->ChannelEvent;
|
||||
}
|
||||
|
||||
@ -1342,9 +1475,8 @@ static UINT cliprdr_server_check_event_handle(CliprdrServerContext* context)
|
||||
|
||||
CliprdrServerContext* cliprdr_server_context_new(HANDLE vcm)
|
||||
{
|
||||
CliprdrServerContext* context;
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
context = (CliprdrServerContext*)calloc(1, sizeof(CliprdrServerContext));
|
||||
CliprdrServerContext* context = (CliprdrServerContext*)calloc(1, sizeof(CliprdrServerContext));
|
||||
|
||||
if (context)
|
||||
{
|
||||
@ -1403,7 +1535,6 @@ void cliprdr_server_context_free(CliprdrServerContext* context)
|
||||
if (cliprdr)
|
||||
{
|
||||
Stream_Free(cliprdr->s, TRUE);
|
||||
free(cliprdr->temporaryDirectory);
|
||||
}
|
||||
|
||||
free(context->handle);
|
||||
|
@ -41,7 +41,7 @@ typedef struct
|
||||
HANDLE ChannelEvent;
|
||||
|
||||
wStream* s;
|
||||
char* temporaryDirectory;
|
||||
char temporaryDirectory[260];
|
||||
} CliprdrServerPrivate;
|
||||
|
||||
#endif /* FREERDP_CHANNEL_CLIPRDR_SERVER_MAIN_H */
|
||||
|
@ -76,10 +76,10 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr)
|
||||
}
|
||||
}
|
||||
|
||||
formatList.msgFlags = CB_RESPONSE_OK;
|
||||
formatList.common.msgFlags = CB_RESPONSE_OK;
|
||||
formatList.numFormats = numFormats;
|
||||
formatList.formats = formats;
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
formatList.common.msgType = CB_FORMAT_LIST;
|
||||
|
||||
if (!afc->cliprdr->ClientFormatList)
|
||||
goto fail;
|
||||
@ -107,8 +107,8 @@ static UINT android_cliprdr_send_client_format_data_request(CliprdrClientContext
|
||||
goto fail;
|
||||
|
||||
ZeroMemory(&formatDataRequest, sizeof(CLIPRDR_FORMAT_DATA_REQUEST));
|
||||
formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.msgFlags = 0;
|
||||
formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.common.msgFlags = 0;
|
||||
formatDataRequest.requestedFormatId = formatId;
|
||||
afc->requestedFormatId = formatId;
|
||||
ResetEvent(afc->clipboardRequestEvent);
|
||||
@ -350,14 +350,14 @@ android_cliprdr_server_format_data_request(CliprdrClientContext* cliprdr,
|
||||
ZeroMemory(&response, sizeof(CLIPRDR_FORMAT_DATA_RESPONSE));
|
||||
formatId = formatDataRequest->requestedFormatId;
|
||||
data = (BYTE*)ClipboardGetData(afc->clipboard, formatId, &size);
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
response.dataLen = size;
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.common.dataLen = size;
|
||||
response.requestedFormatData = data;
|
||||
|
||||
if (!data)
|
||||
{
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.dataLen = 0;
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.common.dataLen = 0;
|
||||
response.requestedFormatData = NULL;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr,
|
||||
else
|
||||
formatId = format->formatId;
|
||||
|
||||
size = formatDataResponse->dataLen;
|
||||
size = formatDataResponse->common.dataLen;
|
||||
|
||||
if (!ClipboardSetData(afc->clipboard, formatId, formatDataResponse->requestedFormatData, size))
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
@ -54,10 +54,10 @@ int mac_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr)
|
||||
formats[index].formatName = _strdup(formatName);
|
||||
}
|
||||
|
||||
formatList.msgFlags = CB_RESPONSE_OK;
|
||||
formatList.common.msgFlags = CB_RESPONSE_OK;
|
||||
formatList.numFormats = numFormats;
|
||||
formatList.formats = formats;
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
formatList.common.msgType = CB_FORMAT_LIST;
|
||||
|
||||
mfc->cliprdr->ClientFormatList(mfc->cliprdr, &formatList);
|
||||
|
||||
@ -76,9 +76,9 @@ static int mac_cliprdr_send_client_format_list_response(CliprdrClientContext *cl
|
||||
{
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
|
||||
|
||||
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
formatListResponse.dataLen = 0;
|
||||
formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.common.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
formatListResponse.common.dataLen = 0;
|
||||
|
||||
cliprdr->ClientFormatListResponse(cliprdr, &formatListResponse);
|
||||
|
||||
@ -93,8 +93,8 @@ static int mac_cliprdr_send_client_format_data_request(CliprdrClientContext *cli
|
||||
|
||||
ZeroMemory(&formatDataRequest, sizeof(CLIPRDR_FORMAT_DATA_REQUEST));
|
||||
|
||||
formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.msgFlags = 0;
|
||||
formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
|
||||
formatDataRequest.common.msgFlags = 0;
|
||||
|
||||
formatDataRequest.requestedFormatId = formatId;
|
||||
mfc->requestedFormatId = formatId;
|
||||
@ -295,14 +295,14 @@ mac_cliprdr_server_format_data_request(CliprdrClientContext *cliprdr,
|
||||
formatId = formatDataRequest->requestedFormatId;
|
||||
data = (BYTE *)ClipboardGetData(mfc->clipboard, formatId, &size);
|
||||
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
response.dataLen = size;
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.common.dataLen = size;
|
||||
response.requestedFormatData = data;
|
||||
|
||||
if (!data)
|
||||
{
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.dataLen = 0;
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.common.dataLen = 0;
|
||||
response.requestedFormatData = NULL;
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr,
|
||||
mfContext *mfc = (mfContext *)cliprdr->custom;
|
||||
MRDPView *view = (MRDPView *)mfc->view;
|
||||
|
||||
if (formatDataResponse->msgFlags & CB_RESPONSE_FAIL)
|
||||
if (formatDataResponse->common.msgFlags & CB_RESPONSE_FAIL)
|
||||
{
|
||||
SetEvent(mfc->clipboardRequestEvent);
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -353,7 +353,7 @@ mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr,
|
||||
else
|
||||
formatId = format->formatId;
|
||||
|
||||
size = formatDataResponse->dataLen;
|
||||
size = formatDataResponse->common.dataLen;
|
||||
|
||||
ClipboardSetData(mfc->clipboard, formatId, formatDataResponse->requestedFormatData, size);
|
||||
|
||||
|
@ -170,10 +170,14 @@ static void wlf_cliprdr_free_client_formats(wfClipboard* clipboard)
|
||||
static UINT wlf_cliprdr_send_client_format_list(wfClipboard* clipboard)
|
||||
{
|
||||
CLIPRDR_FORMAT_LIST formatList = { 0 };
|
||||
formatList.msgFlags = CB_RESPONSE_OK;
|
||||
formatList.common.msgFlags = CB_RESPONSE_OK;
|
||||
formatList.numFormats = (UINT32)clipboard->numClientFormats;
|
||||
formatList.formats = clipboard->clientFormats;
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
formatList.common.msgType = CB_FORMAT_LIST;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatList);
|
||||
return clipboard->context->ClientFormatList(clipboard->context, &formatList);
|
||||
}
|
||||
|
||||
@ -238,6 +242,10 @@ static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, UINT32 formatI
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_REQUEST request = { 0 };
|
||||
request.requestedFormatId = formatId;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatDataRequest);
|
||||
return clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
|
||||
}
|
||||
|
||||
@ -253,9 +261,13 @@ static UINT wlf_cliprdr_send_data_response(wfClipboard* clipboard, const BYTE* d
|
||||
if (size > UINT32_MAX)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
response.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
response.dataLen = (UINT32)size;
|
||||
response.common.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
response.common.dataLen = (UINT32)size;
|
||||
response.requestedFormatData = data;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatDataResponse);
|
||||
return clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -295,8 +307,8 @@ BOOL wlf_cliprdr_handle_event(wfClipboard* clipboard, const UwacClipboardEvent*
|
||||
*/
|
||||
static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
|
||||
{
|
||||
CLIPRDR_CAPABILITIES capabilities;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
|
||||
CLIPRDR_CAPABILITIES capabilities = { 0 };
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = { 0 };
|
||||
capabilities.cCapabilitiesSets = 1;
|
||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
|
||||
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
||||
@ -308,6 +320,9 @@ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
|
||||
generalCapabilitySet.generalFlags |=
|
||||
CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS | CB_HUGE_FILE_SUPPORT_ENABLED;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientCapabilities);
|
||||
return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
|
||||
}
|
||||
|
||||
@ -318,10 +333,13 @@ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
|
||||
*/
|
||||
static UINT wlf_cliprdr_send_client_format_list_response(wfClipboard* clipboard, BOOL status)
|
||||
{
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
|
||||
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
formatListResponse.dataLen = 0;
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse = { 0 };
|
||||
formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.common.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
formatListResponse.common.dataLen = 0;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatListResponse);
|
||||
return clipboard->context->ClientFormatListResponse(clipboard->context, &formatListResponse);
|
||||
}
|
||||
|
||||
@ -708,7 +726,7 @@ wlf_cliprdr_server_format_data_response(CliprdrClientContext* context,
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(formatDataResponse);
|
||||
|
||||
size = formatDataResponse->dataLen;
|
||||
size = formatDataResponse->common.dataLen;
|
||||
data = (LPCSTR)formatDataResponse->requestedFormatData;
|
||||
wdata = (const WCHAR*)formatDataResponse->requestedFormatData;
|
||||
|
||||
@ -758,6 +776,9 @@ wlf_cliprdr_server_file_size_request(wfClipboard* clipboard,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
wClipboardFileSizeRequest request = { 0 };
|
||||
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
request.streamId = fileContentsRequest->streamId;
|
||||
request.listIndex = fileContentsRequest->listIndex;
|
||||
|
||||
@ -768,6 +789,9 @@ wlf_cliprdr_server_file_size_request(wfClipboard* clipboard,
|
||||
fileContentsRequest->cbRequested);
|
||||
}
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->delegate);
|
||||
WINPR_ASSERT(clipboard->delegate->ClientRequestFileSize);
|
||||
return clipboard->delegate->ClientRequestFileSize(clipboard->delegate, &request);
|
||||
}
|
||||
|
||||
@ -776,11 +800,18 @@ wlf_cliprdr_server_file_range_request(wfClipboard* clipboard,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
wClipboardFileRangeRequest request = { 0 };
|
||||
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
request.streamId = fileContentsRequest->streamId;
|
||||
request.listIndex = fileContentsRequest->listIndex;
|
||||
request.nPositionLow = fileContentsRequest->nPositionLow;
|
||||
request.nPositionHigh = fileContentsRequest->nPositionHigh;
|
||||
request.cbRequested = fileContentsRequest->cbRequested;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->delegate);
|
||||
WINPR_ASSERT(clipboard->delegate->ClientRequestFileRange);
|
||||
return clipboard->delegate->ClientRequestFileRange(clipboard->delegate, &request);
|
||||
}
|
||||
|
||||
@ -789,8 +820,14 @@ wlf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.streamId = fileContentsRequest->streamId;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(context->ClientFileContentsResponse);
|
||||
return context->ClientFileContentsResponse(context, &response);
|
||||
}
|
||||
|
||||
@ -839,11 +876,20 @@ static UINT wlf_cliprdr_clipboard_file_size_success(wClipboardDelegate* delegate
|
||||
UINT64 fileSize)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
wfClipboard* clipboard = delegate->custom;
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
wfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.streamId = request->streamId;
|
||||
response.cbRequested = sizeof(UINT64);
|
||||
response.requestedData = (BYTE*)&fileSize;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -852,10 +898,19 @@ static UINT wlf_cliprdr_clipboard_file_size_failure(wClipboardDelegate* delegate
|
||||
UINT errorCode)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
wfClipboard* clipboard = delegate->custom;
|
||||
wfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
WINPR_UNUSED(errorCode);
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.streamId = request->streamId;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -864,11 +919,21 @@ static UINT wlf_cliprdr_clipboard_file_range_success(wClipboardDelegate* delegat
|
||||
const BYTE* data, UINT32 size)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
wfClipboard* clipboard = delegate->custom;
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
wfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
WINPR_ASSERT(data || (size == 0));
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.streamId = request->streamId;
|
||||
response.cbRequested = size;
|
||||
response.requestedData = (const BYTE*)data;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -877,10 +942,19 @@ static UINT wlf_cliprdr_clipboard_file_range_failure(wClipboardDelegate* delegat
|
||||
UINT errorCode)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
wfClipboard* clipboard = delegate->custom;
|
||||
wfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
WINPR_UNUSED(errorCode);
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.streamId = request->streamId;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
|
@ -1280,7 +1280,7 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard)
|
||||
|
||||
formatList.numFormats = numFormats;
|
||||
formatList.formats = formats;
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
formatList.common.msgType = CB_FORMAT_LIST;
|
||||
rc = clipboard->context->ClientFormatList(clipboard->context, &formatList);
|
||||
|
||||
for (index = 0; index < numFormats; index++)
|
||||
@ -1330,7 +1330,7 @@ UINT cliprdr_send_request_filecontents(wfClipboard* clipboard, const void* strea
|
||||
fileContentsRequest.nPositionHigh = positionhigh;
|
||||
fileContentsRequest.cbRequested = nreq;
|
||||
fileContentsRequest.clipDataId = 0;
|
||||
fileContentsRequest.msgFlags = 0;
|
||||
fileContentsRequest.common.msgFlags = 0;
|
||||
rc = clipboard->context->ClientFileContentsRequest(clipboard->context, &fileContentsRequest);
|
||||
|
||||
if (WaitForSingleObject(clipboard->req_fevent, INFINITE) != WAIT_OBJECT_0)
|
||||
@ -1352,7 +1352,7 @@ static UINT cliprdr_send_response_filecontents(wfClipboard* clipboard, UINT32 st
|
||||
fileContentsResponse.streamId = streamId;
|
||||
fileContentsResponse.cbRequested = size;
|
||||
fileContentsResponse.requestedData = data;
|
||||
fileContentsResponse.msgFlags = CB_RESPONSE_OK;
|
||||
fileContentsResponse.common.msgFlags = CB_RESPONSE_OK;
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context,
|
||||
&fileContentsResponse);
|
||||
}
|
||||
@ -1961,7 +1961,7 @@ wf_cliprdr_server_format_list_response(CliprdrClientContext* context,
|
||||
(void)context;
|
||||
(void)formatListResponse;
|
||||
|
||||
if (formatListResponse->msgFlags != CB_RESPONSE_OK)
|
||||
if (formatListResponse->common.msgFlags != CB_RESPONSE_OK)
|
||||
return E_FAIL;
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
@ -2167,8 +2167,8 @@ wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
|
||||
}
|
||||
}
|
||||
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
response.dataLen = size;
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.common.dataLen = size;
|
||||
response.requestedFormatData = (BYTE*)buff;
|
||||
rc = clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
|
||||
free(buff);
|
||||
@ -2191,7 +2191,7 @@ wf_cliprdr_server_format_data_response(CliprdrClientContext* context,
|
||||
if (!context || !formatDataResponse)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
if (formatDataResponse->msgFlags != CB_RESPONSE_OK)
|
||||
if (formatDataResponse->common.msgFlags != CB_RESPONSE_OK)
|
||||
return E_FAIL;
|
||||
|
||||
clipboard = (wfClipboard*)context->custom;
|
||||
@ -2199,7 +2199,7 @@ wf_cliprdr_server_format_data_response(CliprdrClientContext* context,
|
||||
if (!clipboard)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
hMem = GlobalAlloc(GMEM_MOVEABLE, formatDataResponse->dataLen);
|
||||
hMem = GlobalAlloc(GMEM_MOVEABLE, formatDataResponse->common.dataLen);
|
||||
|
||||
if (!hMem)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -2212,7 +2212,7 @@ wf_cliprdr_server_format_data_response(CliprdrClientContext* context,
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
CopyMemory(data, formatDataResponse->requestedFormatData, formatDataResponse->dataLen);
|
||||
CopyMemory(data, formatDataResponse->requestedFormatData, formatDataResponse->common.dataLen);
|
||||
|
||||
if (!GlobalUnlock(hMem) && GetLastError())
|
||||
{
|
||||
@ -2419,7 +2419,7 @@ wf_cliprdr_server_file_contents_response(CliprdrClientContext* context,
|
||||
if (!context || !fileContentsResponse)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
if (fileContentsResponse->msgFlags != CB_RESPONSE_OK)
|
||||
if (fileContentsResponse->common.msgFlags != CB_RESPONSE_OK)
|
||||
return E_FAIL;
|
||||
|
||||
clipboard = (wfClipboard*)context->custom;
|
||||
|
@ -189,7 +189,12 @@ static void xf_cliprdr_set_selection_owner(xfContext* xfc, xfClipboard* clipboar
|
||||
static void xf_cliprdr_check_owner(xfClipboard* clipboard)
|
||||
{
|
||||
Window owner;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
if (clipboard->sync)
|
||||
{
|
||||
@ -205,14 +210,24 @@ static void xf_cliprdr_check_owner(xfClipboard* clipboard)
|
||||
|
||||
static BOOL xf_cliprdr_is_self_owned(xfClipboard* clipboard)
|
||||
{
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
return XGetSelectionOwner(xfc->display, clipboard->clipboard_atom) == xfc->drawable;
|
||||
}
|
||||
|
||||
static void xf_cliprdr_set_raw_transfer_enabled(xfClipboard* clipboard, BOOL enabled)
|
||||
{
|
||||
UINT32 data = enabled;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
XChangeProperty(xfc->display, xfc->drawable, clipboard->raw_transfer_atom, XA_INTEGER, 32,
|
||||
PropModeReplace, (BYTE*)&data, 1);
|
||||
}
|
||||
@ -227,7 +242,13 @@ static BOOL xf_cliprdr_is_raw_transfer_available(xfClipboard* clipboard)
|
||||
UINT32* data = NULL;
|
||||
UINT32 is_enabled = 0;
|
||||
Window owner = None;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
owner = XGetSelectionOwner(xfc->display, clipboard->clipboard_atom);
|
||||
|
||||
if (owner != None)
|
||||
@ -254,6 +275,9 @@ static BOOL xf_cliprdr_is_raw_transfer_available(xfClipboard* clipboard)
|
||||
|
||||
static BOOL xf_cliprdr_formats_equal(const CLIPRDR_FORMAT* server, const xfCliprdrFormat* client)
|
||||
{
|
||||
WINPR_ASSERT(server);
|
||||
WINPR_ASSERT(client);
|
||||
|
||||
if (server->formatName && client->formatName)
|
||||
{
|
||||
/* The server may be using short format names while we store them in full form. */
|
||||
@ -273,6 +297,8 @@ static const xfCliprdrFormat* xf_cliprdr_get_client_format_by_id(xfClipboard* cl
|
||||
{
|
||||
int index;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
for (index = 0; index < clipboard->numClientFormats; index++)
|
||||
{
|
||||
const xfCliprdrFormat* format = &(clipboard->clientFormats[index]);
|
||||
@ -289,6 +315,8 @@ static const xfCliprdrFormat* xf_cliprdr_get_client_format_by_atom(xfClipboard*
|
||||
{
|
||||
int i;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
for (i = 0; i < clipboard->numClientFormats; i++)
|
||||
{
|
||||
const xfCliprdrFormat* format = &(clipboard->clientFormats[i]);
|
||||
@ -304,6 +332,8 @@ static const CLIPRDR_FORMAT* xf_cliprdr_get_server_format_by_atom(xfClipboard* c
|
||||
{
|
||||
int i;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
for (i = 0; i < clipboard->numClientFormats; i++)
|
||||
{
|
||||
const xfCliprdrFormat* client_format = &(clipboard->clientFormats[i]);
|
||||
@ -333,6 +363,10 @@ static UINT xf_cliprdr_send_data_request(xfClipboard* clipboard, UINT32 formatId
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_REQUEST request = { 0 };
|
||||
request.requestedFormatId = formatId;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatDataRequest);
|
||||
return clipboard->context->ClientFormatDataRequest(clipboard->context, &request);
|
||||
}
|
||||
|
||||
@ -345,6 +379,8 @@ static UINT xf_cliprdr_send_data_response(xfClipboard* clipboard, const BYTE* da
|
||||
{
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
/* No request currently pending, do not send a response. */
|
||||
if (clipboard->requestedFormatId < 0)
|
||||
return CHANNEL_RC_OK;
|
||||
@ -352,9 +388,12 @@ static UINT xf_cliprdr_send_data_response(xfClipboard* clipboard, const BYTE* da
|
||||
/* Request handled, reset to invalid */
|
||||
clipboard->requestedFormatId = -1;
|
||||
|
||||
response.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
response.dataLen = size;
|
||||
response.common.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
response.common.dataLen = size;
|
||||
response.requestedFormatData = data;
|
||||
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatDataResponse);
|
||||
return clipboard->context->ClientFormatDataResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -364,6 +403,8 @@ static wStream* xf_cliprdr_serialize_server_format_list(xfClipboard* clipboard)
|
||||
UINT32 formatCount;
|
||||
wStream* s = NULL;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
/* Typical MS Word format list is about 80 bytes long. */
|
||||
if (!(s = Stream_New(NULL, 128)))
|
||||
{
|
||||
@ -408,6 +449,9 @@ static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data, size_t le
|
||||
wStream* s = NULL;
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
|
||||
WINPR_ASSERT(data || (length == 0));
|
||||
WINPR_ASSERT(numFormats);
|
||||
|
||||
if (!(s = Stream_New(data, length)))
|
||||
{
|
||||
WLog_ERR(TAG, "failed to allocate stream for parsing serialized format list");
|
||||
@ -467,6 +511,8 @@ static void xf_cliprdr_free_formats(CLIPRDR_FORMAT* formats, UINT32 numFormats)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
WINPR_ASSERT(formats || (numFormats == 0));
|
||||
|
||||
for (i = 0; i < numFormats; i++)
|
||||
{
|
||||
free(formats[i].formatName);
|
||||
@ -483,7 +529,14 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_raw_server_formats(xfClipboard* clipboard,
|
||||
unsigned long remaining;
|
||||
BYTE* data = NULL;
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(numFormats);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
*numFormats = 0;
|
||||
XGetWindowProperty(xfc->display, clipboard->owner, clipboard->raw_format_list_atom, 0, 4096,
|
||||
False, clipboard->raw_format_list_atom, &type, &format, &length, &remaining,
|
||||
@ -518,7 +571,14 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_formats_from_targets(xfClipboard* clipboar
|
||||
unsigned long length;
|
||||
unsigned long bytes_left;
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(numFormats);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
*numFormats = 0;
|
||||
XGetWindowProperty(xfc->display, xfc->drawable, clipboard->property_atom, 0, 200, 0, XA_ATOM,
|
||||
&atom, &format_property, &length, &bytes_left, &data);
|
||||
@ -562,6 +622,10 @@ out:
|
||||
static CLIPRDR_FORMAT* xf_cliprdr_get_client_formats(xfClipboard* clipboard, UINT32* numFormats)
|
||||
{
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(numFormats);
|
||||
|
||||
*numFormats = 0;
|
||||
|
||||
if (xf_cliprdr_is_raw_transfer_available(clipboard))
|
||||
@ -581,7 +645,13 @@ static CLIPRDR_FORMAT* xf_cliprdr_get_client_formats(xfClipboard* clipboard, UIN
|
||||
static void xf_cliprdr_provide_server_format_list(xfClipboard* clipboard)
|
||||
{
|
||||
wStream* formats = NULL;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
formats = xf_cliprdr_serialize_server_format_list(clipboard);
|
||||
|
||||
if (formats)
|
||||
@ -611,10 +681,15 @@ static BOOL xf_clipboard_format_equal(const CLIPRDR_FORMAT* a, const CLIPRDR_FOR
|
||||
return FALSE;
|
||||
return strcmp(a->formatName, b->formatName) == 0;
|
||||
}
|
||||
|
||||
static BOOL xf_clipboard_changed(xfClipboard* clipboard, const CLIPRDR_FORMAT* formats,
|
||||
UINT32 numFormats)
|
||||
{
|
||||
UINT32 x, y;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(formats || (numFormats == 0));
|
||||
|
||||
if (clipboard->lastSentNumFormats != numFormats)
|
||||
return TRUE;
|
||||
|
||||
@ -639,15 +714,21 @@ static BOOL xf_clipboard_changed(xfClipboard* clipboard, const CLIPRDR_FORMAT* f
|
||||
|
||||
static void xf_clipboard_formats_free(xfClipboard* clipboard)
|
||||
{
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xf_cliprdr_free_formats(clipboard->lastSentFormats, clipboard->lastSentNumFormats);
|
||||
clipboard->lastSentFormats = NULL;
|
||||
clipboard->lastSentNumFormats = 0;
|
||||
}
|
||||
|
||||
static BOOL xf_clipboard_copy_formats(xfClipboard* clipboard, const CLIPRDR_FORMAT* formats,
|
||||
UINT32 numFormats)
|
||||
{
|
||||
UINT32 x;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(formats || (numFormats == 0));
|
||||
|
||||
xf_clipboard_formats_free(clipboard);
|
||||
clipboard->lastSentFormats = calloc(numFormats, sizeof(CLIPRDR_FORMAT));
|
||||
if (!clipboard->lastSentFormats)
|
||||
@ -672,10 +753,13 @@ static UINT xf_cliprdr_send_format_list(xfClipboard* clipboard, const CLIPRDR_FO
|
||||
const CLIPRDR_FORMAT* cpv;
|
||||
CLIPRDR_FORMAT* pv;
|
||||
} cnv = { .cpv = formats };
|
||||
const CLIPRDR_FORMAT_LIST formatList = { .msgFlags = CB_RESPONSE_OK,
|
||||
const CLIPRDR_FORMAT_LIST formatList = { .common.msgFlags = CB_RESPONSE_OK,
|
||||
.numFormats = numFormats,
|
||||
.formats = cnv.pv,
|
||||
.msgType = CB_FORMAT_LIST };
|
||||
.common.msgType = CB_FORMAT_LIST };
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(formats || (numFormats == 0));
|
||||
|
||||
if (!xf_clipboard_changed(clipboard, formats, numFormats))
|
||||
return CHANNEL_RC_OK;
|
||||
@ -683,14 +767,16 @@ static UINT xf_cliprdr_send_format_list(xfClipboard* clipboard, const CLIPRDR_FO
|
||||
xf_clipboard_copy_formats(clipboard, formats, numFormats);
|
||||
/* Ensure all pending requests are answered. */
|
||||
xf_cliprdr_send_data_response(clipboard, NULL, 0);
|
||||
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatList);
|
||||
return clipboard->context->ClientFormatList(clipboard->context, &formatList);
|
||||
}
|
||||
|
||||
static void xf_cliprdr_get_requested_targets(xfClipboard* clipboard)
|
||||
{
|
||||
UINT32 numFormats = 0;
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
formats = xf_cliprdr_get_client_formats(clipboard, &numFormats);
|
||||
CLIPRDR_FORMAT* formats = xf_cliprdr_get_client_formats(clipboard, &numFormats);
|
||||
xf_cliprdr_send_format_list(clipboard, formats, numFormats);
|
||||
xf_cliprdr_free_formats(formats, numFormats);
|
||||
}
|
||||
@ -706,6 +792,8 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL hasDa
|
||||
BYTE* pDstData = NULL;
|
||||
const xfCliprdrFormat* format;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
if (clipboard->incr_starts && hasData)
|
||||
return;
|
||||
|
||||
@ -803,7 +891,12 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target)
|
||||
unsigned long length;
|
||||
unsigned long bytes_left;
|
||||
const xfCliprdrFormat* format;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
format = xf_cliprdr_get_client_format_by_id(clipboard, clipboard->requestedFormatId);
|
||||
|
||||
@ -893,6 +986,7 @@ static void xf_cliprdr_append_target(xfClipboard* clipboard, Atom target)
|
||||
{
|
||||
int i;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
if (clipboard->numTargets < 0)
|
||||
return;
|
||||
|
||||
@ -910,7 +1004,12 @@ static void xf_cliprdr_append_target(xfClipboard* clipboard, Atom target)
|
||||
|
||||
static void xf_cliprdr_provide_targets(xfClipboard* clipboard, const XSelectionEvent* respond)
|
||||
{
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
if (respond->property != None)
|
||||
{
|
||||
@ -921,7 +1020,12 @@ static void xf_cliprdr_provide_targets(xfClipboard* clipboard, const XSelectionE
|
||||
|
||||
static void xf_cliprdr_provide_timestamp(xfClipboard* clipboard, const XSelectionEvent* respond)
|
||||
{
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
if (respond->property != None)
|
||||
{
|
||||
@ -933,7 +1037,12 @@ static void xf_cliprdr_provide_timestamp(xfClipboard* clipboard, const XSelectio
|
||||
static void xf_cliprdr_provide_data(xfClipboard* clipboard, const XSelectionEvent* respond,
|
||||
const BYTE* data, UINT32 size)
|
||||
{
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
if (respond->property != None)
|
||||
{
|
||||
@ -945,6 +1054,9 @@ static void xf_cliprdr_provide_data(xfClipboard* clipboard, const XSelectionEven
|
||||
static BOOL xf_cliprdr_process_selection_notify(xfClipboard* clipboard,
|
||||
const XSelectionEvent* xevent)
|
||||
{
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(xevent);
|
||||
|
||||
if (xevent->target == clipboard->targets[1])
|
||||
{
|
||||
if (xevent->property == None)
|
||||
@ -966,6 +1078,8 @@ static BOOL xf_cliprdr_process_selection_notify(xfClipboard* clipboard,
|
||||
|
||||
static void xf_cliprdr_clear_cached_data(xfClipboard* clipboard)
|
||||
{
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
if (clipboard->data)
|
||||
{
|
||||
free(clipboard->data);
|
||||
@ -1021,7 +1135,13 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
|
||||
BOOL matchingFormat;
|
||||
unsigned long length;
|
||||
unsigned long bytes_left;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(xevent);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
if (xevent->owner != xfc->drawable)
|
||||
return FALSE;
|
||||
@ -1142,7 +1262,13 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard,
|
||||
static BOOL xf_cliprdr_process_selection_clear(xfClipboard* clipboard,
|
||||
const XSelectionClearEvent* xevent)
|
||||
{
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(xevent);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
WINPR_UNUSED(xevent);
|
||||
|
||||
@ -1162,6 +1288,8 @@ static BOOL xf_cliprdr_process_property_notify(xfClipboard* clipboard, const XPr
|
||||
return TRUE;
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(xevent);
|
||||
|
||||
if (xevent->atom == clipboard->timestamp_property_atom)
|
||||
{
|
||||
@ -1263,8 +1391,11 @@ void xf_cliprdr_handle_xevent(xfContext* xfc, const XEvent* event)
|
||||
*/
|
||||
static UINT xf_cliprdr_send_client_capabilities(xfClipboard* clipboard)
|
||||
{
|
||||
CLIPRDR_CAPABILITIES capabilities;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
|
||||
CLIPRDR_CAPABILITIES capabilities = { 0 };
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = { 0 };
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
capabilities.cCapabilitiesSets = 1;
|
||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
|
||||
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
||||
@ -1272,11 +1403,15 @@ static UINT xf_cliprdr_send_client_capabilities(xfClipboard* clipboard)
|
||||
generalCapabilitySet.version = CB_CAPS_VERSION_2;
|
||||
generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
if (clipboard->streams_supported && clipboard->file_formats_registered)
|
||||
generalCapabilitySet.generalFlags |=
|
||||
CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS | CB_HUGE_FILE_SUPPORT_ENABLED;
|
||||
|
||||
clipboard->file_capability_flags = generalCapabilitySet.generalFlags;
|
||||
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientCapabilities);
|
||||
return clipboard->context->ClientCapabilities(clipboard->context, &capabilities);
|
||||
}
|
||||
|
||||
@ -1289,8 +1424,13 @@ static UINT xf_cliprdr_send_client_format_list(xfClipboard* clipboard)
|
||||
{
|
||||
UINT32 i, numFormats;
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
xfContext* xfc = clipboard->xfc;
|
||||
UINT ret;
|
||||
xfContext* xfc;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
numFormats = clipboard->numClientFormats;
|
||||
|
||||
if (numFormats)
|
||||
@ -1330,10 +1470,15 @@ static UINT xf_cliprdr_send_client_format_list(xfClipboard* clipboard)
|
||||
*/
|
||||
static UINT xf_cliprdr_send_client_format_list_response(xfClipboard* clipboard, BOOL status)
|
||||
{
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse;
|
||||
formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
formatListResponse.dataLen = 0;
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse = { 0 };
|
||||
|
||||
formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse.common.msgFlags = status ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
|
||||
formatListResponse.common.dataLen = 0;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFormatListResponse);
|
||||
return clipboard->context->ClientFormatListResponse(clipboard->context, &formatListResponse);
|
||||
}
|
||||
|
||||
@ -1348,10 +1493,12 @@ static UINT xf_cliprdr_send_client_file_contents(xfClipboard* clipboard, UINT32
|
||||
UINT32 nPositionLow, UINT32 nPositionHigh,
|
||||
UINT32 cbRequested)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST formatFileContentsRequest;
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST formatFileContentsRequest = { 0 };
|
||||
formatFileContentsRequest.streamId = streamId;
|
||||
formatFileContentsRequest.listIndex = listIndex;
|
||||
formatFileContentsRequest.dwFlags = dwFlags;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
switch (dwFlags)
|
||||
{
|
||||
/*
|
||||
@ -1561,6 +1708,8 @@ static UINT xf_cliprdr_server_capabilities(CliprdrClientContext* context,
|
||||
|
||||
static void xf_cliprdr_prepare_to_set_selection_owner(xfContext* xfc, xfClipboard* clipboard)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(clipboard);
|
||||
/*
|
||||
* When you're writing to the selection in response to a
|
||||
* normal X event like a mouse click or keyboard action, you
|
||||
@ -1586,6 +1735,8 @@ static void xf_cliprdr_prepare_to_set_selection_owner(xfContext* xfc, xfClipboar
|
||||
|
||||
static void xf_cliprdr_set_selection_owner(xfContext* xfc, xfClipboard* clipboard, Time timestamp)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(clipboard);
|
||||
/*
|
||||
* Actually set ourselves up as the selection owner, now that
|
||||
* we have a timestamp to use.
|
||||
@ -1649,14 +1800,16 @@ static UINT xf_cliprdr_server_format_list(CliprdrClientContext* context,
|
||||
|
||||
for (i = 0; i < formatList->numFormats; i++)
|
||||
{
|
||||
CLIPRDR_FORMAT* format = &formatList->formats[i];
|
||||
clipboard->serverFormats[i].formatId = format->formatId;
|
||||
const CLIPRDR_FORMAT* format = &formatList->formats[i];
|
||||
CLIPRDR_FORMAT* srvFormat = &clipboard->serverFormats[i];
|
||||
|
||||
srvFormat->formatId = format->formatId;
|
||||
|
||||
if (format->formatName)
|
||||
{
|
||||
clipboard->serverFormats[i].formatName = _strdup(format->formatName);
|
||||
srvFormat->formatName = _strdup(format->formatName);
|
||||
|
||||
if (!clipboard->serverFormats[i].formatName)
|
||||
if (!srvFormat->formatName)
|
||||
{
|
||||
UINT32 k;
|
||||
|
||||
@ -1711,6 +1864,8 @@ static UINT
|
||||
xf_cliprdr_server_format_list_response(CliprdrClientContext* context,
|
||||
const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
|
||||
{
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(formatListResponse);
|
||||
// xfClipboard* clipboard = (xfClipboard*) context->custom;
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
@ -1767,6 +1922,7 @@ xf_cliprdr_server_format_data_request(CliprdrClientContext* context,
|
||||
static char* xf_cliprdr_fuse_split_basename(char* name, int len)
|
||||
{
|
||||
int s = len - 1;
|
||||
WINPR_ASSERT(name || (len <= 0));
|
||||
for (; s >= 0; s--)
|
||||
{
|
||||
if (*(name + s) == '\\')
|
||||
@ -1782,6 +1938,7 @@ static xfCliprdrFuseInode* xf_cliprdr_fuse_create_root_node(void)
|
||||
xfCliprdrFuseInode* rootNode = (xfCliprdrFuseInode*)calloc(1, sizeof(xfCliprdrFuseInode));
|
||||
if (!rootNode)
|
||||
return NULL;
|
||||
|
||||
rootNode->ino = 1;
|
||||
rootNode->parent_ino = 1;
|
||||
rootNode->st_mode = S_IFDIR | 0755;
|
||||
@ -1799,6 +1956,7 @@ static xfCliprdrFuseInode* xf_cliprdr_fuse_create_root_node(void)
|
||||
}
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
static BOOL xf_cliprdr_fuse_check_stream(wStream* s, size_t count)
|
||||
{
|
||||
UINT32 nrDescriptors;
|
||||
@ -1982,6 +2140,9 @@ static BOOL xf_cliprdr_fuse_generate_list(xfClipboard* clipboard, const BYTE* da
|
||||
wStream sbuffer = { 0 };
|
||||
wStream* s;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(data || (size == 0));
|
||||
|
||||
if (size < 4)
|
||||
{
|
||||
WLog_ERR(TAG, "size of format data response invalid : %d", size);
|
||||
@ -2049,10 +2210,10 @@ xf_cliprdr_server_format_data_response(CliprdrClientContext* context,
|
||||
xfc = clipboard->xfc;
|
||||
WINPR_ASSERT(xfc);
|
||||
|
||||
size = formatDataResponse->dataLen;
|
||||
size = formatDataResponse->common.dataLen;
|
||||
data = formatDataResponse->requestedFormatData;
|
||||
|
||||
if (formatDataResponse->msgFlags == CB_RESPONSE_FAIL)
|
||||
if (formatDataResponse->common.msgFlags == CB_RESPONSE_FAIL)
|
||||
{
|
||||
WLog_WARN(TAG, "Format Data Response PDU msgFlags is CB_RESPONSE_FAIL");
|
||||
free(clipboard->respond);
|
||||
@ -2229,6 +2390,10 @@ xf_cliprdr_server_file_size_request(xfClipboard* clipboard,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
wClipboardFileSizeRequest request = { 0 };
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
request.streamId = fileContentsRequest->streamId;
|
||||
request.listIndex = fileContentsRequest->listIndex;
|
||||
|
||||
@ -2238,6 +2403,8 @@ xf_cliprdr_server_file_size_request(xfClipboard* clipboard,
|
||||
fileContentsRequest->cbRequested);
|
||||
}
|
||||
|
||||
WINPR_ASSERT(clipboard->delegate);
|
||||
WINPR_ASSERT(clipboard->delegate->ClientRequestFileSize);
|
||||
return clipboard->delegate->ClientRequestFileSize(clipboard->delegate, &request);
|
||||
}
|
||||
|
||||
@ -2246,11 +2413,18 @@ xf_cliprdr_server_file_range_request(xfClipboard* clipboard,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
wClipboardFileRangeRequest request = { 0 };
|
||||
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
request.streamId = fileContentsRequest->streamId;
|
||||
request.listIndex = fileContentsRequest->listIndex;
|
||||
request.nPositionLow = fileContentsRequest->nPositionLow;
|
||||
request.nPositionHigh = fileContentsRequest->nPositionHigh;
|
||||
request.cbRequested = fileContentsRequest->cbRequested;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->delegate);
|
||||
WINPR_ASSERT(clipboard->delegate->ClientRequestFileRange);
|
||||
return clipboard->delegate->ClientRequestFileRange(clipboard->delegate, &request);
|
||||
}
|
||||
|
||||
@ -2259,8 +2433,14 @@ xf_cliprdr_send_file_contents_failure(CliprdrClientContext* context,
|
||||
const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
|
||||
WINPR_ASSERT(fileContentsRequest);
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.streamId = fileContentsRequest->streamId;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(context->ClientFileContentsResponse);
|
||||
return context->ClientFileContentsResponse(context, &response);
|
||||
}
|
||||
|
||||
@ -2308,11 +2488,20 @@ static UINT xf_cliprdr_clipboard_file_size_success(wClipboardDelegate* delegate,
|
||||
UINT64 fileSize)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
xfClipboard* clipboard = delegate->custom;
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
xfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.streamId = request->streamId;
|
||||
response.cbRequested = sizeof(UINT64);
|
||||
response.requestedData = (BYTE*)&fileSize;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -2321,11 +2510,19 @@ static UINT xf_cliprdr_clipboard_file_size_failure(wClipboardDelegate* delegate,
|
||||
UINT errorCode)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
xfClipboard* clipboard = delegate->custom;
|
||||
xfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
WINPR_UNUSED(errorCode);
|
||||
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.streamId = request->streamId;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -2334,11 +2531,20 @@ static UINT xf_cliprdr_clipboard_file_range_success(wClipboardDelegate* delegate
|
||||
const BYTE* data, UINT32 size)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
xfClipboard* clipboard = delegate->custom;
|
||||
response.msgFlags = CB_RESPONSE_OK;
|
||||
xfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
|
||||
response.common.msgFlags = CB_RESPONSE_OK;
|
||||
response.streamId = request->streamId;
|
||||
response.cbRequested = size;
|
||||
response.requestedData = (const BYTE*)data;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -2347,11 +2553,19 @@ static UINT xf_cliprdr_clipboard_file_range_failure(wClipboardDelegate* delegate
|
||||
UINT errorCode)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
|
||||
xfClipboard* clipboard = delegate->custom;
|
||||
xfClipboard* clipboard;
|
||||
|
||||
WINPR_ASSERT(delegate);
|
||||
WINPR_ASSERT(request);
|
||||
WINPR_UNUSED(errorCode);
|
||||
|
||||
response.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.common.msgFlags = CB_RESPONSE_FAIL;
|
||||
response.streamId = request->streamId;
|
||||
|
||||
clipboard = delegate->custom;
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
WINPR_ASSERT(clipboard->context->ClientFileContentsResponse);
|
||||
return clipboard->context->ClientFileContentsResponse(clipboard->context, &response);
|
||||
}
|
||||
|
||||
@ -2369,6 +2583,10 @@ static int xf_cliprdr_fuse_util_stat(xfClipboard* clipboard, fuse_ino_t ino, str
|
||||
{
|
||||
int err = 0;
|
||||
xfCliprdrFuseInode* node;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(stbuf);
|
||||
|
||||
ArrayList_Lock(clipboard->ino_list);
|
||||
|
||||
node = xf_cliprdr_fuse_util_get_inode(clipboard->ino_list, ino);
|
||||
@ -2393,6 +2611,10 @@ static int xf_cliprdr_fuse_util_stmode(xfClipboard* clipboard, fuse_ino_t ino, m
|
||||
{
|
||||
int err = 0;
|
||||
xfCliprdrFuseInode* node;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(mode);
|
||||
|
||||
ArrayList_Lock(clipboard->ino_list);
|
||||
|
||||
node = xf_cliprdr_fuse_util_get_inode(clipboard->ino_list, ino);
|
||||
@ -2411,6 +2633,10 @@ static int xf_cliprdr_fuse_util_lindex(xfClipboard* clipboard, fuse_ino_t ino, U
|
||||
{
|
||||
int err = 0;
|
||||
xfCliprdrFuseInode* node;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(lindex);
|
||||
|
||||
ArrayList_Lock(clipboard->ino_list);
|
||||
|
||||
node = xf_cliprdr_fuse_util_get_inode(clipboard->ino_list, ino);
|
||||
@ -2435,7 +2661,12 @@ static int xf_cliprdr_fuse_util_add_stream_list(xfClipboard* clipboard, fuse_req
|
||||
UINT32* stream_id)
|
||||
{
|
||||
int err = 0;
|
||||
xfCliprdrFuseStream* stream = (xfCliprdrFuseStream*)calloc(1, sizeof(xfCliprdrFuseStream));
|
||||
xfCliprdrFuseStream* stream;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(stream_id);
|
||||
|
||||
stream = (xfCliprdrFuseStream*)calloc(1, sizeof(xfCliprdrFuseStream));
|
||||
if (!stream)
|
||||
{
|
||||
err = ENOMEM;
|
||||
@ -2464,6 +2695,7 @@ static void xf_cliprdr_fuse_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_
|
||||
struct stat stbuf;
|
||||
|
||||
xfClipboard* clipboard = (xfClipboard*)fuse_req_userdata(req);
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
err = xf_cliprdr_fuse_util_stat(clipboard, ino, &stbuf);
|
||||
if (err)
|
||||
@ -2489,6 +2721,8 @@ static void xf_cliprdr_fuse_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
|
||||
xfCliprdrFuseInode* node;
|
||||
xfClipboard* clipboard = (xfClipboard*)fuse_req_userdata(req);
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
ArrayList_Lock(clipboard->ino_list);
|
||||
node = xf_cliprdr_fuse_util_get_inode(clipboard->ino_list, ino);
|
||||
|
||||
@ -2574,6 +2808,7 @@ static void xf_cliprdr_fuse_open(fuse_req_t req, fuse_ino_t ino, struct fuse_fil
|
||||
mode_t mode = 0;
|
||||
xfClipboard* clipboard = (xfClipboard*)fuse_req_userdata(req);
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
err = xf_cliprdr_fuse_util_stmode(clipboard, ino, &mode);
|
||||
if (err)
|
||||
{
|
||||
@ -2606,6 +2841,8 @@ static void xf_cliprdr_fuse_read(fuse_req_t req, fuse_ino_t ino, size_t size, of
|
||||
UINT32 lindex;
|
||||
UINT32 stream_id;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
err = xf_cliprdr_fuse_util_lindex(clipboard, ino, &lindex);
|
||||
if (err)
|
||||
{
|
||||
@ -2638,6 +2875,8 @@ static void xf_cliprdr_fuse_lookup(fuse_req_t req, fuse_ino_t parent, const char
|
||||
xfCliprdrFuseInode* child_node = NULL;
|
||||
xfClipboard* clipboard = (xfClipboard*)fuse_req_userdata(req);
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
ArrayList_Lock(clipboard->ino_list);
|
||||
parent_node = xf_cliprdr_fuse_util_get_inode(clipboard->ino_list, parent);
|
||||
|
||||
@ -2724,6 +2963,7 @@ static void xf_cliprdr_fuse_opendir(fuse_req_t req, fuse_ino_t ino, struct fuse_
|
||||
int err;
|
||||
mode_t mode = 0;
|
||||
xfClipboard* clipboard = (xfClipboard*)fuse_req_userdata(req);
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
err = xf_cliprdr_fuse_util_stmode(clipboard, ino, &mode);
|
||||
if (err)
|
||||
@ -2759,6 +2999,9 @@ static DWORD WINAPI xf_cliprdr_fuse_thread(LPVOID arg)
|
||||
UINT32 basePathSize;
|
||||
char* basePath;
|
||||
char* tmpPath;
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
tmpPath = GetKnownPath(KNOWN_PATH_TEMP);
|
||||
/* 10 is max length of DWORD string and 1 for \0 */
|
||||
basePathSize = strlen(tmpPath) + strlen("/.xfreerdp.cliprdr.") + 11;
|
||||
@ -2840,7 +3083,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc)
|
||||
|
||||
xfc->clipboard = clipboard;
|
||||
clipboard->xfc = xfc;
|
||||
channels = ((rdpContext*)xfc)->channels;
|
||||
channels = xfc->common.context.channels;
|
||||
clipboard->channels = channels;
|
||||
clipboard->system = ClipboardCreate();
|
||||
clipboard->requestedFormatId = -1;
|
||||
@ -3043,7 +3286,10 @@ void xf_clipboard_free(xfClipboard* clipboard)
|
||||
if (clipboard->serverFormats)
|
||||
{
|
||||
for (i = 0; i < clipboard->numServerFormats; i++)
|
||||
free(clipboard->serverFormats[i].formatName);
|
||||
{
|
||||
CLIPRDR_FORMAT* format = &clipboard->serverFormats[i];
|
||||
free(format->formatName);
|
||||
}
|
||||
|
||||
free(clipboard->serverFormats);
|
||||
clipboard->serverFormats = NULL;
|
||||
@ -3092,6 +3338,9 @@ void xf_clipboard_free(xfClipboard* clipboard)
|
||||
|
||||
void xf_cliprdr_init(xfContext* xfc, CliprdrClientContext* cliprdr)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
xfc->cliprdr = cliprdr;
|
||||
xfc->clipboard->context = cliprdr;
|
||||
cliprdr->custom = (void*)xfc->clipboard;
|
||||
@ -3109,6 +3358,9 @@ void xf_cliprdr_init(xfContext* xfc, CliprdrClientContext* cliprdr)
|
||||
|
||||
void xf_cliprdr_uninit(xfContext* xfc, CliprdrClientContext* cliprdr)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(cliprdr);
|
||||
|
||||
xfc->cliprdr = NULL;
|
||||
cliprdr->custom = NULL;
|
||||
|
||||
|
@ -32,26 +32,32 @@
|
||||
* Clipboard Formats
|
||||
*/
|
||||
|
||||
#define CB_FORMAT_HTML 0xD010
|
||||
#define CB_FORMAT_PNG 0xD011
|
||||
#define CB_FORMAT_JPEG 0xD012
|
||||
#define CB_FORMAT_GIF 0xD013
|
||||
#define CB_FORMAT_TEXTURILIST 0xD014
|
||||
#define CB_FORMAT_GNOMECOPIEDFILES 0xD015
|
||||
#define CB_FORMAT_MATECOPIEDFILES 0xD016
|
||||
typedef enum
|
||||
{
|
||||
CB_FORMAT_HTML = 0xD010,
|
||||
CB_FORMAT_PNG = 0xD011,
|
||||
CB_FORMAT_JPEG = 0xD012,
|
||||
CB_FORMAT_GIF = 0xD013,
|
||||
CB_FORMAT_TEXTURILIST = 0xD014,
|
||||
CB_FORMAT_GNOMECOPIEDFILES = 0xD015,
|
||||
CB_FORMAT_MATECOPIEDFILES = 0xD016
|
||||
} CliprdrFormatType;
|
||||
|
||||
/* CLIPRDR_HEADER.msgType */
|
||||
#define CB_MONITOR_READY 0x0001
|
||||
#define CB_FORMAT_LIST 0x0002
|
||||
#define CB_FORMAT_LIST_RESPONSE 0x0003
|
||||
#define CB_FORMAT_DATA_REQUEST 0x0004
|
||||
#define CB_FORMAT_DATA_RESPONSE 0x0005
|
||||
#define CB_TEMP_DIRECTORY 0x0006
|
||||
#define CB_CLIP_CAPS 0x0007
|
||||
#define CB_FILECONTENTS_REQUEST 0x0008
|
||||
#define CB_FILECONTENTS_RESPONSE 0x0009
|
||||
#define CB_LOCK_CLIPDATA 0x000A
|
||||
#define CB_UNLOCK_CLIPDATA 0x000B
|
||||
typedef enum
|
||||
{
|
||||
CB_MONITOR_READY = 0x0001,
|
||||
CB_FORMAT_LIST = 0x0002,
|
||||
CB_FORMAT_LIST_RESPONSE = 0x0003,
|
||||
CB_FORMAT_DATA_REQUEST = 0x0004,
|
||||
CB_FORMAT_DATA_RESPONSE = 0x0005,
|
||||
CB_TEMP_DIRECTORY = 0x0006,
|
||||
CB_CLIP_CAPS = 0x0007,
|
||||
CB_FILECONTENTS_REQUEST = 0x0008,
|
||||
CB_FILECONTENTS_RESPONSE = 0x0009,
|
||||
CB_LOCK_CLIPDATA = 0x000A,
|
||||
CB_UNLOCK_CLIPDATA = 0x000B
|
||||
} CliprdrMsgType;
|
||||
|
||||
/* CLIPRDR_HEADER.msgFlags */
|
||||
#define CB_RESPONSE_OK 0x0001
|
||||
@ -79,141 +85,138 @@
|
||||
#define FILECONTENTS_SIZE 0x00000001
|
||||
#define FILECONTENTS_RANGE 0x00000002
|
||||
|
||||
/* Special Clipboard Response Formats */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 mappingMode;
|
||||
UINT32 xExt;
|
||||
UINT32 yExt;
|
||||
UINT32 metaFileSize;
|
||||
BYTE* metaFileData;
|
||||
} CLIPRDR_MFPICT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Special Clipboard Response Formats */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 mappingMode;
|
||||
UINT32 xExt;
|
||||
UINT32 yExt;
|
||||
UINT32 metaFileSize;
|
||||
BYTE* metaFileData;
|
||||
} CLIPRDR_MFPICT;
|
||||
|
||||
/* Clipboard Messages */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 msgType;
|
||||
UINT16 msgFlags;
|
||||
UINT32 dataLen;
|
||||
} CLIPRDR_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 capabilitySetType;
|
||||
UINT16 capabilitySetLength;
|
||||
} CLIPRDR_CAPABILITY_SET;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 capabilitySetType;
|
||||
UINT16 capabilitySetLength;
|
||||
|
||||
UINT32 version;
|
||||
UINT32 generalFlags;
|
||||
} CLIPRDR_GENERAL_CAPABILITY_SET;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 cCapabilitiesSets;
|
||||
CLIPRDR_CAPABILITY_SET* capabilitySets;
|
||||
} CLIPRDR_CAPABILITIES;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
} CLIPRDR_MONITOR_READY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
char szTempDir[520];
|
||||
} CLIPRDR_TEMP_DIRECTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 formatId;
|
||||
char* formatName;
|
||||
} CLIPRDR_FORMAT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 numFormats;
|
||||
CLIPRDR_FORMAT* formats;
|
||||
} CLIPRDR_FORMAT_LIST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
} CLIPRDR_FORMAT_LIST_RESPONSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 clipDataId;
|
||||
} CLIPRDR_LOCK_CLIPBOARD_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 clipDataId;
|
||||
} CLIPRDR_UNLOCK_CLIPBOARD_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 requestedFormatId;
|
||||
} CLIPRDR_FORMAT_DATA_REQUEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
const BYTE* requestedFormatData;
|
||||
} CLIPRDR_FORMAT_DATA_RESPONSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 streamId;
|
||||
UINT32 listIndex;
|
||||
UINT32 dwFlags;
|
||||
UINT32 nPositionLow;
|
||||
UINT32 nPositionHigh;
|
||||
UINT32 cbRequested;
|
||||
BOOL haveClipDataId;
|
||||
UINT32 clipDataId;
|
||||
} CLIPRDR_FILE_CONTENTS_REQUEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIPRDR_HEADER common;
|
||||
|
||||
UINT32 streamId;
|
||||
UINT32 cbRequested;
|
||||
const BYTE* requestedData;
|
||||
} CLIPRDR_FILE_CONTENTS_RESPONSE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clipboard Messages */
|
||||
|
||||
#define DEFINE_CLIPRDR_HEADER_COMMON() \
|
||||
UINT16 msgType; \
|
||||
UINT16 msgFlags; \
|
||||
UINT32 dataLen
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
} CLIPRDR_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 capabilitySetType;
|
||||
UINT16 capabilitySetLength;
|
||||
} CLIPRDR_CAPABILITY_SET;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 capabilitySetType;
|
||||
UINT16 capabilitySetLength;
|
||||
|
||||
UINT32 version;
|
||||
UINT32 generalFlags;
|
||||
} CLIPRDR_GENERAL_CAPABILITY_SET;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 cCapabilitiesSets;
|
||||
CLIPRDR_CAPABILITY_SET* capabilitySets;
|
||||
} CLIPRDR_CAPABILITIES;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
} CLIPRDR_MONITOR_READY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
char szTempDir[520];
|
||||
} CLIPRDR_TEMP_DIRECTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 formatId;
|
||||
char* formatName;
|
||||
} CLIPRDR_FORMAT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 numFormats;
|
||||
CLIPRDR_FORMAT* formats;
|
||||
} CLIPRDR_FORMAT_LIST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
} CLIPRDR_FORMAT_LIST_RESPONSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 clipDataId;
|
||||
} CLIPRDR_LOCK_CLIPBOARD_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 clipDataId;
|
||||
} CLIPRDR_UNLOCK_CLIPBOARD_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 requestedFormatId;
|
||||
} CLIPRDR_FORMAT_DATA_REQUEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
const BYTE* requestedFormatData;
|
||||
} CLIPRDR_FORMAT_DATA_RESPONSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 streamId;
|
||||
UINT32 listIndex;
|
||||
UINT32 dwFlags;
|
||||
UINT32 nPositionLow;
|
||||
UINT32 nPositionHigh;
|
||||
UINT32 cbRequested;
|
||||
BOOL haveClipDataId;
|
||||
UINT32 clipDataId;
|
||||
} CLIPRDR_FILE_CONTENTS_REQUEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEFINE_CLIPRDR_HEADER_COMMON();
|
||||
|
||||
UINT32 streamId;
|
||||
UINT32 cbRequested;
|
||||
const BYTE* requestedData;
|
||||
} CLIPRDR_FILE_CONTENTS_RESPONSE;
|
||||
|
||||
#endif /* FREERDP_CHANNEL_CLIPRDR_H */
|
||||
|
Loading…
Reference in New Issue
Block a user