5#include "ClipboardFreeRDP.h"
12#include <QStandardPaths>
15#include "ConnectFreeRDP.h"
16#include "ClipboardMimeData.h"
18static Q_LOGGING_CATEGORY(log,
"FreeRDP.Clipboard")
22 m_pCliprdrClientContext(
nullptr),
23 m_pClipboard(
nullptr),
24 m_FileCapabilityFlags(0),
25 m_bFileSupported(false),
26 m_bFileFormatsRegistered(false)
28 qDebug(log) <<
"CClipboardFreeRDP::CClipboardFreeRDP()";
29 m_pClipboard = ClipboardCreate();
30 if (ClipboardGetFormatId(m_pClipboard,
"text/uri-list"))
31 m_bFileFormatsRegistered =
true;
32 wClipboardDelegate* pDelegate = ClipboardGetDelegate(m_pClipboard);
33 pDelegate->custom =
this;
35 QString szPath = QStandardPaths::writableLocation(
36 QStandardPaths::TempLocation)
37 + QDir::separator() +
"Rabbit"
38 + QDir::separator() +
"RabbitRemoteControl";
39 qDebug(log) <<
"Delegate base path:" << szPath;
41 pDelegate->basePath = _strdup(szPath.toStdString().c_str());
42 pDelegate->ClipboardFileSizeSuccess = cb_clipboard_file_size_success;
43 pDelegate->ClipboardFileSizeFailure = cb_clipboard_file_size_failure;
44 pDelegate->ClipboardFileRangeSuccess = cb_clipboard_file_range_success;
45 pDelegate->ClipboardFileRangeFailure = cb_clipboard_file_range_failure;
47#if FreeRDP_VERSION_MAJOR > 2 || (FreeRDP_VERSION_MAJOR == 2 && FreeRDP_VERSION_MINOR > 7)
48 pDelegate->IsFileNameComponentValid = cbIsFileNameComponentValid;
52CClipboardFreeRDP::~CClipboardFreeRDP()
54 qDebug(log) <<
"CClipboardFreeRdp::~CClipboardFreeRdp()";
59 emit sigServerFileContentsRespose(-1, data);
60 ClipboardDestroy(m_pClipboard);
63int CClipboardFreeRDP::Init(CliprdrClientContext *context,
bool bEnable)
65 if(!bEnable)
return 0;
67 m_pCliprdrClientContext = context;
68 context->custom =
this;
72 context->ServerCapabilities = cb_cliprdr_server_capabilities;
73 context->MonitorReady = cb_cliprdr_monitor_ready;
74 context->ServerFormatList = cb_cliprdr_server_format_list;
75 context->ServerFormatListResponse = cb_cliprdr_server_format_list_response;
76 context->ServerFormatDataRequest = cb_cliprdr_server_format_data_request;
77 context->ServerFormatDataResponse = cb_cliprdr_server_format_data_response;
78 context->ServerFileContentsRequest = cb_cliprdr_server_file_contents_request;
83int CClipboardFreeRDP::UnInit(CliprdrClientContext *context,
bool bEnable)
85 context->custom =
nullptr;
86 m_pCliprdrClientContext =
nullptr;
90void CClipboardFreeRDP::slotClipBoardChanged()
92 qDebug(log) <<
"CClipboardFreeRdp::slotClipBoardChanged";
94 const QMimeData* pMimeType = QApplication::clipboard()->mimeData();
95 if(!pMimeType)
return;
98 QVariant d = pMimeType->data(MIME_TYPE_RABBITREMOTECONTROL_PLUGINS_FREERDP);
101 if(!m_lstClipboardMimeDataId.isEmpty()
102 && m_lstClipboardMimeDataId.contains(data))
105 <<
"CClipboardFreeRdp::slotClipBoardChanged: clipboard is this owner"
106 << data << m_lstClipboardMimeDataId;
112 qDebug(log) <<
"CClipboardFreeRdp::slotClipBoardChanged:"
113 << data << m_lstClipboardMimeDataId;
114 m_lstClipboardMimeDataId.clear();
115 SendClientFormatList(m_pCliprdrClientContext);
118UINT CClipboardFreeRDP::cb_cliprdr_server_capabilities(
119 CliprdrClientContext* context,
120 const CLIPRDR_CAPABILITIES* capabilities)
122 qDebug(log) <<
"CClipboardFreeRdp::cb_cliprdr_server_capabilities";
124 int nRet = CHANNEL_RC_OK;
127 pThis->m_bFileSupported = FALSE;
128 const CLIPRDR_CAPABILITY_SET* caps;
129 const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps;
130 const BYTE* capsPtr = (
const BYTE*)capabilities->capabilitySets;
132 for (UINT32 i = 0; i < capabilities->cCapabilitiesSets; i++)
134 caps = (
const CLIPRDR_CAPABILITY_SET*)capsPtr;
136 if (caps->capabilitySetType == CB_CAPSTYPE_GENERAL)
138 generalCaps = (
const CLIPRDR_GENERAL_CAPABILITY_SET*)caps;
140 if (generalCaps->generalFlags & CB_STREAM_FILECLIP_ENABLED)
143 pThis->m_bFileSupported = TRUE;
147 capsPtr += caps->capabilitySetLength;
156UINT CClipboardFreeRDP::cb_cliprdr_monitor_ready(
157 CliprdrClientContext *context,
158 const CLIPRDR_MONITOR_READY *monitorReady)
160 qDebug(log) <<
"CClipboardFreeRdp::cb_cliprdr_monitor_ready";
161 UINT nRet = CHANNEL_RC_OK;
163 if (!context || !context->ClientCapabilities)
166 return ERROR_INTERNAL_ERROR;
171 CLIPRDR_CAPABILITIES capabilities;
172 CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
173 capabilities.cCapabilitiesSets = 1;
174 capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet);
175 generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
176 generalCapabilitySet.capabilitySetLength = 12;
177 generalCapabilitySet.version = CB_CAPS_VERSION_2;
178 generalCapabilitySet.generalFlags = CB_USE_LONG_FORMAT_NAMES;
180 if (pThis->m_bFileSupported && pThis->m_bFileFormatsRegistered)
182 generalCapabilitySet.generalFlags |=
183 CB_STREAM_FILECLIP_ENABLED | CB_FILECLIP_NO_FILE_PATHS
184#if FreeRDP_VERSION_MAJOR > 2 || (FreeRDP_VERSION_MAJOR == 2 && FreeRDP_VERSION_MINOR > 7)
185 | CB_HUGE_FILE_SUPPORT_ENABLED
190 pThis->m_FileCapabilityFlags = generalCapabilitySet.generalFlags;
191 if((nRet = context->ClientCapabilities(context, &capabilities))
194 qCritical(log) <<
"Send Client Capabilities fail";
199 return SendClientFormatList(context);
205UINT CClipboardFreeRDP::SendClientFormatList(CliprdrClientContext *context)
207 qDebug(log) <<
"CClipboardFreeRdp::SendClientFormatList";
208 int nRet = CHANNEL_RC_OK;
210 CLIPRDR_FORMAT* pFormats =
nullptr;
211 CLIPRDR_FORMAT_LIST formatList = { 0 };
212 UINT32 numFormats = 0;
214 if(!context)
return nRet;
217 QClipboard *clipboard = QApplication::clipboard();
220 qDebug(log) <<
"clipboard is null";
224 QVector<UINT32> formatIds;
225 const QMimeData* pData = clipboard->mimeData();
226 if(!pData || pData->formats().isEmpty())
228 qDebug(log) <<
"clipboard->mimeData is null";
231 auto clipFormats = pData->formats();
232 if(!clipFormats.isEmpty())
234 nLen = clipFormats.length()
235 + ClipboardCountRegisteredFormats(pThis->m_pClipboard);
236 pFormats =
new CLIPRDR_FORMAT[nLen];
240 qCritical(log) <<
"Failed to allocate"
241 << nLen <<
"CLIPRDR_FORMAT structs";
242 return CHANNEL_RC_NO_MEMORY;
244 memset(pFormats, 0,
sizeof(CLIPRDR_FORMAT) * nLen);
245 qDebug(log) <<
"Clipboard formats:" << clipFormats;
246 foreach(
auto f, pData->formats())
248 UINT32
id = ClipboardRegisterFormat(
249 pThis->m_pClipboard, f.toStdString().c_str());
250 if(!formatIds.contains(
id))
252 pFormats[numFormats].formatName = _strdup(f.toStdString().c_str());
253 pFormats[numFormats].formatId = id;
254 formatIds.push_back(pFormats[numFormats].formatId);
261 UINT32
id = ClipboardRegisterFormat(
262 pThis->m_pClipboard,
"FileGroupDescriptorW");
263 if(!formatIds.contains(
id))
265 pFormats[numFormats].formatName = _strdup(
"FileGroupDescriptorW");
266 pFormats[numFormats].formatId = id;
267 formatIds.push_back(pFormats[numFormats].formatId);
270 id = ClipboardRegisterFormat(pThis->m_pClipboard,
"FileContents");
271 if(!formatIds.contains(
id))
273 pFormats[numFormats].formatName = _strdup(
"FileContents");
274 pFormats[numFormats].formatId = id;
275 formatIds.push_back(pFormats[numFormats].formatId);
278 id = ClipboardRegisterFormat(pThis->m_pClipboard,
"text/uri-list");
279 if(!formatIds.contains(
id))
281 pFormats[numFormats].formatName = _strdup(
"text/uri-list");
282 pFormats[numFormats].formatId = id;
283 formatIds.push_back(pFormats[numFormats].formatId);
287 if(pData->hasImage())
296 if(!formatIds.contains(CF_DIB))
298 pFormats[numFormats].formatId = CF_DIB;
299 pFormats[numFormats].formatName =
nullptr;
300 formatIds.push_back(pFormats[numFormats].formatId);
303 if(!formatIds.contains(CF_DIBV5))
305 pFormats[numFormats].formatId = CF_DIBV5;
306 pFormats[numFormats].formatName =
nullptr;
307 formatIds.push_back(pFormats[numFormats].formatId);
313 UINT32
id = ClipboardRegisterFormat(
314 pThis->m_pClipboard,
"text/html");
315 if(!formatIds.contains(
id))
317 pFormats[numFormats].formatId = id;
318 pFormats[numFormats].formatName = _strdup(
"text/html");
319 formatIds.push_back(pFormats[numFormats].formatId);
322 id = ClipboardRegisterFormat(
323 pThis->m_pClipboard,
"HTML Format");
324 if(!formatIds.contains(
id))
326 pFormats[numFormats].formatId = id;
327 pFormats[numFormats].formatName = _strdup(
"HTML Format");
328 formatIds.push_back(pFormats[numFormats].formatId);
334 if(!formatIds.contains(CF_TEXT))
336 pFormats[numFormats].formatId = CF_TEXT;
337 pFormats[numFormats].formatName =
nullptr;
338 formatIds.push_back(pFormats[numFormats].formatId);
341 if(!formatIds.contains(CF_OEMTEXT))
343 pFormats[numFormats].formatId = CF_OEMTEXT;
344 pFormats[numFormats].formatName =
nullptr;
345 formatIds.push_back(pFormats[numFormats].formatId);
348 if(!formatIds.contains(CF_UNICODETEXT))
350 pFormats[numFormats].formatId = CF_UNICODETEXT;
351 pFormats[numFormats].formatName =
nullptr;
352 formatIds.push_back(pFormats[numFormats].formatId);
355 if(!formatIds.contains(CF_LOCALE))
357 pFormats[numFormats].formatId = CF_LOCALE;
358 pFormats[numFormats].formatName =
nullptr;
359 formatIds.push_back(pFormats[numFormats].formatId);
365 for(
int i = 0; i < numFormats; i++)
367 szFormats +=
" id:" + QString::number(pFormats[i].formatId);
368 if(pFormats[i].formatName)
371 szFormats += pFormats[i].formatName;
376 qDebug(log,
"SendClientFormatList formats: %d:%s",
378 szFormats.toStdString().c_str());
379#if FreeRDP_VERSION_MAJOR >= 3
380 formatList.common.msgFlags = CB_RESPONSE_OK;
381 formatList.common.msgType = CB_FORMAT_LIST;
383 formatList.msgFlags = CB_RESPONSE_OK;
384 formatList.msgType = CB_FORMAT_LIST;
386 formatList.numFormats = numFormats;
387 formatList.formats = pFormats;
391 SendFormatDataResponse(context, NULL, 0);
393 Q_ASSERT(context->ClientFormatList);
394 nRet = context->ClientFormatList(context, &formatList);
395 qDebug(log) <<
"SendClientFormatList nRet:" << nRet;
396 for(UINT32 i = 0; i < numFormats; i++)
397 if(pFormats[i].formatName)
400 free(pFormats[i].formatName);
408UINT CClipboardFreeRDP::cb_cliprdr_server_format_data_request(
409 CliprdrClientContext* context,
410 const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
413 <<
"CClipboardFreeRdp::cb_cliprdr_server_format_data_request";
415 int nRet = CHANNEL_RC_OK;
416 bool bSuucess =
false;
418 BYTE* pDstData = NULL;
420 UINT32 dstFormatId = formatDataRequest->requestedFormatId;
421 UINT32 scrFormatID = 0;
422 if(!context)
return ERROR_INTERNAL_ERROR;
425 qDebug(log) <<
"server format date request formatID:"
427 QClipboard *clipboard = QApplication::clipboard();
428 if(!clipboard)
return ERROR_INTERNAL_ERROR;
437 if(clipboard->mimeData()->hasText())
439 QString szData = clipboard->text();
440 bSuucess = ClipboardSetData(
441 pThis->m_pClipboard, CF_UNICODETEXT,
442 szData.data(), (szData.size() + 1) *
sizeof(QChar));
449 if(clipboard->mimeData()->hasImage())
451 QImage img = clipboard->image();
456 if(buffer.open(QIODevice::WriteOnly))
458 img.save(&buffer,
"BMP");
462 bSuucess = ClipboardSetData(
464 ClipboardGetFormatId(pThis->m_pClipboard,
"image/bmp"),
465 (BYTE*)d.data(), d.length());
469 if(ClipboardGetFormatId(pThis->m_pClipboard,
"HTML Format")
472 mimeType =
"text/html";
473 scrFormatID = ClipboardGetFormatId(pThis->m_pClipboard,
475 }
else if(ClipboardGetFormatId(pThis->m_pClipboard,
476 "FileGroupDescriptorW")
479 mimeType =
"text/uri-list";
480 scrFormatID = ClipboardGetFormatId(pThis->m_pClipboard,
483 mimeType = ClipboardGetFormatName(pThis->m_pClipboard, dstFormatId);
484 scrFormatID = dstFormatId;
486 if(!mimeType.isEmpty() && scrFormatID > 0)
488 QByteArray data = clipboard->mimeData()->data(mimeType);
489 qDebug(log) <<
"mimeData:" << data << data.length();
491 bSuucess = ClipboardSetData(pThis->m_pClipboard, scrFormatID,
492 data.data(), data.size());
498 pDstData = (BYTE*)ClipboardGetData(pThis->m_pClipboard,
499 dstFormatId, &dstSize);
504 <<
"ClipboardGetData fail: dstFormatId:" << dstFormatId
505 <<
", srcFormatId:" << scrFormatID;
506 nRet = SendFormatDataResponse(context, NULL, 0);
518 && (ClipboardGetFormatId(pThis->m_pClipboard,
"FileGroupDescriptorW")
521 UINT error = NO_ERROR;
522 FILEDESCRIPTORW* file_array = (FILEDESCRIPTORW*)pDstData;
523 UINT32 file_count = dstSize /
sizeof(FILEDESCRIPTORW);
525 error = cliprdr_serialize_file_list_ex(
526 pThis->m_FileCapabilityFlags, file_array,
527 file_count, &pDstData, &dstSize);
530 <<
"failed to serialize CLIPRDR_FILELIST:" << error;
534 nRet = SendFormatDataResponse(context, pDstData, dstSize);
546UINT CClipboardFreeRDP::SendFormatDataResponse(CliprdrClientContext *context,
547 const BYTE *data,
size_t size)
549 qDebug(log) << Q_FUNC_INFO;
550 CLIPRDR_FORMAT_DATA_RESPONSE response = { 0 };
551#if FreeRDP_VERSION_MAJOR >= 3
552 response.common.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
553 response.common.dataLen = size;
555 response.msgFlags = (data) ? CB_RESPONSE_OK : CB_RESPONSE_FAIL;
556 response.dataLen = size;
558 response.requestedFormatData = data;
559 return context->ClientFormatDataResponse(context, &response);
564UINT CClipboardFreeRDP::cb_clipboard_file_size_success(
565 wClipboardDelegate* delegate,
566 const wClipboardFileSizeRequest* request,
569 qDebug(log) <<
"CClipboardFreeRDP::cb_clipboard_file_size_success";
570 CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
572#if FreeRDP_VERSION_MAJOR >= 3
573 response.common.msgFlags = CB_RESPONSE_OK;
575 response.msgFlags = CB_RESPONSE_OK;
577 response.streamId = request->streamId;
578 response.cbRequested =
sizeof(UINT64);
579 response.requestedData = (BYTE*)&fileSize;
580 return pThis->m_pCliprdrClientContext->ClientFileContentsResponse(
581 pThis->m_pCliprdrClientContext, &response);
584UINT CClipboardFreeRDP::cb_clipboard_file_size_failure(
585 wClipboardDelegate* delegate,
586 const wClipboardFileSizeRequest* request,
589 qDebug(log) <<
"CClipboardFreeRDP::cb_clipboard_file_size_failure";
590 CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
592 WINPR_UNUSED(errorCode);
593#if FreeRDP_VERSION_MAJOR >= 3
594 response.common.msgFlags = CB_RESPONSE_FAIL;
596 response.msgFlags = CB_RESPONSE_FAIL;
598 response.streamId = request->streamId;
599 return pThis->m_pCliprdrClientContext->ClientFileContentsResponse(
600 pThis->m_pCliprdrClientContext, &response);
603UINT CClipboardFreeRDP::cb_clipboard_file_range_success(
604 wClipboardDelegate* delegate,
605 const wClipboardFileRangeRequest* request,
606 const BYTE* data, UINT32 size)
608 qDebug(log) <<
"CClipboardFreeRDP::cb_clipboard_file_range_success";
609 CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
611#if FreeRDP_VERSION_MAJOR >= 3
612 response.common.msgFlags = CB_RESPONSE_OK;
614 response.msgFlags = CB_RESPONSE_OK;
616 response.streamId = request->streamId;
617 response.cbRequested = size;
618 response.requestedData = (BYTE*)data;
619 return pThis->m_pCliprdrClientContext->ClientFileContentsResponse(
620 pThis->m_pCliprdrClientContext, &response);
623UINT CClipboardFreeRDP::cb_clipboard_file_range_failure(
624 wClipboardDelegate* delegate,
625 const wClipboardFileRangeRequest* request,
628 qDebug(log) <<
"CClipboardFreeRDP::cb_clipboard_file_range_failure";
629 CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
631 WINPR_UNUSED(errorCode);
632#if FreeRDP_VERSION_MAJOR >= 3
633 response.common.msgFlags = CB_RESPONSE_FAIL;
635 response.msgFlags = CB_RESPONSE_FAIL;
637 response.streamId = request->streamId;
638 return pThis->m_pCliprdrClientContext->ClientFileContentsResponse(
639 pThis->m_pCliprdrClientContext, &response);
642BOOL CClipboardFreeRDP::cbIsFileNameComponentValid(LPCWSTR lpFileName)
644 qDebug(log) <<
"CClipboardFreeRDP::cbIsFileNameComponentValid:" << lpFileName;
650 if (lpFileName[0] == L
'\0')
654 for (c = lpFileName; *c; ++c)
663UINT CClipboardFreeRDP::SendFileContentsFailure(
664 CliprdrClientContext* context,
665 const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
667 qDebug(log) << Q_FUNC_INFO;
668 CLIPRDR_FILE_CONTENTS_RESPONSE response = { 0 };
669#if FreeRDP_VERSION_MAJOR >= 3
670 response.common.msgFlags = CB_RESPONSE_FAIL;
672 response.msgFlags = CB_RESPONSE_FAIL;
674 response.streamId = fileContentsRequest->streamId;
675 return context->ClientFileContentsResponse(context, &response);
678UINT CClipboardFreeRDP::ServerFileRangeRequest(
679 const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
681 qDebug(log) << Q_FUNC_INFO;
682 wClipboardFileRangeRequest request = { 0 };
683 request.streamId = fileContentsRequest->streamId;
684 request.listIndex = fileContentsRequest->listIndex;
685 request.nPositionLow = fileContentsRequest->nPositionLow;
686 request.nPositionHigh = fileContentsRequest->nPositionHigh;
687 request.cbRequested = fileContentsRequest->cbRequested;
688 wClipboardDelegate* pDelegate = ClipboardGetDelegate(m_pClipboard);
690 return pDelegate->ClientRequestFileRange(pDelegate, &request);
694UINT CClipboardFreeRDP::ServerFileSizeRequest(
695 const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
697 qDebug(log) << Q_FUNC_INFO;
698 wClipboardFileSizeRequest request = { 0 };
699 request.streamId = fileContentsRequest->streamId;
700 request.listIndex = fileContentsRequest->listIndex;
702 wClipboardDelegate* pDelegate = ClipboardGetDelegate(m_pClipboard);
703 if(!pDelegate)
return E_FAIL;
705 if (fileContentsRequest->cbRequested !=
sizeof(UINT64))
707 qWarning(log) <<
"unexpected FILECONTENTS_SIZE request:"
708 << fileContentsRequest->cbRequested <<
" bytes";
711 return pDelegate->ClientRequestFileSize(pDelegate, &request);
714UINT CClipboardFreeRDP::cb_cliprdr_server_file_contents_request(
715 CliprdrClientContext* context,
716 const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
719 "CClipboardFreeRdp::cb_cliprdr_server_file_contents_request";
720 int nRet = CHANNEL_RC_OK;
722 UINT error = NO_ERROR;
724 if(!context)
return nRet;
732 if ((fileContentsRequest->dwFlags
733 & (FILECONTENTS_SIZE | FILECONTENTS_RANGE))
734 == (FILECONTENTS_SIZE | FILECONTENTS_RANGE))
736 qCritical(log) <<
"invalid CLIPRDR_FILECONTENTS_REQUEST.dwFlags";
737 return SendFileContentsFailure(context, fileContentsRequest);
740 if (fileContentsRequest->dwFlags & FILECONTENTS_SIZE)
741 error = pThis->ServerFileSizeRequest(fileContentsRequest);
743 if (fileContentsRequest->dwFlags & FILECONTENTS_RANGE)
744 error = pThis->ServerFileRangeRequest(fileContentsRequest);
749 <<
"failed to handle CLIPRDR_FILECONTENTS_REQUEST:" << error;
750 return SendFileContentsFailure(context, fileContentsRequest);
757UINT CClipboardFreeRDP::cb_cliprdr_server_format_list(
758 CliprdrClientContext* context,
759 const CLIPRDR_FORMAT_LIST* formatList)
761 qDebug(log) <<
"CClipboardFreeRdp::cb_cliprdr_server_format_list";
762 int nRet = CHANNEL_RC_OK;
766 if(formatList->numFormats < 0)
772 if(!pMimeData)
return nRet;
773 if(pMimeData->SetFormat(formatList))
775 pMimeData->deleteLater();
780 check = connect(pThis,
783 SLOT(slotServerFormatData(
const BYTE*, UINT32, UINT32)),
784 Qt::DirectConnection);
786 check = connect(pThis,
787 SIGNAL(sigServerFileContentsRespose(UINT32, QByteArray&)),
789 SLOT(slotServerFileContentsRespose(UINT32, QByteArray&)),
790 Qt::DirectConnection);
792 check = connect(pMimeData,
793 SIGNAL(sigSendDataRequest(CliprdrClientContext*, UINT32)),
795 SLOT(slotSendFormatDataRequest(CliprdrClientContext*, UINT32)));
798 pThis->m_lstClipboardMimeDataId.push_back(pMimeData->GetId());
799 emit pThis->m_pConnect->sigSetClipboard(pMimeData);
803UINT CClipboardFreeRDP::cb_cliprdr_server_format_list_response(
804 CliprdrClientContext* context,
805 const CLIPRDR_FORMAT_LIST_RESPONSE* pformatListResponse)
807#if FreeRDP_VERSION_MAJOR >= 3
809 <<
"CClipboardFreeRdp::cb_cliprdr_server_format_list_response:type:"
810 << pformatListResponse->common.msgType
811 <<
";flag:" << pformatListResponse->common.msgFlags
812 <<
";datalen:" << pformatListResponse->common.dataLen;
815 <<
"CClipboardFreeRdp::cb_cliprdr_server_format_list_response:type:"
816 << pformatListResponse->msgType
817 <<
";flag:" << pformatListResponse->msgFlags
818 <<
";datalen:" << pformatListResponse->dataLen;
822#
if FreeRDP_VERSION_MAJOR >= 3
823 pformatListResponse->common.msgFlags
825 pformatListResponse->msgFlags
828 qDebug(log) <<
"The server is not support the format";
829 return CHANNEL_RC_OK;
832UINT CClipboardFreeRDP::slotSendFormatDataRequest(CliprdrClientContext* context,
835 UINT rc = CHANNEL_RC_OK;
836 CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest;
837 qDebug(log) << Q_FUNC_INFO;
838 if (!context || !context->ClientFormatDataRequest)
839 return ERROR_INTERNAL_ERROR;
842 pThis->m_RequestFormatId = formatId;
843 formatDataRequest.requestedFormatId = formatId;
844 rc = context->ClientFormatDataRequest(context, &formatDataRequest);
849UINT CClipboardFreeRDP::cb_cliprdr_server_format_data_response(
850 CliprdrClientContext* context,
851 const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
853 qDebug(log) <<
"CClipboardFreeRdp::cb_cliprdr_server_format_data_response";
854 int nRet = CHANNEL_RC_OK;
855 if(!context)
return nRet;
859 emit pThis->sigServerFormatData(formatDataResponse->requestedFormatData,
860#
if FreeRDP_VERSION_MAJOR >= 3
861 formatDataResponse->common.dataLen,
863 formatDataResponse->dataLen,
865 pThis->m_RequestFormatId);
869UINT CClipboardFreeRDP::cb_cliprdr_server_file_contents_response(
870 CliprdrClientContext* context,
871 const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
873 qDebug(log) <<
"CClipboardFreeRdp::cb_cliprdr_server_file_contents_response";
874 int nRet = CHANNEL_RC_OK;
876 if (!context || !fileContentsResponse)
877 return ERROR_INTERNAL_ERROR;
880#
if FreeRDP_VERSION_MAJOR >= 3
881 fileContentsResponse->common.msgFlags
883 fileContentsResponse->msgFlags
888 <<
"File contents response error";
894 if(0 == fileContentsResponse->cbRequested)
896 qDebug(log) <<
"CClipboardFreeRdp::cb_cliprdr_server_file_contents_response size is zero.";
898 emit pThis->sigServerFileContentsRespose(
899 fileContentsResponse->streamId,
902 QByteArray data((
char*)fileContentsResponse->requestedData,
903 fileContentsResponse->cbRequested);
904 emit pThis->sigServerFileContentsRespose(
905 fileContentsResponse->streamId,
void sigServerFormatData(const BYTE *pData, UINT32 nLen, UINT32 formatId)
Notify clipboard get data from server.