- Timestamp:
- Jun 21, 2023 10:39:24 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/clipboard-x11.cpp
r100205 r100235 52 52 #include "clipboard.h" 53 53 54 #include <iprt/req.h>55 56 54 57 55 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP 58 #if 059 /**60 * Worker for reading the transfer root list from the host.61 */62 static DECLCALLBACK(int) vbclX11ReqTransferReadRootListWorker(PSHCLCONTEXT pCtx, PSHCLTRANSFER pTransfer)63 {64 RT_NOREF(pCtx);65 66 LogFlowFuncEnter();67 68 int rc = ShClTransferRootListRead(pTransfer);69 70 LogFlowFuncLeaveRC(rc);71 return rc;72 }73 #endif74 75 56 /** 76 57 * Worker for waiting for a transfer status change. … … 206 187 * Worker for a reading clipboard from the host. 207 188 */ 208 static DECLCALLBACK(int) vbclX11Re qReadDataWorker(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb, void *pvUser)189 static DECLCALLBACK(int) vbclX11ReadDataWorker(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb, void *pvUser) 209 190 { 210 191 RT_NOREF(pvUser); … … 286 267 LogFlowFunc(("pCtx=%p, uFmt=%#x\n", pCtx, uFmt)); 287 268 288 /* Request reading host clipboard data. */ 289 PRTREQ pReq = NULL; 290 int rc = RTReqQueueCallEx(pCtx->X11.hReqQ, &pReq, SHCL_TIMEOUT_DEFAULT_MS, RTREQFLAGS_IPRT_STATUS, 291 (PFNRT)vbclX11ReqReadDataWorker, 5, pCtx, uFmt, ppv, pcb, pvUser); 292 RTReqRelease(pReq); 269 int rc; 293 270 294 271 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP … … 297 274 PSHCLHTTPSERVER pSrv = &pCtx->X11.HttpCtx.HttpServer; 298 275 299 rc = ShClTransferHttpServerWaitForStatusChange(pSrv, SHCLHTTPSERVERSTATUS_TRANSFER_REGISTERED, SHCL_TIMEOUT_DEFAULT_MS);276 rc = vbclX11ReadDataWorker(pCtx, uFmt, ppv, pcb, pvUser); 300 277 if (RT_SUCCESS(rc)) 301 { 302 PSHCLTRANSFER pTransfer = ShClTransferHttpServerGetTransferFirst(pSrv); 278 rc = ShClTransferHttpServerWaitForStatusChange(pSrv, SHCLHTTPSERVERSTATUS_TRANSFER_REGISTERED, 5000 /* SHCL_TIMEOUT_DEFAULT_MS */); 279 if (RT_SUCCESS(rc)) 280 { 281 PSHCLTRANSFER pTransfer = ShClTransferHttpServerGetTransferLast(pSrv); 303 282 if (pTransfer) 304 283 { … … 313 292 *pcb = strlen(pszData) + 1 /* Include terminator */; 314 293 294 LogFlowFunc(("pszURL=%s\n", pszURL)); 295 315 296 RTStrFree(pszURL); 316 297 317 298 rc = VINF_SUCCESS; 318 319 LogFlowFunc(("pszURL=%s\n", pszURL));320 299 } 321 300 } … … 326 305 LogRel(("Shared Clipboard: Could not start transfer, as the HTTP server is not running\n")); 327 306 } 307 else /* Anything else */ 328 308 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP */ 309 { 310 rc = vbclX11ReadDataWorker(pCtx, uFmt, ppv, pcb, pvUser); 311 } 329 312 330 313 if (RT_FAILURE(rc)) … … 336 319 337 320 /** 338 * Worker for reporting clipboard formats to the host. 339 */ 340 static DECLCALLBACK(int) vbclX11ReqReportFormatsWorker(PSHCLCONTEXT pCtx, uint32_t fFormats, void *pvUser) 321 * @copydoc SHCLCALLBACKS::pfnReportFormats 322 * 323 * Reports clipboard formats to the host. 324 * 325 * @thread X11 event thread. 326 */ 327 static DECLCALLBACK(int) vbclX11ReportFormatsCallback(PSHCLCONTEXT pCtx, uint32_t fFormats, void *pvUser) 341 328 { 342 329 RT_NOREF(pvUser); … … 345 332 346 333 int rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, fFormats); 347 348 LogFlowFuncLeaveRC(rc);349 return rc;350 }351 352 /**353 * @copydoc SHCLCALLBACKS::pfnReportFormats354 *355 * Reports clipboard formats to the host.356 *357 * @thread X11 event thread.358 */359 static DECLCALLBACK(int) vbclX11ReportFormatsCallback(PSHCLCONTEXT pCtx, uint32_t fFormats, void *pvUser)360 {361 /* Request reading host clipboard data. */362 PRTREQ pReq = NULL;363 int rc = RTReqQueueCallEx(pCtx->X11.hReqQ, &pReq, SHCL_TIMEOUT_DEFAULT_MS, RTREQFLAGS_IPRT_STATUS,364 (PFNRT)vbclX11ReqReportFormatsWorker, 3, pCtx, fFormats, pvUser);365 RTReqRelease(pReq);366 334 367 335 LogFlowFuncLeaveRC(rc); … … 430 398 { 431 399 PSHCLCONTEXT pCtx = &g_Ctx; 432 433 int rc = RTReqQueueCreate(&pCtx->X11.hReqQ);434 AssertRCReturn(rc, rc);435 400 436 401 bool fShutdown = false; … … 459 424 pCtx->CmdCtx.fUseLegacyProtocol, pCtx->CmdCtx.fHostFeatures)); 460 425 461 /* The thread processes incoming messages from the host and the worker queue. */ 462 PVBGLR3CLIPBOARDEVENT pEvent = NULL; 426 int rc; 427 428 /* The thread waits for incoming messages from the host. */ 463 429 for (;;) 464 430 { 465 if (!pEvent) 466 pEvent = (PVBGLR3CLIPBOARDEVENT)RTMemAllocZ(sizeof(VBGLR3CLIPBOARDEVENT)); 431 PVBGLR3CLIPBOARDEVENT pEvent = (PVBGLR3CLIPBOARDEVENT)RTMemAllocZ(sizeof(VBGLR3CLIPBOARDEVENT)); 467 432 AssertPtrBreakStmt(pEvent, rc = VERR_NO_MEMORY); 468 433 469 434 uint32_t idMsg = 0; 470 435 uint32_t cParms = 0; 471 rc = VbglR3ClipboardMsgPeek (&pCtx->CmdCtx, &idMsg, &cParms, NULL /* pidRestoreCheck */);436 rc = VbglR3ClipboardMsgPeekWait(&pCtx->CmdCtx, &idMsg, &cParms, NULL /* pidRestoreCheck */); 472 437 if (RT_SUCCESS(rc)) 473 438 { … … 477 442 rc = VbglR3ClipboardEventGetNext(idMsg, cParms, &pCtx->CmdCtx, pEvent); 478 443 #endif 479 }480 else if (rc == VERR_TRY_AGAIN) /* No new message (yet). */481 {482 RTReqQueueProcess(pCtx->X11.hReqQ, RT_MS_1SEC);483 continue;484 444 } 485 445 … … 592 552 } 593 553 594 RTReqQueueDestroy(pCtx->X11.hReqQ);595 596 554 LogFlowFuncLeaveRC(rc); 597 555 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.