VirtualBox

Ignore:
Timestamp:
Nov 14, 2019 4:30:44 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134637
Message:

Shared Clipboard/Transfers: Update.

Location:
trunk/src/VBox/GuestHost/SharedClipboard
Files:
2 edited

Legend:

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

    r81321 r81843  
    459459        LogFlowFunc(("fFormats=0x%08X\n", fFormats));
    460460
    461         pFormats->uFormats = fFormats;
     461        pFormats->Formats = fFormats;
    462462        pFormats->fFlags   = 0; /** @todo Handle flags. */
    463463    }
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r81829 r81843  
    252252#endif
    253253    /** What formats does VBox have on offer? */
    254     uint32_t vboxFormats;
     254    SHCLFORMATS vboxFormats;
    255255    /** Cache of the last unicode data that we received */
    256256    void *pvUnicodeCache;
     
    11001100void ClipDestructX11(CLIPBACKEND *pCtx)
    11011101{
     1102    if (!pCtx)
     1103        return;
     1104
    11021105    if (pCtx->fHaveX11)
     1106    {
    11031107        /* We set this to NULL when the event thread exits.  It really should
    11041108         * have exited at this point, when we are about to unload the code from
    11051109         * memory. */
    11061110        Assert(pCtx->widget == NULL);
     1111    }
     1112
    11071113    RTMemFree(pCtx);
    11081114}
     
    12511257 * data returned.
    12521258 */
    1253 static int clipReadVBoxShCl(CLIPBACKEND *pCtx, uint32_t u32Format,
     1259static int clipReadVBoxShCl(CLIPBACKEND *pCtx, SHCLFORMAT Format,
    12541260                            void **ppv, uint32_t *pcb)
    12551261{
     1262    LogFlowFunc(("pCtx=%p, Format=%02X, ppv=%p, pcb=%p\n", pCtx, Format, ppv, pcb));
     1263
    12561264    int rc = VINF_SUCCESS;
    1257     LogFlowFunc(("pCtx=%p, u32Format=%02X, ppv=%p, pcb=%p\n", pCtx,
    1258                  u32Format, ppv, pcb));
    1259     if (u32Format == VBOX_SHCL_FMT_UNICODETEXT)
     1265
     1266    if (Format == VBOX_SHCL_FMT_UNICODETEXT)
    12601267    {
    12611268        if (pCtx->pvUnicodeCache == NULL)
    1262             rc = ClipRequestDataForX11Callback(pCtx->pFrontend, u32Format,
     1269            rc = ClipRequestDataForX11Callback(pCtx->pFrontend, Format,
    12631270                                               &pCtx->pvUnicodeCache,
    12641271                                               &pCtx->cbUnicodeCache);
     
    12721279    }
    12731280    else
    1274         rc = ClipRequestDataForX11Callback(pCtx->pFrontend, u32Format,
     1281        rc = ClipRequestDataForX11Callback(pCtx->pFrontend, Format,
    12751282                                           ppv, pcb);
    12761283    if (RT_SUCCESS(rc))
     
    14891496
    14901497    CLIPX11FORMAT x11Format = clipFindX11FormatByAtom(pCtx, *atomTarget);
    1491     CLIPFORMAT format = clipRealFormatForX11Format(x11Format);
    1492 
    1493     if (   ((format == UTF8) || (format == TEXT))
     1498    CLIPFORMAT clipFormat = clipRealFormatForX11Format(x11Format);
     1499
     1500    LogFlowFunc(("fFormats=0x%x, x11Format=%u, clipFormat=%u\n", pCtx->vboxFormats, x11Format, clipFormat));
     1501
     1502    if (   ((clipFormat == UTF8) || (clipFormat == TEXT))
    14941503        && (pCtx->vboxFormats & VBOX_SHCL_FMT_UNICODETEXT))
    14951504    {
     
    14991508        if (RT_SUCCESS(rc) && (cb == 0))
    15001509            rc = VERR_NO_DATA;
    1501         if (RT_SUCCESS(rc) && ((format == UTF8) || (format == TEXT)))
     1510        if (RT_SUCCESS(rc) && ((clipFormat == UTF8) || (clipFormat == TEXT)))
    15021511            rc = clipWinTxtToUtf8ForX11CB(XtDisplay(pCtx->widget),
    15031512                                          (PRTUTF16)pv, cb, atomTarget,
     
    15051514                                          pcLenReturn, piFormatReturn);
    15061515        if (RT_SUCCESS(rc))
    1507             clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, format);
     1516            clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat);
    15081517
    15091518        RTMemFree(pv);
    15101519    }
    1511     else if (   (format == BMP)
     1520    else if (   (clipFormat == BMP)
    15121521             && (pCtx->vboxFormats & VBOX_SHCL_FMT_BITMAP))
    15131522    {
     
    15171526        if (RT_SUCCESS(rc) && (cb == 0))
    15181527            rc = VERR_NO_DATA;
    1519         if (RT_SUCCESS(rc) && (format == BMP))
     1528        if (RT_SUCCESS(rc) && (clipFormat == BMP))
    15201529        {
    15211530            /* Create a full BMP from it */
     
    15341543        RTMemFree(pv);
    15351544    }
    1536     else if (  (format == HTML)
     1545    else if (  (clipFormat == HTML)
    15371546            && (pCtx->vboxFormats & VBOX_SHCL_FMT_HTML))
    15381547    {
     
    15571566                                           pcLenReturn, piFormatReturn);
    15581567            if (RT_SUCCESS(rc))
    1559                 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, format);
     1568                clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat);
    15601569
    15611570            RTMemFree(pv);
    15621571        }
    15631572    }
     1573#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     1574    else if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST)
     1575    {
     1576        switch (clipFormat)
     1577        {
     1578            case TEXT:
     1579                RT_FALL_THROUGH();
     1580            case UTF8:
     1581            {
     1582                void    *pv = NULL;
     1583                uint32_t cb = 0;
     1584                rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_URI_LIST, &pv, &cb);
     1585
     1586                RTMemFree(pv);
     1587                break;
     1588            }
     1589
     1590            case URI_LIST:
     1591            {
     1592                break;
     1593            }
     1594
     1595            default:
     1596                rc = VERR_NOT_SUPPORTED;
     1597                break;
     1598        }
     1599    }
     1600#endif
    15641601    else
     1602    {
     1603        *atomTypeReturn = XT_CONVERT_FAIL;
     1604        *pValReturn     = (XtPointer)NULL;
     1605        *pcLenReturn    = 0;
     1606        *piFormatReturn = 0;
     1607
    15651608        rc = VERR_NOT_SUPPORTED;
     1609    }
     1610
     1611    if (RT_FAILURE(rc))
     1612        LogRel2(("Shared Clipboard: Converting format 0x%x for X11 (x11Format=%u, clipFormat=%u) failed, rc=%Rrc\n",
     1613                 pCtx->vboxFormats, x11Format, clipFormat, rc));
    15661614
    15671615    LogFlowFuncLeaveRC(rc);
     
    15871635
    15881636    if (!pCtx)
    1589         return false;
     1637        return False;
    15901638
    15911639    if (!clipIsSupportedSelectionType(pCtx, *atomSelection))
    1592         return false;
     1640        return False;
    15931641
    15941642    if (*atomTarget == clipGetAtom(pCtx, "TARGETS"))
     
    15991647                                     pValReturn, pcLenReturn, piFormatReturn);
    16001648
    1601     LogFlowFunc(("returning, internal status code %Rrc\n", rc));
    1602     return RT_SUCCESS(rc);
     1649    LogFlowFunc(("returning %RTbool, internal status code %Rrc\n", RT_SUCCESS(rc), rc));
     1650    return RT_SUCCESS(rc) ? True : False;
    16031651}
    16041652
     
    16111659    CLIPBACKEND *pCtx;
    16121660    /** Formats supported by VBox. */
    1613     SHCLFORMATS  formats;
     1661    SHCLFORMATS  Formats;
    16141662} CLIPNEWVBOXFORMATS, *PCLIPNEWVBOXFORMATS;
    16151663
     
    16271675 * Takes possession of the X11 clipboard (and middle-button selection).
    16281676 */
    1629 static void clipGrabX11CB(CLIPBACKEND *pCtx, uint32_t u32Formats)
    1630 {
     1677static void clipGrabX11CB(CLIPBACKEND *pCtx, SHCLFORMATS Formats)
     1678{
     1679    LogFlowFuncEnter();
     1680
    16311681    if (XtOwnSelection(pCtx->widget, clipGetAtom(pCtx, "CLIPBOARD"),
    16321682                       CurrentTime, clipXtConvertSelectionProc, NULL, 0))
    16331683    {
    1634         pCtx->vboxFormats = u32Formats;
     1684        pCtx->vboxFormats = Formats;
    16351685        /* Grab the middle-button paste selection too. */
    16361686        XtOwnSelection(pCtx->widget, clipGetAtom(pCtx, "PRIMARY"),
     
    16631713    CLIPBACKEND *pCtx = pFormats->pCtx;
    16641714
    1665     uint32_t fFormats = pFormats->formats;
     1715    uint32_t fFormats = pFormats->Formats;
    16661716
    16671717    RTMemFree(pFormats);
     
    16801730 *
    16811731 * @returns VBox status code.
    1682  * @param   u32Formats          Clipboard formats offered.
    1683  */
    1684 int ClipAnnounceFormatToX11(CLIPBACKEND *pCtx, uint32_t u32Formats)
     1732 * @param   Formats             Clipboard formats offered.
     1733 */
     1734int ClipAnnounceFormatToX11(CLIPBACKEND *pCtx, uint32_t Formats)
    16851735{
    16861736    /*
     
    16971747    {
    16981748        pFormats->pCtx    = pCtx;
    1699         pFormats->formats = u32Formats;
     1749        pFormats->Formats = Formats;
    17001750
    17011751        rc = clipQueueToEventThread(pCtx, clipAnnounceFormatToX11Worker,
     
    22892339 * @returns VBox status code.
    22902340 * @param  pCtx                 Context data for the clipboard backend.
    2291  * @param  u32Format            The format that the VBox would like to receive the data in.
     2341 * @param  Format               The format that the VBox would like to receive the data in.
    22922342 * @param  pReq                 Read callback request to use. Must be free'd in the callback.
    22932343 *
    22942344 * @note   We allocate a request structure which must be freed by the worker.
    22952345 */
    2296 int ClipReadDataFromX11(CLIPBACKEND *pCtx, uint32_t u32Format, CLIPREADCBREQ *pReq)
     2346int ClipReadDataFromX11(CLIPBACKEND *pCtx, SHCLFORMAT Format, CLIPREADCBREQ *pReq)
    22972347{
    22982348    /*
     
    23082358    {
    23092359        pX11Req->mpCtx   = pCtx;
    2310         pX11Req->mFormat = u32Format;
     2360        pX11Req->mFormat = Format;
    23112361        pX11Req->mpReq   = pReq;
    23122362
     
    23862436
    23872437/* Return the data in the simulated VBox clipboard. */
    2388 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)
    2389 {
    2390     RT_NOREF(pCtx, u32Format);
     2438DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t Format, void **ppv, uint32_t *pcb)
     2439{
     2440    RT_NOREF(pCtx, Format);
    23912441    *pcb = g_tstVBoxDataCb;
    23922442    if (g_tstVBoxDataPv != NULL)
     
    25032553}
    25042554
    2505 /* The formats currently on offer from X11 via the shared clipboard */
     2555/* The formats currently on offer from X11 via the shared clipboard. */
    25062556static uint32_t g_fX11Formats = 0;
    25072557
    2508 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, uint32_t u32Formats)
     2558DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, SHCLFORMATS Formats)
    25092559{
    25102560    RT_NOREF(pCtx);
    2511     g_fX11Formats = u32Formats;
     2561    g_fX11Formats = Formats;
    25122562}
    25132563
     
    31453195# include <iprt/test.h>
    31463196
    3147 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)
    3148 {
    3149     RT_NOREF(pCtx, u32Format, ppv, pcb);
     3197DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb)
     3198{
     3199    RT_NOREF(pCtx, Format, ppv, pcb);
    31503200    return VERR_NO_DATA;
    31513201}
    31523202
    3153 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, uint32_t u32Formats)
    3154 {
    3155     RT_NOREF(pCtx, u32Formats);
     3203DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, SHCLFORMATS Formats)
     3204{
     3205    RT_NOREF(pCtx, Formats);
    31563206}
    31573207
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