VirtualBox

Ignore:
Timestamp:
Dec 10, 2019 1:46:40 AM (5 years ago)
Author:
vboxsync
Message:

SharedClipboardSvc,Vbgl: Worked over the host messages, taking locks when needed, not using C++ lists and a bunch of other simplifications. bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r82525 r82527  
    9393
    9494#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     95
    9596/**
    9697 * Cleanup helper function for transfer callbacks.
     
    218219    vboxClipboardTransferCallbackCleanup(pData);
    219220}
     221
    220222#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
    221223
     
    559561            Assert(pEvent->enmType == VBGLR3CLIPBOARDEVENTTYPE_READ_DATA);
    560562
    561             const SHCLFORMAT fFormat = (uint32_t)pEvent->u.ReadData.uFmt;
     563            const SHCLFORMAT fFormat = (uint32_t)pEvent->u.fReadData;
    562564
    563565            HANDLE hClip = NULL;
     
    991993    int rc;
    992994
    993     uint32_t uMsg;
    994     uint32_t uFormats;
    995 
    996995    /* The thread waits for incoming messages from the host. */
    997996    for (;;)
    998997    {
    999         PVBGLR3CLIPBOARDEVENT pEvent = NULL;
    1000 
    1001998        LogFlowFunc(("Waiting for host message (fUseLegacyProtocol=%RTbool, fHostFeatures=%#RX64) ...\n",
    1002999                     pCtx->CmdCtx.fUseLegacyProtocol, pCtx->CmdCtx.fHostFeatures));
    10031000
    1004         if (pCtx->CmdCtx.fUseLegacyProtocol)
    1005         {
    1006             rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.idClient, &uMsg, &uFormats);
    1007             if (RT_FAILURE(rc))
    1008             {
    1009                 if (rc == VERR_INTERRUPTED)
    1010                     break;
    1011 
    1012                 LogFunc(("Error getting host message, rc=%Rrc\n", rc));
    1013             }
    1014             else
    1015             {
    1016                 pEvent = (PVBGLR3CLIPBOARDEVENT)RTMemAllocZ(sizeof(VBGLR3CLIPBOARDEVENT));
    1017                 AssertPtrBreakStmt(pEvent, rc = VERR_NO_MEMORY);
    1018 
    1019                 switch (uMsg)
    1020                 {
    1021                     case VBOX_SHCL_HOST_MSG_FORMATS_REPORT:
    1022                     {
    1023                         pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS;
    1024                         pEvent->u.ReportedFormats.Formats = uFormats;
    1025                         break;
    1026                     }
    1027 
    1028                     case VBOX_SHCL_HOST_MSG_READ_DATA:
    1029                     {
    1030                         pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_READ_DATA;
    1031                         pEvent->u.ReadData.uFmt = uFormats;
    1032                         break;
    1033                     }
    1034 
    1035                     case VBOX_SHCL_HOST_MSG_QUIT:
    1036                     {
    1037                         pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_QUIT;
    1038                         break;
    1039                     }
    1040 
    1041                     default:
    1042                         rc = VERR_NOT_SUPPORTED;
    1043                         break;
    1044                 }
    1045 
    1046                 if (RT_SUCCESS(rc))
    1047                 {
    1048                     /* Copy over our command context to the event. */
    1049                     pEvent->cmdCtx = pCtx->CmdCtx;
    1050                 }
    1051             }
    1052         }
    1053         else /* Host service has peeking for messages support. */
    1054         {
    1055             pEvent = (PVBGLR3CLIPBOARDEVENT)RTMemAllocZ(sizeof(VBGLR3CLIPBOARDEVENT));
    1056             AssertPtrBreakStmt(pEvent, rc = VERR_NO_MEMORY);
    1057 
    1058             uint32_t uMsg   = 0;
    1059             uint32_t cParms = 0;
    1060             rc = VbglR3ClipboardMsgPeekWait(&pCtx->CmdCtx, &uMsg, &cParms, NULL /* pidRestoreCheck */);
    1061             if (RT_SUCCESS(rc))
    1062             {
    1063 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    1064                 rc = VbglR3ClipboardEventGetNextEx(uMsg, cParms, &pCtx->CmdCtx, &pCtx->TransferCtx, pEvent);
     1001        PVBGLR3CLIPBOARDEVENT pEvent = (PVBGLR3CLIPBOARDEVENT)RTMemAllocZ(sizeof(VBGLR3CLIPBOARDEVENT));
     1002        AssertPtrBreakStmt(pEvent, rc = VERR_NO_MEMORY);
     1003
     1004        uint32_t idMsg  = 0;
     1005        uint32_t cParms = 0;
     1006        rc = VbglR3ClipboardMsgPeekWait(&pCtx->CmdCtx, &idMsg, &cParms, NULL /* pidRestoreCheck */);
     1007        if (RT_SUCCESS(rc))
     1008        {
     1009#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     1010            rc = VbglR3ClipboardEventGetNextEx(idMsg, cParms, &pCtx->CmdCtx, &pCtx->TransferCtx, pEvent);
    10651011#else
    1066                 rc = VbglR3ClipboardEventGetNext(uMsg, cParms, &pCtx->CmdCtx, pEvent);
    1067 #endif
    1068             }
     1012            rc = VbglR3ClipboardEventGetNext(idMsg, cParms, &pCtx->CmdCtx, pEvent);
     1013#endif
    10691014        }
    10701015
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