VirtualBox

Changeset 103450 in vbox


Ignore:
Timestamp:
Feb 19, 2024 2:55:20 PM (13 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161781
Message:

Shared Clipboard: Condensed more code by adding a new Windows-specific function SharedClipboardWinTransferHandOffToDataObject(). bugref:9437

Location:
trunk
Files:
4 edited

Legend:

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

    r100541 r103450  
    499499void SharedClipboardWinTransferDestroy(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer);
    500500
     501int SharedClipboardWinTransferHandOffToDataObject(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer);
    501502int SharedClipboardWinTransferCreateAndSetDataObject(PSHCLWINCTX pWinCtx, PSHCLCONTEXT pCtx, SharedClipboardWinDataObject::PCALLBACKS pCallbacks);
    502503# endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r103442 r103450  
    179179    AssertPtr(pCtx);
    180180
    181     switch(ShClTransferGetDir(pCbCtx->pTransfer))
     181    PSHCLTRANSFER pTransfer = pCbCtx->pTransfer;
     182    AssertPtr(pTransfer);
     183
     184    switch(ShClTransferGetDir(pTransfer))
    182185    {
    183186        case SHCLTRANSFERDIR_FROM_REMOTE: /* G->H */
    184187        {
    185             SharedClipboardWinDataObject *pObj = pCtx->Win.pDataObjInFlight;
    186             if (pObj)
    187             {
    188                 rc = pObj->SetTransfer(pCbCtx->pTransfer);
    189                 if (RT_SUCCESS(rc))
    190                     rc = pObj->SetStatus(SharedClipboardWinDataObject::Running);
    191 
    192                 pCtx->Win.pDataObjInFlight = NULL; /* Hand off to Windows. */
    193             }
    194             else
    195                 AssertMsgFailed(("No data object in flight!\n"));
    196 
     188            rc = SharedClipboardWinTransferHandOffToDataObject(&pCtx->Win, pTransfer);
    197189            break;
    198190        }
     
    200192        case SHCLTRANSFERDIR_TO_REMOTE: /* H->G */
    201193        {
    202             rc = SharedClipboardWinTransferGetRootsFromClipboard(&pCtx->Win, pCbCtx->pTransfer);
     194            rc = SharedClipboardWinTransferGetRootsFromClipboard(&pCtx->Win, pTransfer);
    203195            break;
    204196        }
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp

    r100665 r103450  
    11921192
    11931193/**
     1194 * Hands off a transfer to the current data object in-flight.
     1195 *
     1196 * @returns VBox status code.
     1197 * @param   pWinCtx             Windows context to use.
     1198 * @param   pTransfer           Transfer to hand off to the data object.
     1199 *
     1200 * @note    The data object will be put into running state on success and handed over to Windows.
     1201 *          Our data object pointer will be invalid afterwards.
     1202 */
     1203int SharedClipboardWinTransferHandOffToDataObject(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer)
     1204{
     1205    int rc = RTCritSectEnter(&pCtx->Win.CritSect);
     1206    if (RT_SUCCESS(rc))
     1207    {
     1208        SharedClipboardWinDataObject *pObj = pCtx->Win.pDataObjInFlight;
     1209        if (pObj)
     1210        {
     1211            rc = pObj->SetTransfer(pTransfer);
     1212            if (RT_SUCCESS(rc))
     1213                rc = pObj->SetStatus(SharedClipboardWinDataObject::Running);
     1214
     1215            pCtx->Win.pDataObjInFlight = NULL; /* Hand off to Windows. */
     1216        }
     1217        else
     1218        {
     1219            AssertMsgFailed(("No data object in flight (yet)!\n"));
     1220            rc = VERR_WRONG_ORDER);
     1221        }
     1222
     1223        int rc2 = RTCritSectLeave(&pCtx->Win.CritSect);
     1224        AssertRC(rc2);
     1225    }
     1226
     1227    return rc;
     1228}
     1229
     1230/**
    11941231 * Retrieves the roots for a transfer by opening the clipboard and getting the clipboard data
    11951232 * as string list (CF_HDROP), assigning it to the transfer as roots then.
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r103445 r103450  
    312312        case SHCLTRANSFERDIR_FROM_REMOTE: /* G->H */
    313313        {
    314             rc = RTCritSectEnter(&pCtx->Win.CritSect);
    315             if (RT_SUCCESS(rc))
    316             {
    317                 SharedClipboardWinDataObject *pObj = pCtx->Win.pDataObjInFlight;
    318                 if (pObj)
    319                 {
    320                     rc = pObj->SetTransfer(pTransfer);
    321                     if (RT_SUCCESS(rc))
    322                         rc = pObj->SetStatus(SharedClipboardWinDataObject::Running);
    323 
    324                     pCtx->Win.pDataObjInFlight = NULL; /* Hand off to Windows. */
    325                 }
    326                 else
    327                     AssertMsgFailed(("No data object in flight!\n"));
    328 
    329                 int rc2 = RTCritSectLeave(&pCtx->Win.CritSect);
    330                 AssertRC(rc2);
    331             }
    332 
     314            rc = SharedClipboardWinTransferSet(&pCtx->Win, pTransfer);
    333315            break;
    334316        }
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