VirtualBox

Ignore:
Timestamp:
Oct 22, 2019 10:23:38 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134163
Message:

Shared Clipboard/Svc: More legacy handling (protocol v0) tweaks needed for VBOX_SHCL_HOST_MSG_READ_DATA. See comments for details.

File:
1 edited

Legend:

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

    r81443 r81445  
    427427 * @param   paDstParms  The peek parameter vector.
    428428 * @param   cDstParms   The number of peek parameters (at least two).
    429  */
    430 int shclSvcMsgSetGetHostMsgOldReturn(PSHCLCLIENTMSG pMsg, PVBOXHGCMSVCPARM paDstParms, uint32_t cDstParms)
     429 * @param   pfRemove    Returns whether the message can be removed from the queue or not.
     430 *                      This is needed for certain messages which need to stay around for more than one (guest) call.
     431 */
     432int shclSvcMsgSetGetHostMsgOldReturn(PSHCLCLIENTMSG pMsg, PVBOXHGCMSVCPARM paDstParms, uint32_t cDstParms,
     433                                     bool *pfRemove)
    431434{
    432435    AssertPtrReturn(pMsg,           VERR_INVALID_POINTER);
    433436    AssertPtrReturn(paDstParms,     VERR_INVALID_POINTER);
    434437    AssertReturn   (cDstParms >= 2, VERR_INVALID_PARAMETER);
     438    AssertPtrReturn(pfRemove,       VERR_INVALID_POINTER);
    435439
    436440    int rc = VINF_SUCCESS;
     441
     442    bool fRemove = true;
     443
     444    LogFlowFunc(("uMsg=%RU32 (%s), cParms=%RU32\n",
     445                 pMsg->uMsg, ShClHostMsgToStr(pMsg->uMsg), pMsg->cParms));
    437446
    438447    switch (pMsg->uMsg)
     
    449458            HGCMSvcSetU32(&paDstParms[0], VBOX_SHCL_HOST_MSG_READ_DATA);
    450459            AssertBreakStmt(pMsg->cParms >= 2, rc = VERR_INVALID_PARAMETER); /* Paranoia. */
    451             uint32_t uFmt;
    452             rc = HGCMSvcGetU32(&pMsg->paParms[1] /* uFormat */, &uFmt);
     460            uint32_t uSrcFmt = VBOX_SHCL_FMT_NONE;
     461            uint32_t uDstFmt = VBOX_SHCL_FMT_NONE;
     462            rc = HGCMSvcGetU32(&pMsg->paParms[1] /* uFormat */, &uSrcFmt);
    453463            if (RT_SUCCESS(rc))
    454                 HGCMSvcSetU32(&paDstParms[1], uFmt);
     464            {
     465                if (uSrcFmt & VBOX_SHCL_FMT_UNICODETEXT)
     466                    uDstFmt = VBOX_SHCL_FMT_UNICODETEXT;
     467                else if (uSrcFmt & VBOX_SHCL_FMT_BITMAP)
     468                    uDstFmt = VBOX_SHCL_FMT_BITMAP;
     469                else if (uSrcFmt & VBOX_SHCL_FMT_HTML)
     470                    uDstFmt = VBOX_SHCL_FMT_HTML;
     471                else
     472                    AssertStmt(uSrcFmt == VBOX_SHCL_FMT_NONE, uSrcFmt = VBOX_SHCL_FMT_NONE);
     473
     474                /* Remove format we're going to return from the queued message. */
     475                uSrcFmt &= ~uDstFmt;
     476                HGCMSvcSetU32(&pMsg->paParms[1], uSrcFmt);
     477
     478                /* Only report back one format at a time. */
     479                HGCMSvcSetU32(&paDstParms[1], uDstFmt);
     480
     481                /* If no more formats are left, the message can be removed finally. */
     482                fRemove = uSrcFmt == VBOX_SHCL_FMT_NONE;
     483
     484                LogFlowFunc(("uSrcFmt=0x%x, fRemove=%RTbool\n", uSrcFmt, fRemove));
     485            }
    455486            break;
    456487        }
     
    472503            break;
    473504    }
     505
     506    *pfRemove = fRemove;
    474507
    475508    LogFlowFuncLeaveRC(rc);
     
    780813                         pFirstMsg->cParms));
    781814
    782             rc = shclSvcMsgSetGetHostMsgOldReturn(pFirstMsg, paParms, cParms);
     815            bool fRemove;
     816            rc = shclSvcMsgSetGetHostMsgOldReturn(pFirstMsg, paParms, cParms, &fRemove);
    783817            if (RT_SUCCESS(rc))
    784818            {
    785819                AssertPtr(g_pHelpers);
    786820                rc = g_pHelpers->pfnCallComplete(hCall, rc);
    787                 if (rc != VERR_CANCELLED)
     821                if (   rc != VERR_CANCELLED
     822                    && fRemove)
    788823                {
    789824                    pClient->queueMsg.removeFirst();
     
    9751010                else if (pClient->Pending.uType == VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD) /* Legacy */
    9761011                {
    977                     rc = shclSvcMsgSetGetHostMsgOldReturn(pFirstMsg, pClient->Pending.paParms, pClient->Pending.cParms);
     1012                    bool fRemove;
     1013                    rc = shclSvcMsgSetGetHostMsgOldReturn(pFirstMsg, pClient->Pending.paParms, pClient->Pending.cParms,
     1014                                                          &fRemove);
    9781015                    if (RT_SUCCESS(rc))
    9791016                    {
    980                         /* The old (legacy) protocol gets the message right when returning from peeking, so
    981                          * remove the actual message from our queue right now. */
    982                         pClient->queueMsg.removeFirst();
    983                         shclSvcMsgFree(pFirstMsg);
     1017                        if (fRemove)
     1018                        {
     1019                            /* The old (legacy) protocol gets the message right when returning from peeking, so
     1020                             * remove the actual message from our queue right now. */
     1021                            pClient->queueMsg.removeFirst();
     1022                            shclSvcMsgFree(pFirstMsg);
     1023                        }
    9841024
    9851025                        fDonePending = true;
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