Changeset 55549 in vbox for trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
- Timestamp:
- Apr 30, 2015 12:28:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r55539 r55549 496 496 else 497 497 rc = VERR_COM_INVALID_OBJECT_STATE; 498 499 ASMAtomicWriteBool(&pTarget->mDataBase.mfTransferIsPending, false); 498 500 499 501 LogFlowFunc(("pTarget=%p returning rc=%Rrc\n", (GuestDnDTarget *)pTarget, rc)); … … 521 523 #else /* VBOX_WITH_DRAG_AND_DROP */ 522 524 523 /** @todo Add input validation. */524 /** @todo Check if another sendData() call currently is being processed. */525 526 525 AutoCaller autoCaller(this); 527 526 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 528 527 529 /* Note: At the moment we only support one response at a time. */ 528 /* Input validation. */ 529 if (RT_UNLIKELY((aFormat.c_str()) == NULL || *(aFormat.c_str()) == '\0')) 530 return setError(E_INVALIDARG, tr("No data format specified")); 531 if (RT_UNLIKELY(!aData.size())) 532 return setError(E_INVALIDARG, tr("No data to send specified")); 533 534 /* Note: At the moment we only support one transfer at a time. */ 535 if (ASMAtomicReadBool(&mDataBase.mfTransferIsPending)) 536 return setError(E_INVALIDARG, tr("Another send operation already is in progress")); 537 538 ASMAtomicWriteBool(&mDataBase.mfTransferIsPending, true); 539 540 /* Dito. */ 530 541 GuestDnDResponse *pResp = GuestDnDInst()->response(); 531 542 AssertPtr(pResp); … … 549 560 AssertReturn(pTask->isOk(), pTask->getRC()); 550 561 551 RTTHREAD sendThread; 552 int rc = RTThreadCreate(&sendThread, GuestDnDTarget::i_sendDataThread, 562 int rc = RTThreadCreate(NULL, GuestDnDTarget::i_sendDataThread, 553 563 (void *)pTask, 0, RTTHREADTYPE_MAIN_WORKER, 0, "dndTgtSndData"); 554 564 if (RT_SUCCESS(rc)) … … 569 579 hr = setError(E_OUTOFMEMORY); 570 580 } 581 582 /* Note: mDataBase.mfTransferIsPending will be set to false again by i_sendDataThread. */ 571 583 572 584 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); … … 608 620 609 621 ASMAtomicWriteBool(&pCtx->mIsActive, true); 622 623 /* Clear all remaining outgoing messages. */ 624 mDataBase.mListOutgoing.clear(); 610 625 611 626 do … … 694 709 rc = aFile.OpenEx(strPathSrc, DnDURIObject::File, DnDURIObject::Source, 695 710 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 0 /* fFlags */); 711 if (RT_FAILURE(rc)) 712 LogRel2(("DnD: Error opening host file \"%s\", rc=%Rrc\n", strPathSrc.c_str(), rc)); 696 713 } 697 714 … … 718 735 719 736 LogFlowFunc(("Sending file header ...\n")); 737 LogRel2(("DnD: Transferring host file to guest: %s (%RU64 bytes, mode 0x%x)\n", 738 strPathSrc.c_str(), aFile.GetSize(), aFile.GetMode())); 720 739 } 721 740 else … … 800 819 if (aFile.IsComplete()) /* Done reading? */ 801 820 { 821 LogRel2(("DnD: File transfer to guest complete: %s\n", aFile.GetSourcePath().c_str())); 802 822 LogFlowFunc(("File \"%s\" complete\n", aFile.GetSourcePath().c_str())); 803 823 rc = VINF_EOF; … … 821 841 822 842 int rc = VINF_SUCCESS; 823 bool fNotify = false;824 843 825 844 switch (uMsg) … … 849 868 850 869 if (RT_FAILURE(rc)) 851 {852 if (rc == VERR_NO_DATA) /* All URI objects processed? */853 {854 /* Unregister this callback. */855 AssertPtr(pCtx->mpResp);856 int rc2 = pCtx->mpResp->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);857 if (RT_FAILURE(rc2))858 LogFlowFunc(("Error: Unable to unregister callback for message %RU32, rc=%Rrc\n", uMsg, rc2));859 }860 861 870 delete pMsg; 862 }863 871 } 864 872 catch(std::bad_alloc & /*e*/) … … 866 874 rc = VERR_NO_MEMORY; 867 875 } 876 break; 877 } 878 case DragAndDropSvc::GUEST_DND_GH_EVT_ERROR: 879 { 880 DragAndDropSvc::PVBOXDNDCBEVTERRORDATA pCBData = reinterpret_cast<DragAndDropSvc::PVBOXDNDCBEVTERRORDATA>(pvParms); 881 AssertPtr(pCBData); 882 AssertReturn(sizeof(DragAndDropSvc::VBOXDNDCBEVTERRORDATA) == cbParms, VERR_INVALID_PARAMETER); 883 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_GH_EVT_ERROR == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER); 884 885 pCtx->mpResp->reset(); 886 rc = pCtx->mpResp->setProgress(100, DragAndDropSvc::DND_PROGRESS_ERROR, pCBData->rc); 887 if (RT_SUCCESS(rc)) 888 rc = pCBData->rc; 868 889 break; 869 890 } … … 917 938 } 918 939 919 if (fNotify) 920 { 921 int rc2 = pCtx->mCallback.Notify(rc); 940 if (RT_FAILURE(rc)) 941 { 942 switch (rc) 943 { 944 case VERR_NO_DATA: 945 LogRel2(("DnD: Transfer complete\n")); 946 break; 947 948 case VERR_CANCELLED: 949 LogRel2(("DnD: Transfer canceled\n")); 950 break; 951 952 default: 953 LogRel(("DnD: Error %Rrc occurred, aborting transfer\n", rc)); 954 break; 955 } 956 957 /* Unregister this callback. */ 958 AssertPtr(pCtx->mpResp); 959 int rc2 = pCtx->mpResp->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */); 960 AssertRC(rc2); 961 962 /* Notify waiters. */ 963 rc2 = pCtx->mCallback.Notify(rc); 922 964 AssertRC(rc2); 923 965 }
Note:
See TracChangeset
for help on using the changeset viewer.