VirtualBox

Changeset 81746 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 8, 2019 8:28:06 AM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/Transfers: Update.

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

Legend:

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

    r81451 r81746  
    7676        formatData.uFormats = fFormats;
    7777
    78         rc = shClSvcFormatsReport(pCtx->pClient, &formatData);
     78        rc = ShClSvcFormatsReport(pCtx->pClient, &formatData);
    7979    }
    8080
     
    223223    dataReq.cbSize = _64K; /** @todo Make this more dynamic. */
    224224
    225     return shClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */);
     225    return ShClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */);
    226226}
    227227
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r81559 r81746  
    179179} SHCLEXTSTATE, *PSHCLEXTSTATE;
    180180
    181 /*
    182  * The service functions. Locking is between the service thread and the platform-dependent (window) thread.
    183  */
    184 int shClSvcDataReadRequest(PSHCLCLIENT pClient, PSHCLDATAREQ pDataReq, PSHCLEVENTID puEvent);
    185 int shClSvcDataReadSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, PSHCLDATABLOCK pData);
    186 int shClSvcFormatsReport(PSHCLCLIENT pClient, PSHCLFORMATDATA pFormats);
    187 
    188181int shClSvcSetSource(PSHCLCLIENT pClient, SHCLSOURCE enmSource);
    189182
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r81451 r81746  
    179179
    180180    SHCLEVENTID uEvent = 0;
    181     int rc = shClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent);
     181    int rc = ShClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent);
    182182    if (RT_SUCCESS(rc))
    183183    {
     
    591591            && Formats.uFormats != VBOX_SHCL_FMT_NONE)
    592592        {
    593             rc = shClSvcFormatsReport(pCtx->pClient, &Formats);
     593            rc = ShClSvcFormatsReport(pCtx->pClient, &Formats);
    594594        }
    595595    }
     
    864864    LogFlowFuncEnter();
    865865
    866     int rc = shClSvcDataReadSignal(pClient, pCmdCtx, pData);
     866    int rc = ShClSvcDataReadSignal(pClient, pCmdCtx, pData);
    867867
    868868    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r81699 r81746  
    5050    CLIPBACKEND         *pBackend;
    5151    /** Pointer to the VBox host client data structure. */
    52     PSHCLCLIENT pClient;
     52    PSHCLCLIENT          pClient;
    5353    /** We set this when we start shutting down as a hint not to post any new
    5454     * requests. */
     
    5656};
    5757
    58 
    59 /**
    60  * Report formats available in the X11 clipboard to VBox.
    61  * @param  pCtx                 Opaque context pointer for the glue code.
    62  * @param  u32Formats           The formats available.
    63  */
    64 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, uint32_t u32Formats)
    65 {
    66     LogFlowFunc(("pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats));
    67 
    68     if (u32Formats == VBOX_SHCL_FMT_NONE) /* No formats to report? Bail out early. */
    69         return;
    70 
    71     SHCLFORMATDATA formatData;
    72     RT_ZERO(formatData);
    73 
    74     formatData.uFormats = u32Formats;
    75 
    76     int rc = shClSvcFormatsReport(pCtx->pClient, &formatData);
    77     RT_NOREF(rc);
    78 
    79     LogFlowFuncLeaveRC(rc);
    80 }
    8158
    8259int ShClSvcImplInit(void)
     
    144121    formatData.uFormats = VBOX_SHCL_FMT_NONE;
    145122
    146     return shClSvcFormatsReport(pClient, &formatData);
     123    return ShClSvcFormatsReport(pClient, &formatData);
    147124}
    148125
     
    193170struct _CLIPREADCBREQ
    194171{
    195     /** Where to write the returned data to. Weak pointer! */
     172    /** User-supplied data pointer, based on the request type. */
    196173    void                *pv;
    197     /** The size of the buffer in pv. */
     174    /** The size (in bytes) of the the user-supplied pointer in pv. */
    198175    uint32_t             cb;
    199176    /** The actual size of the data written. */
    200177    uint32_t            *pcbActual;
    201178    /** The request's event ID. */
    202     SHCLEVENTID uEvent;
     179    SHCLEVENTID          uEvent;
    203180};
    204181
     
    229206        pReq->uEvent    = uEvent;
    230207
    231         rc = ClipRequestDataFromX11(pClient->State.pCtx->pBackend, pData->uFormat, pReq);
     208        rc = ShClEventRegister(&pClient->Events, uEvent);
    232209        if (RT_SUCCESS(rc))
    233210        {
    234             rc = ShClEventRegister(&pClient->Events, uEvent);
     211            rc = ClipRequestDataFromX11(pClient->State.pCtx->pBackend, pData->uFormat, pReq);
    235212            if (RT_SUCCESS(rc))
    236213            {
     
    244221                    Assert(pData->cbData == pPayload->cbData); /* Sanity. */
    245222                }
    246 
    247                 ShClEventUnregister(&pClient->Events, uEvent);
    248223            }
     224
     225            ShClEventUnregister(&pClient->Events, uEvent);
    249226        }
    250227    }
     
    266243                 pClient, pData->pvData, pData->cbData, pData->uFormat));
    267244
    268     int rc = shClSvcDataReadSignal(pClient, pCmdCtx, pData);
    269 
    270     LogFlowFuncLeaveRC(rc);
    271     return rc;
     245    int rc = ShClSvcDataReadSignal(pClient, pCmdCtx, pData);
     246
     247    LogFlowFuncLeaveRC(rc);
     248    return rc;
     249}
     250
     251/**
     252 * Reports formats available in the X11 clipboard to VBox.
     253 *
     254 * @note   Runs in Xt event thread.
     255 *
     256 * @param  pCtx                 Opaque context pointer for the glue code.
     257 * @param  u32Formats           The formats available.
     258 */
     259DECLCALLBACK(void) ClipReportX11FormatsCallback(PSHCLCONTEXT pCtx, uint32_t u32Formats)
     260{
     261    LogFlowFunc(("pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats));
     262
     263    if (u32Formats == VBOX_SHCL_FMT_NONE) /* No formats to report? Bail out early. */
     264        return;
     265
     266    SHCLFORMATDATA formatData;
     267    RT_ZERO(formatData);
     268
     269    formatData.uFormats = u32Formats;
     270
     271    int rc = ShClSvcFormatsReport(pCtx->pClient, &formatData);
     272    RT_NOREF(rc);
     273
     274    LogFlowFuncLeaveRC(rc);
    272275}
    273276
     
    276279 * The data should be written to the buffer provided in the initial request.
    277280 *
     281 * @note   Runs in Xt event thread.
     282 *
    278283 * @param  pCtx                 Request context information.
    279  * @param  rc                   The completion status of the request.
    280  * @param  pReq                 Request.
    281  * @param  pv                   Address.
    282  * @param  cb                   Size.
     284 * @param  rcCompletion         The completion status of the request.
     285 * @param  pReq                 Request to complete.
     286 * @param  pv                   Address of data from completed request. Optional.
     287 * @param  cb                   Size (in bytes) of data from completed request. Optional.
    283288 *
    284289 * @todo   Change this to deal with the buffer issues rather than offloading them onto the caller.
    285290 */
    286 void ClipRequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc,
    287                                         CLIPREADCBREQ *pReq, void *pv, uint32_t cb)
    288 {
    289     AssertMsgRC(rc, ("Clipboard data completion from X11 failed with %Rrc\n", rc));
    290 
    291     PSHCLEVENTPAYLOAD pPayload;
    292     int rc2 = ShClPayloadAlloc(pReq->uEvent, pv, cb, &pPayload);
    293     if (RT_SUCCESS(rc2))
     291DECLCALLBACK(void) ClipRequestFromX11CompleteCallback(PSHCLCONTEXT pCtx, int rcCompletion,
     292                                                      CLIPREADCBREQ *pReq, void *pv, uint32_t cb)
     293{
     294    RT_NOREF(rcCompletion);
     295
     296    LogFlowFunc(("rcCompletion=%Rrc, pReq=%p, pv=%p, cb=%RU32, uEvent=%RU32\n", rcCompletion, pReq, pv, cb, pReq->uEvent));
     297
     298    AssertMsgRC(rcCompletion, ("Clipboard data completion from X11 failed with %Rrc\n", rcCompletion));
     299
     300    if (pReq->uEvent != NIL_SHCLEVENTID)
     301    {
     302        int rc2;
     303
     304        PSHCLEVENTPAYLOAD pPayload = NULL;
     305        if (pv && cb)
     306        {
     307            rc2 = ShClPayloadAlloc(pReq->uEvent, pv, cb, &pPayload);
     308            AssertRC(rc2);
     309        }
     310
    294311        rc2 = ShClEventSignal(&pCtx->pClient->Events, pReq->uEvent, pPayload);
    295 
    296     AssertRC(rc);
     312        AssertRC(rc2);
     313    }
    297314
    298315    RTMemFree(pReq);
     
    302319 * Reads clipboard data from the guest and passes it to the X11 clipboard.
    303320 *
    304  * @param  pCtx      Pointer to the host clipboard structure
     321 * @note   Runs in Xt event thread.
     322 *
     323 * @param  pCtx      Pointer to the host clipboard structure.
    305324 * @param  u32Format The format in which the data should be transferred
    306325 * @param  ppv       On success and if pcb > 0, this will point to a buffer
    307326 *                   to be freed with RTMemFree containing the data read.
    308327 * @param  pcb       On success, this contains the number of bytes of data
    309  *                   returned
    310  * @note   Host glue code.
    311  */
    312 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)
     328 *                   returned.
     329 */
     330DECLCALLBACK(int) ClipRequestDataForX11Callback(PSHCLCONTEXT pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)
    313331{
    314332    LogFlowFunc(("pCtx=%p, u32Format=%02X, ppv=%p\n", pCtx, u32Format, ppv));
     
    329347
    330348    SHCLEVENTID uEvent;
    331     int rc = shClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent);
     349    int rc = ShClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent);
    332350    if (RT_SUCCESS(rc))
    333351    {
     
    373391int ShClSvcImplTransferGetRoots(PSHCLCLIENT pClient, PSHCLTRANSFER pTransfer)
    374392{
    375     RT_NOREF(pClient, pTransfer);
    376 
    377     int rc = VINF_SUCCESS;
     393    LogFlowFuncEnter();
     394
     395    int rc;
     396
     397    CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)RTMemAllocZ(sizeof(CLIPREADCBREQ));
     398    if (pReq)
     399    {
     400        pReq->pv        = pTransfer;
     401        pReq->cb        = sizeof(SHCLTRANSFER);
     402        pReq->uEvent    = NIL_SHCLEVENTID; /* No event handling needed. */
     403
     404    #if 0
     405        SHCLEVENTID uEvent = ShClEventIDGenerate(&pClient->Events);
     406
     407        rc = ShClEventRegister(&pClient->Events, uEvent);
     408        if (RT_SUCCESS(rc))
     409        {
     410    #endif
     411            rc = ClipRequestDataFromX11(pClient->State.pCtx->pBackend, VBOX_SHCL_FMT_URI_LIST, pReq);
     412    #if 0
     413            if (RT_SUCCESS(rc))
     414            {
     415                /* X supplies the data asynchronously, so we need to wait for data to arrive first. */
     416                rc = ShClEventWait(&pClient->Events, uEvent, 30 * 1000, NULL /* pPayload */);
     417            }
     418
     419            ShClEventUnregister(&pClient->Events, uEvent);
     420        }
     421    #endif
     422    }
     423    else
     424        rc = VERR_NO_MEMORY;
    378425
    379426    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r81699 r81746  
    10611061 * @param   puEvent             Event ID for waiting for new data. Optional.
    10621062 */
    1063 int shClSvcDataReadRequest(PSHCLCLIENT pClient, PSHCLDATAREQ pDataReq,
     1063int ShClSvcDataReadRequest(PSHCLCLIENT pClient, PSHCLDATAREQ pDataReq,
    10641064                           PSHCLEVENTID puEvent)
    10651065{
     
    10671067    AssertPtrReturn(pDataReq, VERR_INVALID_POINTER);
    10681068    /* puEvent is optional. */
     1069
     1070    LogFlowFuncEnter();
    10691071
    10701072    int rc;
     
    11051107}
    11061108
    1107 int shClSvcDataReadSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx,
     1109int ShClSvcDataReadSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx,
    11081110                          PSHCLDATABLOCK pData)
    11091111{
     
    11121114    AssertPtrReturn(pData,   VERR_INVALID_POINTER);
    11131115
     1116    LogFlowFuncEnter();
     1117
    11141118    SHCLEVENTID uEvent;
    11151119    if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy */
     
    11391143}
    11401144
    1141 int shClSvcFormatsReport(PSHCLCLIENT pClient, PSHCLFORMATDATA pFormats)
     1145int ShClSvcFormatsReport(PSHCLCLIENT pClient, PSHCLFORMATDATA pFormats)
    11421146{
    11431147    AssertPtrReturn(pClient,  VERR_INVALID_POINTER);
    11441148    AssertPtrReturn(pFormats, VERR_INVALID_POINTER);
     1149
     1150    LogFlowFuncEnter();
    11451151
    11461152    int rc;
     
    16501656                                Assert(formatData.uFormats != VBOX_SHCL_FMT_NONE); /* There better is *any* format here now. */
    16511657
    1652                                 int rc2 = shClSvcFormatsReport(pClient, &formatData);
     1658                                int rc2 = ShClSvcFormatsReport(pClient, &formatData);
    16531659                                AssertRC(rc2);
    16541660
     
    21282134                    formatData.uFormats = u32Format;
    21292135
    2130                     rc = shClSvcFormatsReport(pClient, &formatData);
     2136                    rc = ShClSvcFormatsReport(pClient, &formatData);
    21312137                }
    21322138
     
    21432149                dataReq.cbSize = _64K; /** @todo Make this more dynamic. */
    21442150
    2145                 rc = shClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */);
     2151                rc = ShClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */);
    21462152                break;
    21472153            }
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