Changeset 56909 in vbox for trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
- Timestamp:
- Jul 10, 2015 6:09:14 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r56657 r56909 756 756 } 757 757 758 int GuestDnDTarget::i_sendDirectory(PSENDDATACTX pCtx, GuestDnDMsg *pMsg, DnDURIObject &aDirectory) 759 { 760 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 761 762 RTCString strPath = aDirectory.GetDestPath(); 758 int GuestDnDTarget::i_sendDirectory(PSENDDATACTX pCtx, GuestDnDMsg *pMsg, DnDURIObject *pObject) 759 { 760 AssertPtrReturn(pObject, VERR_INVALID_POINTER); 761 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 762 763 RTCString strPath = pObject->GetDestPath(); 763 764 if (strPath.isEmpty()) 764 765 return VERR_INVALID_PARAMETER; … … 771 772 pMsg->setNextString(strPath.c_str()); /* path */ 772 773 pMsg->setNextUInt32((uint32_t)(strPath.length() + 1)); /* path length - note: Maximum is RTPATH_MAX on guest side. */ 773 pMsg->setNextUInt32( aDirectory.GetMode()); /* mode */774 pMsg->setNextUInt32(pObject->GetMode()); /* mode */ 774 775 775 776 return VINF_SUCCESS; 776 777 } 777 778 778 int GuestDnDTarget::i_sendFile(PSENDDATACTX pCtx, GuestDnDMsg *pMsg, DnDURIObject &aFile) 779 { 780 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 781 782 RTCString strPathSrc = aFile.GetSourcePath(); 779 int GuestDnDTarget::i_sendFile(PSENDDATACTX pCtx, GuestDnDMsg *pMsg, DnDURIObject *pObject) 780 { 781 AssertPtrReturn(pObject, VERR_INVALID_POINTER); 782 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 783 784 RTCString strPathSrc = pObject->GetSourcePath(); 783 785 if (strPathSrc.isEmpty()) 784 786 return VERR_INVALID_PARAMETER; … … 789 791 strPathSrc.c_str(), mData.mcbBlockSize, mDataBase.mProtocolVersion)); 790 792 791 bool fOpen = aFile.IsOpen();793 bool fOpen = pObject->IsOpen(); 792 794 if (!fOpen) 793 795 { 794 796 LogFlowFunc(("Opening \"%s\" ...\n", strPathSrc.c_str())); 795 rc = aFile.OpenEx(strPathSrc, DnDURIObject::File, DnDURIObject::Source,797 rc = pObject->OpenEx(strPathSrc, DnDURIObject::File, DnDURIObject::Source, 796 798 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 0 /* fFlags */); 797 799 if (RT_FAILURE(rc)) … … 813 815 pMsg->setType(DragAndDropSvc::HOST_DND_HG_SND_FILE_HDR); 814 816 pMsg->setNextUInt32(0); /* context ID */ 815 rc = pMsg->setNextString( aFile.GetDestPath().c_str()); /* pvName */817 rc = pMsg->setNextString(pObject->GetDestPath().c_str()); /* pvName */ 816 818 AssertRC(rc); 817 pMsg->setNextUInt32((uint32_t)( aFile.GetDestPath().length() + 1)); /* cbName */819 pMsg->setNextUInt32((uint32_t)(pObject->GetDestPath().length() + 1)); /* cbName */ 818 820 pMsg->setNextUInt32(0); /* uFlags */ 819 pMsg->setNextUInt32( aFile.GetMode()); /* fMode */820 pMsg->setNextUInt64( aFile.GetSize()); /* uSize */821 pMsg->setNextUInt32(pObject->GetMode()); /* fMode */ 822 pMsg->setNextUInt64(pObject->GetSize()); /* uSize */ 821 823 822 824 LogFlowFunc(("Sending file header ...\n")); 823 825 LogRel2(("DnD: Transferring host file to guest: %s (%RU64 bytes, mode 0x%x)\n", 824 strPathSrc.c_str(), aFile.GetSize(), aFile.GetMode()));826 strPathSrc.c_str(), pObject->GetSize(), pObject->GetMode())); 825 827 826 828 /** @todo Set progress object title to current file being transferred? */ … … 842 844 && fSendFileData) 843 845 { 844 rc = i_sendFileData(pCtx, pMsg, aFile);846 rc = i_sendFileData(pCtx, pMsg, pObject); 845 847 } 846 848 … … 849 851 } 850 852 851 int GuestDnDTarget::i_sendFileData(PSENDDATACTX pCtx, GuestDnDMsg *pMsg, DnDURIObject &aFile) 852 { 853 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 854 AssertPtrReturn(pMsg, VERR_INVALID_POINTER); 853 int GuestDnDTarget::i_sendFileData(PSENDDATACTX pCtx, GuestDnDMsg *pMsg, DnDURIObject *pObject) 854 { 855 AssertPtrReturn(pObject, VERR_INVALID_POINTER); 856 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 857 AssertPtrReturn(pMsg, VERR_INVALID_POINTER); 855 858 856 859 GuestDnDResponse *pResp = pCtx->mpResp; … … 877 880 if (mDataBase.mProtocolVersion <= 1) 878 881 { 879 pMsg->setNextString( aFile.GetDestPath().c_str()); /* pvName */880 pMsg->setNextUInt32((uint32_t)( aFile.GetDestPath().length() + 1)); /* cbName */882 pMsg->setNextString(pObject->GetDestPath().c_str()); /* pvName */ 883 pMsg->setNextUInt32((uint32_t)(pObject->GetDestPath().length() + 1)); /* cbName */ 881 884 } 882 885 else … … 888 891 uint32_t cbRead = 0; 889 892 890 int rc = aFile.Read(pCtx->mURI.pvScratchBuf, pCtx->mURI.cbScratchBuf, &cbRead);893 int rc = pObject->Read(pCtx->mURI.pvScratchBuf, pCtx->mURI.cbScratchBuf, &cbRead); 891 894 if (RT_SUCCESS(rc)) 892 895 { … … 897 900 pMsg->setNextPointer(pCtx->mURI.pvScratchBuf, cbRead); /* pvData */ 898 901 pMsg->setNextUInt32(cbRead); /* cbData */ 899 pMsg->setNextUInt32( aFile.GetMode()); /* fMode */902 pMsg->setNextUInt32(pObject->GetMode()); /* fMode */ 900 903 } 901 904 else … … 905 908 } 906 909 907 if ( aFile.IsComplete()) /* Done reading? */908 { 909 LogRel2(("DnD: File transfer to guest complete: %s\n", aFile.GetSourcePath().c_str()));910 LogFlowFunc(("File \"%s\" complete\n", aFile.GetSourcePath().c_str()));910 if (pObject->IsComplete()) /* Done reading? */ 911 { 912 LogRel2(("DnD: File transfer to guest complete: %s\n", pObject->GetSourcePath().c_str())); 913 LogFlowFunc(("File \"%s\" complete\n", pObject->GetSourcePath().c_str())); 911 914 rc = VINF_EOF; 912 915 } … … 1261 1264 1262 1265 Assert(!lstURI.IsEmpty()); 1263 DnDURIObject &curObj = lstURI.First();1264 1265 uint32_t fMode = curObj.GetMode();1266 DnDURIObject *pCurObj = lstURI.First(); 1267 1268 uint32_t fMode = pCurObj->GetMode(); 1266 1269 LogFlowFunc(("Processing srcPath=%s, dstPath=%s, fMode=0x%x, cbSize=%RU32, fIsDir=%RTbool, fIsFile=%RTbool\n", 1267 curObj.GetSourcePath().c_str(), curObj.GetDestPath().c_str(),1268 fMode, curObj.GetSize(),1270 pCurObj->GetSourcePath().c_str(), pCurObj->GetDestPath().c_str(), 1271 fMode, pCurObj->GetSize(), 1269 1272 RTFS_IS_DIRECTORY(fMode), RTFS_IS_FILE(fMode))); 1270 1273 1271 1274 if (RTFS_IS_DIRECTORY(fMode)) 1272 1275 { 1273 rc = i_sendDirectory(pCtx, pMsg, curObj);1276 rc = i_sendDirectory(pCtx, pMsg, pCurObj); 1274 1277 } 1275 1278 else if (RTFS_IS_FILE(fMode)) 1276 1279 { 1277 rc = i_sendFile(pCtx, pMsg, curObj);1280 rc = i_sendFile(pCtx, pMsg, pCurObj); 1278 1281 } 1279 1282 else 1280 1283 { 1281 1284 AssertMsgFailed(("fMode=0x%x is not supported for srcPath=%s, dstPath=%s\n", 1282 fMode, curObj.GetSourcePath().c_str(), curObj.GetDestPath().c_str()));1285 fMode, pCurObj->GetSourcePath().c_str(), pCurObj->GetDestPath().c_str())); 1283 1286 rc = VERR_NOT_SUPPORTED; 1284 1287 } 1285 1288 1286 1289 bool fRemove = false; /* Remove current entry? */ 1287 if ( curObj.IsComplete()1290 if ( pCurObj->IsComplete() 1288 1291 || RT_FAILURE(rc)) 1289 1292 { … … 1293 1296 if (fRemove) 1294 1297 { 1295 LogFlowFunc(("Removing \"%s\" from list, rc=%Rrc\n", curObj.GetSourcePath().c_str(), rc));1298 LogFlowFunc(("Removing \"%s\" from list, rc=%Rrc\n", pCurObj->GetSourcePath().c_str(), rc)); 1296 1299 lstURI.RemoveFirst(); 1297 1300 }
Note:
See TracChangeset
for help on using the changeset viewer.