VirtualBox

Changeset 100393 in vbox


Ignore:
Timestamp:
Jul 5, 2023 4:18:02 PM (17 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Made setting the transfer callbacks part of ShClTransferCreate(), otherwise the pfnOnCreated callback won't be called. ​​bugref:9437

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard-transfers.h

    r100373 r100393  
    11291129 */
    11301130int ShClTransferCreateEx(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, uint32_t cbMaxChunkSize, uint32_t cMaxListHandles, uint32_t cMaxObjHandles, PSHCLTRANSFER *ppTransfer);
    1131 int ShClTransferCreate(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, PSHCLTRANSFER *ppTransfer);
     1131int ShClTransferCreate(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, PSHCLTRANSFERCALLBACKS pCallbacks, PSHCLTRANSFER *ppTransfer);
    11321132int ShClTransferInit(PSHCLTRANSFER pTransfer);
    11331133int ShClTransferDestroy(PSHCLTRANSFER pTransfer);
     
    11881188PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry);
    11891189
    1190 void ShClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKS pCallbacksDst, PSHCLTRANSFERCALLBACKS pCallbacksSrc);
    1191 void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks);
    11921190int ShClTransferSetProvider(PSHCLTRANSFER pTransfer, PSHCLTXPROVIDER pProvider);
    11931191
  • trunk/include/VBox/GuestHost/SharedClipboard.h

    r100328 r100393  
    402402    DECLCALLBACKMEMBER(int, pfnOnSendDataToDest, (PSHCLCONTEXT pCtx, void *pv, uint32_t cb, void *pvUser));
    403403} SHCLCALLBACKS;
     404/** Pointer to a Shared Clipboard callback table. */
    404405typedef SHCLCALLBACKS *PSHCLCALLBACKS;
    405406/** @} */
  • trunk/include/VBox/VBoxGuestLib.h

    r100367 r100393  
    724724#  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    725725VBGLR3DECL(int)     VbglR3ClipboardTransferRequest(PVBGLR3SHCLCMDCTX pCmdCtx);
    726 VBGLR3DECL(void)    VbglR3ClipboardTransferSetCallbacks(PSHCLTRANSFERCALLBACKS pCallbacks);
    727726VBGLR3DECL(int)     VbglR3ClipboardEventGetNextEx(uint32_t idMsg, uint32_t cParms, PVBGLR3SHCLCMDCTX pCtx, PSHCLTRANSFERCTX pTransferCtx, PVBGLR3CLIPBOARDEVENT pEvent);
    728727
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp

    r100391 r100393  
    19731973
    19741974    PSHCLTRANSFER pTransfer;
    1975     int rc = ShClTransferCreate(enmDir, enmSource, &pTransfer);
    1976     if (RT_SUCCESS(rc))
    1977     {
    1978         /* Set the callbacks the (OS-dependent) implementation relies on. Optional. */
    1979         ShClTransferSetCallbacks(pTransfer, &pCmdCtx->Transfers.Callbacks);
    1980 
     1975    int rc = ShClTransferCreate(enmDir, enmSource, &pCmdCtx->Transfers.Callbacks, &pTransfer);
     1976    if (RT_SUCCESS(rc))
     1977    {
    19811978        rc = ShClTransferCtxRegisterById(pTransferCtx, pTransfer, idTransfer);
    19821979        if (   RT_SUCCESS(rc)
     
    22182215    LogFlowFuncLeaveRC(rc);
    22192216    return rc;
    2220 }
    2221 
    2222 /**
    2223  * Sets transfer callbacks of a Shared Clipboard command context.
    2224  *
    2225  * @param   pCmdCtx             Command context to set callbacks for.
    2226  * @param   pCallbacks          Pointer to callback table to set.
    2227  */
    2228 VBGLR3DECL(void) VbglR3ClipboardTransferSetCallbacks(PVBGLR3SHCLCMDCTX pCmdCtx,  PSHCLTRANSFERCALLBACKS pCallbacks)
    2229 {
    2230     AssertPtrReturnVoid(pCmdCtx);
    2231     AssertPtrReturnVoid(pCallbacks);
    2232 
    2233     ShClTransferCopyCallbacks(&pCmdCtx->Transfers.Callbacks, pCallbacks);
    22342217}
    22352218
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp

    r100385 r100393  
    4444
    4545
     46
     47/*********************************************************************************************************************************
     48 * Prototypes                                                                                                                    *
     49 ********************************************************************************************************************************/
     50
     51static void shClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKS pCallbacksDst, PSHCLTRANSFERCALLBACKS pCallbacksSrc);
    4652DECLINLINE(void) shClTransferLock(PSHCLTRANSFER pTransfer);
    4753DECLINLINE(void) shClTransferUnlock(PSHCLTRANSFER pTransfer);
     54static void shClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks);
    4855static int shClTransferSetStatus(PSHCLTRANSFER pTransfer, SHCLTRANSFERSTATUS enmStatus);
    4956static int shClTransferThreadCreate(PSHCLTRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser);
     
    10521059 * @param   enmDir              Specifies the transfer direction of this transfer.
    10531060 * @param   enmSource           Specifies the data source of the transfer.
     1061 * @param   pCallbacks          Callback table to use. Optional and can be NULL.
    10541062 * @param   cbMaxChunkSize      Maximum transfer chunk size (in bytes) to use.
    10551063 * @param   cMaxListHandles     Maximum list entries the transfer can have.
     
    10581066 *                              Must be destroyed by ShClTransferDestroy().
    10591067 */
    1060 int ShClTransferCreateEx(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource,
     1068int ShClTransferCreateEx(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, PSHCLTRANSFERCALLBACKS pCallbacks,
    10611069                         uint32_t cbMaxChunkSize, uint32_t cMaxListHandles, uint32_t cMaxObjHandles, PSHCLTRANSFER *ppTransfer)
    10621070{
    1063 
    1064 
    10651071    AssertPtrReturn(ppTransfer, VERR_INVALID_POINTER);
     1072    /* pCallbacks can be NULL. */
    10661073
    10671074    LogFlowFuncEnter();
     
    10961103    RT_ZERO(pTransfer->ProviderCtx);
    10971104    RT_ZERO(pTransfer->ProviderIface);
     1105
     1106    /* Make sure to set the callbacks before calling pfnOnCreate below. */
     1107    shClTransferSetCallbacks(pTransfer, pCallbacks);
    10981108
    10991109    ShClTransferListInit(&pTransfer->lstRoots);
     
    11321142 * @param   enmDir              Specifies the transfer direction of this transfer.
    11331143 * @param   enmSource           Specifies the data source of the transfer.
     1144 * @param   pCallbacks          Callback table to use. Optional and can be NULL.
    11341145 * @param   ppTransfer          Where to return the created clipboard transfer struct.
    11351146 *                              Must be destroyed by ShClTransferDestroy().
    11361147 */
    1137 int ShClTransferCreate(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, PSHCLTRANSFER *ppTransfer)
    1138 {
    1139     return ShClTransferCreateEx(enmDir, enmSource,
     1148int ShClTransferCreate(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, PSHCLTRANSFERCALLBACKS pCallbacks, PSHCLTRANSFER *ppTransfer)
     1149{
     1150    return ShClTransferCreateEx(enmDir, enmSource, pCallbacks,
    11401151                                SHCL_TRANSFER_DEFAULT_MAX_CHUNK_SIZE,
    11411152                                SHCL_TRANSFER_DEFAULT_MAX_LIST_HANDLES,
     
    14691480 *                              destination callback table will be unset.
    14701481 */
    1471 void ShClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKS pCallbacksDst,
    1472                                PSHCLTRANSFERCALLBACKS pCallbacksSrc)
     1482static void shClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKS pCallbacksDst, PSHCLTRANSFERCALLBACKS pCallbacksSrc)
    14731483{
    14741484    AssertPtrReturnVoid(pCallbacksDst);
     1485    /* pCallbacksSrc can be NULL */
    14751486
    14761487    if (pCallbacksSrc) /* Set */
     
    15081519 * @note    Must come before initializing the transfer via ShClTransferInit().
    15091520 */
    1510 void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer,
    1511                               PSHCLTRANSFERCALLBACKS pCallbacks)
     1521static void shClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks)
    15121522{
    15131523    AssertPtrReturnVoid(pTransfer);
    15141524    /* pCallbacks can be NULL. */
    15151525
    1516     ShClTransferCopyCallbacks(&pTransfer->Callbacks, pCallbacks);
     1526    shClTransferCopyCallbacks(&pTransfer->Callbacks, pCallbacks);
    15171527
    15181528    /* Make sure that the callback context has all values set according to the callback table.
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardHttpServer.cpp

    r100367 r100393  
    212212            {
    213213                PSHCLTRANSFER pTx;
    214                 RTTEST_CHECK_RC_OK(hTest, ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, &pTx));
     214                RTTEST_CHECK_RC_OK(hTest, ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTx));
    215215                RTTEST_CHECK_RC_OK(hTest, ShClTransferSetProvider(pTx, &Provider));
    216216                RTTEST_CHECK_RC_OK(hTest, ShClTransferInit(pTx));
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-transfers.cpp

    r100374 r100393  
    22582258
    22592259    PSHCLTRANSFER pTransfer;
    2260     int rc = ShClTransferCreate(enmDir, enmSource, &pTransfer);
     2260    int rc = ShClTransferCreate(enmDir, enmSource, &pClient->Transfers.Callbacks, &pTransfer);
    22612261    if (RT_SUCCESS(rc))
    22622262    {
     
    23422342        LogRel2(("Shared Clipboard: Initializing %s transfer ...\n",
    23432343                 enmDir == SHCLTRANSFERDIR_FROM_REMOTE ? "guest -> host" : "host -> guest"));
    2344 
    2345         ShClTransferSetCallbacks(pTransfer, &pClient->Transfers.Callbacks);
    2346 
    2347         pClient->Transfers.Provider.enmSource = pClient->State.enmSource;
    2348         pClient->Transfers.Provider.pvUser    = pClient;
    23492344
    23502345        rc = ShClTransferInit(pTransfer);
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r100392 r100393  
    417417
    418418    PSHCLTXPROVIDERIFACE pIface = &pClient->Transfers.Provider.Interface;
     419
     420    pClient->Transfers.Provider.enmSource = pClient->State.enmSource;
     421    pClient->Transfers.Provider.pvUser    = pClient;
    419422
    420423    switch (ShClTransferGetDir(pTransfer))
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardTransfers.cpp

    r100367 r100393  
    212212{
    213213    PSHCLTRANSFER pTransfer;
    214     int rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, &pTransfer);
     214    int rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTransfer);
    215215    RTTESTI_CHECK_RC_OK(rc);
    216216
     
    246246
    247247    PSHCLTRANSFER pTransfer;
    248     int rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, &pTransfer);
     248    int rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTransfer);
    249249    RTTESTI_CHECK_RC_OK(rc);
    250250
     
    309309    RTTESTI_CHECK_RC_OK(rc);
    310310    PSHCLTRANSFER pTransfer;
    311     rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, &pTransfer);
     311    rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTransfer);
    312312    RTTESTI_CHECK_RC_OK(rc);
    313313    rc = ShClTransferDestroy(pTransfer);
     
    318318    PSHCLLIST pList = ShClTransferListAlloc();
    319319    RTTESTI_CHECK(pList != NULL);
    320     rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, &pTransfer);
     320    rc = ShClTransferCreate(SHCLTRANSFERDIR_TO_REMOTE, SHCLSOURCE_LOCAL, NULL /* Callbacks */, &pTransfer);
    321321    RTTESTI_CHECK_RC_OK(rc);
    322322    ShClTransferListFree(pList);
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