VirtualBox

Changeset 91749 in vbox


Ignore:
Timestamp:
Oct 14, 2021 9:02:32 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147507
Message:

VRDP: Shared Clipboard: delegate clipboard processing to VRDP service when remote RDP clients are connected, bugref:10117.

Location:
trunk/src/VBox/HostServices/SharedClipboard
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp

    r90238 r91749  
    8484                                       &fFormats, &fChanged);
    8585    if (   RT_SUCCESS(rc)
    86         && fChanged)
     86        && fChanged
     87        && ShClSvcIsBackendActive())
    8788        rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats);
    8889
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r91622 r91749  
    259259} SHCLEXTSTATE, *PSHCLEXTSTATE;
    260260
     261extern SHCLEXTSTATE g_ExtState;
     262
    261263int shClSvcSetSource(PSHCLCLIENT pClient, SHCLSOURCE enmSource);
    262264
     
    298300bool ShClSvcLock(void);
    299301void 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 */
     307DECLINLINE(bool) ShClSvcIsBackendActive(void)
     308{
     309    return g_ExtState.pfnExtension == NULL;
     310}
    300311/** @} */
    301312
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r90238 r91749  
    590590        rc = SharedClipboardWinGetFormats(&pCtx->Win, &fFormats);
    591591        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())
    593594            rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats);
    594595    }
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r91624 r91749  
    140140     * there is data in the host clipboard it will automatically be sent to
    141141     * 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;
    143145}
    144146
     
    290292    if (RT_SUCCESS(rc))
    291293    {
    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            }
    296301        }
    297302
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r91513 r91749  
    14001400 * Reports available VBox clipboard formats to the guest.
    14011401 *
     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 *
    14021406 * @returns VBox status code.
    14031407 * @param   pClient             Client to report clipboard formats to.
     
    15451549        if (RT_SUCCESS(rc))
    15461550        {
    1547             if (g_ExtState.pfnExtension)
     1551            rc = RTCritSectEnter(&g_CritSect);
     1552            if (RT_SUCCESS(rc))
    15481553            {
    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);
    15541578            }
    15551579            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));
    15671581        }
    15681582    }
     
    16691683     * Do the reading.
    16701684     */
    1671     int rc;
    16721685    uint32_t cbActual = 0;
     1686
     1687    int rc = RTCritSectEnter(&g_CritSect);
     1688    AssertRCReturn(rc, rc);
    16731689
    16741690    /* If there is a service extension active, try reading data from it first. */
     
    17271743            rc = VINF_BUFFER_OVERFLOW;
    17281744    }
     1745
     1746    RTCritSectLeave(&g_CritSect);
    17291747
    17301748    LogFlowFuncLeaveRC(rc);
     
    18541872#ifdef LOG_ENABLED
    18551873    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    }
    18591879#endif
    18601880
     
    18621882     * Write the data to the active host side clipboard.
    18631883     */
    1864     int rc;
     1884    int rc = RTCritSectEnter(&g_CritSect);
     1885    AssertRCReturn(rc, rc);
     1886
    18651887    if (g_ExtState.pfnExtension)
    18661888    {
     
    18871909        AssertRC(rc2);
    18881910    }
     1911
     1912    RTCritSectLeave(&g_CritSect);
    18891913
    18901914    LogFlowFuncLeaveRC(rc);
     
    26952719    RT_ZERO(parms);
    26962720
     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
    26972729    if (pfnExtension)
    26982730    {
     
    27022734
    27032735        parms.u.pfnCallback = extCallback;
    2704 
    27052736        g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof(parms));
     2737
     2738        LogRel2(("Shared Clipboard: registered service extension\n"));
    27062739    }
    27072740    else
     
    27112744
    27122745        /* Uninstall extension. */
     2746        g_ExtState.pvExtension  = NULL;
    27132747        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);
    27162753
    27172754    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette