VirtualBox

Ignore:
Timestamp:
Oct 20, 2015 10:05:12 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103528
Message:

DnD: Updates/bugfixes:

  • Added separate VBOXDNDDISCONNECTMSG message for letting Main know about client disconnects.
  • Various cleanups and bugfixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp

    r58257 r58329  
    131131        Msg.u.v1.uAllActions.SetUInt32(0);
    132132        Msg.u.v1.pvFormats.SetPtr(pszFormats, cbFormats);
    133         Msg.u.v1.cFormats.SetUInt32(0);
     133        Msg.u.v1.cbFormats.SetUInt32(0);
    134134    }
    135135    else
     
    144144        Msg.u.v3.uAllActions.SetUInt32(0);
    145145        Msg.u.v3.pvFormats.SetPtr(pszFormats, cbFormats);
    146         Msg.u.v3.cFormats.SetUInt32(0);
     146        Msg.u.v3.cbFormats.SetUInt32(0);
    147147    }
    148148
     
    160160                rc = Msg.u.v1.uDefAction.GetUInt32(puDefAction);   AssertRC(rc);
    161161                rc = Msg.u.v1.uAllActions.GetUInt32(puAllActions); AssertRC(rc);
    162                 rc = Msg.u.v1.cFormats.GetUInt32(pcbFormatsRecv); AssertRC(rc);
     162                rc = Msg.u.v1.cbFormats.GetUInt32(pcbFormatsRecv); AssertRC(rc);
    163163            }
    164164            else
     
    170170                rc = Msg.u.v3.uDefAction.GetUInt32(puDefAction);   AssertRC(rc);
    171171                rc = Msg.u.v3.uAllActions.GetUInt32(puAllActions); AssertRC(rc);
    172                 rc = Msg.u.v3.cFormats.GetUInt32(pcbFormatsRecv); AssertRC(rc);
     172                rc = Msg.u.v3.cbFormats.GetUInt32(pcbFormatsRecv); AssertRC(rc);
    173173            }
    174174
     
    447447}
    448448
    449 static int vbglR3DnDHGRecvURIData(PVBGLR3GUESTDNDCMDCTX pCtx, DnDDroppedFiles *pDroppedFiles)
     449static int vbglR3DnDHGRecvURIData(PVBGLR3GUESTDNDCMDCTX pCtx, PVBOXDNDSNDDATAHDR pDataHdr, DnDDroppedFiles *pDroppedFiles)
    450450{
    451451    AssertPtrReturn(pCtx,          VERR_INVALID_POINTER);
     452    AssertPtrReturn(pDataHdr,      VERR_INVALID_POINTER);
    452453    AssertPtrReturn(pDroppedFiles, VERR_INVALID_POINTER);
     454
     455    /* Only count the raw data minus the already received meta data. */
     456    Assert(pDataHdr->cbTotal >= pDataHdr->cbMeta);
     457    uint64_t cbToRecvBytes = pDataHdr->cbTotal - pDataHdr->cbMeta;
     458    uint64_t cToRecvObjs   = pDataHdr->cObjects;
     459
     460    LogFlowFunc(("cbToRecvBytes=%RU64, cToRecvObjs=%RU64, (cbTotal=%RU64, cbMeta=%RU32)\n",
     461                 cbToRecvBytes, cToRecvObjs, pDataHdr->cbTotal, pDataHdr->cbMeta));
     462
     463    /*
     464     * Only do accounting for protocol v3 and up.
     465     * The older protocols did not have any data accounting available, so
     466     * we simply tried to receive as much data as available and bail out.
     467     */
     468    const bool fDoAccounting = pCtx->uProtocol >= 3;
     469
     470    /* Anything to do at all? */
     471    if (fDoAccounting)
     472    {
     473        if (   !cbToRecvBytes
     474            && !cToRecvObjs)
     475        {
     476            return VINF_SUCCESS;
     477        }
     478    }
    453479
    454480    /*
     
    484510    char szPathName[RTPATH_MAX] = { 0 };
    485511    uint32_t cbPathName = 0;
    486     uint32_t fFlags = 0;
    487     uint32_t fMode = 0;
    488 
    489     while (RT_SUCCESS(rc))
    490     {
     512    uint32_t fFlags     = 0;
     513    uint32_t fMode      = 0;
     514
     515    /*
     516     * Only wait for new incoming commands for protocol v3 and up.
     517     * The older protocols did not have any data accounting available, so
     518     * we simply tried to receive as much data as available and bail out.
     519     */
     520    const bool fWait = pCtx->uProtocol >= 3;
     521
     522    do
     523    {
     524        LogFlowFunc(("Wating for new message ...\n"));
     525
    491526        uint32_t uNextMsg;
    492527        uint32_t cNextParms;
    493         rc = vbglR3DnDGetNextMsgType(pCtx, &uNextMsg, &cNextParms, false /* fWait */);
     528        rc = vbglR3DnDGetNextMsgType(pCtx, &uNextMsg, &cNextParms, fWait);
    494529        if (RT_SUCCESS(rc))
    495530        {
     
    519554                        if (RT_SUCCESS(rc))
    520555                            rc = pDroppedFiles->AddDir(pszPathAbs);
     556
     557                        if (   RT_SUCCESS(rc)
     558                            && fDoAccounting)
     559                        {
     560                            Assert(cToRecvObjs);
     561                            cToRecvObjs--;
     562                        }
    521563
    522564                        RTStrFree(pszPathAbs);
     
    623665                                /* Data transfer complete? Close the file. */
    624666                                fClose = objFile.IsComplete();
     667                                if (   fClose
     668                                    && fDoAccounting)
     669                                {
     670                                    Assert(cToRecvObjs);
     671                                    cToRecvObjs--;
     672                                }
    625673
    626674                                /* Only since protocol v2 we know the file size upfront. */
     
    631679
    632680                            cbFileWritten += cbChunkWritten;
     681
     682                            if (pCtx->uProtocol >= 3)
     683                            {
     684                                Assert(cbToRecvBytes >= cbChunkRead);
     685                                cbToRecvBytes -= cbChunkRead;
     686                            }
    633687                        }
    634688
     
    660714            break;
    661715
    662     } /* while */
     716        if (fDoAccounting)
     717        {
     718            LogFlowFunc(("cbToRecvBytes=%RU64, cToRecvObjs=%RU64\n", cbToRecvBytes, cToRecvObjs));
     719            if (   !cbToRecvBytes
     720                && !cToRecvObjs)
     721            {
     722                break;
     723            }
     724        }
     725
     726    } while (RT_SUCCESS(rc));
    663727
    664728    LogFlowFunc(("Loop ended with %Rrc\n", rc));
     
    723787        uint32_t cbDataRecv;
    724788
    725         if (pCtx->uProtocol < 3) /* For VBox < 5.0.8. */
     789        if (pCtx->uProtocol < 3)
    726790        {
    727791            Msg.hdr.cParms  = 5;
     
    901965    uint32_t cbDataRecv;
    902966
    903     if (pCtx->uProtocol < 3) /* For VBox < 5.0.8. */
     967    LogFlowFuncEnter();
     968
     969    if (pCtx->uProtocol < 3)
    904970    {
    905971        uint64_t cbDataTmp = pCtx->cbMaxChunkSize;
     
    9791045            RTMemFree(pvDataTmp);
    9801046    }
    981     else /* Protocol v3 and up. Since VBox 5.0.8. */
     1047    else /* Protocol v3 and up. */
    9821048    {
    9831049        rc = vbglR3DnDHGRecvDataHdr(pCtx, pDataHdr);
    9841050        if (RT_SUCCESS(rc))
    9851051        {
    986             LogFlowFunc(("cbMeta=%RU32\n", pDataHdr->cbMeta));
     1052            LogFlowFunc(("cbTotal=%RU64, cbMeta=%RU32\n", pDataHdr->cbTotal, pDataHdr->cbMeta));
    9871053            if (pDataHdr->cbMeta)
    9881054            {
     
    10861152            rc = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */);
    10871153            if (RT_SUCCESS(rc))
    1088                 rc = vbglR3DnDHGRecvURIData(pCtx, &droppedFiles);
     1154                rc = vbglR3DnDHGRecvURIData(pCtx, &dataHdr, &droppedFiles);
    10891155
    10901156            if (RT_SUCCESS(rc)) /** @todo Remove this block as soon as we hand in DnDURIList. */
     
    15061572    Msg.hdr.u32Function = GUEST_DND_HG_ACK_OP;
    15071573
     1574    LogFlowFunc(("uProto=%RU32\n", pCtx->uProtocol));
     1575
    15081576    if (pCtx->uProtocol < 3)
    15091577    {
     
    16601728
    16611729    /* For protocol v3 and up we need to send the data header first. */
    1662     if (pCtx->uProtocol > 2)
     1730    if (pCtx->uProtocol >= 3)
    16631731    {
    16641732        AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER);
     
    16751743        Msg.uScreenId.SetUInt32(0);                          /** @todo Not used for guest->host (yet). */
    16761744        Msg.cbTotal.SetUInt64(pDataHdr->cbTotal);
    1677         Msg.cbMeta.SetUInt64(pDataHdr->cbMeta);
     1745        Msg.cbMeta.SetUInt32(pDataHdr->cbMeta);
    16781746        Msg.pvMetaFmt.SetPtr(pDataHdr->pvMetaFmt, pDataHdr->cbMetaFmt);
    16791747        Msg.cbMetaFmt.SetUInt32(pDataHdr->cbMetaFmt);
     
    17001768        Msg.hdr.u32Function = GUEST_DND_GH_SND_DATA;
    17011769
    1702         if (pCtx->uProtocol > 2)
     1770        if (pCtx->uProtocol >= 3)
    17031771        {
    17041772            Msg.hdr.cParms = 5;
     
    17211789        uint32_t       cbSent     = 0;
    17221790
    1723         HGCMFunctionParameter *pParm = (pCtx->uProtocol > 2)
     1791        HGCMFunctionParameter *pParm = (pCtx->uProtocol >= 3)
    17241792                                     ? &Msg.u.v3.pvData
    17251793                                     : &Msg.u.v1.pvData;
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