Changeset 58329 in vbox for trunk/src/VBox/Additions/common/VBoxGuestLib
- Timestamp:
- Oct 20, 2015 10:05:12 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103528
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r58257 r58329 131 131 Msg.u.v1.uAllActions.SetUInt32(0); 132 132 Msg.u.v1.pvFormats.SetPtr(pszFormats, cbFormats); 133 Msg.u.v1.c Formats.SetUInt32(0);133 Msg.u.v1.cbFormats.SetUInt32(0); 134 134 } 135 135 else … … 144 144 Msg.u.v3.uAllActions.SetUInt32(0); 145 145 Msg.u.v3.pvFormats.SetPtr(pszFormats, cbFormats); 146 Msg.u.v3.c Formats.SetUInt32(0);146 Msg.u.v3.cbFormats.SetUInt32(0); 147 147 } 148 148 … … 160 160 rc = Msg.u.v1.uDefAction.GetUInt32(puDefAction); AssertRC(rc); 161 161 rc = Msg.u.v1.uAllActions.GetUInt32(puAllActions); AssertRC(rc); 162 rc = Msg.u.v1.c Formats.GetUInt32(pcbFormatsRecv);AssertRC(rc);162 rc = Msg.u.v1.cbFormats.GetUInt32(pcbFormatsRecv); AssertRC(rc); 163 163 } 164 164 else … … 170 170 rc = Msg.u.v3.uDefAction.GetUInt32(puDefAction); AssertRC(rc); 171 171 rc = Msg.u.v3.uAllActions.GetUInt32(puAllActions); AssertRC(rc); 172 rc = Msg.u.v3.c Formats.GetUInt32(pcbFormatsRecv);AssertRC(rc);172 rc = Msg.u.v3.cbFormats.GetUInt32(pcbFormatsRecv); AssertRC(rc); 173 173 } 174 174 … … 447 447 } 448 448 449 static int vbglR3DnDHGRecvURIData(PVBGLR3GUESTDNDCMDCTX pCtx, DnDDroppedFiles *pDroppedFiles)449 static int vbglR3DnDHGRecvURIData(PVBGLR3GUESTDNDCMDCTX pCtx, PVBOXDNDSNDDATAHDR pDataHdr, DnDDroppedFiles *pDroppedFiles) 450 450 { 451 451 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 452 AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER); 452 453 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 } 453 479 454 480 /* … … 484 510 char szPathName[RTPATH_MAX] = { 0 }; 485 511 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 491 526 uint32_t uNextMsg; 492 527 uint32_t cNextParms; 493 rc = vbglR3DnDGetNextMsgType(pCtx, &uNextMsg, &cNextParms, f alse /* fWait */);528 rc = vbglR3DnDGetNextMsgType(pCtx, &uNextMsg, &cNextParms, fWait); 494 529 if (RT_SUCCESS(rc)) 495 530 { … … 519 554 if (RT_SUCCESS(rc)) 520 555 rc = pDroppedFiles->AddDir(pszPathAbs); 556 557 if ( RT_SUCCESS(rc) 558 && fDoAccounting) 559 { 560 Assert(cToRecvObjs); 561 cToRecvObjs--; 562 } 521 563 522 564 RTStrFree(pszPathAbs); … … 623 665 /* Data transfer complete? Close the file. */ 624 666 fClose = objFile.IsComplete(); 667 if ( fClose 668 && fDoAccounting) 669 { 670 Assert(cToRecvObjs); 671 cToRecvObjs--; 672 } 625 673 626 674 /* Only since protocol v2 we know the file size upfront. */ … … 631 679 632 680 cbFileWritten += cbChunkWritten; 681 682 if (pCtx->uProtocol >= 3) 683 { 684 Assert(cbToRecvBytes >= cbChunkRead); 685 cbToRecvBytes -= cbChunkRead; 686 } 633 687 } 634 688 … … 660 714 break; 661 715 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)); 663 727 664 728 LogFlowFunc(("Loop ended with %Rrc\n", rc)); … … 723 787 uint32_t cbDataRecv; 724 788 725 if (pCtx->uProtocol < 3) /* For VBox < 5.0.8. */789 if (pCtx->uProtocol < 3) 726 790 { 727 791 Msg.hdr.cParms = 5; … … 901 965 uint32_t cbDataRecv; 902 966 903 if (pCtx->uProtocol < 3) /* For VBox < 5.0.8. */ 967 LogFlowFuncEnter(); 968 969 if (pCtx->uProtocol < 3) 904 970 { 905 971 uint64_t cbDataTmp = pCtx->cbMaxChunkSize; … … 979 1045 RTMemFree(pvDataTmp); 980 1046 } 981 else /* Protocol v3 and up. Since VBox 5.0.8.*/1047 else /* Protocol v3 and up. */ 982 1048 { 983 1049 rc = vbglR3DnDHGRecvDataHdr(pCtx, pDataHdr); 984 1050 if (RT_SUCCESS(rc)) 985 1051 { 986 LogFlowFunc(("cb Meta=%RU32\n", pDataHdr->cbMeta));1052 LogFlowFunc(("cbTotal=%RU64, cbMeta=%RU32\n", pDataHdr->cbTotal, pDataHdr->cbMeta)); 987 1053 if (pDataHdr->cbMeta) 988 1054 { … … 1086 1152 rc = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */); 1087 1153 if (RT_SUCCESS(rc)) 1088 rc = vbglR3DnDHGRecvURIData(pCtx, &d roppedFiles);1154 rc = vbglR3DnDHGRecvURIData(pCtx, &dataHdr, &droppedFiles); 1089 1155 1090 1156 if (RT_SUCCESS(rc)) /** @todo Remove this block as soon as we hand in DnDURIList. */ … … 1506 1572 Msg.hdr.u32Function = GUEST_DND_HG_ACK_OP; 1507 1573 1574 LogFlowFunc(("uProto=%RU32\n", pCtx->uProtocol)); 1575 1508 1576 if (pCtx->uProtocol < 3) 1509 1577 { … … 1660 1728 1661 1729 /* For protocol v3 and up we need to send the data header first. */ 1662 if (pCtx->uProtocol > 2)1730 if (pCtx->uProtocol >= 3) 1663 1731 { 1664 1732 AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER); … … 1675 1743 Msg.uScreenId.SetUInt32(0); /** @todo Not used for guest->host (yet). */ 1676 1744 Msg.cbTotal.SetUInt64(pDataHdr->cbTotal); 1677 Msg.cbMeta.SetUInt 64(pDataHdr->cbMeta);1745 Msg.cbMeta.SetUInt32(pDataHdr->cbMeta); 1678 1746 Msg.pvMetaFmt.SetPtr(pDataHdr->pvMetaFmt, pDataHdr->cbMetaFmt); 1679 1747 Msg.cbMetaFmt.SetUInt32(pDataHdr->cbMetaFmt); … … 1700 1768 Msg.hdr.u32Function = GUEST_DND_GH_SND_DATA; 1701 1769 1702 if (pCtx->uProtocol > 2)1770 if (pCtx->uProtocol >= 3) 1703 1771 { 1704 1772 Msg.hdr.cParms = 5; … … 1721 1789 uint32_t cbSent = 0; 1722 1790 1723 HGCMFunctionParameter *pParm = (pCtx->uProtocol > 2)1791 HGCMFunctionParameter *pParm = (pCtx->uProtocol >= 3) 1724 1792 ? &Msg.u.v3.pvData 1725 1793 : &Msg.u.v1.pvData;
Note:
See TracChangeset
for help on using the changeset viewer.