Changeset 50561 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Feb 24, 2014 9:07:22 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92425
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDImpl.cpp
r50508 r50561 239 239 DnDGuestResponse *response(void) const { return m_pDnDResponse; } 240 240 241 voidadjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const;242 voidhostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;241 HRESULT adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const; 242 int hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const; 243 243 244 244 /* Static helpers. */ … … 310 310 int DnDGuestResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */) 311 311 { 312 int vrc = RTSemEventWait(m_EventSem, msTimeout);312 int rc = RTSemEventWait(m_EventSem, msTimeout); 313 313 #ifdef DEBUG_andy 314 LogFlowFunc(("msTimeout=%RU32, rc=%Rrc\n", msTimeout, vrc));314 LogFlowFunc(("msTimeout=%RU32, rc=%Rrc\n", msTimeout, rc)); 315 315 #endif 316 return vrc;316 return rc; 317 317 } 318 318 … … 350 350 m_pvData = NULL; 351 351 } 352 353 352 m_cbData = 0; 353 354 m_cbDataCurrent = 0; 355 m_cbDataTotal = 0; 354 356 } 355 357 … … 377 379 { 378 380 BOOL fCompleted; 379 HRESULT rc= m_progress->COMGETTER(Completed)(&fCompleted);381 HRESULT hr = m_progress->COMGETTER(Completed)(&fCompleted); 380 382 if (!fCompleted) 381 383 { 382 384 if (uState == DragAndDropSvc::DND_PROGRESS_ERROR) 383 385 { 384 rc= m_progress->notifyComplete(E_FAIL,386 hr = m_progress->notifyComplete(E_FAIL, 385 387 COM_IIDOF(IGuest), 386 388 m_parent->getComponentName(), 387 389 m_parent->tr("Drag'n drop guest error (%Rrc)"), rcOp); 390 reset(); 388 391 } 389 392 else if (uState == DragAndDropSvc::DND_PROGRESS_CANCELLED) 390 393 { 391 rc = m_progress->Cancel(); 392 vrc = VERR_CANCELLED; 394 hr = m_progress->Cancel(); 395 if (SUCCEEDED(hr)) 396 vrc = VERR_CANCELLED; 397 398 reset(); 393 399 } 394 400 else /* uState == DragAndDropSvc::DND_PROGRESS_RUNNING */ 395 401 { 396 rc = m_progress->SetCurrentOperationProgress(uPercentage); 397 #ifndef DEBUG_andy 398 Assert(SUCCEEDED(rc)); 399 #endif 402 hr = m_progress->SetCurrentOperationProgress(uPercentage); 403 AssertComRC(hr); 400 404 if ( uState == DragAndDropSvc::DND_PROGRESS_COMPLETE 401 405 || uPercentage >= 100) 402 rc= m_progress->notifyComplete(S_OK);406 hr = m_progress->notifyComplete(S_OK); 403 407 } 408 } 409 } 410 411 return vrc; 412 } 413 414 int DnDGuestResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */) 415 { 416 if (cbDataTotal) 417 { 404 418 #ifndef DEBUG_andy 405 Assert(SUCCEEDED(rc)); 419 AssertMsg(m_cbDataTotal <= cbDataTotal, ("New data size must not be smaller (%zu) than old value (%zu)\n", 420 cbDataTotal, m_cbDataTotal)); 406 421 #endif 407 } 408 } 409 410 return vrc; 411 } 412 413 int DnDGuestResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */) 414 { 415 if (cbDataTotal) 416 { 417 AssertMsg(m_cbDataTotal <= cbDataTotal, ("New data size size must not be smaller (%zu) than old value (%zu)\n", 418 cbDataTotal, m_cbDataTotal)); 422 LogFlowFunc(("Updating total data size from %zu to %zu\n", m_cbDataTotal, cbDataTotal)); 419 423 m_cbDataTotal = cbDataTotal; 420 LogFlowFunc(("Updating total data size to: %zu\n", m_cbDataTotal));421 424 } 422 425 AssertMsg(m_cbDataTotal, ("m_cbDataTotal must not be <= 0\n")); … … 433 436 LogFlowFunc(("Updating transfer status (%zu/%zu), status=%ld\n", 434 437 m_cbDataCurrent, m_cbDataTotal, uStatus)); 435 #endif 436 438 #else 437 439 AssertMsg(m_cbDataCurrent <= m_cbDataTotal, 438 440 ("More data transferred (%RU32) than initially announced (%RU32)\n", 439 441 m_cbDataCurrent, m_cbDataTotal)); 440 442 #endif 441 443 int rc = setProgress(cPercentage, uStatus); 442 444 … … 455 457 } 456 458 457 voidGuestDnDPrivate::adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const459 HRESULT GuestDnDPrivate::adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const 458 460 { 459 461 /* For multi-monitor support we need to add shift values to the coordinates 460 462 * (depending on the screen number). */ 461 463 ComPtr<IDisplay> pDisplay; 462 HRESULT rc= p->mParent->COMGETTER(Display)(pDisplay.asOutParam());463 if (FAILED( rc))464 throw rc;464 HRESULT hr = p->mParent->COMGETTER(Display)(pDisplay.asOutParam()); 465 if (FAILED(hr)) 466 return hr; 465 467 466 468 ComPtr<IFramebuffer> pFramebuffer; 467 469 LONG xShift, yShift; 468 rc= pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(),470 hr = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(), 469 471 &xShift, &yShift); 470 if (FAILED( rc))471 throw rc;472 if (FAILED(hr)) 473 return hr; 472 474 473 475 *puX += xShift; 474 476 *puY += yShift; 475 } 476 477 void GuestDnDPrivate::hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const 478 { 479 VMMDev *vmmDev = NULL; 477 478 return hr; 479 } 480 481 int GuestDnDPrivate::hostCall(uint32_t u32Function, uint32_t cParms, 482 PVBOXHGCMSVCPARM paParms) const 483 { 484 VMMDev *pVMMDev = NULL; 480 485 { 481 486 /* Make sure mParent is valid, so set the read lock while using. … … 486 491 /* Forward the information to the VMM device. */ 487 492 AssertPtr(p->mParent); 488 vmmDev = p->mParent->getVMMDev();489 } 490 491 if (! vmmDev)493 pVMMDev = p->mParent->getVMMDev(); 494 } 495 496 if (!pVMMDev) 492 497 throw p->setError(VBOX_E_VM_ERROR, 493 498 p->tr("VMM device is not available (is the VM running?)")); 494 499 495 500 LogFlowFunc(("hgcmHostCall msg=%RU32, numParms=%RU32\n", u32Function, cParms)); 496 int vrc = vmmDev->hgcmHostCall("VBoxDragAndDropSvc",501 int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc", 497 502 u32Function, 498 503 cParms, paParms); 499 if (RT_FAILURE( vrc))500 { 501 LogFlowFunc(("hgcmHostCall error: %Rrc\n", vrc));504 if (RT_FAILURE(rc)) 505 { 506 LogFlowFunc(("hgcmHostCall error: %Rrc\n", rc)); 502 507 throw p->setError(VBOX_E_VM_ERROR, 503 p->tr("hgcmHostCall failed (%Rrc)"), vrc); 504 } 508 p->tr("hgcmHostCall failed (%Rrc)"), rc); 509 } 510 511 return rc; 505 512 } 506 513 … … 653 660 return S_OK; 654 661 655 HRESULT rc= S_OK;662 HRESULT hr = S_OK; 656 663 657 664 try … … 674 681 paParms); 675 682 676 DnDGuestResponse *p DnD= d->response();683 DnDGuestResponse *pResp = d->response(); 677 684 /* This blocks until the request is answered (or timeout). */ 678 if (p DnD->waitForGuestResponse() == VERR_TIMEOUT)685 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 679 686 return S_OK; 680 687 681 688 /* Copy the response info */ 682 *pResultAction = d->toMainAction(p DnD->defAction());689 *pResultAction = d->toMainAction(pResp->defAction()); 683 690 LogFlowFunc(("*pResultAction=%ld\n", *pResultAction)); 684 691 } 685 catch (HRESULT rc2)686 { 687 rc = rc2;688 } 689 690 return rc;692 catch (HRESULT hr2) 693 { 694 hr = hr2; 695 } 696 697 return hr; 691 698 } 692 699 … … 717 724 return S_OK; 718 725 719 HRESULT rc= S_OK;726 HRESULT hr = S_OK; 720 727 721 728 try … … 738 745 paParms); 739 746 740 DnDGuestResponse *p DnD= d->response();747 DnDGuestResponse *pResp = d->response(); 741 748 /* This blocks until the request is answered (or timeout). */ 742 if (p DnD->waitForGuestResponse() == VERR_TIMEOUT)749 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 743 750 return S_OK; 744 751 745 752 /* Copy the response info */ 746 *pResultAction = d->toMainAction(p DnD->defAction());753 *pResultAction = d->toMainAction(pResp->defAction()); 747 754 LogFlowFunc(("*pResultAction=%ld\n", *pResultAction)); 748 755 } 749 catch (HRESULT rc2)750 { 751 rc = rc2;752 } 753 754 return rc;756 catch (HRESULT hr2) 757 { 758 hr = hr2; 759 } 760 761 return hr; 755 762 } 756 763 … … 760 767 const ComObjPtr<Guest> &p = d->p; 761 768 762 HRESULT rc= S_OK;769 HRESULT hr = S_OK; 763 770 764 771 try … … 768 775 NULL); 769 776 770 DnDGuestResponse *p DnD= d->response();777 DnDGuestResponse *pResp = d->response(); 771 778 /* This blocks until the request is answered (or timeout). */ 772 p DnD->waitForGuestResponse();773 } 774 catch (HRESULT rc2)775 { 776 rc = rc2;777 } 778 779 return rc;779 pResp->waitForGuestResponse(); 780 } 781 catch (HRESULT hr2) 782 { 783 hr = hr2; 784 } 785 786 return hr; 780 787 } 781 788 … … 807 814 return S_OK; 808 815 809 HRESULT rc= S_OK;816 HRESULT hr = S_OK; 810 817 811 818 try … … 828 835 paParms); 829 836 830 DnDGuestResponse *p DnD= d->response();837 DnDGuestResponse *pResp = d->response(); 831 838 /* This blocks until the request is answered (or timeout). */ 832 if (p DnD->waitForGuestResponse() == VERR_TIMEOUT)839 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 833 840 return S_OK; 834 841 835 842 /* Copy the response info */ 836 *pResultAction = d->toMainAction(p DnD->defAction());837 Bstr(p DnD->format()).cloneTo(pstrFormat);843 *pResultAction = d->toMainAction(pResp->defAction()); 844 Bstr(pResp->format()).cloneTo(pstrFormat); 838 845 839 846 LogFlowFunc(("*pResultAction=%ld\n", *pResultAction)); 840 847 } 841 catch (HRESULT rc2)842 { 843 rc = rc2;844 } 845 846 return rc;848 catch (HRESULT hr2) 849 { 850 hr = hr2; 851 } 852 853 return hr; 847 854 } 848 855 … … 853 860 const ComObjPtr<Guest> &p = d->p; 854 861 855 HRESULT rc= S_OK;862 HRESULT hr = S_OK; 856 863 857 864 try … … 868 875 paParms[i++].setUInt32((uint32_t)sfaData.size()); 869 876 870 DnDGuestResponse *p DnD= d->response();877 DnDGuestResponse *pResp = d->response(); 871 878 /* Reset any old progress status. */ 872 p DnD->resetProgress(p);879 pResp->resetProgress(p); 873 880 874 881 /* Note: The actual data transfer of files/directoies is performed by the … … 879 886 880 887 /* Query the progress object to the caller. */ 881 p DnD->queryProgressTo(ppProgress);882 } 883 catch (HRESULT rc2)884 { 885 rc = rc2;886 } 887 888 return rc;888 pResp->queryProgressTo(ppProgress); 889 } 890 catch (HRESULT hr2) 891 { 892 hr = hr2; 893 } 894 895 return hr; 889 896 } 890 897 … … 901 908 *pDefaultAction = DragAndDropAction_Ignore; 902 909 903 HRESULT rc= S_OK;910 HRESULT hr = S_OK; 904 911 905 912 try … … 913 920 paParms); 914 921 915 DnDGuestResponse *pDnD = d->response();916 /* This blocks until the request is answered (or timeout). */917 if (p DnD->waitForGuestResponse() == VERR_TIMEOUT)922 /* This blocks until the request is answered (or timed out). */ 923 DnDGuestResponse *pResp = d->response(); 924 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 918 925 return S_OK; 919 926 920 if (isDnDIgnoreAction(p DnD->defAction()))927 if (isDnDIgnoreAction(pResp->defAction())) 921 928 return S_OK; 922 929 923 930 /* Fetch the default action to use. */ 924 *pDefaultAction = d->toMainAction(pDnD->defAction()); 925 /* Convert the formats strings to a vector of strings. */ 926 d->toFormatSafeArray(pDnD->format(), ComSafeArrayOutArg(formats)); 927 /* Convert the action bit field to a vector of actions. */ 928 d->toMainActions(pDnD->allActions(), ComSafeArrayOutArg(allowedActions)); 931 *pDefaultAction = d->toMainAction(pResp->defAction()); 932 d->toFormatSafeArray(pResp->format(), ComSafeArrayOutArg(formats)); 933 d->toMainActions(pResp->allActions(), ComSafeArrayOutArg(allowedActions)); 929 934 930 935 LogFlowFunc(("*pDefaultAction=0x%x\n", *pDefaultAction)); 931 936 } 932 catch (HRESULT rc2)933 { 934 rc = rc2;935 } 936 937 return rc;937 catch (HRESULT hr2) 938 { 939 hr = hr2; 940 } 941 942 return hr; 938 943 } 939 944 … … 957 962 pcszFormat, uAction, fNeedsDropDir)); 958 963 959 DnDGuestResponse *pDnD = d->response(); 960 AssertPtr(pDnD); 964 DnDGuestResponse *pResp = d->response(); 965 AssertPtr(pResp); 966 967 pResp->reset(); 961 968 962 969 if (fNeedsDropDir) … … 970 977 LogFlowFunc(("Dropped files directory on the host is: %s\n", szDropDir)); 971 978 972 p DnD->setDropDir(szDropDir);979 pResp->setDropDir(szDropDir); 973 980 } 974 981 … … 982 989 983 990 /* Reset any old data and the progress status. */ 984 p DnD->reset();985 p DnD->resetProgress(p);991 pResp->reset(); 992 pResp->resetProgress(p); 986 993 987 994 d->hostCall(DragAndDropSvc::HOST_DND_GH_EVT_DROPPED, … … 990 997 991 998 /* Query the progress object to the caller. */ 992 p DnD->queryProgressTo(ppProgress);993 } 994 catch (HRESULT rc2)995 { 996 hr = rc2;999 pResp->queryProgressTo(ppProgress); 1000 } 1001 catch (HRESULT hr2) 1002 { 1003 hr = hr2; 997 1004 } 998 1005 … … 1019 1026 1020 1027 Utf8Str strFormat = pResp->format(); 1021 LogFlowFunc(("strFormat=%s, strDropDir=%s\n",1022 strFormat.c_str(), pResp->dropDir().c_str()));1028 LogFlowFunc(("strFormat=%s, cbData=%zu, pvData=0x%p\n", 1029 strFormat.c_str(), cbData, pvData)); 1023 1030 1024 1031 if (DnDMIMEHasFileURLs(strFormat.c_str(), strFormat.length())) 1025 1032 { 1033 LogFlowFunc(("strDropDir=%s\n", pResp->dropDir().c_str())); 1034 1026 1035 DnDURIList lstURI; 1027 1036 int rc2 = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */); … … 1029 1038 { 1030 1039 Utf8Str strURIs = lstURI.RootToString(pResp->dropDir()); 1031 if (sfaData.resize(strURIs.length())) 1032 memcpy(sfaData.raw(), strURIs.c_str(), strURIs.length()); 1040 size_t cbURIs = strURIs.length(); 1041 if (sfaData.resize(cbURIs + 1 /* Include termination */)) 1042 memcpy(sfaData.raw(), strURIs.c_str(), cbURIs); 1033 1043 else 1034 1044 hr = E_OUTOFMEMORY; … … 1049 1059 } 1050 1060 1051 LogFlowFunc(("cbData=%zu\n", cbData));1052 1053 1061 /* Detach in any case, regardless of data size. */ 1054 1062 sfaData.detachTo(ComSafeArrayOutArg(data));
Note:
See TracChangeset
for help on using the changeset viewer.