Changeset 55520 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Apr 29, 2015 12:51:40 PM (10 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp
r55514 r55520 78 78 , mpCtx(pCtx) { } 79 79 80 virtual ~RecvDataTask(void) 81 { 82 if (mpCtx) 83 { 84 delete mpCtx; 85 mpCtx = NULL; 86 } 87 } 80 virtual ~RecvDataTask(void) { } 88 81 89 82 PRECVDATACTX getCtx(void) { return mpCtx; } … … 106 99 /* Note: Never ever rely on information from the guest; the host dictates what and 107 100 * how to do something, so try to negogiate a sensible value here later. */ 108 m_cbBlockSize = _64K; /** @todo Make this configurable. */ 101 mData.mcbBlockSize = _64K; /** @todo Make this configurable. */ 102 mData.mfDropIsPending = false; 109 103 110 104 LogFlowThisFunc(("\n")); … … 247 241 248 242 /* Determine guest DnD protocol to use. */ 249 GuestDnDBase::getProtocolVersion(&mData .mProtocolVersion);243 GuestDnDBase::getProtocolVersion(&mDataBase.mProtocolVersion); 250 244 251 245 /* Default is ignoring the action. */ … … 254 248 HRESULT hr = S_OK; 255 249 256 VBOXHGCMSVCPARM paParms[1];257 int i = 0;258 paParms[i++].setUInt32(uScreenId);259 260 int rc = GuestDnDInst()->hostCall( DragAndDropSvc::HOST_DND_GH_REQ_PENDING, i, paParms);250 GuestDnDMsg Msg; 251 Msg.setType(DragAndDropSvc::HOST_DND_GH_REQ_PENDING); 252 Msg.setNextUInt32(uScreenId); 253 254 int rc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms()); 261 255 if (RT_SUCCESS(rc)) 262 256 { … … 313 307 return S_OK; 314 308 309 if (ASMAtomicReadBool(&mData.mfDropIsPending)) 310 return setError(E_INVALIDARG, tr("Another drop operation already is in progress")); 311 312 ASMAtomicWriteBool(&mData.mfDropIsPending, true); 313 315 314 HRESULT hr = S_OK; 316 315 … … 325 324 try 326 325 { 327 PRECVDATACTX pRecvCtx = new RECVDATACTX; 328 RT_BZERO(pRecvCtx, sizeof(RECVDATACTX)); 329 330 pRecvCtx->mpSource = this; 331 pRecvCtx->mpResp = pResp; 332 pRecvCtx->mFormat = aFormat; 333 334 RecvDataTask *pTask = new RecvDataTask(this, pRecvCtx); 326 mData.mRecvCtx.mpSource = this; 327 mData.mRecvCtx.mpResp = pResp; 328 mData.mRecvCtx.mFormat = aFormat; 329 330 RecvDataTask *pTask = new RecvDataTask(this, &mData.mRecvCtx); 335 331 AssertReturn(pTask->isOk(), pTask->getRC()); 336 332 … … 344 340 /* Note: pTask is now owned by the worker thread. */ 345 341 } 346 else if (pRecvCtx)347 delete pRecvCtx;348 342 } 349 343 catch(std::bad_alloc &) … … 355 349 } 356 350 /** @todo SetError(...) */ 351 352 ASMAtomicWriteBool(&mData.mfDropIsPending, false); 357 353 358 354 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); … … 372 368 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 373 369 370 if (ASMAtomicReadBool(&mData.mfDropIsPending)) 371 return setError(E_INVALIDARG, tr("Current drop operation still running")); 372 373 PRECVDATACTX pCtx = &mData.mRecvCtx; 374 375 if (pCtx->mData.vecData.empty()) 376 { 377 aData.resize(0); 378 return S_OK; 379 } 380 374 381 HRESULT hr = S_OK; 375 376 #if 0 377 GuestDnDResponse *pResp = GuestDnDInst()->response(); 378 if (pResp) 379 { 380 size_t cbData = pResp->size(); 381 if (cbData) 382 { 383 const void *pvData = pResp->data(); 384 AssertPtr(pvData); 385 386 Utf8Str strFormat = pResp->format(); 387 LogFlowFunc(("strFormat=%s, cbData=%zu, pvData=0x%p\n", strFormat.c_str(), cbData, pvData)); 388 389 try 390 { 391 if (DnDMIMEHasFileURLs(strFormat.c_str(), strFormat.length())) 392 { 393 LogFlowFunc(("strDropDir=%s\n", pResp->dropDir().c_str())); 394 395 DnDURIList lstURI; 396 int rc2 = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */); 397 if (RT_SUCCESS(rc2)) 398 { 399 Utf8Str strURIs = lstURI.RootToString(pResp->dropDir()); 400 size_t cbURIs = strURIs.length(); 401 402 LogFlowFunc(("Found %zu root URIs (%zu bytes)\n", lstURI.RootCount(), cbURIs)); 403 404 aData.resize(cbURIs + 1 /* Include termination */); 405 memcpy(&aData.front(), strURIs.c_str(), cbURIs); 406 } 407 else 408 hr = VBOX_E_IPRT_ERROR; 409 } 410 else 411 { 412 /* Copy the data into a safe array of bytes. */ 413 aData.resize(cbData); 414 memcpy(&aData.front(), pvData, cbData); 415 } 416 } 417 catch (std::bad_alloc &) 418 { 419 hr = E_OUTOFMEMORY; 420 } 421 } 422 423 /* Delete the data. */ 424 pResp->reset(); 425 } 426 else 427 hr = VBOX_E_INVALID_OBJECT_STATE; 428 #endif 429 430 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); 382 size_t cbData; 383 384 try 385 { 386 bool fHasURIList = DnDMIMENeedsDropDir(pCtx->mFormat.c_str(), pCtx->mFormat.length()); 387 if (fHasURIList) 388 { 389 Utf8Str strURIs = pCtx->mURI.lstURI.RootToString(pCtx->mURI.strDropDir); 390 cbData = strURIs.length(); 391 392 LogFlowFunc(("Found %zu root URIs (%zu bytes)\n", pCtx->mURI.lstURI.RootCount(), cbData)); 393 394 aData.resize(cbData + 1 /* Include termination */); 395 memcpy(&aData.front(), strURIs.c_str(), cbData); 396 } 397 else 398 { 399 cbData = pCtx->mData.vecData.size(); 400 401 /* Copy the data into a safe array of bytes. */ 402 aData.resize(cbData); 403 memcpy(&aData.front(), &pCtx->mData.vecData[0], cbData); 404 } 405 } 406 catch (std::bad_alloc &) 407 { 408 hr = E_OUTOFMEMORY; 409 } 410 411 LogFlowFunc(("Returning cbData=%zu, hr=%Rhrc\n", cbData, hr)); 431 412 return hr; 432 413 #endif /* VBOX_WITH_DRAG_AND_DROP */ … … 451 432 { 452 433 if ( cbData > cbTotalSize 453 || cbData > m _cbBlockSize)434 || cbData > mData.mcbBlockSize) 454 435 { 455 436 LogFlowFunc(("Data sizes invalid: cbData=%RU32, cbTotalSize=%RU64\n", cbData, cbTotalSize)); … … 586 567 587 568 /* Note: Protocol v1 does not send any file sizes, so always 0. */ 588 if (mData .mProtocolVersion >= 2)569 if (mDataBase.mProtocolVersion >= 2) 589 570 rc = pCtx->mURI.objURI.SetSize(cbSize); 590 571 } … … 645 626 if (pCtx->mURI.objURI.IsComplete()) 646 627 { 647 /* Prepare URI object for next use. */648 pCtx->mURI.objURI.Reset();649 650 628 /** @todo Sanitize path. */ 651 629 LogRel2(("DnD: File transfer to host complete: %s\n", pCtx->mURI.objURI.GetDestPath().c_str())); 652 630 rc = VINF_EOF; 631 632 /* Prepare URI object for next use. */ 633 pCtx->mURI.objURI.Reset(); 653 634 } 654 635 } … … 839 820 REGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_DATA); 840 821 REGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_DIR); 841 if (mData .mProtocolVersion >= 2)822 if (mDataBase.mProtocolVersion >= 2) 842 823 REGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_FILE_HDR); 843 824 REGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_FILE_DATA); … … 884 865 UNREGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_DATA); 885 866 UNREGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_DIR); 886 if (mData .mProtocolVersion >= 2)867 if (mDataBase.mProtocolVersion >= 2) 887 868 UNREGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_FILE_HDR); 888 869 UNREGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_SND_FILE_DATA); … … 1024 1005 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_GH_SND_FILE_DATA == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER); 1025 1006 1026 if (pThis->mData .mProtocolVersion <= 1)1007 if (pThis->mDataBase.mProtocolVersion <= 1) 1027 1008 { 1028 1009 /** -
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r55514 r55520 111 111 /* Note: Never ever rely on information from the guest; the host dictates what and 112 112 * how to do something, so try to negogiate a sensible value here later. */ 113 m _cbBlockSize = _64K; /** @todo Make this configurable. */113 mData.mcbBlockSize = _64K; /** @todo Make this configurable. */ 114 114 115 115 LogFlowThisFunc(("\n")); … … 261 261 262 262 /* Determine guest DnD protocol to use. */ 263 GuestDnDBase::getProtocolVersion(&mData .mProtocolVersion);263 GuestDnDBase::getProtocolVersion(&mDataBase.mProtocolVersion); 264 264 265 265 /* Default action is ignoring. */ … … 287 287 if (RT_SUCCESS(rc)) 288 288 { 289 VBOXHGCMSVCPARM paParms[8]; 290 int i = 0; 291 paParms[i++].setUInt32(aScreenId); 292 paParms[i++].setUInt32(aX); 293 paParms[i++].setUInt32(aY); 294 paParms[i++].setUInt32(uDefAction); 295 paParms[i++].setUInt32(uAllowedActions); 296 paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1); 297 paParms[i++].setUInt32(strFormats.length() + 1); 298 299 rc = GuestDnDInst()->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_ENTER, 300 i, paParms); 289 GuestDnDMsg Msg; 290 Msg.setType(DragAndDropSvc::HOST_DND_HG_EVT_ENTER); 291 Msg.setNextUInt32(aScreenId); 292 Msg.setNextUInt32(aX); 293 Msg.setNextUInt32(aY); 294 Msg.setNextUInt32(uDefAction); 295 Msg.setNextUInt32(uAllowedActions); 296 Msg.setNextPointer((void*)strFormats.c_str(), strFormats.length() + 1); 297 Msg.setNextUInt32(strFormats.length() + 1); 298 299 rc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms()); 301 300 if (RT_SUCCESS(rc)) 302 301 { … … 353 352 if (RT_SUCCESS(rc)) 354 353 { 355 VBOXHGCMSVCPARM paParms[8]; 356 int i = 0; 357 paParms[i++].setUInt32(aScreenId); 358 paParms[i++].setUInt32(aX); 359 paParms[i++].setUInt32(aY); 360 paParms[i++].setUInt32(uDefAction); 361 paParms[i++].setUInt32(uAllowedActions); 362 paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1); 363 paParms[i++].setUInt32(strFormats.length() + 1); 364 365 rc = GuestDnDInst()->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_MOVE, 366 i, paParms); 354 GuestDnDMsg Msg; 355 Msg.setType(DragAndDropSvc::HOST_DND_HG_EVT_MOVE); 356 Msg.setNextUInt32(aScreenId); 357 Msg.setNextUInt32(aX); 358 Msg.setNextUInt32(aY); 359 Msg.setNextUInt32(uDefAction); 360 Msg.setNextUInt32(uAllowedActions); 361 Msg.setNextPointer((void*)strFormats.c_str(), strFormats.length() + 1); 362 Msg.setNextUInt32(strFormats.length() + 1); 363 364 rc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms()); 367 365 if (RT_SUCCESS(rc)) 368 366 { … … 446 444 if (RT_SUCCESS(rc)) 447 445 { 448 VBOXHGCMSVCPARM paParms[8]; 449 int i = 0; 450 paParms[i++].setUInt32(aScreenId); 451 paParms[i++].setUInt32(aX); 452 paParms[i++].setUInt32(aY); 453 paParms[i++].setUInt32(uDefAction); 454 paParms[i++].setUInt32(uAllowedActions); 455 paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1); 456 paParms[i++].setUInt32(strFormats.length() + 1); 457 458 rc = GuestDnDInst()->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_DROPPED, 459 i, paParms); 446 GuestDnDMsg Msg; 447 Msg.setType(DragAndDropSvc::HOST_DND_HG_EVT_DROPPED); 448 Msg.setNextUInt32(aScreenId); 449 Msg.setNextUInt32(aX); 450 Msg.setNextUInt32(aY); 451 Msg.setNextUInt32(uDefAction); 452 Msg.setNextUInt32(uAllowedActions); 453 Msg.setNextPointer((void*)strFormats.c_str(), strFormats.length() + 1); 454 Msg.setNextUInt32(strFormats.length() + 1); 455 456 rc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms()); 460 457 if (RT_SUCCESS(rc)) 461 458 { … … 669 666 return VERR_BUFFER_OVERFLOW; 670 667 671 LogFlowFunc(("Sending directory \"%s\" using protocol v%RU32 ...\n", strPath.c_str(), mData .mProtocolVersion));668 LogFlowFunc(("Sending directory \"%s\" using protocol v%RU32 ...\n", strPath.c_str(), mDataBase.mProtocolVersion)); 672 669 673 670 pMsg->setType(DragAndDropSvc::HOST_DND_HG_SND_DIR); … … 690 687 691 688 LogFlowFunc(("Sending \"%s\" (%RU32 bytes buffer) using protocol v%RU32 ...\n", 692 strPathSrc.c_str(), m _cbBlockSize, mData.mProtocolVersion));689 strPathSrc.c_str(), mData.mcbBlockSize, mDataBase.mProtocolVersion)); 693 690 694 691 bool fOpen = aFile.IsOpen(); … … 703 700 if (RT_SUCCESS(rc)) 704 701 { 705 if (mData .mProtocolVersion >= 2)702 if (mDataBase.mProtocolVersion >= 2) 706 703 { 707 704 if (!fOpen) … … 772 769 /* Protocol version 1 sends the file path *every* time with a new file chunk. 773 770 * In protocol version 2 we only do this once with HOST_DND_HG_SND_FILE_HDR. */ 774 if (mData .mProtocolVersion <= 1)771 if (mDataBase.mProtocolVersion <= 1) 775 772 { 776 773 pMsg->setNextString(aFile.GetSourcePath().c_str()); /* pvName */ … … 790 787 pCtx->mData.cbProcessed += cbRead; 791 788 792 if (mData .mProtocolVersion <= 1)789 if (mDataBase.mProtocolVersion <= 1) 793 790 { 794 791 pMsg->setNextPointer(pCtx->mURI.pvScratchBuf, cbRead); /* pvData */ … … 944 941 } 945 942 946 void *pvBuf = RTMemAlloc(m _cbBlockSize);943 void *pvBuf = RTMemAlloc(mData.mcbBlockSize); 947 944 if (!pvBuf) 948 945 return VERR_NO_MEMORY; … … 971 968 /* Host callbacks. */ 972 969 REGISTER_CALLBACK(DragAndDropSvc::HOST_DND_HG_SND_DIR); 973 if (mData .mProtocolVersion >= 2)970 if (mDataBase.mProtocolVersion >= 2) 974 971 REGISTER_CALLBACK(DragAndDropSvc::HOST_DND_HG_SND_FILE_HDR); 975 972 REGISTER_CALLBACK(DragAndDropSvc::HOST_DND_HG_SND_FILE_DATA); … … 981 978 */ 982 979 pCtx->mURI.pvScratchBuf = pvBuf; 983 pCtx->mURI.cbScratchBuf = m _cbBlockSize;980 pCtx->mURI.cbScratchBuf = mData.mcbBlockSize; 984 981 985 982 /* … … 1047 1044 /* Host callbacks. */ 1048 1045 UNREGISTER_CALLBACK(DragAndDropSvc::HOST_DND_HG_SND_DIR); 1049 if (mData .mProtocolVersion >= 2)1046 if (mDataBase.mProtocolVersion >= 2) 1050 1047 UNREGISTER_CALLBACK(DragAndDropSvc::HOST_DND_HG_SND_FILE_HDR); 1051 1048 UNREGISTER_CALLBACK(DragAndDropSvc::HOST_DND_HG_SND_FILE_DATA);
Note:
See TracChangeset
for help on using the changeset viewer.