Changeset 59848 in vbox
- Timestamp:
- Feb 26, 2016 12:53:19 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r58404 r59848 5 5 6 6 /* 7 * Copyright (C) 2011-201 5Oracle Corporation7 * Copyright (C) 2011-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 640 640 } 641 641 else 642 { 643 AssertMsgFailed(("ObjType=%RU32, Proto=%RU32\n", objFile.GetType(), pCtx->uProtocol)); 642 644 rc = VERR_WRONG_ORDER; 645 } 643 646 644 647 RTStrFree(pszPathAbs); … … 651 654 && uNextMsg == HOST_DND_HG_SND_FILE_DATA) 652 655 { 653 bool fClose = false;654 655 656 uint32_t cbChunkWritten; 656 657 rc = objFile.Write(pvChunk, cbChunkRead, &cbChunkWritten); … … 661 662 cbChunkRead, cbChunkWritten, cbFileWritten + cbChunkWritten, cbFileSize)); 662 663 663 if (pCtx->uProtocol >= 2) 664 cbFileWritten += cbChunkWritten; 665 666 if (fDoAccounting) 664 667 { 665 /* Data transfer complete? Close the file. */ 666 fClose = objFile.IsComplete(); 667 if ( fClose 668 && fDoAccounting) 669 { 670 Assert(cToRecvObjs); 671 cToRecvObjs--; 672 } 673 674 /* Only since protocol v2 we know the file size upfront. */ 675 Assert(cbFileWritten <= cbFileSize); 676 } 677 else 678 fClose = true; /* Always close the file after each chunk. */ 679 680 cbFileWritten += cbChunkWritten; 681 682 if (pCtx->uProtocol >= 3) 683 { 684 Assert(cbToRecvBytes >= cbChunkRead); 668 Assert(cbChunkRead <= cbToRecvBytes); 685 669 cbToRecvBytes -= cbChunkRead; 686 670 } 687 671 } 688 689 if (fClose) 672 } 673 674 bool fClose = false; 675 if (pCtx->uProtocol >= 2) 676 { 677 /* Data transfer complete? Close the file. */ 678 fClose = objFile.IsComplete(); 679 if ( fClose 680 && fDoAccounting) 690 681 { 691 LogFlowFunc(("Closing file\n"));692 objFile.Close();682 Assert(cToRecvObjs); 683 cToRecvObjs--; 693 684 } 685 686 /* Only since protocol v2 we know the file size upfront. */ 687 Assert(cbFileWritten <= cbFileSize); 694 688 } 689 else 690 fClose = true; /* Always close the file after each chunk. */ 691 692 if (fClose) 693 { 694 LogFlowFunc(("Closing file\n")); 695 objFile.Close(); 696 } 697 695 698 break; 696 699 } … … 741 744 { 742 745 objFile.Close(); 743 744 int rc2 = pDroppedFiles->Rollback(); 745 AssertRC(rc2); /* Not fatal, don't report back to host. */ 746 pDroppedFiles->Rollback(); 746 747 } 747 748 else … … 1201 1202 1202 1203 int rc2 = VbglR3DnDHGSendProgress(pCtx, DND_PROGRESS_ERROR, 100 /* Percent */, rc); 1203 AssertRC(rc2); 1204 if (RT_FAILURE(rc2)) 1205 LogFlowFunc(("Unable to send progress error %Rrc to host: %Rrc\n", rc, rc2)); 1204 1206 } 1205 1207 else if (RT_SUCCESS(rc)) … … 1419 1421 Msg.hdr.cParms = 3; 1420 1422 1421 1423 /** @todo Context ID not used yet. */ 1422 1424 Msg.u.v3.uContext.SetUInt32(0); 1423 1425 Msg.u.v3.uProtocol.SetUInt32(pCtx->uProtocol); … … 1711 1713 1712 1714 if (!RTStrIsValidEncoding(pcszFormats)) 1713 return VERR_INVALID_ PARAMETER;1715 return VERR_INVALID_UTF8_ENCODING; 1714 1716 1715 1717 VBOXDNDGHACKPENDINGMSG Msg; … … 1786 1788 rc = Msg.hdr.result; 1787 1789 1788 LogFlowFunc(("cbTotal=%RU64, cbMeta=%RU 64, cObjects=%RU64, rc=%Rrc\n",1790 LogFlowFunc(("cbTotal=%RU64, cbMeta=%RU32, cObjects=%RU64, rc=%Rrc\n", 1789 1791 pDataHdr->cbTotal, pDataHdr->cbMeta, pDataHdr->cObjects, rc)); 1790 1792 } … … 1839 1841 } 1840 1842 1843 LogFlowFunc(("cbMaxChunk=%RU32, cbData=%RU64, cbSent=%RU32, rc=%Rrc\n", 1844 cbMaxChunk, cbData, cbSent, rc)); 1845 1841 1846 if (RT_SUCCESS(rc)) 1842 1847 Assert(cbSent == cbData); 1843 1848 } 1844 1849 1845 LogFlowFunc (("Returning rc=%Rrc, cbData=%RU64\n", rc, cbData));1850 LogFlowFuncLeaveRC(rc); 1846 1851 return rc; 1847 1852 } … … 2073 2078 } 2074 2079 2075 static int vbglR3DnDGHSendURIData(PVBGLR3GUESTDNDCMDCTX pCtx, 2076 const void *pvData, uint32_t cbData) 2080 static int vbglR3DnDGHSendRawData(PVBGLR3GUESTDNDCMDCTX pCtx, void *pvData, size_t cbData) 2081 { 2082 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 2083 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 2084 /* cbData can be 0. */ 2085 2086 VBOXDNDDATAHDR dataHdr; 2087 RT_ZERO(dataHdr); 2088 2089 /* For raw data only the total size is required to be specified. */ 2090 dataHdr.cbTotal = cbData; 2091 2092 return vbglR3DnDGHSendDataInternal(pCtx, pvData, cbData, &dataHdr); 2093 } 2094 2095 static int vbglR3DnDGHSendURIData(PVBGLR3GUESTDNDCMDCTX pCtx, const void *pvData, size_t cbData) 2077 2096 { 2078 2097 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 2109 2128 const uint32_t cbMetaFmt = (uint32_t)strlen(szMetaFmt) + 1; /* Include termination. */ 2110 2129 2111 VBOXDNDDATAHDR dataH eader;2112 dataH eader.uFlags = 0; /* Flags not used yet. */2113 dataH eader.cbTotal = cbTotal;2114 dataH eader.cbMeta = cbURLIist;2115 dataH eader.pvMetaFmt = (void *)szMetaFmt;2116 dataH eader.cbMetaFmt = cbMetaFmt;2117 dataH eader.cObjects = lstURI.TotalCount();2130 VBOXDNDDATAHDR dataHdr; 2131 dataHdr.uFlags = 0; /* Flags not used yet. */ 2132 dataHdr.cbTotal = cbTotal; 2133 dataHdr.cbMeta = cbURLIist; 2134 dataHdr.pvMetaFmt = (void *)szMetaFmt; 2135 dataHdr.cbMetaFmt = cbMetaFmt; 2136 dataHdr.cObjects = lstURI.TotalCount(); 2118 2137 2119 2138 rc = vbglR3DnDGHSendDataInternal(pCtx, 2120 pvURIList, cbURLIist, &dataH eader);2139 pvURIList, cbURLIist, &dataHdr); 2121 2140 } 2122 2141 else … … 2153 2172 if (DnDMIMEHasFileURLs(pszFormat, strlen(pszFormat))) 2154 2173 { 2174 /* Send file data. */ 2155 2175 rc = vbglR3DnDGHSendURIData(pCtx, pvData, cbData); 2156 2176 } 2157 else /* Send raw data. */ 2158 { 2159 rc = vbglR3DnDGHSendDataInternal(pCtx, pvData, cbData, NULL /* pDataHdr */); 2160 } 2177 else 2178 rc = vbglR3DnDGHSendRawData(pCtx, pvData, cbData); 2161 2179 2162 2180 if (RT_FAILURE(rc)) … … 2197 2215 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 2198 2216 if (RT_SUCCESS(rc)) 2199 rc = Msg.hdr.result; 2200 2201 if (RT_FAILURE(rc)) 2202 LogFlowFunc(("Sending error %Rrc failed with rc=%Rrc\n", rcErr, rc)); 2217 { 2218 if (RT_FAILURE(Msg.hdr.result)) 2219 { 2220 LogFlowFunc(("Sending error %Rrc failed with rc=%Rrc\n", rcErr, Msg.hdr.result)); 2221 2222 /* Never return an error if the host did not accept the error at 2223 * the current time. This can be due to the host not having any appropriate 2224 * callbacks set which would handle that error. */ 2225 rc = VINF_SUCCESS; 2226 } 2227 } 2228 2203 2229 return rc; 2204 2230 }
Note:
See TracChangeset
for help on using the changeset viewer.