VirtualBox

Changeset 81699 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 6, 2019 10:54:35 AM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/Transfers: Update.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r81460 r81699  
    22032203    AssertPtrReturn(pTransfer, 0);
    22042204
     2205    LogFlowFunc(("[Transfer %RU16] cRoots=%RU64\n", pTransfer->State.uID, pTransfer->cRoots));
    22052206    return (uint32_t)pTransfer->cRoots;
    22062207}
     
    24982499    AssertPtrReturn(pTransfer, SHCLTRANSFERDIR_UNKNOWN);
    24992500
     2501    LogFlowFunc(("[Transfer %RU16] enmDir=%RU32\n", pTransfer->State.uID, pTransfer->State.enmDir));
    25002502    return pTransfer->State.enmDir;
    25012503}
     
    25112513    AssertPtrReturn(pTransfer, SHCLSOURCE_INVALID);
    25122514
     2515    LogFlowFunc(("[Transfer %RU16] enmSource=%RU32\n", pTransfer->State.uID, pTransfer->State.enmSource));
    25132516    return pTransfer->State.enmSource;
    25142517}
     
    25242527    AssertPtrReturn(pTransfer, SHCLTRANSFERSTATUS_NONE);
    25252528
     2529    LogFlowFunc(("[Transfer %RU16] enmStatus=%RU32\n", pTransfer->State.uID, pTransfer->State.enmStatus));
    25262530    return pTransfer->State.enmStatus;
    25272531}
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r81656 r81699  
    8383    UTF8,
    8484    BMP,
    85     HTML
     85    HTML,
     86#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     87    URI_LIST,
     88#endif
    8689};
    8790
     
    126129    { "image/bmp", BMP, VBOX_SHCL_FMT_BITMAP },
    127130    { "image/x-bmp", BMP, VBOX_SHCL_FMT_BITMAP },
    128     { "image/x-MS-bmp", BMP, VBOX_SHCL_FMT_BITMAP }
    129 
     131    { "image/x-MS-bmp", BMP, VBOX_SHCL_FMT_BITMAP },
    130132    /** @todo Inkscape exports image/png but not bmp... */
     133#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     134    { "text/uri-list", URI_LIST, VBOX_SHCL_FMT_URI_LIST },
     135    { "x-special/gnome-copied-files", URI_LIST, VBOX_SHCL_FMT_URI_LIST },
     136    { "x-special/nautilus-clipboard", URI_LIST, VBOX_SHCL_FMT_URI_LIST },
     137    { "application/x-kde-cutselection", URI_LIST, VBOX_SHCL_FMT_URI_LIST },
     138    /** @todo Anything else we need to add here? */
     139    /** @todo Add Wayland / Weston support. */
     140#endif
    131141};
    132142
     
    236246     * table */
    237247    CLIPX11FORMAT X11HTMLFormat;
     248#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     249    /** The best HTML format X11 has to offer, as an index into the formats
     250     * table */
     251    CLIPX11FORMAT X11URIListFormat;
     252#endif
    238253    /** What formats does VBox have on offer? */
    239254    uint32_t vboxFormats;
     
    262277};
    263278
    264 /** The number of simultaneous instances we support.  For all normal purposes
     279/**
     280 * The number of simultaneous instances we support.  For all normal purposes
    265281 * we should never need more than one.  For the testcase it is convenient to
    266282 * have a second instance that the first can interact with in order to have
    267  * a more controlled environment. */
     283 * a more controlled environment.
     284 */
    268285enum { CLIP_MAX_CONTEXTS = 20 };
    269286
    270 /** Array of structures for mapping Xt widgets to context pointers.  We
    271  *  need this because the widget clipboard callbacks do not pass user data. */
     287/**
     288 * Array of structures for mapping Xt widgets to context pointers.  We
     289 * need this because the widget clipboard callbacks do not pass user data.
     290 */
    272291static struct
    273292{
     
    278297} g_contexts[CLIP_MAX_CONTEXTS];
    279298
    280 /** Registers a new X11 clipboard context. */
     299/**
     300 * Registers a new X11 clipboard context.
     301 *
     302 * @param   pCtx                The clipboard backend context to use.
     303 */
    281304static int clipRegisterContext(CLIPBACKEND *pCtx)
    282305{
     
    302325}
    303326
    304 /** Unregister an X11 clipboard context. */
     327/**
     328 * Unregister an X11 clipboard context.
     329 *
     330 * @param   pCtx                The clipboard backend context to use.
     331 */
    305332static void clipUnregisterContext(CLIPBACKEND *pCtx)
    306333{
     
    340367}
    341368
    342 /** Converts an atom name string to an X11 atom, looking it up in a cache
    343  *  before asking the server. */
     369/**
     370 * Converts an atom name string to an X11 atom, looking it up in a cache
     371 * before asking the server.
     372 */
    344373static Atom clipGetAtom(CLIPBACKEND *pCtx, const char *pszName)
    345374{
     
    358387#define WAKE_UP_STRING_LEN  ( sizeof(WAKE_UP_STRING) - 1 )
    359388
    360 /** Schedule a function call to run on the Xt event thread by passing it to
     389/**
     390 * Schedules a function call to run on the Xt event thread by passing it to
    361391 * the application context as a 0ms timeout and waking up the event loop by
    362  * writing to the wakeup pipe which it monitors. */
     392 * writing to the wakeup pipe which it monitors.
     393 */
    363394static int clipQueueToEventThread(CLIPBACKEND *pCtx,
    364395                                  void (*proc)(void *, void *),
     
    385416/**
    386417 * Reports the formats currently supported by the X11 clipboard to VBox.
     418 *
     419 * @param   pCtx                The clipboard backend context to use.
    387420 */
    388421static void clipReportFormatsToVBox(CLIPBACKEND *pCtx)
    389422{
    390     uint32_t u32VBoxFormats = clipVBoxFormatForX11Format(pCtx->X11TextFormat);
    391     u32VBoxFormats |= clipVBoxFormatForX11Format(pCtx->X11BitmapFormat);
    392     u32VBoxFormats |= clipVBoxFormatForX11Format(pCtx->X11HTMLFormat);
    393     LogFlowFunc(("clipReportFormatsToVBox format: %d\n", u32VBoxFormats));
    394     LogFlowFunc(("clipReportFormatsToVBox txt: %d, bitm: %d, html:%d, u32VBoxFormats: %d\n",
    395                     pCtx->X11TextFormat, pCtx->X11BitmapFormat, pCtx->X11HTMLFormat,
    396                     u32VBoxFormats ));
    397     ClipReportX11FormatsCallback(pCtx->pFrontend, u32VBoxFormats);
     423    uint32_t fFormats  = clipVBoxFormatForX11Format(pCtx->X11TextFormat);
     424             fFormats |= clipVBoxFormatForX11Format(pCtx->X11BitmapFormat);
     425             fFormats |= clipVBoxFormatForX11Format(pCtx->X11HTMLFormat);
     426#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     427             fFormats |= clipVBoxFormatForX11Format(pCtx->X11URIListFormat);
     428#endif
     429
     430    LogFlowFunc(("fFormats=0x%x\n", fFormats));
     431    LogFlowFunc(("txt: %u, bmp: %u, html: %u\n",
     432                 pCtx->X11TextFormat, pCtx->X11BitmapFormat, pCtx->X11HTMLFormat));
     433#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     434    LogFlowFunc(("uri list: %u\n", pCtx->X11URIListFormat));
     435#endif
     436
     437    ClipReportX11FormatsCallback(pCtx->pFrontend, fFormats);
    398438}
    399439
    400440/**
    401441 * Forgets which formats were previously in the X11 clipboard.  Called when we
    402  * grab the clipboard. */
     442 * grab the clipboard.
     443 *
     444 * @param   pCtx                The clipboard backend context to use.
     445 */
    403446static void clipResetX11Formats(CLIPBACKEND *pCtx)
    404447{
    405     pCtx->X11TextFormat = INVALID;
    406     pCtx->X11BitmapFormat = INVALID;
    407     pCtx->X11HTMLFormat = INVALID;
     448    LogFlowFuncEnter();
     449
     450    pCtx->X11TextFormat    = INVALID;
     451    pCtx->X11BitmapFormat  = INVALID;
     452    pCtx->X11HTMLFormat    = INVALID;
     453#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     454    pCtx->X11URIListFormat = INVALID;
     455#endif
    408456}
    409457
     
    421469 *
    422470 * @return Supported X clipboard format.
    423  * @param  pCtx                 The clipboard backend context structure.
     471 * @param  pCtx                 The clipboard backend context to use.
    424472 * @param  pTargets             The list of targets.
    425473 * @param  cTargets             The size of the list in @a pTargets.
     
    439487        if (format != NIL_CLIPX11FORMAT)
    440488        {
    441             if (   (clipVBoxFormatForX11Format(format)
    442                             == VBOX_SHCL_FMT_UNICODETEXT)
    443                     && enmBestTextTarget < clipRealFormatForX11Format(format))
     489            if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_UNICODETEXT)
     490                && enmBestTextTarget < clipRealFormatForX11Format(format))
    444491            {
    445492                enmBestTextTarget = clipRealFormatForX11Format(format);
     
    477524 *
    478525 * @return Supported X clipboard format.
    479  * @param  pCtx                 The clipboard backend context structure.
     526 * @param  pCtx                 The clipboard backend context to use.
    480527 * @param  pTargets             The list of targets.
    481528 * @param  cTargets             The size of the list in @a pTargets.
     
    495542        if (format != NIL_CLIPX11FORMAT)
    496543        {
    497             if (   (clipVBoxFormatForX11Format(format)
    498                             == VBOX_SHCL_FMT_BITMAP)
    499                     && enmBestBitmapTarget < clipRealFormatForX11Format(format))
     544            if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_BITMAP)
     545                && enmBestBitmapTarget < clipRealFormatForX11Format(format))
    500546            {
    501547                enmBestBitmapTarget = clipRealFormatForX11Format(format);
     
    512558 *
    513559 * @return Supported X clipboard format.
    514  * @param  pCtx                 The clipboard backend context structure.
     560 * @param   pCtx                The clipboard backend context to use.
    515561 * @param  pTargets             The list of targets.
    516562 * @param  cTargets             The size of the list in @a pTargets.
     
    541587}
    542588
     589#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     590/**
     591 * Goes through an array of X11 clipboard targets to see if they contain an URI list
     592 * format we can support, and if so choose the ones we prefer.
     593 *
     594 * @return Supported X clipboard format.
     595 * @param  pCtx                 The clipboard backend context to use.
     596 * @param  pTargets             The list of targets.
     597 * @param  cTargets             The size of the list in @a pTargets.
     598 */
     599static CLIPX11FORMAT clipGetURIListFormatFromTargets(CLIPBACKEND *pCtx,
     600                                                     CLIPX11FORMAT *pTargets,
     601                                                     size_t cTargets)
     602{
     603    AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT);
     604    AssertReturn(VALID_PTR(pTargets) || cTargets == 0, NIL_CLIPX11FORMAT);
     605
     606    CLIPX11FORMAT bestURIListFormat = NIL_CLIPX11FORMAT;
     607    CLIPFORMAT enmBestURIListTarget = INVALID;
     608    for (unsigned i = 0; i < cTargets; ++i)
     609    {
     610        CLIPX11FORMAT format = pTargets[i];
     611        if (format != NIL_CLIPX11FORMAT)
     612        {
     613            if (   (clipVBoxFormatForX11Format(format) == VBOX_SHCL_FMT_URI_LIST)
     614                && enmBestURIListTarget < clipRealFormatForX11Format(format))
     615            {
     616                enmBestURIListTarget = clipRealFormatForX11Format(format);
     617                bestURIListFormat = format;
     618            }
     619        }
     620    }
     621    return bestURIListFormat;
     622}
     623#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
    543624
    544625/**
     
    547628 * better than plain text).
    548629 *
    549  * @param  pCtx                 The clipboard backend context structure.
     630 * @param  pCtx                 The clipboard backend context to use.
    550631 * @param  pTargets             The list of targets.
    551632 * @param  cTargets             The size of the list in @a pTargets.
     
    556637    AssertPtrReturnVoid(pCtx);
    557638    AssertPtrReturnVoid(pTargets);
    558     CLIPX11FORMAT bestTextFormat;
    559     CLIPX11FORMAT bestBitmapFormat;
    560     CLIPX11FORMAT bestHtmlFormat;
    561     bestTextFormat = clipGetTextFormatFromTargets(pCtx, pTargets, cTargets);
     639
     640    CLIPX11FORMAT bestTextFormat = clipGetTextFormatFromTargets(pCtx, pTargets, cTargets);
    562641    if (pCtx->X11TextFormat != bestTextFormat)
    563     {
    564642        pCtx->X11TextFormat = bestTextFormat;
    565     }
    566     pCtx->X11BitmapFormat = INVALID;  /* not yet supported */
    567     bestBitmapFormat = clipGetBitmapFormatFromTargets(pCtx, pTargets, cTargets);
     643
     644    pCtx->X11BitmapFormat = INVALID; /* not yet supported */
     645    CLIPX11FORMAT bestBitmapFormat = clipGetBitmapFormatFromTargets(pCtx, pTargets, cTargets);
    568646    if (pCtx->X11BitmapFormat != bestBitmapFormat)
    569     {
    570647        pCtx->X11BitmapFormat = bestBitmapFormat;
    571     }
    572     bestHtmlFormat = clipGetHtmlFormatFromTargets(pCtx, pTargets, cTargets);
    573     if(pCtx->X11HTMLFormat != bestHtmlFormat)
    574     {
     648
     649    CLIPX11FORMAT bestHtmlFormat = clipGetHtmlFormatFromTargets(pCtx, pTargets, cTargets);
     650    if (pCtx->X11HTMLFormat != bestHtmlFormat)
    575651        pCtx->X11HTMLFormat = bestHtmlFormat;
    576     }
     652
     653#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     654    CLIPX11FORMAT bestURIListFormat = clipGetURIListFormatFromTargets(pCtx, pTargets, cTargets);
     655    if (pCtx->X11URIListFormat != bestURIListFormat)
     656        pCtx->X11URIListFormat = bestURIListFormat;
     657#endif
    577658}
    578659
     
    583664 * based on an array of X11 atoms.
    584665 *
    585  * @param  pCtx                 The context to be updated.
     666 * @param   pCtx                The clipboard backend context to use.
    586667 * @param  pTargets             The array of atoms describing the targets supported.
    587668 * @param  cTargets             The size of the array @a pTargets.
     
    614695 * "targets" information obtained from the X11 clipboard.
    615696 *
    616  * @note  Callback for XtGetSelectionValue
     697 * @note  Callback for XtGetSelectionValue.
    617698 * @note  This function is treated as API glue, and as such is not part of any
    618699 *        unit test.  So keep it simple, be paranoid and log everything.
     
    626707
    627708    CLIPBACKEND *pCtx = reinterpret_cast<CLIPBACKEND *>(pClient);
     709
    628710    Atom *pAtoms = (Atom *)pValue;
    629711    unsigned i, j;
     
    639721       pFormats = (CLIPX11FORMAT *)RTMemAllocZ(*pcLen * sizeof(CLIPX11FORMAT));
    640722    }
     723
    641724#if defined(DEBUG) && !defined(TESTCASE)
    642725    if (pValue)
     
    653736    }
    654737#endif
     738
    655739    if (pFormats)
    656740    {
     
    685769/**
    686770 * Callback to notify us when the contents of the X11 clipboard change.
     771 *
     772 * @param   pCtx                The clipboard backend context to use.
    687773 */
    688774static void clipQueryX11CBFormats(CLIPBACKEND *pCtx)
     
    729815 * Waits until an event arrives and handle it if it is an XFIXES selection
    730816 * event, which Xt doesn't know about.
     817 *
     818 * @param   pCtx                The clipboard backend context to use.
    731819 */
    732820void clipPeekEventAndDoXFixesHandling(CLIPBACKEND *pCtx)
     
    754842/**
    755843 * The main loop of our clipboard reader.
     844 *
    756845 * @note  X11 backend code.
    757846 */
     
    775864#endif
    776865
    777 /** X11 specific uninitialisation for the shared clipboard.
     866/**
     867 * X11 specific uninitialisation for the shared clipboard.
     868 *
    778869 * @note  X11 backend code.
     870 *
     871 * @param   pCtx                The clipboard backend context to use.
    779872 */
    780873static void clipUninit(CLIPBACKEND *pCtx)
     
    817910
    818911#ifndef TESTCASE
    819 /** Setup the XFixes library and load the XFixesSelectSelectionInput symbol */
     912/**
     913 * Sets up the XFixes library and load the XFixesSelectSelectionInput symbol.
     914 */
    820915static int clipLoadXFixes(Display *pDisplay, CLIPBACKEND *pCtx)
    821916{
     
    841936            {
    842937                if (pCtx->fixesEventBase >= 0)
     938                {
    843939                    rc = VINF_SUCCESS;
     940                }
    844941                else
    845942                {
    846                     LogRel(("clipLoadXFixes: fixesEventBase is less than zero: %d\n", pCtx->fixesEventBase));
     943                    LogRel(("Shared Clipboard: fixesEventBase is less than zero: %d\n", pCtx->fixesEventBase));
    847944                    rc = VERR_NOT_SUPPORTED;
    848945                }
     
    850947            else
    851948            {
    852                 LogRel(("clipLoadXFixes: XQueryExtension failed\n"));
     949                LogRel(("Shared Clipboard: XQueryExtension failed\n"));
    853950                rc = VERR_NOT_SUPPORTED;
    854951            }
     
    856953        else
    857954        {
    858             LogRel(("clipLoadXFixes: Symbol XFixesSelectSelectionInput not found!\n"));
     955            LogRel(("Shared Clipboard: Symbol XFixesSelectSelectionInput not found!\n"));
    859956            rc = VERR_NOT_SUPPORTED;
    860957        }
     
    862959    else
    863960    {
    864         LogRel(("clipLoadXFixes: libxFixes.so.* not found!\n"));
     961        LogRel(("Shared Clipboard: libxFixes.so.* not found!\n"));
    865962        rc = VERR_NOT_SUPPORTED;
    866963    }
     
    869966#endif
    870967
    871 /** This is the callback which is scheduled when data is available on the
    872  * wakeup pipe.  It simply reads all data from the pipe. */
     968/**
     969 * This is the callback which is scheduled when data is available on the
     970 * wakeup pipe.  It simply reads all data from the pipe.
     971 */
    873972static void clipDrainWakeupPipe(XtPointer pUserData, int *, XtInputId *)
    874973{
     
    881980}
    882981
    883 /** X11 specific initialisation for the shared clipboard.
     982/**
     983 * X11 specific initialisation for the shared clipboard.
     984 *
    884985 * @note  X11 backend code.
     986 *
     987 * @returns VBox status code.
     988 * @param   pCtx                The clipboard backend context to use.
    885989 */
    886990static int clipInit(CLIPBACKEND *pCtx)
     
    892996    Display *pDisplay;
    893997
    894     /* Make sure we are thread safe */
     998    /* Make sure we are thread safe. */
    895999    XtToolkitThreadInitialize();
    896     /* Set up the Clipboard application context and main window.  We call all
     1000
     1001    /*
     1002     * Set up the Clipboard application context and main window.  We call all
    8971003     * these functions directly instead of calling XtOpenApplication() so
    898      * that we can fail gracefully if we can't get an X11 display. */
     1004     * that we can fail gracefully if we can't get an X11 display.
     1005     */
    8991006    XtToolkitInitialize();
    9001007    pCtx->appContext = XtCreateApplicationContext();
     
    9321039        XtRealizeWidget(pCtx->widget);
    9331040#ifndef TESTCASE
    934         /* Enable clipboard update notification */
     1041        /* Enable clipboard update notification. */
    9351042        pCtx->fixesSelectInput(pDisplay, XtWindow(pCtx->widget),
    9361043                               clipGetAtom(pCtx, "CLIPBOARD"),
     
    9381045#endif
    9391046    }
    940     /* Create the pipes */
     1047
     1048    /*
     1049     * Create the pipes.
     1050     */
    9411051    int pipes[2];
    9421052    if (!pipe(pipes))
     
    9791089         * This is important for VBoxHeadless.
    9801090         */
    981         LogRel(("Shared Clipboard: X11 DISPLAY variable not set -- disabling shared clipboard\n"));
     1091        LogRel(("Shared Clipboard: X11 DISPLAY variable not set -- disabling clipboard sharing\n"));
    9821092        pCtx->fHaveX11 = false;
    9831093        return pCtx;
     
    9871097
    9881098    LogRel(("Shared Clipboard: Initializing X11 clipboard backend\n"));
     1099
    9891100    if (pCtx)
    9901101        pCtx->pFrontend = pFrontend;
     
    9951106 * Destructs the shared clipboard X11 backend.
    9961107 *
    997  * @note  X11 backend code
     1108 * @note  X11 backend code.
     1109 *
     1110 * @param   pCtx                The clipboard backend context to use.
    9981111 */
    9991112void ClipDestructX11(CLIPBACKEND *pCtx)
     
    10081121
    10091122/**
    1010  * Announce to the X11 backend that we are ready to start.
    1011  * @param  grab  whether we should try to grab the shared clipboard at once
    1012  */
    1013 int ClipStartX11(CLIPBACKEND *pCtx, bool grab)
     1123 * Announces to the X11 backend that we are ready to start.
     1124 *
     1125 * @returns VBox status code.
     1126 * @param   pCtx                The clipboard backend context to use.
     1127 * @param   fGrab               Whether we should try to grab the shared clipboard at once.
     1128 */
     1129int ClipStartX11(CLIPBACKEND *pCtx, bool fGrab)
    10141130{
    10151131    int rc = VINF_SUCCESS;
     
    10251141    {
    10261142        clipResetX11Formats(pCtx);
    1027         pCtx->fGrabClipboardOnStart = grab;
     1143        pCtx->fGrabClipboardOnStart = fGrab;
    10281144    }
    10291145#ifndef TESTCASE
     
    10431159
    10441160/**
    1045  * Shut down the shared clipboard X11 backend.
    1046  * @note  X11 backend code
     1161 * Shuts down the shared clipboard X11 backend.
     1162 *
     1163 * @note  X11 backend code.
    10471164 * @note  Any requests from this object to get clipboard data from VBox
    10481165 *        *must* have completed or aborted before we are called, as
    10491166 *        otherwise the X11 event loop will still be waiting for the request
    10501167 *        to return and will not be able to terminate.
     1168 *
     1169 * @returns VBox status code.
     1170 * @param   pCtx                The clipboard backend context to use.
    10511171 */
    10521172int ClipStopX11(CLIPBACKEND *pCtx)
     
    10931213 *
    10941214 * @returns VBox status code.
     1215 * @param  pCtx                 The clipboard backend context to use.
    10951216 * @param  atomTypeReturn       The type of the data we are returning.
    10961217 * @param  pValReturn           A pointer to the data we are returning. This
     
    11421263 */
    11431264static int clipReadVBoxShCl(CLIPBACKEND *pCtx, uint32_t u32Format,
    1144                                  void **ppv, uint32_t *pcb)
     1265                            void **ppv, uint32_t *pcb)
    11451266{
    11461267    int rc = VINF_SUCCESS;
     
    13361457 * Does this atom correspond to one of the two selection types we support?
    13371458 *
    1338  * @param  widget               A valid Xt widget.
     1459 * @param  pCtx                 The clipboard backend context to use.
    13391460 * @param  selType              The atom in question.
    13401461 */
     
    13801501        void *pv = NULL;
    13811502        uint32_t cb = 0;
    1382         rc = clipReadVBoxShCl(pCtx,
    1383                                    VBOX_SHCL_FMT_UNICODETEXT,
    1384                                    &pv, &cb);
     1503        rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_UNICODETEXT, &pv, &cb);
    13851504        if (RT_SUCCESS(rc) && (cb == 0))
    13861505            rc = VERR_NO_DATA;
     
    18451964    /** The HTML format we requested from X11 if we requested HTML */
    18461965    CLIPX11FORMAT mHtmlFormat;
     1966#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     1967    /** The URI list format we requested from X11 if we requested URI lists. */
     1968    CLIPX11FORMAT mURIListFormat;
     1969#endif
    18471970    /** The clipboard context this request is associated with */
    18481971    CLIPBACKEND *mCtx;
     
    20322155#endif
    20332156
    2034 static void getSelectionValue(CLIPBACKEND *pCtx, CLIPX11FORMAT format,
    2035                               CLIPREADX11CBREQ *pReq)
     2157static int getSelectionValue(CLIPBACKEND *pCtx, CLIPX11FORMAT format,
     2158                             CLIPREADX11CBREQ *pReq)
    20362159{
    20372160#ifndef TESTCASE
     
    20442167    testRequestData(pCtx, format, (void *)pReq);
    20452168#endif
    2046 }
    2047 
    2048 /** Worker function for ClipRequestDataFromX11 which runs on the event
    2049  * thread. */
     2169
     2170    return VINF_SUCCESS; /** @todo Return real rc. */
     2171}
     2172
     2173/**
     2174 * Worker function for ClipRequestDataFromX11 which runs on the event thread.
     2175 */
    20502176static void vboxClipboardReadX11Worker(void *pUserData,
    20512177                                       void * /* interval */)
    20522178{
     2179    AssertPtrReturnVoid(pUserData);
     2180
    20532181    CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pUserData;
    2054     CLIPBACKEND *pCtx = pReq->mCtx;
     2182    CLIPBACKEND      *pCtx = pReq->mCtx;
    20552183
    20562184    LogFlowFunc(("pReq->mFormat = %02X\n", pReq->mFormat));
    20572185
    2058     int rc = VINF_SUCCESS;
     2186    int rc = VERR_NO_DATA; /* VBox thinks we have data and we don't. */
     2187
    20592188#ifndef VBOX_AFTER_5_2
    20602189    bool fBusy = pCtx->fBusy;
    20612190    pCtx->fBusy = true;
    20622191    if (fBusy)
     2192    {
    20632193        /* If the clipboard is busy just fend off the request. */
    20642194        rc = VERR_TRY_AGAIN;
     2195    }
    20652196    else
    20662197#endif
    20672198    if (pReq->mFormat == VBOX_SHCL_FMT_UNICODETEXT)
    20682199    {
    2069         /*
    2070          * VBox wants to read data in the given format.
    2071          */
    20722200        pReq->mTextFormat = pCtx->X11TextFormat;
    2073         if (pReq->mTextFormat == INVALID)
    2074             /* VBox thinks we have data and we don't */
    2075             rc = VERR_NO_DATA;
    2076         else
    2077             /* Send out a request for the data to the current clipboard
    2078              * owner */
    2079             getSelectionValue(pCtx, pCtx->X11TextFormat, pReq);
     2201        if (pReq->mTextFormat != INVALID)
     2202        {
     2203            /* Send out a request for the data to the current clipboard owner. */
     2204            rc = getSelectionValue(pCtx, pCtx->X11TextFormat, pReq);
     2205        }
    20802206    }
    20812207    else if (pReq->mFormat == VBOX_SHCL_FMT_BITMAP)
    20822208    {
    20832209        pReq->mBitmapFormat = pCtx->X11BitmapFormat;
    2084         if (pReq->mBitmapFormat == INVALID)
    2085             /* VBox thinks we have data and we don't */
    2086             rc = VERR_NO_DATA;
    2087         else
    2088             /* Send out a request for the data to the current clipboard
    2089              * owner */
    2090             getSelectionValue(pCtx, pCtx->X11BitmapFormat, pReq);
     2210        if (pReq->mBitmapFormat != INVALID)
     2211        {
     2212            /* Send out a request for the data to the current clipboard owner. */
     2213            rc = getSelectionValue(pCtx, pCtx->X11BitmapFormat, pReq);
     2214        }
    20912215    }
    20922216    else if (pReq->mFormat == VBOX_SHCL_FMT_HTML)
    20932217    {
    2094         /* Send out a request for the data to the current clipboard
    2095              * owner */
    20962218        pReq->mHtmlFormat = pCtx->X11HTMLFormat;
    2097         if(pReq->mHtmlFormat == INVALID)
    2098                     /* VBox thinks we have data and we don't */
    2099             rc = VERR_NO_DATA;
    2100         else
    2101             /* Send out a request for the data to the current clipboard
    2102              * owner */
    2103             getSelectionValue(pCtx, pCtx->X11HTMLFormat, pReq);
    2104     }
     2219        if (pReq->mHtmlFormat != INVALID)
     2220        {
     2221            /* Send out a request for the data to the current clipboard owner. */
     2222            rc = getSelectionValue(pCtx, pCtx->X11HTMLFormat, pReq);
     2223        }
     2224    }
     2225#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     2226    else if (pReq->mFormat == VBOX_SHCL_FMT_URI_LIST)
     2227    {
     2228        pReq->mURIListFormat = pCtx->X11URIListFormat;
     2229        if (pReq->mURIListFormat != INVALID)
     2230        {
     2231            /* Send out a request for the data to the current clipboard owner. */
     2232            rc = getSelectionValue(pCtx, pCtx->X11HTMLFormat, pReq);
     2233        }
     2234    }
     2235#endif
    21052236    else
    21062237    {
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r81451 r81699  
    7474    formatData.uFormats = u32Formats;
    7575
    76     int rc2 = shClSvcFormatsReport(pCtx->pClient, &formatData);
    77     AssertRC(rc2);
     76    int rc = shClSvcFormatsReport(pCtx->pClient, &formatData);
     77    RT_NOREF(rc);
     78
     79    LogFlowFuncLeaveRC(rc);
    7880}
    7981
     
    182184    RT_NOREF(pCmdCtx);
    183185
    184 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    185     if (pFormats->uFormats & VBOX_SHCL_FMT_URI_LIST) /* No transfer support yet. */
    186         return VINF_SUCCESS;
    187 #endif
    188 
    189     ClipAnnounceFormatToX11(pClient->State.pCtx->pBackend, pFormats->uFormats);
    190 
    191     return VINF_SUCCESS;
     186    int rc = ClipAnnounceFormatToX11(pClient->State.pCtx->pBackend, pFormats->uFormats);
     187
     188    LogFlowFuncLeaveRC(rc);
     189    return rc;
    192190}
    193191
     
    356354{
    357355    RT_NOREF(pClient, pTransfer);
    358     return VINF_SUCCESS;
     356
     357    int rc = VINF_SUCCESS;
     358
     359    LogFlowFuncLeaveRC(rc);
     360    return rc;
    359361}
    360362
     
    362364{
    363365    RT_NOREF(pClient, pTransfer);
    364     return VINF_SUCCESS;
     366
     367    int rc = VINF_SUCCESS;
     368
     369    LogFlowFuncLeaveRC(rc);
     370    return rc;
    365371}
    366372
     
    368374{
    369375    RT_NOREF(pClient, pTransfer);
    370     return VINF_SUCCESS;
     376
     377    int rc = VINF_SUCCESS;
     378
     379    LogFlowFuncLeaveRC(rc);
     380    return rc;
    371381}
    372382#endif
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r81559 r81699  
    17321732            }
    17331733            else
     1734            {
     1735                LogRel2(("Shared Clipboard: File transfers are disabled for this VM\n"));
    17341736                rc = VERR_ACCESS_DENIED;
     1737            }
    17351738#else
    1736             rc = VERR_NOT_IMPLEMENTED;
     1739            rc = VERR_NOT_SUPPORTED;
    17371740#endif
    17381741            break;
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