VirtualBox

Changeset 103363 in vbox


Ignore:
Timestamp:
Feb 14, 2024 5:23:47 PM (10 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Added a dedicated VERR_SHCLPB_NO_DATA error code, to indicate that clipboard data for a format currently is not available.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r102977 r103363  
    32033203/** Shared Clipboard event failed error. */
    32043204#define VERR_SHCLPB_EVENT_FAILED                    (-7152)
     3205/** No clipboard data available for requested format. */
     3206#define VERR_SHCLPB_NO_DATA                         (-7153)
    32053207/** @} */
    32063208
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r100657 r103363  
    103103/**
    104104 * Worker for a reading clipboard from the host.
     105 *
     106 * @returns VBox status code.
     107 * @retval  VERR_SHCLPB_NO_DATA if no clipboard data is available.
     108 * @param   pCtx                Shared Clipbaord context to use.
     109 * @param   uFmt                The format to read clipboard data in.
     110 * @param   ppv                 Where to return the allocated data read.
     111 *                              Must be free'd by the caller.
     112 * @param   pcb                 Where to return number of bytes read.
     113 * @param   pvUser              User-supplied context.
    105114 */
    106115static DECLCALLBACK(int) vbtrReadDataWorker(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb, void *pvUser)
     
    110119    LogFlowFuncEnter();
    111120
    112     int rc = VERR_NO_DATA; /* Play safe. */
     121    int rc;
    113122
    114123    uint32_t cbRead = 0;
     
    145154
    146155    if (!cbRead)
    147         rc = VERR_NO_DATA;
     156        rc = VERR_SHCLPB_NO_DATA;
    148157
    149158    if (RT_SUCCESS(rc))
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard-common.cpp

    r101721 r103363  
    109109}
    110110
     111/**
     112 * Reads clipboard from the host.
     113 *
     114 * @returns VBox status code.
     115 * @retval  VERR_SHCLPB_NO_DATA if no clipboard data is available.
     116 * @param   pCtx                Shared Clipbaord context to use.
     117 * @param   uFmt                The format to read clipboard data in.
     118 * @param   ppv                 Where to return the allocated data read.
     119 *                              Must be free'd by the caller.
     120 * @param   pcb                 Where to return number of bytes read.
     121 */
    111122RTDECL(int) VBClClipboardReadHostClipboard(PVBGLR3SHCLCMDCTX pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb)
    112123{
     
    153164
    154165    if (!cbRead)
    155         rc = VERR_NO_DATA;
     166        rc = VERR_SHCLPB_NO_DATA;
    156167
    157168    if (RT_FAILURE(rc))
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard-x11.cpp

    r103323 r103363  
    212212    LogFlowFuncEnter();
    213213
    214     int rc = VERR_NO_DATA; /* Play safe. */
     214    int rc;
    215215
    216216    uint32_t cbRead = 0;
     
    247247
    248248    if (!cbRead)
    249         rc = VERR_NO_DATA;
     249        rc = VERR_SHCLPB_NO_DATA;
    250250
    251251    if (RT_SUCCESS(rc))
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r103323 r103363  
    14951495 * Helper for clipConvertToX11Data() that will cache the data returned.
    14961496 *
    1497  * @returns VBox status code. VERR_NO_DATA if no data available.
     1497 * @returns VBox status code. VERR_SHCLPB_NO_DATA if no data available.
    14981498 * @param   pCtx                The X11 clipboard context to use.
    14991499 * @param   uFmt                Clipboard format to read data in.
     
    15531553
    15541554    /* Safey net in case the stuff above misbehaves
    1555      * (must return VERR_NO_DATA if no data available). */
     1555     * (must return VERR_SHCLPB_NO_DATA if no data available). */
    15561556    if (   RT_SUCCESS(rc)
    15571557        && (pv == NULL || cb == 0))
    1558         rc = VERR_NO_DATA;
     1558        rc = VERR_SHCLPB_NO_DATA;
    15591559
    15601560    if (RT_SUCCESS(rc))
     
    15641564    }
    15651565
    1566     if (RT_FAILURE(rc))
     1566    if (   RT_FAILURE(rc)
     1567        && rc != VERR_SHCLPB_NO_DATA)
    15671568        LogRel(("Shared Clipboard: Requesting data for X11 from source failed with %Rrc\n", rc));
    15681569
     
    16051606 * Satisfies a request from X11 to convert the clipboard text to UTF-8 LF.
    16061607 *
    1607  * @returns VBox status code. VERR_NO_DATA if no data was converted.
     1608 * @returns VBox status code. VERR_SHCLPB_NO_DATA if no data was converted.
    16081609 * @param  pDisplay             An X11 display structure, needed for conversions
    16091610 *                              performed by Xlib.
     
    16331634    const size_t cwcSrc = cbSrc / sizeof(RTUTF16);
    16341635    if (!cwcSrc)
    1635         return VERR_NO_DATA;
     1636        return VERR_SHCLPB_NO_DATA;
    16361637
    16371638    /* This may slightly overestimate the space needed. */
     
    18661867    }
    18671868
    1868     if (RT_FAILURE(rc))
     1869    if (   RT_FAILURE(rc)
     1870        && rc != VERR_SHCLPB_NO_DATA)
    18691871    {
    18701872        char *pszFmts2 = ShClFormatsToStrA(pCtx->vboxFormats);
     
    22472249    {
    22482250        /* The clipboard selection may have changed before we could get it. */
    2249         rc = VERR_NO_DATA;
     2251        rc = VERR_SHCLPB_NO_DATA;
    22502252    }
    22512253    else if (pReq->Read.uFmtVBox == VBOX_SHCL_FMT_UNICODETEXT)
     
    25842586    LogFlowFunc(("pReq->uFmtVBox=%#x, idxFmtX11=%#x\n", pReq->Read.uFmtVBox, pReq->Read.idxFmtX11));
    25852587
    2586     int rc = VERR_NO_DATA; /* VBox thinks we have data and we don't. */
     2588    int rc = VERR_SHCLPB_NO_DATA; /* VBox thinks we have data and we don't. */
    25872589
    25882590#ifdef VBOX_WITH_SHARED_CLIPBOARD_XT_BUSY
     
    27042706 *
    27052707 * @returns VBox status code.
    2706  * @retval  VERR_NO_DATA if format is supported but no data is available currently.
     2708 * @retval  VERR_SHCLPB_NO_DATA if format is supported but no data is available currently.
    27072709 * @retval  VERR_NOT_IMPLEMENTED if the format is not implemented.
    27082710 * @param   pCtx                Context data for the clipboard backend.
     
    27452747                }
    27462748                else /* No payload given; could happen on invalid / not-expected formats. */
    2747                     rc = VERR_NO_DATA;
     2749                    rc = VERR_SHCLPB_NO_DATA;
    27482750            }
    27492751            else if (rc == VERR_SHCLPB_EVENT_FAILED)
     
    27622764 *
    27632765 * @returns VBox status code.
    2764  * @retval  VERR_NO_DATA if format is supported but no data is available currently.
     2766 * @retval  VERR_SHCLPB_NO_DATA if format is supported but no data is available currently.
    27652767 * @retval  VERR_NOT_IMPLEMENTED if the format is not implemented.
    27662768 * @param   pCtx                Context data for the clipboard backend.
     
    28072809 *
    28082810 * @returns VBox status code.
    2809  * @retval  VERR_NO_DATA if format is supported but no data is available currently.
     2811 * @retval  VERR_SHCLPB_NO_DATA if format is supported but no data is available currently.
    28102812 * @retval  VERR_NOT_IMPLEMENTED if the format is not implemented.
    28112813 * @param   pCtx                Context data for the clipboard backend.
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp

    r103239 r103363  
    739739    RTTestSub(hTest, "X11 conversion failure (timeout)");
    740740    tstClipSetSelectionValues("UTF8_STRING", XT_CONVERT_FAIL, NULL,0, 8);
    741     tstStringFromX11(hTest, &X11Ctx, "", VERR_NO_DATA);
     741    tstStringFromX11(hTest, &X11Ctx, "", VERR_SHCLPB_NO_DATA);
    742742
    743743    /*
     
    747747    tstClipSetSelectionValues("UTF8_STRING", XA_STRING, NULL, 0, 8);
    748748    rc = ShClX11ReadDataFromX11(&X11Ctx, &g_EventSource, g_msTimeout, VBOX_SHCL_FMT_UNICODETEXT, abBuf, sizeof(abBuf), &cbActual);
    749     RTTEST_CHECK_MSG(hTest, rc == VERR_NO_DATA,
    750                      (hTest, "Returned %Rrc instead of VERR_NO_DATA\n",
     749    RTTEST_CHECK_MSG(hTest, rc == VERR_SHCLPB_NO_DATA,
     750                     (hTest, "Returned %Rrc instead of VERR_SHCLPB_NO_DATA\n",
    751751                      rc));
    752752
     
    765765    RTTestSub(hTest, "a request for an invalid VBox format from X11");
    766766    /* Testing for 0xffff will go into handling VBOX_SHCL_FMT_UNICODETEXT, where we don't have
    767      * have any data at the moment so far, so this will return VERR_NO_DATA. */
     767     * have any data at the moment so far, so this will return VERR_SHCLPB_NO_DATA. */
    768768    rc = ShClX11ReadDataFromX11(&X11Ctx, &g_EventSource, g_msTimeout, 0xffff /* vboxFormat */, abBuf, sizeof(abBuf), &cbActual);
    769     RTTEST_CHECK_MSG(hTest, rc == VERR_NO_DATA,
    770                      (hTest, "Returned %Rrc instead of VERR_NO_DATA\n",
     769    RTTEST_CHECK_MSG(hTest, rc == VERR_SHCLPB_NO_DATA,
     770                     (hTest, "Returned %Rrc instead of VERR_SHCLPB_NO_DATA\n",
    771771                      rc));
    772772    /*
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp

    r102929 r103363  
    3333#include <iprt/assert.h>
    3434#include <iprt/env.h>
    35 #include <iprt/err.h>
    3635#include <iprt/test.h>
    3736
     37#include <VBox/err.h>
    3838#include <VBox/GuestHost/SharedClipboard.h>
    3939#include <VBox/GuestHost/SharedClipboard-x11.h>
     
    5050{
    5151    RT_NOREF(pCtx, uFmt, ppv, pcb, pvUser);
    52     return VERR_NO_DATA;
     52    return VERR_SHCLPB_NO_DATA;
    5353}
    5454
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r100655 r103363  
    175175static int vboxClipboardSvcWinReadDataFromGuestWorker(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppvData, uint32_t *pcbData)
    176176{
    177     LogFlowFunc(("uFmt=%#x\n", uFmt));
    178 
    179     int rc = ShClSvcReadDataFromGuest(pCtx->pClient, uFmt, ppvData, pcbData);
    180     if (RT_FAILURE(rc))
    181         LogRel(("Shared Clipboard: Reading guest clipboard data for Windows host failed with %Rrc\n", rc));
    182 
    183     LogFlowFuncLeaveRC(rc);
    184     return rc;
     177    return ShClSvcReadDataFromGuest(pCtx->pClient, uFmt, ppvData, pcbData);
    185178}
    186179
     
    519512                uint32_t cbData = 0;
    520513                int rc = ShClSvcReadDataFromGuest(pCtx->pClient, uFmtVBox, &pvData, &cbData);
    521                 if (   RT_SUCCESS(rc)
    522                     && pvData
    523                     && cbData)
     514                if (RT_SUCCESS(rc))
    524515                {
    525516                    /* Wrap HTML clipboard content info CF_HTML format if needed. */
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r100881 r103363  
    13861386 *
    13871387 * @returns VBox status code.
     1388 * @retval  VERR_SHCLPB_NO_DATA if no clipboard data is available.
    13881389 * @param   pClient             Client to request to read data form.
    13891390 * @param   fFormats            The formats being requested, OR'ed together (VBOX_SHCL_FMT_XXX).
     
    13941395int ShClSvcReadDataFromGuest(PSHCLCLIENT pClient, SHCLFORMAT fFormats, void **ppv, uint32_t *pcb)
    13951396{
     1397    AssertPtrReturn(ppv, VERR_INVALID_POINTER);
     1398    AssertPtrReturn(pcb, VERR_INVALID_POINTER);
     1399
    13961400    LogFlowFuncEnter();
    13971401
     
    14051409        if (RT_SUCCESS(rc))
    14061410        {
    1407             if (   !pPayload
    1408                 || !pPayload->cbData)
    1409             {
    1410                 rc = VERR_NO_DATA;
    1411             }
    1412             else
     1411            if (   pPayload
     1412                && pPayload->cbData)
    14131413            {
    14141414                *ppv = pPayload->pvData;
    14151415                *pcb = pPayload->cbData;
    14161416            }
     1417            else
     1418                rc = VERR_SHCLPB_NO_DATA;
    14171419        }
    14181420
     
    14201422    }
    14211423
    1422     if (RT_FAILURE(rc))
     1424    if (   RT_FAILURE(rc)
     1425        && rc != VERR_SHCLPB_NO_DATA)
    14231426        LogRel(("Shared Clipboard: Reading data from guest failed with %Rrc\n", rc));
    14241427
    1425     LogFlowFuncLeaveRC(rc);
     1428    LogFlowFunc(("rc=%Rc, pv=%p, cb=%RU32", rc, *ppv, *pcb));
    14261429    return rc;
    14271430}
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