Changeset 91749 in vbox
- Timestamp:
- Oct 14, 2021 9:02:32 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 147507
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
r90238 r91749 84 84 &fFormats, &fChanged); 85 85 if ( RT_SUCCESS(rc) 86 && fChanged) 86 && fChanged 87 && ShClSvcIsBackendActive()) 87 88 rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 88 89 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r91622 r91749 259 259 } SHCLEXTSTATE, *PSHCLEXTSTATE; 260 260 261 extern SHCLEXTSTATE g_ExtState; 262 261 263 int shClSvcSetSource(PSHCLCLIENT pClient, SHCLSOURCE enmSource); 262 264 … … 298 300 bool ShClSvcLock(void); 299 301 void ShClSvcUnlock(void); 302 303 /** 304 * Checks if the backend is active (@c true), or if VRDE is in control of 305 * the host side. 306 */ 307 DECLINLINE(bool) ShClSvcIsBackendActive(void) 308 { 309 return g_ExtState.pfnExtension == NULL; 310 } 300 311 /** @} */ 301 312 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r90238 r91749 590 590 rc = SharedClipboardWinGetFormats(&pCtx->Win, &fFormats); 591 591 if ( RT_SUCCESS(rc) 592 && fFormats != VBOX_SHCL_FMT_NONE) /** @todo r=bird: BUGBUG: revisit this. */ 592 && fFormats != VBOX_SHCL_FMT_NONE /** @todo r=bird: BUGBUG: revisit this. */ 593 && ShClSvcIsBackendActive()) 593 594 rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 594 595 } -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r91624 r91749 140 140 * there is data in the host clipboard it will automatically be sent to 141 141 * the guest when the clipboard starts up. */ 142 return ShClSvcHostReportFormats(pClient, VBOX_SHCL_FMT_NONE); 142 if (ShClSvcIsBackendActive()) 143 return ShClSvcHostReportFormats(pClient, VBOX_SHCL_FMT_NONE); 144 return VINF_SUCCESS; 143 145 } 144 146 … … 290 292 if (RT_SUCCESS(rc)) 291 293 { 292 /** @todo r=bird: BUGBUG: Revisit this */ 293 if (fFormats != VBOX_SHCL_FMT_NONE) /* No formats to report? */ 294 { 295 rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 294 if (ShClSvcIsBackendActive()) 295 { 296 /** @todo r=bird: BUGBUG: Revisit this */ 297 if (fFormats != VBOX_SHCL_FMT_NONE) /* No formats to report? */ 298 { 299 rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 300 } 296 301 } 297 302 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r91513 r91749 1400 1400 * Reports available VBox clipboard formats to the guest. 1401 1401 * 1402 * @note Host backend callers must check if it's active (use 1403 * ShClSvcIsBackendActive) before calling to prevent mixing up the 1404 * VRDE clipboard. 1405 * 1402 1406 * @returns VBox status code. 1403 1407 * @param pClient Client to report clipboard formats to. … … 1545 1549 if (RT_SUCCESS(rc)) 1546 1550 { 1547 if (g_ExtState.pfnExtension) 1551 rc = RTCritSectEnter(&g_CritSect); 1552 if (RT_SUCCESS(rc)) 1548 1553 { 1549 SHCLEXTPARMS parms; 1550 RT_ZERO(parms); 1551 parms.uFormat = fFormats; 1552 1553 g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, &parms, sizeof(parms)); 1554 if (g_ExtState.pfnExtension) 1555 { 1556 SHCLEXTPARMS parms; 1557 RT_ZERO(parms); 1558 parms.uFormat = fFormats; 1559 1560 g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, &parms, sizeof(parms)); 1561 } 1562 else 1563 { 1564 #ifdef LOG_ENABLED 1565 char *pszFmts = ShClFormatsToStrA(fFormats); 1566 if (pszFmts) 1567 { 1568 LogRel2(("Shared Clipboard: Guest reported formats '%s' to host\n", pszFmts)); 1569 RTStrFree(pszFmts); 1570 } 1571 #endif 1572 rc = ShClBackendFormatAnnounce(pClient, fFormats); 1573 if (RT_FAILURE(rc)) 1574 LogRel(("Shared Clipboard: Reporting guest clipboard formats to the host failed with %Rrc\n", rc)); 1575 } 1576 1577 RTCritSectLeave(&g_CritSect); 1554 1578 } 1555 1579 else 1556 { 1557 #ifdef LOG_ENABLED 1558 char *pszFmts = ShClFormatsToStrA(fFormats); 1559 AssertPtrReturn(pszFmts, VERR_NO_MEMORY); 1560 LogRel2(("Shared Clipboard: Guest reported formats '%s' to host\n", pszFmts)); 1561 RTStrFree(pszFmts); 1562 #endif 1563 rc = ShClBackendFormatAnnounce(pClient, fFormats); 1564 if (RT_FAILURE(rc)) 1565 LogRel(("Shared Clipboard: Reporting guest clipboard formats to the host failed with %Rrc\n", rc)); 1566 } 1580 LogRel2(("Shared Clipboard: Unable to take internal lock while receiving guest clipboard announcement: %Rrc\n", rc)); 1567 1581 } 1568 1582 } … … 1669 1683 * Do the reading. 1670 1684 */ 1671 int rc;1672 1685 uint32_t cbActual = 0; 1686 1687 int rc = RTCritSectEnter(&g_CritSect); 1688 AssertRCReturn(rc, rc); 1673 1689 1674 1690 /* If there is a service extension active, try reading data from it first. */ … … 1727 1743 rc = VINF_BUFFER_OVERFLOW; 1728 1744 } 1745 1746 RTCritSectLeave(&g_CritSect); 1729 1747 1730 1748 LogFlowFuncLeaveRC(rc); … … 1854 1872 #ifdef LOG_ENABLED 1855 1873 char *pszFmt = ShClFormatsToStrA(uFormat); 1856 AssertPtrReturn(pszFmt, VERR_NO_MEMORY); 1857 LogRel2(("Shared Clipboard: Guest writes %RU32 bytes clipboard data in format '%s' to host\n", cbData, pszFmt)); 1858 RTStrFree(pszFmt); 1874 if (pszFmt) 1875 { 1876 LogRel2(("Shared Clipboard: Guest writes %RU32 bytes clipboard data in format '%s' to host\n", cbData, pszFmt)); 1877 RTStrFree(pszFmt); 1878 } 1859 1879 #endif 1860 1880 … … 1862 1882 * Write the data to the active host side clipboard. 1863 1883 */ 1864 int rc; 1884 int rc = RTCritSectEnter(&g_CritSect); 1885 AssertRCReturn(rc, rc); 1886 1865 1887 if (g_ExtState.pfnExtension) 1866 1888 { … … 1887 1909 AssertRC(rc2); 1888 1910 } 1911 1912 RTCritSectLeave(&g_CritSect); 1889 1913 1890 1914 LogFlowFuncLeaveRC(rc); … … 2695 2719 RT_ZERO(parms); 2696 2720 2721 /* 2722 * Reference counting for service extension registration is done a few 2723 * layers up (in ConsoleVRDPServer::ClipboardCreate()). 2724 */ 2725 2726 int rc = RTCritSectEnter(&g_CritSect); 2727 AssertLogRelRCReturn(rc, rc); 2728 2697 2729 if (pfnExtension) 2698 2730 { … … 2702 2734 2703 2735 parms.u.pfnCallback = extCallback; 2704 2705 2736 g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof(parms)); 2737 2738 LogRel2(("Shared Clipboard: registered service extension\n")); 2706 2739 } 2707 2740 else … … 2711 2744 2712 2745 /* Uninstall extension. */ 2746 g_ExtState.pvExtension = NULL; 2713 2747 g_ExtState.pfnExtension = NULL; 2714 g_ExtState.pvExtension = NULL; 2715 } 2748 2749 LogRel2(("Shared Clipboard: de-registered service extension\n")); 2750 } 2751 2752 RTCritSectLeave(&g_CritSect); 2716 2753 2717 2754 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.