Changeset 100655 in vbox
- Timestamp:
- Jul 19, 2023 4:06:24 PM (17 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/VBoxClipboardExt.h
r100647 r100655 47 47 48 48 /** Sets (or unsets) a clipboard extension callback. */ 49 #define VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK (0) 50 /** The guest announces clipboard formats to the extension. */ 51 #define VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE (1) 49 #define VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK (0) 50 /** The guest reports clipboard formats to the extension. */ 51 #define VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST (1) 52 /** The clipboard service wants to report formats to the guest. */ 53 #define VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_GUEST (2) 52 54 /** The clipboard service requests clipboard data from the extension. */ 53 #define VBOX_CLIPBOARD_EXT_FN_DATA_READ (2)55 #define VBOX_CLIPBOARD_EXT_FN_DATA_READ (3) 54 56 /** The clipboard service writes clipboard data to the extension. */ 55 #define VBOX_CLIPBOARD_EXT_FN_DATA_WRITE (3)57 #define VBOX_CLIPBOARD_EXT_FN_DATA_WRITE (4) 56 58 /** The clipboard service announces an error to the extension. */ 57 #define VBOX_CLIPBOARD_EXT_FN_ERROR (4)59 #define VBOX_CLIPBOARD_EXT_FN_ERROR (5) 58 60 59 61 typedef DECLCALLBACKTYPE(int, FNSHCLEXTCALLBACK,(uint32_t u32Function, uint32_t u32Format, void *pvData, uint32_t cbData)); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
r100646 r100655 94 94 &fFormats, &fChanged); 95 95 if ( RT_SUCCESS(rc) 96 && fChanged 97 && ShClSvcIsBackendActive()) 96 && fChanged) 98 97 rc = ShClSvcReportFormats(pCtx->pClient, fFormats); 99 98 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r100646 r100655 319 319 bool ShClSvcLock(void); 320 320 void ShClSvcUnlock(void); 321 322 /**323 * Checks if the backend is active (@c true), or if VRDE is in control of324 * the host side.325 */326 DECLINLINE(bool) ShClSvcIsBackendActive(void)327 {328 return g_ExtState.pfnExtension == NULL;329 }330 321 /** @} */ 331 322 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r100646 r100655 789 789 SHCLFORMATS fFormats = 0; 790 790 rc = SharedClipboardWinGetFormats(&pCtx->Win, &fFormats); 791 if ( RT_SUCCESS(rc) 792 && fFormats != VBOX_SHCL_FMT_NONE /** @todo r=bird: BUGBUG: revisit this. */ 793 && ShClSvcIsBackendActive()) 791 if (RT_SUCCESS(rc)) 794 792 rc = ShClSvcReportFormats(pCtx->pClient, fFormats); 795 793 } -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r100646 r100655 220 220 * there is data in the host clipboard it will automatically be sent to 221 221 * the guest when the clipboard starts up. */ 222 if (ShClSvcIsBackendActive()) 223 return ShClSvcReportFormats(pClient, VBOX_SHCL_FMT_NONE); 224 return VINF_SUCCESS; 222 return ShClSvcReportFormats(pClient, VBOX_SHCL_FMT_NONE); 225 223 } 226 224 … … 369 367 AssertPtr(pClient); 370 368 371 rc = RTCritSectEnter(&pClient->CritSect); 372 if (RT_SUCCESS(rc)) 373 { 374 if (ShClSvcIsBackendActive()) 375 { 376 /** @todo r=bird: BUGBUG: Revisit this */ 377 if (fFormats != VBOX_SHCL_FMT_NONE) /* No formats to report? */ 378 { 379 rc = ShClSvcReportFormats(pCtx->pClient, fFormats); 380 } 381 } 382 383 RTCritSectLeave(&pClient->CritSect); 384 } 369 rc = ShClSvcReportFormats(pCtx->pClient, fFormats); 385 370 386 371 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r100646 r100655 1473 1473 * Reports clipboard formats to the guest. 1474 1474 * 1475 * @note Host backend callers must check if it's active (use1476 * ShClSvcIsBackendActive) before calling to prevent mixing up the1477 * VRDE clipboard.1478 *1479 1475 * @returns VBox status code. 1480 1476 * @param pClient Client to report clipboard formats to. 1481 * @param fFormats The formats to report (VBOX_SHCL_FMT_XXX), zero 1482 * is okay (empty the clipboard). 1483 * 1477 * @param fFormats The formats to report (VBOX_SHCL_FMT_XXX). 1478 * VBOX_SHCL_FMT_NONE will empty (clear) the clipboard. 1484 1479 * @thread Backend thread. 1485 1480 */ 1486 1481 int ShClSvcReportFormats(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 1487 1482 { 1488 LogFlowFuncEnter(); 1483 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1484 1485 LogFlowFunc(("fFormats=%#x\n", fFormats)); 1489 1486 1490 1487 /* … … 1501 1498 return VINF_SUCCESS; 1502 1499 1503 AssertPtrReturn(pClient, VERR_INVALID_POINTER);1504 1505 LogFlowFunc(("fFormats=%#x\n", fFormats));1506 1507 1500 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1508 1501 bool fSkipTransfers = false; … … 1529 1522 #endif 1530 1523 1524 int rc; 1525 1526 /* 1527 * Check if the HGCM callback can handle this first. 1528 * This is needed in order to not mess up the clipboard if VRDE is active, for example. 1529 */ 1530 if (g_ExtState.pfnExtension) /* Extension set? */ 1531 { 1532 SHCLEXTPARMS parms; 1533 RT_ZERO(parms); 1534 1535 parms.u.ReportFormats.uFormats = fFormats; 1536 1537 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_GUEST, &parms, sizeof(parms)); 1538 if (rc == VERR_NOT_SUPPORTED) 1539 { 1540 /* Not handled by the extension, continue below. */ 1541 } 1542 else /* Handled by the extension, bail out. */ 1543 return rc; 1544 } 1545 1531 1546 /* 1532 1547 * Allocate a message, populate parameters and post it to the client. 1533 1548 */ 1534 int rc;1535 1549 PSHCLCLIENTMSG pMsg = shClSvcMsgAlloc(pClient, VBOX_SHCL_HOST_MSG_FORMATS_REPORT, 2); 1536 1550 if (pMsg) … … 1539 1553 HGCMSvcSetU32(&pMsg->aParms[1], fFormats); 1540 1554 1541 RTCritSectEnter(&pClient->CritSect); 1555 shClSvcClientLock(pClient); 1556 1542 1557 rc = shClSvcMsgAddAndWakeupClient(pClient, pMsg); 1543 RTCritSectLeave(&pClient->CritSect); 1558 1559 shClSvcClientUnlock(pClient); 1544 1560 } 1545 1561 else … … 1620 1636 parms.u.ReportFormats.uFormats = fFormats; 1621 1637 1622 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ ANNOUNCE, &parms, sizeof(parms));1638 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST, &parms, sizeof(parms)); 1623 1639 } 1624 1640 else … … 2730 2746 switch (u32Function) 2731 2747 { 2732 /* The service extension announces formats to the guest. */2733 case VBOX_CLIPBOARD_EXT_FN_FORMAT_ ANNOUNCE:2748 /* The service extension announces formats to the host. */ 2749 case VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST: 2734 2750 { 2735 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_FORMAT_ ANNOUNCE: g_ExtState.fReadingData=%RTbool\n", g_ExtState.fReadingData));2751 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST: g_ExtState.fReadingData=%RTbool\n", g_ExtState.fReadingData)); 2736 2752 if (!g_ExtState.fReadingData) 2737 2753 rc = ShClSvcReportFormats(pClient, u32Format); … … 2775 2791 } 2776 2792 2777 /** @todo BUGBUG Why no VBOX_CLIPBOARD_EXT_FN_DATA_WRITE here? */2778 2779 2793 default: 2780 2794 /* Just skip other messages. */ -
trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
r100612 r100655 3307 3307 if (pServer->mpfnClipboardCallback) 3308 3308 { 3309 vrc = pServer->mpfnClipboardCallback(VBOX_CLIPBOARD_EXT_FN_FORMAT_ ANNOUNCE,3309 vrc = pServer->mpfnClipboardCallback(VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST, 3310 3310 u32Format, 3311 3311 (void *)pvData, … … 3334 3334 } 3335 3335 3336 /*static*/ DECLCALLBACK(int) 3337 ConsoleVRDPServer::ClipboardServiceExtension(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms) 3336 /** 3337 * Service extension callback called by GuestShCl::hgcmDispatcher(). 3338 * 3339 * @returns VBox status code. 3340 * @retval VERR_NOT_SUPPORTED if the extension didn't handle the requested function. This will invoke the regular backend then. 3341 * @param pvExtension Pointer to service extension. 3342 * @param u32Function Callback HGCM message ID. 3343 * @param pvParms Pointer to optional data provided for a particular message. Optional. 3344 * @param cbParms Size (in bytes) of \a pvParms. 3345 */ 3346 /* static */ 3347 DECLCALLBACK(int) ConsoleVRDPServer::ClipboardServiceExtension(void *pvExtension, 3348 uint32_t u32Function, void *pvParms, uint32_t cbParms) 3338 3349 { 3339 3350 RT_NOREF(cbParms); … … 3344 3355 3345 3356 ConsoleVRDPServer *pServer = static_cast <ConsoleVRDPServer *>(pvExtension); 3357 AssertPtrReturn(pServer, VERR_INVALID_POINTER); 3346 3358 3347 3359 SHCLEXTPARMS *pParms = (SHCLEXTPARMS *)pvParms; 3360 AssertPtrReturn(pParms, VERR_INVALID_POINTER); 3348 3361 3349 3362 switch (u32Function) … … 3354 3367 } break; 3355 3368 3356 case VBOX_CLIPBOARD_EXT_FN_FORMAT_ ANNOUNCE:3357 { 3358 /* The guest announces clipboard formats . This must be delivered to all clients. */3369 case VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST: 3370 { 3371 /* The guest announces clipboard formats to the host. This must be delivered to all clients. */ 3359 3372 if (mpEntryPoints && pServer->mhServer) 3360 3373 { … … 3366 3379 NULL); 3367 3380 } 3381 } break; 3382 3383 case VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_GUEST: 3384 { 3385 /* We need to handle this case here, to act as a no-op. 3386 * 3387 * If not being handled, this function otherwise would return VERR_NOT_SUPPORTED, 3388 * which in turn then will invoke the host backend, messing up the VRDE clipboard handling. */ 3368 3389 } break; 3369 3390
Note:
See TracChangeset
for help on using the changeset viewer.