VirtualBox

Changeset 100684 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 21, 2023 3:03:01 PM (17 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Added ShClX11ReadDataFromX11(), useful for enabling the X11 testcases (again). bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r100385 r100684  
    25852585}
    25862586
     2587/**
     2588 * Reads the X11 clipboard.
     2589 *
     2590 * @returns VBox status code.
     2591 * @retval  VERR_NO_DATA if format is supported but no data is available currently.
     2592 * @retval  VERR_NOT_IMPLEMENTED if the format is not implemented.
     2593 * @param   pCtx                Context data for the clipboard backend.
     2594 * @param   pEventSource        Event source to use.
     2595 * @param   msTimeout           Timeout (in ms) for waiting.
     2596 * @param   uFmt                The format that the VBox would like to receive the data in.
     2597 * @param   pvBuf               Where to store the received data on success.
     2598 * @param   cbBuf               Size (in bytes) of \a pvBuf. Also marks maximum data to read (in bytes).
     2599 * @param   pcbRead             Where to return the read bytes on success.
     2600 */
     2601int ShClX11ReadDataFromX11(PSHCLX11CTX pCtx, PSHCLEVENTSOURCE pEventSource, RTMSINTERVAL msTimeout,
     2602                           SHCLFORMAT uFmt, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)
     2603{
     2604    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     2605    AssertPtrReturn(pEventSource, VERR_INVALID_POINTER);
     2606    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
     2607    AssertReturn(cbBuf, VERR_INVALID_PARAMETER);
     2608    AssertPtrReturn(pcbRead, VERR_INVALID_POINTER);
     2609
     2610    PSHCLEVENT pEvent;
     2611    int rc = ShClEventSourceGenerateAndRegisterEvent(pEventSource, &pEvent);
     2612    if (RT_SUCCESS(rc))
     2613    {
     2614        rc = ShClX11ReadDataFromX11Async(pCtx, uFmt, cbBuf, pEvent);
     2615        if (RT_SUCCESS(rc))
     2616        {
     2617            PSHCLEVENTPAYLOAD pPayload;
     2618            rc = ShClEventWait(pEvent, msTimeout, &pPayload);
     2619            if (RT_SUCCESS(rc))
     2620            {
     2621                if (pPayload)
     2622                {
     2623                    Assert(pPayload->cbData == sizeof(SHCLX11RESPONSE));
     2624                    PSHCLX11RESPONSE pResp = (PSHCLX11RESPONSE)pPayload->pvData;
     2625
     2626                    memcpy(pvBuf, pResp->Read.pvData, RT_MIN(cbBuf, pResp->Read.cbData));
     2627                    *pcbRead = pResp->Read.cbData;
     2628
     2629                    RTMemFree(pResp->Read.pvData);
     2630                    pResp->Read.cbData = 0;
     2631
     2632                    ShClPayloadFree(pPayload);
     2633                }
     2634            }
     2635        }
     2636    }
     2637
     2638    LogFlowFuncLeaveRC(rc);
     2639    return rc;
     2640}
     2641
Note: See TracChangeset for help on using the changeset viewer.

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