Changeset 50460 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Feb 14, 2014 9:46:58 AM (11 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDImpl.cpp
r50265 r50460 24 24 # include "GuestDnDImpl.h" 25 25 26 # include <iprt/dir.h> 27 # include <iprt/path.h> 28 # include <iprt/stream.h> 29 # include <iprt/semaphore.h> 30 # include <iprt/cpp/utils.h> 31 26 32 # include <VMMDev.h> 27 33 28 34 # include <VBox/com/list.h> 35 # include <VBox/GuestHost/DragAndDrop.h> 29 36 # include <VBox/HostServices/DragAndDropSvc.h> 30 37 … … 34 41 # define LOG_GROUP LOG_GROUP_GUEST_DND 35 42 # include <VBox/log.h> 36 37 # include <iprt/stream.h>38 # include <iprt/semaphore.h>39 # include <iprt/cpp/utils.h>40 43 41 44 /* How does this work: … … 209 212 }; 210 213 214 /** @todo This class needs a major cleanup. Later. */ 211 215 class GuestDnDPrivate 212 216 { 213 217 private: 214 /* todo: currently we only support one response. Maybe this needs to be extended at some time. */ 218 219 /** @todo Currently we only support one response. Maybe this needs to be extended at some time. */ 215 220 GuestDnDPrivate(GuestDnD *q, const ComObjPtr<Guest>& pGuest) 216 221 : q_ptr(q) … … 225 230 void hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const; 226 231 227 /* Static helper */232 /* Static helpers. */ 228 233 static RTCString toFormatString(ComSafeArrayIn(IN_BSTR, formats)); 229 234 static void toFormatSafeArray(const RTCString &strFormats, ComSafeArrayOut(BSTR, formats)); … … 238 243 ComObjPtr<Guest> p; 239 244 240 /* Private helper members */245 /* Private helper members. */ 241 246 static const RTCList<RTCString> m_sstrAllowedMimeTypes; 242 247 DnDGuestResponse *m_pDnDResponse; … … 396 401 ComPtr<IDisplay> pDisplay; 397 402 HRESULT rc = p->mParent->COMGETTER(Display)(pDisplay.asOutParam()); 398 if (FAILED(rc)) throw rc; 403 if (FAILED(rc)) 404 throw rc; 405 399 406 ComPtr<IFramebuffer> pFramebuffer; 400 407 LONG xShift, yShift; 401 rc = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(), &xShift, &yShift); 402 if (FAILED(rc)) throw rc; 408 rc = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(), 409 &xShift, &yShift); 410 if (FAILED(rc)) 411 throw rc; 412 403 413 *puX += xShift; 404 414 *puY += yShift; … … 696 706 } 697 707 698 HRESULT GuestDnD::dragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction) 708 HRESULT GuestDnD::dragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, 709 DragAndDropAction_T defaultAction, 710 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 711 ComSafeArrayIn(IN_BSTR, formats), 712 BSTR *pstrFormat, 713 DragAndDropAction_T *pResultAction) 699 714 { 700 715 DPTR(GuestDnD); … … 783 798 pDnD->resetProgress(p); 784 799 800 /* Note: The actual data transfer of files/directoies is performed by the 801 * DnD host service. */ 785 802 d->hostCall(DragAndDropSvc::HOST_DND_HG_SND_DATA, 786 803 i, … … 854 871 855 872 Utf8Str strFormat(bstrFormat); 856 HRESULT rc= S_OK;873 HRESULT hr = S_OK; 857 874 858 875 uint32_t uAction = d->toHGCMAction(action); … … 861 878 return S_OK; 862 879 880 const char *pcszFormat = strFormat.c_str(); 881 LogFlowFunc(("strFormat=%s, uAction=0x%x\n", pcszFormat, uAction)); 882 if (DnDMIMENeedsDropDir(pcszFormat, strlen(pcszFormat))) 883 { 884 char szDropDir[RTPATH_MAX]; 885 int rc = DnDDirCreateDroppedFiles(szDropDir, sizeof(szDropDir)); 886 if (RT_FAILURE(rc)) 887 return p->setError(VBOX_E_IPRT_ERROR, 888 p->tr("Unable to create the temporary drag'n drop directory \"%s\" (%Rrc)\n"), 889 szDropDir, rc); 890 LogFlowFunc(("Dropped files directory on the host is: %s\n", szDropDir)); 891 } 892 863 893 try 864 894 { 865 LogFlowFunc(("strFormat=%s, uAction=0x%x\n", strFormat.c_str(), uAction));866 867 895 VBOXHGCMSVCPARM paParms[3]; 868 896 int i = 0; … … 872 900 873 901 DnDGuestResponse *pDnD = d->response(); 902 874 903 /* Reset any old data and the progress status. */ 875 904 pDnD->reset(); … … 885 914 catch (HRESULT rc2) 886 915 { 887 rc= rc2;888 } 889 890 return rc;916 hr = rc2; 917 } 918 919 return hr; 891 920 } 892 921 … … 906 935 if (cbData) 907 936 { 908 /* Copy the data into a nsafe array of bytes. */937 /* Copy the data into a safe array of bytes. */ 909 938 const void *pvData = pDnD->data(); 910 939 if (sfaData.resize(cbData)) … … 1006 1035 if (RT_SUCCESS(rc)) 1007 1036 { 1037 /** @todo Store pCBData->cbAllSize in the guest's response struct 1038 * if not set already. */ 1008 1039 uint32_t cbTotalSize = pCBData->cbAllSize; 1009 1040 unsigned int cPercentage; … … 1015 1046 /** @todo Don't use anonymous enums. */ 1016 1047 uint32_t uState = DragAndDropSvc::DND_PROGRESS_RUNNING; 1017 if ( pCBData->cbAllSize == cbCurSize1048 if ( cbTotalSize == cbCurSize 1018 1049 /* Empty data? Should not happen, but anyway ... */ 1019 || ! pCBData->cbAllSize)1050 || !cbTotalSize) 1020 1051 { 1021 1052 uState = DragAndDropSvc::DND_PROGRESS_COMPLETE; … … 1024 1055 rc = pResp->setProgress(cPercentage, uState); 1025 1056 } 1026 /* Todo: for now we instantly confirm the cancel. Check if the 1027 * guest should first clean up stuff itself and than really confirm 1028 * the cancel request by an extra message. */ 1057 1058 /** @todo For now we instantly confirm the cancel. Check if the 1059 * guest should first clean up stuff itself and than really confirm 1060 * the cancel request by an extra message. */ 1029 1061 if (rc == VERR_CANCELLED) 1030 1062 pResp->setProgress(100, DragAndDropSvc::DND_PROGRESS_CANCELLED); … … 1053 1085 return rc; 1054 1086 } 1055 1056 1087 #endif /* VBOX_WITH_DRAG_AND_DROP */ 1057 1088 -
trunk/src/VBox/Main/src-client/GuestImpl.cpp
r50370 r50460 838 838 } 839 839 840 STDMETHODIMP Guest::DragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction) 840 STDMETHODIMP Guest::DragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY, 841 DragAndDropAction_T defaultAction, 842 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 843 ComSafeArrayIn(IN_BSTR, formats), 844 DragAndDropAction_T *pResultAction) 841 845 { 842 846 /* Input validation */ … … 849 853 850 854 #ifdef VBOX_WITH_DRAG_AND_DROP 851 return m_pGuestDnD->dragHGEnter(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pResultAction); 855 return m_pGuestDnD->dragHGEnter(uScreenId, uX, uY, defaultAction, 856 ComSafeArrayInArg(allowedActions), 857 ComSafeArrayInArg(formats), 858 pResultAction); 852 859 #else /* VBOX_WITH_DRAG_AND_DROP */ 853 860 ReturnComNotImplemented(); … … 855 862 } 856 863 857 STDMETHODIMP Guest::DragHGMove(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction) 864 STDMETHODIMP Guest::DragHGMove(ULONG uScreenId, ULONG uX, ULONG uY, 865 DragAndDropAction_T defaultAction, 866 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 867 ComSafeArrayIn(IN_BSTR, formats), 868 DragAndDropAction_T *pResultAction) 858 869 { 859 870 /* Input validation */ … … 866 877 867 878 #ifdef VBOX_WITH_DRAG_AND_DROP 868 return m_pGuestDnD->dragHGMove(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pResultAction); 879 return m_pGuestDnD->dragHGMove(uScreenId, uX, uY, defaultAction, 880 ComSafeArrayInArg(allowedActions), 881 ComSafeArrayInArg(formats), 882 pResultAction); 869 883 #else /* VBOX_WITH_DRAG_AND_DROP */ 870 884 ReturnComNotImplemented(); … … 884 898 } 885 899 886 STDMETHODIMP Guest::DragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction) 900 STDMETHODIMP Guest::DragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, 901 DragAndDropAction_T defaultAction, 902 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 903 ComSafeArrayIn(IN_BSTR, formats), 904 BSTR *pstrFormat, DragAndDropAction_T *pResultAction) 887 905 { 888 906 /* Input validation */ … … 896 914 897 915 #ifdef VBOX_WITH_DRAG_AND_DROP 898 return m_pGuestDnD->dragHGDrop(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pstrFormat, pResultAction); 916 return m_pGuestDnD->dragHGDrop(uScreenId, uX, uY, 917 defaultAction, 918 ComSafeArrayInArg(allowedActions), 919 ComSafeArrayInArg(formats), 920 pstrFormat, pResultAction); 899 921 #else /* VBOX_WITH_DRAG_AND_DROP */ 900 922 ReturnComNotImplemented(); … … 902 924 } 903 925 904 STDMETHODIMP Guest::DragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress) 926 STDMETHODIMP Guest::DragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat, 927 ComSafeArrayIn(BYTE, data), 928 IProgress **ppProgress) 905 929 { 906 930 /* Input validation */ … … 913 937 914 938 #ifdef VBOX_WITH_DRAG_AND_DROP 915 return m_pGuestDnD->dragHGPutData(uScreenId, bstrFormat, ComSafeArrayInArg(data), ppProgress); 939 return m_pGuestDnD->dragHGPutData(uScreenId, bstrFormat, 940 ComSafeArrayInArg(data), ppProgress); 916 941 #else /* VBOX_WITH_DRAG_AND_DROP */ 917 942 ReturnComNotImplemented(); … … 919 944 } 920 945 921 STDMETHODIMP Guest::DragGHPending(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction) 946 STDMETHODIMP Guest::DragGHPending(ULONG uScreenId, 947 ComSafeArrayOut(BSTR, formats), 948 ComSafeArrayOut(DragAndDropAction_T, allowedActions), 949 DragAndDropAction_T *pDefaultAction) 922 950 { 923 951 /* Input validation */ … … 930 958 931 959 #if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH) 932 return m_pGuestDnD->dragGHPending(uScreenId, ComSafeArrayOutArg(formats), ComSafeArrayOutArg(allowedActions), pDefaultAction); 960 return m_pGuestDnD->dragGHPending(uScreenId, 961 ComSafeArrayOutArg(formats), 962 ComSafeArrayOutArg(allowedActions), 963 pDefaultAction); 933 964 #else /* VBOX_WITH_DRAG_AND_DROP */ 934 965 ReturnComNotImplemented(); … … 936 967 } 937 968 938 STDMETHODIMP Guest::DragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action, IProgress **ppProgress) 969 STDMETHODIMP Guest::DragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action, 970 IProgress **ppProgress) 939 971 { 940 972 /* Input validation */
Note:
See TracChangeset
for help on using the changeset viewer.