Changeset 74380 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
- Timestamp:
- Sep 20, 2018 10:02:42 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
r73947 r74380 543 543 case WM_VBOXTRAY_DND_MESSAGE: 544 544 { 545 VBOXDNDEVENT *pEvent = (PVBOXDNDEVENT)lParam;545 PVBOXDNDEVENT pEvent = (PVBOXDNDEVENT)lParam; 546 546 if (!pEvent) 547 547 break; /* No event received, bail out. */ 548 548 549 LogFlowThisFunc(("Received uType=%RU32, uScreenID=%RU32\n", 550 pEvent->Event.uType, pEvent->Event.uScreenId)); 549 PVBGLR3DNDEVENT pVbglR3Event = pEvent->pVbglR3Event; 550 AssertPtrBreak(pVbglR3Event); 551 552 LogFlowThisFunc(("Received enmType=%RU32\n", pVbglR3Event->enmType)); 551 553 552 554 int rc; 553 switch (p Event->Event.uType)555 switch (pVbglR3Event->enmType) 554 556 { 555 case HOST_DND_HG_EVT_ENTER:557 case VBGLR3DNDEVENTTYPE_HG_ENTER: 556 558 { 557 LogFlowThisFunc(("HOST_DND_HG_EVT_ENTER\n")); 558 559 if (pEvent->Event.cbFormats) 559 if (pVbglR3Event->u.HG_Enter.cbFormats) 560 560 { 561 561 RTCList<RTCString> lstFormats = 562 RTCString(pEvent->Event.pszFormats, pEvent->Event.cbFormats - 1).split("\r\n"); 563 rc = OnHgEnter(lstFormats, pEvent->Event.u.a.uAllActions); 562 RTCString(pVbglR3Event->u.HG_Enter.pszFormats, pVbglR3Event->u.HG_Enter.cbFormats - 1).split("\r\n"); 563 rc = OnHgEnter(lstFormats, pVbglR3Event->u.HG_Enter.uAllActions); 564 if (RT_FAILURE(rc)) 565 break; 564 566 } 565 567 else … … 567 569 AssertMsgFailed(("cbFormats is 0\n")); 568 570 rc = VERR_INVALID_PARAMETER; 571 break; 569 572 } 570 573 571 574 /* Note: After HOST_DND_HG_EVT_ENTER there immediately is a move 572 575 * event, so fall through is intentional here. */ 576 RT_FALL_THROUGH(); 573 577 } 574 578 575 case HOST_DND_HG_EVT_MOVE:579 case VBGLR3DNDEVENTTYPE_HG_MOVE: 576 580 { 577 LogFlowThisFunc(("HOST_DND_HG_EVT_MOVE: %d,%d\n", 578 pEvent->Event.u.a.uXpos, pEvent->Event.u.a.uYpos)); 579 580 rc = OnHgMove(pEvent->Event.u.a.uXpos, pEvent->Event.u.a.uYpos, 581 pEvent->Event.u.a.uDefAction); 581 rc = OnHgMove(pVbglR3Event->u.HG_Move.uXpos, pVbglR3Event->u.HG_Move.uYpos, 582 pVbglR3Event->u.HG_Move.uDefAction); 582 583 break; 583 584 } 584 585 585 case HOST_DND_HG_EVT_LEAVE:586 case VBGLR3DNDEVENTTYPE_HG_LEAVE: 586 587 { 587 LogFlowThisFunc(("HOST_DND_HG_EVT_LEAVE\n"));588 589 588 rc = OnHgLeave(); 590 589 break; 591 590 } 592 591 593 case HOST_DND_HG_EVT_DROPPED:592 case VBGLR3DNDEVENTTYPE_HG_DROP: 594 593 { 595 LogFlowThisFunc(("HOST_DND_HG_EVT_DROPPED\n"));596 597 594 rc = OnHgDrop(); 598 595 break; 599 596 } 600 597 601 case HOST_DND_HG_SND_DATA: 602 /* Protocol v1 + v2: Also contains the header data. 603 /* Note: Fall through is intentional. */ 604 case HOST_DND_HG_SND_DATA_HDR: 598 /** 599 * The data header now will contain all the (meta) data the guest needs in 600 * order to complete the DnD operation. 601 */ 602 case VBGLR3DNDEVENTTYPE_HG_RECEIVE: 605 603 { 606 LogFlowThisFunc(("HOST_DND_HG_SND_DATA\n")); 607 608 rc = OnHgDataReceived(pEvent->Event.u.b.pvData, 609 pEvent->Event.u.b.cbData); 604 rc = OnHgDataReceive(&pVbglR3Event->u.HG_Received.Meta); 610 605 break; 611 606 } 612 607 613 case HOST_DND_HG_EVT_CANCEL:608 case VBGLR3DNDEVENTTYPE_HG_CANCEL: 614 609 { 615 LogFlowThisFunc(("HOST_DND_HG_EVT_CANCEL\n"));616 617 610 rc = OnHgCancel(); 618 611 break; 619 612 } 620 613 621 case HOST_DND_GH_REQ_PENDING: 614 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 615 case VBGLR3DNDEVENTTYPE_GH_ERROR: 622 616 { 623 LogFlowThisFunc(("HOST_DND_GH_REQ_PENDING\n")); 624 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 625 rc = OnGhIsDnDPending(pEvent->Event.uScreenId); 626 627 #else 628 rc = VERR_NOT_SUPPORTED; 629 #endif 617 reset(); 618 rc = VINF_SUCCESS; 630 619 break; 631 620 } 632 621 633 case HOST_DND_GH_EVT_DROPPED:622 case VBGLR3DNDEVENTTYPE_GH_REQ_PENDING: 634 623 { 635 LogFlowThisFunc(("HOST_DND_GH_EVT_DROPPED\n")); 636 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 637 rc = OnGhDropped(pEvent->Event.pszFormats, 638 pEvent->Event.cbFormats, 639 pEvent->Event.u.a.uDefAction); 640 #else 641 rc = VERR_NOT_SUPPORTED; 642 #endif 624 rc = OnGhIsDnDPending(); 643 625 break; 644 626 } 645 627 628 case VBGLR3DNDEVENTTYPE_GH_DROP: 629 { 630 rc = OnGhDrop(pVbglR3Event->u.GH_Drop.pszFormat, pVbglR3Event->u.GH_Drop.uAction); 631 break; 632 } 633 #endif 646 634 default: 635 { 636 LogRel(("DnD: Received unsupported message '%RU32'\n", pVbglR3Event->enmType)); 647 637 rc = VERR_NOT_SUPPORTED; 648 638 break; 639 } 649 640 } 650 641 651 /* Some messages require cleanup. */652 switch (pEvent->Event.uType)642 LogFlowFunc(("Message %RU32 processed with %Rrc\n", pVbglR3Event->enmType, rc)); 643 if (RT_FAILURE(rc)) 653 644 { 654 case HOST_DND_HG_EVT_ENTER: 655 case HOST_DND_HG_EVT_MOVE: 656 case HOST_DND_HG_EVT_DROPPED: 657 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 658 case HOST_DND_GH_EVT_DROPPED: 659 #endif 660 { 661 if (pEvent->Event.pszFormats) 662 RTMemFree(pEvent->Event.pszFormats); 663 break; 664 } 665 666 case HOST_DND_HG_SND_DATA: 667 case HOST_DND_HG_SND_DATA_HDR: 668 { 669 if (pEvent->Event.pszFormats) 670 RTMemFree(pEvent->Event.pszFormats); 671 if (pEvent->Event.u.b.pvData) 672 RTMemFree(pEvent->Event.u.b.pvData); 673 break; 674 } 675 676 default: 677 /* Ignore. */ 678 break; 645 /* Tell the user. */ 646 LogRel(("DnD: Processing message %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc)); 647 648 /* If anything went wrong, do a reset and start over. */ 649 reset(); 679 650 } 680 651 681 if (pEvent) 682 { 683 LogFlowThisFunc(("Processing event %RU32 resulted in rc=%Rrc\n", 684 pEvent->Event.uType, rc)); 685 686 RTMemFree(pEvent); 687 } 652 VbglR3DnDEventFree(pEvent->pVbglR3Event); 653 pEvent->pVbglR3Event = NULL; 654 688 655 return 0; 689 656 } … … 777 744 if (RT_FAILURE(rc)) 778 745 { 779 Log FlowThisFunc(("Connection to host service failed, rc=%Rrc\n", rc));746 LogRel(("DnD: Connection to host service failed, rc=%Rrc\n", rc)); 780 747 return rc; 781 748 } … … 1071 1038 * 1072 1039 * @return IPRT status code. 1073 * @param pvData Pointer to raw data received. 1074 * @param cbData Size of data (in bytes) received. 1075 */ 1076 int VBoxDnDWnd::OnHgDataReceived(const void *pvData, uint32_t cbData) 1077 { 1078 LogFlowThisFunc(("mState=%ld, pvData=%p, cbData=%RU32\n", 1079 mState, pvData, cbData)); 1040 * @param pMeta Pointer to meta data received. 1041 */ 1042 int VBoxDnDWnd::OnHgDataReceive(PVBGLR3GUESTDNDMETADATA pMeta) 1043 { 1044 LogFlowThisFunc(("mState=%ld, enmMetaType=%RU32, cbMeta=%RU32\n", mState, pMeta->enmType, pMeta->cbMeta)); 1080 1045 1081 1046 mState = Dropped; 1082 1047 1083 1048 int rc = VINF_SUCCESS; 1084 if (p vData)1085 { 1086 Assert( cbData);1049 if (pMeta->pvMeta) 1050 { 1051 Assert(pMeta->cbMeta); 1087 1052 rc = RTCritSectEnter(&mCritSect); 1088 1053 if (RT_SUCCESS(rc)) 1089 1054 { 1090 1055 if (startupInfo.pDataObject) 1091 rc = startupInfo.pDataObject->Signal(mFormatRequested, p vData, cbData);1056 rc = startupInfo.pDataObject->Signal(mFormatRequested, pMeta->pvMeta, pMeta->cbMeta); 1092 1057 else 1093 1058 rc = VERR_NOT_FOUND; … … 1152 1117 * 1153 1118 * @return IPRT status code. 1154 * @param uScreenID Screen ID the host wants to query a pending operation 1155 * for. Currently not used/needed here. 1156 */ 1157 int VBoxDnDWnd::OnGhIsDnDPending(uint32_t uScreenID) 1158 { 1159 RT_NOREF(uScreenID); 1160 LogFlowThisFunc(("mMode=%ld, mState=%ld, uScreenID=%RU32\n", mMode, mState, uScreenID)); 1119 */ 1120 int VBoxDnDWnd::OnGhIsDnDPending(void) 1121 { 1122 LogFlowThisFunc(("mMode=%ld, mState=%ld, uScreenID=%RU32\n", mMode, mState)); 1161 1123 1162 1124 if (mMode == Unknown) … … 1304 1266 * @param uDefAction Default action on the host. 1305 1267 */ 1306 int VBoxDnDWnd::OnGhDrop ped(const char *pszFormat, uint32_t cbFormat, uint32_t uDefAction)1268 int VBoxDnDWnd::OnGhDrop(const RTCString &strFormat, uint32_t uDefAction) 1307 1269 { 1308 1270 RT_NOREF(uDefAction); 1309 AssertPtrReturn(pszFormat, VERR_INVALID_POINTER); 1310 AssertReturn(cbFormat, VERR_INVALID_PARAMETER); 1311 1312 LogFlowThisFunc(("mMode=%ld, mState=%ld, pDropTarget=0x%p, pszFormat=%s, uDefAction=0x%x\n", 1313 mMode, mState, pDropTarget, pszFormat, uDefAction)); 1271 1272 LogFlowThisFunc(("mMode=%ld, mState=%ld, pDropTarget=0x%p, strFormat=%s, uDefAction=0x%x\n", 1273 mMode, mState, pDropTarget, strFormat.c_str(), uDefAction)); 1314 1274 int rc; 1315 1275 if (mMode == GH) … … 1339 1299 && cbData) 1340 1300 { 1341 rc = VbglR3DnDGHSendData(&mDnDCtx, pszFormat, pvData, cbData);1301 rc = VbglR3DnDGHSendData(&mDnDCtx, strFormat.c_str(), pvData, cbData); 1342 1302 LogFlowFunc(("Sent pvData=0x%p, cbData=%RU32, rc=%Rrc\n", pvData, cbData, rc)); 1343 1303 } … … 1823 1783 /* Note: pEvent will be free'd by the consumer later. */ 1824 1784 1825 rc = VbglR3DnDRecvNextMsg(&pCtx->cmdCtx, &pEvent->Event); 1826 LogFlowFunc(("VbglR3DnDRecvNextMsg: uType=%RU32, rc=%Rrc\n", pEvent->Event.uType, rc)); 1827 1828 if ( RT_SUCCESS(rc) 1829 /* Cancelled from host. */ 1830 || rc == VERR_CANCELLED 1831 ) 1785 PVBGLR3DNDEVENT pVbglR3Event = NULL; 1786 rc = VbglR3DnDEventGetNext(&pCtx->cmdCtx, &pVbglR3Event); 1787 LogFlowFunc(("enmType=%RU32, rc=%Rrc\n", pVbglR3Event->enmType, rc)); 1788 1789 if (RT_SUCCESS(rc)) 1832 1790 { 1833 1791 cMsgSkippedInvalid = 0; /* Reset skipped messages count. */ 1834 1792 1835 LogFlowFunc(("Received new event, type=%RU32, rc=%Rrc\n", pEvent->Event.uType, rc)); 1793 LogRel2(("DnD: Received new event, type=%RU32, rc=%Rrc\n", pVbglR3Event->enmType, rc)); 1794 1795 /* pEvent now owns pVbglR3Event. */ 1796 pEvent->pVbglR3Event = pVbglR3Event; 1797 pVbglR3Event = NULL; 1836 1798 1837 1799 rc = pWnd->ProcessEvent(pEvent); … … 1842 1804 } 1843 1805 else 1844 LogRel(("DnD: Processing proxy window event %RU32 on screen %RU32 failed with %Rrc\n", 1845 pEvent->Event.uType, pEvent->Event.uScreenId, rc)); 1806 LogRel(("DnD: Processing proxy window event %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc)); 1846 1807 } 1847 1808 else if (rc == VERR_INTERRUPTED) /* Disconnected from service. */ … … 1854 1815 if (RT_FAILURE(rc)) 1855 1816 { 1817 VbglR3DnDEventFree(pVbglR3Event); 1818 pVbglR3Event = NULL; 1819 1856 1820 LogFlowFunc(("Processing next message failed with rc=%Rrc\n", rc)); 1857 1821
Note:
See TracChangeset
for help on using the changeset viewer.