23 #include <freerdp/config.h>
25 #include <winpr/crt.h>
26 #include <winpr/print.h>
28 #include <freerdp/types.h>
29 #include <freerdp/freerdp.h>
30 #include <freerdp/settings.h>
31 #include <freerdp/constants.h>
32 #include <freerdp/client/cliprdr.h>
34 #include "cliprdr_main.h"
35 #include "cliprdr_format.h"
36 #include "../cliprdr_common.h"
39 const UINT32 checkMask)
41 const UINT32 maskData =
42 checkMask & (CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL);
43 const UINT32 maskFiles =
44 checkMask & (CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES);
48 filtered.common.msgType = CB_FORMAT_LIST;
49 filtered.numFormats = list->numFormats;
50 filtered.formats = calloc(filtered.numFormats,
sizeof(
CLIPRDR_FORMAT));
53 if ((mask & checkMask) == checkMask)
55 for (
size_t x = 0; x < list->numFormats; x++)
59 cur->formatId = format->formatId;
60 if (format->formatName)
61 cur->formatName = _strdup(format->formatName);
65 else if ((mask & maskFiles) != 0)
67 for (
size_t x = 0; x < list->numFormats; x++)
72 if (!format->formatName)
74 if (strcmp(format->formatName, type_FileGroupDescriptorW) == 0 ||
75 strcmp(format->formatName, type_FileContents) == 0)
77 cur->formatId = format->formatId;
78 cur->formatName = _strdup(format->formatName);
83 else if ((mask & maskData) != 0)
85 for (
size_t x = 0; x < list->numFormats; x++)
90 if (!format->formatName ||
91 (strcmp(format->formatName, type_FileGroupDescriptorW) != 0 &&
92 strcmp(format->formatName, type_FileContents) != 0))
94 cur->formatId = format->formatId;
95 if (format->formatName)
96 cur->formatName = _strdup(format->formatName);
101 WINPR_ASSERT(wpos <= UINT32_MAX);
102 filtered.numFormats = (UINT32)wpos;
116 CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
117 UINT error = CHANNEL_RC_OK;
119 formatList.common.msgType = CB_FORMAT_LIST;
120 formatList.common.msgFlags = msgFlags;
121 formatList.common.dataLen = dataLen;
123 if ((error = cliprdr_read_format_list(s, &formatList, cliprdr->useLongFormatNames)))
128 filteredFormatList = cliprdr_filter_format_list(
129 &formatList, mask, CLIPRDR_FLAG_REMOTE_TO_LOCAL | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES);
130 if (filteredFormatList.numFormats == 0)
133 WLog_Print(cliprdr->log, WLOG_DEBUG,
"ServerFormatList: numFormats: %" PRIu32
"",
134 filteredFormatList.numFormats);
136 if (context->ServerFormatList)
138 if ((error = context->ServerFormatList(context, &filteredFormatList)))
139 WLog_ERR(TAG,
"ServerFormatList failed with error %" PRIu32
"", error);
143 cliprdr_free_format_list(&filteredFormatList);
144 cliprdr_free_format_list(&formatList);
157 CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
158 UINT error = CHANNEL_RC_OK;
160 WLog_Print(cliprdr->log, WLOG_DEBUG,
"ServerFormatListResponse");
162 formatListResponse.common.msgType = CB_FORMAT_LIST_RESPONSE;
163 formatListResponse.common.msgFlags = msgFlags;
164 formatListResponse.common.dataLen = dataLen;
166 IFCALLRET(context->ServerFormatListResponse, error, context, &formatListResponse);
168 WLog_ERR(TAG,
"ServerFormatListResponse failed with error %" PRIu32
"!", error);
182 CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
183 UINT error = CHANNEL_RC_OK;
185 WLog_Print(cliprdr->log, WLOG_DEBUG,
"ServerFormatDataRequest");
187 formatDataRequest.common.msgType = CB_FORMAT_DATA_REQUEST;
188 formatDataRequest.common.msgFlags = msgFlags;
189 formatDataRequest.common.dataLen = dataLen;
191 if ((error = cliprdr_read_format_data_request(s, &formatDataRequest)))
196 if ((mask & (CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES)) == 0)
198 return cliprdr_send_error_response(cliprdr, CB_FORMAT_DATA_RESPONSE);
201 context->lastRequestedFormatId = formatDataRequest.requestedFormatId;
202 IFCALLRET(context->ServerFormatDataRequest, error, context, &formatDataRequest);
204 WLog_ERR(TAG,
"ServerFormatDataRequest failed with error %" PRIu32
"!", error);
218 CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
219 UINT error = CHANNEL_RC_OK;
221 WLog_Print(cliprdr->log, WLOG_DEBUG,
"ServerFormatDataResponse");
223 formatDataResponse.common.msgType = CB_FORMAT_DATA_RESPONSE;
224 formatDataResponse.common.msgFlags = msgFlags;
225 formatDataResponse.common.dataLen = dataLen;
227 if ((error = cliprdr_read_format_data_response(s, &formatDataResponse)))
232 if ((mask & (CLIPRDR_FLAG_REMOTE_TO_LOCAL | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES)) == 0)
235 "Received ServerFormatDataResponse but remote -> local clipboard is disabled");
236 return CHANNEL_RC_OK;
239 IFCALLRET(context->ServerFormatDataResponse, error, context, &formatDataResponse);
241 WLog_ERR(TAG,
"ServerFormatDataResponse failed with error %" PRIu32
"!", error);
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.