Changeset 55539 in vbox for trunk/src/VBox
- Timestamp:
- Apr 30, 2015 9:48:34 AM (10 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r55509 r55539 73 73 # ifdef VBOX_WITH_DRAG_AND_DROP 74 74 # include "CGuest.h" 75 # include "CDnDSource.h" 75 76 # include "CDnDTarget.h" 76 77 # endif /* VBOX_WITH_DRAG_AND_DROP */ … … 2399 2400 2400 2401 #ifdef VBOX_WITH_DRAG_AND_DROP 2401 void UIMessageCenter::cannotDropData (const CGuest &guest, QWidget *pParent /* = 0*/) const2402 { 2403 error(pParent, MessageType_Error, 2404 tr("Drag and drop operation f ailed."),2405 formatErrorInfo( guest));2406 } 2407 2408 void UIMessageCenter::cannotDropData (const CProgress &progress, QWidget *pParent /* = 0*/) const2409 { 2410 error(pParent, MessageType_Error, 2411 tr(" Failed while dropping data."),2402 void UIMessageCenter::cannotDropDataToGuest(const CDnDTarget &dndTarget, QWidget *pParent /* = 0*/) const 2403 { 2404 error(pParent, MessageType_Error, 2405 tr("Drag and drop operation from host to guest failed."), 2406 formatErrorInfo(dndTarget)); 2407 } 2408 2409 void UIMessageCenter::cannotDropDataToGuest(const CProgress &progress, QWidget *pParent /* = 0*/) const 2410 { 2411 error(pParent, MessageType_Error, 2412 tr("Drag and drop operation from host to guest failed."), 2412 2413 formatErrorInfo(progress)); 2413 2414 } 2414 2415 2415 void UIMessageCenter::cannotCancelDrop (const CDnDTarget &dndTarget, QWidget *pParent /* = 0*/) const2416 { 2417 error(pParent, MessageType_Error, 2418 tr("Unable to cancel drag and drop operation."),2416 void UIMessageCenter::cannotCancelDropToGuest(const CDnDTarget &dndTarget, QWidget *pParent /* = 0*/) const 2417 { 2418 error(pParent, MessageType_Error, 2419 tr("Unable to cancel host to guest drag and drop operation."), 2419 2420 formatErrorInfo(dndTarget)); 2421 } 2422 2423 void UIMessageCenter::cannotDropDataToHost(const CDnDSource &dndSource, QWidget *pParent /* = 0*/) const 2424 { 2425 error(pParent, MessageType_Error, 2426 tr("Drag and drop operation from guest to host failed."), 2427 formatErrorInfo(dndSource)); 2428 } 2429 2430 void UIMessageCenter::cannotDropDataToHost(const CProgress &progress, QWidget *pParent /* = 0*/) const 2431 { 2432 error(pParent, MessageType_Error, 2433 tr("Drag and drop operation from guest to host failed."), 2434 formatErrorInfo(progress)); 2420 2435 } 2421 2436 #endif /* VBOX_WITH_DRAG_AND_DROP */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r55509 r55539 349 349 350 350 #ifdef VBOX_WITH_DRAG_AND_DROP 351 /* API: Drag&drop warnings: */ 352 void cannotDropData(const CGuest &guest, QWidget *pParent = 0) const; 353 void cannotDropData(const CProgress &progress, QWidget *pParent = 0) const; 354 void cannotCancelDrop(const CDnDTarget &dndTarget, QWidget *pParent = 0) const; 351 /* API: Drag and drop errors: Host -> Guest */ 352 void cannotDropDataToGuest(const CDnDTarget &dndTarget, QWidget *pParent = 0) const; 353 void cannotCancelDropToGuest(const CDnDTarget &dndTarget, QWidget *pParent = 0) const; 354 void cannotDropDataToGuest(const CProgress &progress, QWidget *pParent /* = 0*/) const; 355 /* API: Drag and drop errors: Guest -> Host */ 356 void cannotDropDataToHost(const CDnDSource &dndSource, QWidget *pParent = 0) const; 357 void cannotDropDataToHost(const CProgress &progress, QWidget *pParent /* = 0*/) const; 355 358 #endif /* VBOX_WITH_DRAG_AND_DROP */ 356 359 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp
r55524 r55539 151 151 CProgress progress = dndSource.Drop(strMimeType, 152 152 UIDnDHandler::toVBoxDnDAction(dropAction)); 153 if ( guest.isOk())153 if (dndSource.isOk()) 154 154 { 155 155 msgCenter().showModalProgressDialog(progress, … … 201 201 } 202 202 else 203 msgCenter().cannotDropData (progress, pParent);203 msgCenter().cannotDropDataToHost(progress, pParent); 204 204 } 205 205 else /* Don't pop up a message. */ … … 208 208 else 209 209 { 210 msgCenter().cannotDropData (guest, pParent);210 msgCenter().cannotDropDataToHost(dndSource, pParent); 211 211 rc = VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */ 212 212 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp
r55422 r55539 134 134 CProgress progress = dndTarget.SendData(screenId, format, dv); 135 135 136 if ( progress.isOk())136 if (dndTarget.isOk()) 137 137 { 138 138 LogFlowFunc(("Transferring data to guest ...\n")); … … 146 146 147 147 BOOL fCanceled = progress.GetCanceled(); 148 149 /* Some error occurred? */150 148 if ( !fCanceled 151 149 && ( !progress.isOk() 152 150 || progress.GetResultCode() != 0)) 153 151 { 154 msgCenter().cannotDropData (progress, pParent);152 msgCenter().cannotDropDataToGuest(progress, pParent); 155 153 result = KDnDAction_Ignore; 156 154 } 157 #if 0158 else if (fCanceled) /* Operation canceled by user? */159 {160 Assert(progress.isOk());161 Assert(progress.GetResultCode() == 0);162 163 /* Tell the guest. */164 BOOL fVeto = dndTarget.Cancel();165 if (fVeto) /* Cancelling vetoed by the target? Tell the user why. */166 msgCenter().cannotCancelDrop(dndTarget, pParent);167 }168 #endif169 155 } 170 156 else 171 157 { 172 msgCenter().cannotDropData (guest, pParent);158 msgCenter().cannotDropDataToGuest(dndTarget, pParent); 173 159 result = KDnDAction_Ignore; 174 160 } -
trunk/src/VBox/HostServices/DragAndDrop/service.cpp
r55527 r55539 480 480 rc = paParms[1].getUInt32(&data.uAllActions); 481 481 if (RT_SUCCESS(rc)) 482 { 483 uint32_t cTmp; 484 rc = paParms[2].getPointer((void**)&data.pszFormat, &cTmp); 485 } 482 rc = paParms[2].getPointer((void**)&data.pszFormat, &data.cbFormat); 486 483 DO_HOST_CALLBACK(); 487 484 } -
trunk/src/VBox/Main/include/GuestDnDSourceImpl.h
r55520 r55539 84 84 protected: 85 85 86 int i_receiveData(PRECVDATACTX pCtx );87 int i_receiveRawData(PRECVDATACTX pCtx );88 int i_receiveURIData(PRECVDATACTX pCtx );86 int i_receiveData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout); 87 int i_receiveRawData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout); 88 int i_receiveURIData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout); 89 89 int i_updateProcess(PRECVDATACTX pCtx, uint32_t cbDataAdd); 90 90 -
trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp
r55512 r55539 413 413 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_HG_REQ_DATA == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER); 414 414 415 setFormat(pCBData->pszFormat); 416 rc = notifyAboutGuestResponse(); 415 if ( pCBData->cbFormat == 0 416 || pCBData->cbFormat > _64K) 417 { 418 rc = VERR_INVALID_PARAMETER; 419 } 420 else 421 { 422 setFormat(pCBData->pszFormat); 423 424 rc = VINF_SUCCESS; 425 } 426 427 int rc2 = notifyAboutGuestResponse(); 428 if (RT_SUCCESS(rc)) 429 rc = rc2; 417 430 break; 418 431 } … … 440 453 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_GH_ACK_PENDING == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER); 441 454 442 setFormat (pCBData->pszFormat); 443 setDefAction (pCBData->uDefAction); 444 setAllActions(pCBData->uAllActions); 445 446 rc = notifyAboutGuestResponse(); 455 if ( pCBData->cbFormat == 0 456 || pCBData->cbFormat > _64K) 457 { 458 rc = VERR_INVALID_PARAMETER; 459 } 460 else 461 { 462 setFormat (pCBData->pszFormat); 463 setDefAction (pCBData->uDefAction); 464 setAllActions(pCBData->uAllActions); 465 466 rc = VINF_SUCCESS; 467 } 468 469 int rc2 = notifyAboutGuestResponse(); 470 if (RT_SUCCESS(rc)) 471 rc = rc2; 447 472 break; 448 473 } -
trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp
r55525 r55539 229 229 ///////////////////////////////////////////////////////////////////////////// 230 230 231 HRESULT GuestDnDSource::dragIsPending(ULONG uScreenId, 232 std::vector<com::Utf8Str> &aFormats, 233 std::vector<DnDAction_T> &aAllowedActions, 234 DnDAction_T *aDefaultAction) 231 HRESULT GuestDnDSource::dragIsPending(ULONG uScreenId, std::vector<com::Utf8Str> &aFormats, 232 std::vector<DnDAction_T> &aAllowedActions, DnDAction_T *aDefaultAction) 235 233 { 236 234 #if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH) … … 282 280 if (RT_FAILURE(rc)) 283 281 hr = setError(VBOX_E_IPRT_ERROR, 284 tr("Error retrieving drag 'ndrop pending status (%Rrc)\n"), rc);282 tr("Error retrieving drag and drop pending status (%Rrc)\n"), rc); 285 283 286 284 LogFlowFunc(("hr=%Rhrc, defaultAction=0x%x\n", hr, defaultAction)); … … 289 287 } 290 288 291 HRESULT GuestDnDSource::drop(const com::Utf8Str &aFormat, 292 DnDAction_T aAction, ComPtr<IProgress> &aProgress) 289 HRESULT GuestDnDSource::drop(const com::Utf8Str &aFormat, DnDAction_T aAction, ComPtr<IProgress> &aProgress) 293 290 { 294 291 #if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH) … … 308 305 return S_OK; 309 306 307 /* Note: At the moment we only support one transfer at a time. */ 310 308 if (ASMAtomicReadBool(&mData.mfDropIsPending)) 311 309 return setError(E_INVALIDARG, tr("Another drop operation already is in progress")); … … 313 311 ASMAtomicWriteBool(&mData.mfDropIsPending, true); 314 312 315 HRESULT hr = S_OK; 316 317 /* Note: At the moment we only support one response at a time. */ 313 /* Dito. */ 318 314 GuestDnDResponse *pResp = GuestDnDInst()->response(); 319 if (pResp) 320 { 321 pResp->resetProgress(m_pGuest); 322 323 int rc; 324 325 try 326 { 327 mData.mRecvCtx.mpSource = this; 328 mData.mRecvCtx.mpResp = pResp; 329 mData.mRecvCtx.mFormat = aFormat; 330 331 RecvDataTask *pTask = new RecvDataTask(this, &mData.mRecvCtx); 332 AssertReturn(pTask->isOk(), pTask->getRC()); 333 334 rc = RTThreadCreate(NULL, GuestDnDSource::i_receiveDataThread, 315 AssertPtr(pResp); 316 317 HRESULT hr = pResp->resetProgress(m_pGuest); 318 if (FAILED(hr)) 319 return hr; 320 321 try 322 { 323 mData.mRecvCtx.mIsActive = false; 324 mData.mRecvCtx.mpSource = this; 325 mData.mRecvCtx.mpResp = pResp; 326 mData.mRecvCtx.mFormat = aFormat; 327 328 RecvDataTask *pTask = new RecvDataTask(this, &mData.mRecvCtx); 329 AssertReturn(pTask->isOk(), pTask->getRC()); 330 331 RTTHREAD recvThread; 332 int rc = RTThreadCreate(&recvThread, GuestDnDSource::i_receiveDataThread, 335 333 (void *)pTask, 0, RTTHREADTYPE_MAIN_WORKER, 0, "dndSrcRcvData"); 336 if (RT_SUCCESS(rc)) 337 { 338 hr = pResp->queryProgressTo(aProgress.asOutParam()); 339 ComAssertComRC(hr); 340 341 /* Note: pTask is now owned by the worker thread. */ 342 } 343 } 344 catch(std::bad_alloc &) 345 { 346 rc = VERR_NO_MEMORY; 347 } 348 349 /*if (RT_FAILURE(vrc)) @todo SetError(...) */ 350 } 351 /** @todo SetError(...) */ 352 353 ASMAtomicWriteBool(&mData.mfDropIsPending, false); 334 if (RT_SUCCESS(rc)) 335 { 336 hr = pResp->queryProgressTo(aProgress.asOutParam()); 337 ComAssertComRC(hr); 338 339 /* Note: pTask is now owned by the worker thread. */ 340 } 341 else 342 hr = setError(VBOX_E_IPRT_ERROR, tr("Starting thread failed (%Rrc)"), rc); 343 } 344 catch(std::bad_alloc &) 345 { 346 hr = setError(E_OUTOFMEMORY); 347 } 348 349 /* Note: mData.mfDropIsPending will be set to false again by i_receiveDataThread. */ 354 350 355 351 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); … … 680 676 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 681 677 682 int GuestDnDSource::i_receiveData(PRECVDATACTX pCtx )678 int GuestDnDSource::i_receiveData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout) 683 679 { 684 680 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 691 687 AssertPtr(pCtx->mpResp); 692 688 689 /* Is this context already in receiving state? */ 690 if (ASMAtomicReadBool(&pCtx->mIsActive)) 691 return VERR_WRONG_ORDER; 692 693 693 ASMAtomicWriteBool(&pCtx->mIsActive, true); 694 694 … … 697 697 return rc; 698 698 699 /* 700 * Reset any old data. 701 */ 699 702 pCtx->mData.vecData.clear(); 700 703 pCtx->mData.cbToProcess = 0; 701 704 pCtx->mData.cbProcessed = 0; 702 705 703 do 704 { 705 /* Reset any old data. */ 706 pResp->reset(); 707 pResp->resetProgress(m_pGuest); 708 709 /* Set the format we are going to retrieve to have it around 710 * when retrieving the data later. */ 711 pResp->setFormat(pCtx->mFormat); 712 713 bool fHasURIList = DnDMIMENeedsDropDir(pCtx->mFormat.c_str(), pCtx->mFormat.length()); 714 LogFlowFunc(("strFormat=%s, uAction=0x%x, fHasURIList=%RTbool\n", pCtx->mFormat.c_str(), pCtx->mAction, fHasURIList)); 715 716 if (fHasURIList) 717 { 718 rc = i_receiveURIData(pCtx); 719 } 720 else 721 { 722 rc = i_receiveRawData(pCtx); 723 } 724 725 } while (0); 706 pResp->reset(); 707 pResp->resetProgress(m_pGuest); 708 709 /* Set the format we are going to retrieve to have it around 710 * when retrieving the data later. */ 711 pResp->setFormat(pCtx->mFormat); 712 713 bool fHasURIList = DnDMIMENeedsDropDir(pCtx->mFormat.c_str(), pCtx->mFormat.length()); 714 LogFlowFunc(("strFormat=%s, uAction=0x%x, fHasURIList=%RTbool\n", pCtx->mFormat.c_str(), pCtx->mAction, fHasURIList)); 715 if (fHasURIList) 716 { 717 rc = i_receiveURIData(pCtx, msTimeout); 718 } 719 else 720 { 721 rc = i_receiveRawData(pCtx, msTimeout); 722 } 726 723 727 724 ASMAtomicWriteBool(&pCtx->mIsActive, false); … … 747 744 if (SUCCEEDED(autoCaller.rc())) 748 745 { 749 rc = pSource->i_receiveData(pTask->getCtx() );746 rc = pSource->i_receiveData(pTask->getCtx(), RT_INDEFINITE_WAIT); 750 747 } 751 748 else … … 756 753 if (pTask) 757 754 delete pTask; 755 756 ASMAtomicWriteBool(&pSource->mData.mfDropIsPending, false); 757 758 758 return rc; 759 759 } 760 760 761 int GuestDnDSource::i_receiveRawData(PRECVDATACTX pCtx )761 int GuestDnDSource::i_receiveRawData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout) 762 762 { 763 763 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 807 807 * wait event. 808 808 */ 809 LogFlowFunc(("Waiting for raw data callback ...\n"));810 rc = pCtx->mCallback.Wait( RT_INDEFINITE_WAIT);809 LogFlowFunc(("Waiting for raw data callback (%RU32ms timeout) ...\n", msTimeout)); 810 rc = pCtx->mCallback.Wait(msTimeout); 811 811 LogFlowFunc(("Raw callback done, rc=%Rrc\n", rc)); 812 812 } … … 827 827 } 828 828 829 int GuestDnDSource::i_receiveURIData(PRECVDATACTX pCtx )829 int GuestDnDSource::i_receiveURIData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout) 830 830 { 831 831 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 888 888 * wait event. 889 889 */ 890 LogFlowFunc(("Waiting for URI callback ...\n"));891 rc = pCtx->mCallback.Wait( RT_INDEFINITE_WAIT);890 LogFlowFunc(("Waiting for URI callback (%RU32ms timeout) ...\n", msTimeout)); 891 rc = pCtx->mCallback.Wait(msTimeout); 892 892 LogFlowFunc(("URI callback done, rc=%Rrc\n", rc)); 893 893 } -
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r55520 r55539 22 22 #include "GuestImpl.h" 23 23 #include "GuestDnDTargetImpl.h" 24 #include "VirtualBoxErrorInfoImpl.h"25 24 26 25 #include "Global.h" … … 528 527 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 529 528 530 HRESULT hr = S_OK;531 int vrc;532 533 529 /* Note: At the moment we only support one response at a time. */ 534 530 GuestDnDResponse *pResp = GuestDnDInst()->response(); 535 if (pResp) 536 { 537 pResp->resetProgress(m_pGuest); 538 539 try 540 { 541 PSENDDATACTX pSendCtx = new SENDDATACTX; 542 RT_BZERO(pSendCtx, sizeof(SENDDATACTX)); 543 544 pSendCtx->mpTarget = this; 545 pSendCtx->mpResp = pResp; 546 pSendCtx->mScreenID = aScreenId; 547 pSendCtx->mFormat = aFormat; 548 pSendCtx->mData.vecData = aData; 549 550 SendDataTask *pTask = new SendDataTask(this, pSendCtx); 551 AssertReturn(pTask->isOk(), pTask->getRC()); 552 553 vrc = RTThreadCreate(NULL, GuestDnDTarget::i_sendDataThread, 554 (void *)pTask, 0, RTTHREADTYPE_MAIN_WORKER, 0, "dndTgtSndData"); 555 if (RT_SUCCESS(vrc)) 556 { 557 hr = pResp->queryProgressTo(aProgress.asOutParam()); 558 ComAssertComRC(hr); 559 560 /* Note: pTask is now owned by the worker thread. */ 561 } 562 else if (pSendCtx) 563 delete pSendCtx; 564 } 565 catch(std::bad_alloc &) 566 { 567 vrc = VERR_NO_MEMORY; 568 } 569 570 /*if (RT_FAILURE(vrc)) ** @todo SetError(...) */ 571 } 572 /** @todo SetError(...) */ 573 531 AssertPtr(pResp); 532 533 HRESULT hr = pResp->resetProgress(m_pGuest); 534 if (FAILED(hr)) 535 return hr; 536 537 try 538 { 539 PSENDDATACTX pSendCtx = new SENDDATACTX; 540 RT_BZERO(pSendCtx, sizeof(SENDDATACTX)); 541 542 pSendCtx->mpTarget = this; 543 pSendCtx->mpResp = pResp; 544 pSendCtx->mScreenID = aScreenId; 545 pSendCtx->mFormat = aFormat; 546 pSendCtx->mData.vecData = aData; 547 548 SendDataTask *pTask = new SendDataTask(this, pSendCtx); 549 AssertReturn(pTask->isOk(), pTask->getRC()); 550 551 RTTHREAD sendThread; 552 int rc = RTThreadCreate(&sendThread, GuestDnDTarget::i_sendDataThread, 553 (void *)pTask, 0, RTTHREADTYPE_MAIN_WORKER, 0, "dndTgtSndData"); 554 if (RT_SUCCESS(rc)) 555 { 556 hr = pResp->queryProgressTo(aProgress.asOutParam()); 557 ComAssertComRC(hr); 558 559 /* Note: pTask is now owned by the worker thread. */ 560 } 561 else 562 hr = setError(VBOX_E_IPRT_ERROR, tr("Starting thread failed (%Rrc)"), rc); 563 564 if (RT_FAILURE(rc)) 565 delete pSendCtx; 566 } 567 catch(std::bad_alloc &) 568 { 569 hr = setError(E_OUTOFMEMORY); 570 } 571 572 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); 574 573 return hr; 575 574 #endif /* VBOX_WITH_DRAG_AND_DROP */ … … 963 962 * Register callbacks. 964 963 */ 965 /* G enericcallbacks. */964 /* Guest callbacks. */ 966 965 REGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GET_NEXT_HOST_MSG); 967 966 REGISTER_CALLBACK(DragAndDropSvc::GUEST_DND_GH_EVT_ERROR);
Note:
See TracChangeset
for help on using the changeset viewer.