Changeset 51476 in vbox
- Timestamp:
- May 30, 2014 2:58:02 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 41 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/user_ChangeLogImpl.xml
r50744 r51476 2566 2566 2567 2567 <listitem> 2568 <para>Added experimental support for Drag'n'drop from the host to2568 <para>Added experimental support for drag'n'drop from the host to 2569 2569 Linux guests. Support for more guests and for guest-to-host is 2570 2570 planned. (bug #81)</para> -
trunk/include/VBox/log.h
r51436 r51476 4 4 5 5 /* 6 * Copyright (C) 2006-201 3Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 340 340 /** Main group, IDisplaySourceBitmap. */ 341 341 LOG_GROUP_MAIN_DISPLAYSOURCEBITMAP, 342 /** Main group, IDragAndDropModeChangedEvent. */ 343 LOG_GROUP_MAIN_DRAGANDDROPMODECHANGEDEVENT, 342 /** Main group, IDnDModeChangedEvent. */ 343 LOG_GROUP_MAIN_DNDMODECHANGEDEVENT, 344 /** Main group, IDnDSource. */ 345 LOG_GROUP_MAIN_DNDSOURCE, 346 /** Main group, IDnDTarget. */ 347 LOG_GROUP_MAIN_DNDTARGET, 344 348 /** Main group, IEmulatedUSB. */ 345 349 LOG_GROUP_MAIN_EMULATEDUSB, … … 378 382 /** Main group, IGuestDirectory. */ 379 383 LOG_GROUP_MAIN_GUESTDIRECTORY, 384 /** Main group, IGuestDnDSource. */ 385 LOG_GROUP_MAIN_GUESTDNDSOURCE, 386 /** Main group, IGuestDnDTarget. */ 387 LOG_GROUP_MAIN_GUESTDNDTARGET, 380 388 /** Main group, IGuestErrorInfo. */ 381 389 LOG_GROUP_MAIN_GUESTERRORINFO, … … 901 909 "MAIN_DISPLAY", \ 902 910 "MAIN_DISPLAYSOURCEBITMAP", \ 903 "MAIN_DRAGANDDROPMODECHANGEDEVENT", \ 911 "MAIN_DNDMODECHANGEDEVENT", \ 912 "MAIN_DNDSOURCE", \ 913 "MAIN_DNDTARGET", \ 904 914 "MAIN_EMULATEDUSB", \ 905 915 "MAIN_EVENT", \ … … 920 930 "MAIN_GUEST", \ 921 931 "MAIN_GUESTDIRECTORY", \ 932 "MAIN_GUESTDNDSOURCE", \ 933 "MAIN_GUESTDNDTARGET", \ 922 934 "MAIN_GUESTERRORINFO", \ 923 935 "MAIN_GUESTFILE", \ -
trunk/include/VBox/settings.h
r50996 r51476 934 934 SharedFoldersList llSharedFolders; 935 935 ClipboardMode_T clipboardMode; 936 D ragAndDropMode_T dragAndDropMode;936 DnDMode_T dndMode; 937 937 938 938 uint32_t ulMemoryBalloonSize; -
trunk/src/VBox
- Property svn:mergeinfo changed
/branches/VBox-4.3/src/VBox merged: 93628-93629
- Property svn:mergeinfo changed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
r51206 r51476 668 668 /* 669 669 * Install our allowed MIME types. 670 ** @todo See todo for m_sstrAllowedMimeTypes in GuestDnDImpl.cpp.670 ** @todo Also see GuestDnDPrivate.cpp. 671 671 */ 672 672 const RTCList<RTCString> lstAllowedMimeTypes = RTCList<RTCString>() -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDataObject.cpp
r51469 r51476 34 34 35 35 #ifdef DEBUG 36 /* Enable the following line to get much more debug output about37 * (un)known clipboard formats. */38 //#define VBOX_DND_DEBUG_FORMATS36 /* Enable the following line to get much more debug output about 37 * (un)known clipboard formats. */ 38 //# define VBOX_DND_DEBUG_FORMATS 39 39 #endif 40 40 … … 206 206 return DV_E_FORMATETC; 207 207 208 LogFlowFunc(("pFormatEtc=%p, pMedium=%p\n", pFormatEtc, pMedium));209 210 208 FORMATETC *pThisFormat = &mpFormatEtc[lIndex]; 211 209 AssertPtr(pThisFormat); … … 213 211 STGMEDIUM *pThisMedium = &mpStgMedium[lIndex]; 214 212 AssertPtr(pThisMedium); 213 214 LogFlowFunc(("Using pThisFormat=%p, pThisMedium=%p\n", pThisFormat, pThisMedium)); 215 215 216 216 HRESULT hr = DV_E_FORMATETC; … … 288 288 if (pMedium->hGlobal) 289 289 { 290 /** @todo Not working yet -- needs URI to plain ASCII conversion. */291 292 290 char *pcDst = (char *)GlobalLock(pMedium->hGlobal); 293 291 memcpy(pcDst, mpvData, mcbData); … … 486 484 const char* VBoxDnDDataObject::ClipboardFormatToString(CLIPFORMAT fmt) 487 485 { 488 #if def VBOX_DND_DEBUG_FORMATS486 #if 0 489 487 char szFormat[128]; 490 488 if (GetClipboardFormatName(fmt, szFormat, sizeof(szFormat))) -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropSource.cpp
r51469 r51476 100 100 STDMETHODIMP VBoxDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState) 101 101 { 102 #if ndef DEBUG_andy102 #if 1 103 103 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, muCurAction=%RU32\n", 104 104 fEscapePressed, dwKeyState, mdwCurEffect, muCurAction)); … … 111 111 muCurAction = DND_IGNORE_ACTION; 112 112 113 LogFlowFunc(("Canceled\n")); 113 114 return DRAGDROP_S_CANCEL; 114 115 } … … 116 117 /* Left mouse button released? Start "drop" action. */ 117 118 if ((dwKeyState & MK_LBUTTON) == 0) 119 { 120 LogFlowFunc(("Dropping ...\n")); 118 121 return DRAGDROP_S_DROP; 122 } 119 123 120 124 /* No change, just continue. */ … … 132 136 uint32_t uAction = DND_IGNORE_ACTION; 133 137 134 #if ndef DEBUG_andy138 #if 1 135 139 LogFlowFunc(("dwEffect=0x%x\n", dwEffect)); 136 140 #endif -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
r48538 r51476 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 198 198 } 199 199 200 D ragAndDropMode_T mode;200 DnDMode_T mode; 201 201 if (!strcmp(a->argv[2], "disabled")) 202 mode = D ragAndDropMode_Disabled;202 mode = DnDMode_Disabled; 203 203 else if (!strcmp(a->argv[2], "hosttoguest")) 204 mode = D ragAndDropMode_HostToGuest;204 mode = DnDMode_HostToGuest; 205 205 else if (!strcmp(a->argv[2], "guesttohost")) 206 mode = D ragAndDropMode_GuestToHost;206 mode = DnDMode_GuestToHost; 207 207 else if (!strcmp(a->argv[2], "bidirectional")) 208 mode = D ragAndDropMode_Bidirectional;208 mode = DnDMode_Bidirectional; 209 209 else 210 210 { … … 214 214 if (SUCCEEDED(rc)) 215 215 { 216 CHECK_ERROR_BREAK(sessionMachine, COMSETTER(D ragAndDropMode)(mode));216 CHECK_ERROR_BREAK(sessionMachine, COMSETTER(DnDMode)(mode)); 217 217 } 218 218 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r51384 r51476 1610 1610 { 1611 1611 const char *psz = "Unknown"; 1612 D ragAndDropMode_T enmMode;1613 rc = machine->COMGETTER(D ragAndDropMode)(&enmMode);1612 DnDMode_T enmMode; 1613 rc = machine->COMGETTER(DnDMode)(&enmMode); 1614 1614 switch (enmMode) 1615 1615 { 1616 case D ragAndDropMode_Disabled:1616 case DnDMode_Disabled: 1617 1617 if (details == VMINFO_MACHINEREADABLE) 1618 1618 psz = "disabled"; … … 1620 1620 psz = "disabled"; 1621 1621 break; 1622 case D ragAndDropMode_HostToGuest:1622 case DnDMode_HostToGuest: 1623 1623 if (details == VMINFO_MACHINEREADABLE) 1624 1624 psz = "hosttoguest"; … … 1626 1626 psz = "HostToGuest"; 1627 1627 break; 1628 case D ragAndDropMode_GuestToHost:1628 case DnDMode_GuestToHost: 1629 1629 if (details == VMINFO_MACHINEREADABLE) 1630 1630 psz = "guesttohost"; … … 1632 1632 psz = "GuestToHost"; 1633 1633 break; 1634 case D ragAndDropMode_Bidirectional:1634 case DnDMode_Bidirectional: 1635 1635 if (details == VMINFO_MACHINEREADABLE) 1636 1636 psz = "bidirectional"; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r51259 r51476 2168 2168 case MODIFYVM_DRAGANDDROP: 2169 2169 { 2170 D ragAndDropMode_T mode;2170 DnDMode_T mode; 2171 2171 if (!RTStrICmp(ValueUnion.psz, "disabled")) 2172 mode = D ragAndDropMode_Disabled;2172 mode = DnDMode_Disabled; 2173 2173 else if (!RTStrICmp(ValueUnion.psz, "hosttoguest")) 2174 mode = D ragAndDropMode_HostToGuest;2174 mode = DnDMode_HostToGuest; 2175 2175 else if (!RTStrICmp(ValueUnion.psz, "guesttohost")) 2176 mode = D ragAndDropMode_GuestToHost;2176 mode = DnDMode_GuestToHost; 2177 2177 else if (!RTStrICmp(ValueUnion.psz, "bidirectional")) 2178 mode = D ragAndDropMode_Bidirectional;2178 mode = DnDMode_Bidirectional; 2179 2179 else 2180 2180 { … … 2184 2184 if (SUCCEEDED(rc)) 2185 2185 { 2186 CHECK_ERROR(machine, COMSETTER(D ragAndDropMode)(mode));2186 CHECK_ERROR(machine, COMSETTER(DnDMode)(mode)); 2187 2187 } 2188 2188 break; -
trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.cpp
r51410 r51476 606 606 QString strClipboardMode = gpConverter->toString(m.GetClipboardMode()); 607 607 /* Determine Drag&Drop mode: */ 608 QString strD ragAndDropMode = gpConverter->toString(m.GetDragAndDropMode());608 QString strDnDMode = gpConverter->toString(m.GetDnDMode()); 609 609 610 610 /* Deterine virtualization attributes: */ … … 658 658 strResult += formatValue(tr("VM Uptime"), strUptime, iMaxLength); 659 659 strResult += formatValue(tr("Clipboard Mode"), strClipboardMode, iMaxLength); 660 strResult += formatValue(tr("Drag'n'Drop Mode"), strD ragAndDropMode, iMaxLength);660 strResult += formatValue(tr("Drag'n'Drop Mode"), strDnDMode, iMaxLength); 661 661 strResult += formatValue(VBoxGlobal::tr("VT-x/AMD-V", "details report"), strVirtualization, iMaxLength); 662 662 strResult += formatValue(VBoxGlobal::tr("Nested Paging", "details report"), strNestedPaging, iMaxLength); -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h
r51401 r51476 6 6 7 7 /* 8 * Copyright (C) 2012 Oracle Corporation8 * Copyright (C) 2012-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 88 88 template<> bool canConvert<KDeviceType>(); 89 89 template<> bool canConvert<KClipboardMode>(); 90 template<> bool canConvert<KD ragAndDropMode>();90 template<> bool canConvert<KDnDMode>(); 91 91 template<> bool canConvert<KPointingHIDType>(); 92 92 template<> bool canConvert<KMediumType>(); … … 161 161 template<> QString toString(const KDeviceType &type); 162 162 template<> QString toString(const KClipboardMode &mode); 163 template<> QString toString(const KD ragAndDropMode &mode);163 template<> QString toString(const KDnDMode &mode); 164 164 template<> QString toString(const KPointingHIDType &type); 165 165 template<> QString toString(const KMediumType &type); -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp
r50041 r51476 7 7 8 8 /* 9 * Copyright (C) 2012-201 3Oracle Corporation9 * Copyright (C) 2012-2014 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 34 34 template<> bool canConvert<KDeviceType>() { return true; } 35 35 template<> bool canConvert<KClipboardMode>() { return true; } 36 template<> bool canConvert<KD ragAndDropMode>() { return true; }36 template<> bool canConvert<KDnDMode>() { return true; } 37 37 template<> bool canConvert<KPointingHIDType>() { return true; } 38 38 template<> bool canConvert<KMediumType>() { return true; } … … 202 202 } 203 203 204 /* QString <= KD ragAndDropMode: */205 template<> QString toString(const KD ragAndDropMode &mode)204 /* QString <= KDnDMode: */ 205 template<> QString toString(const KDnDMode &mode) 206 206 { 207 207 switch (mode) 208 208 { 209 case KD ragAndDropMode_Disabled: return QApplication::translate("VBoxGlobal", "Disabled", "DragAndDropType");210 case KD ragAndDropMode_HostToGuest: return QApplication::translate("VBoxGlobal", "Host To Guest", "DragAndDropType");211 case KD ragAndDropMode_GuestToHost: return QApplication::translate("VBoxGlobal", "Guest To Host", "DragAndDropType");212 case KD ragAndDropMode_Bidirectional: return QApplication::translate("VBoxGlobal", "Bidirectional", "DragAndDropType");209 case KDnDMode_Disabled: return QApplication::translate("VBoxGlobal", "Disabled", "DragAndDropType"); 210 case KDnDMode_HostToGuest: return QApplication::translate("VBoxGlobal", "Host To Guest", "DragAndDropType"); 211 case KDnDMode_GuestToHost: return QApplication::translate("VBoxGlobal", "Guest To Host", "DragAndDropType"); 212 case KDnDMode_Bidirectional: return QApplication::translate("VBoxGlobal", "Bidirectional", "DragAndDropType"); 213 213 default: AssertMsgFailed(("No text for %d", mode)); break; 214 214 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp
r50604 r51476 41 41 42 42 UIDnDDataObject::UIDnDDataObject(CSession &session, 43 CDnDSource &dndSource, 43 44 const QStringList &lstFormats, 44 45 QWidget *pParent) 45 46 : mSession(session), 47 mDnDSource(dndSource), 46 48 mpParent(pParent), 47 49 mStatus(Uninitialized), … … 65 67 RT_BZERO(mpStgMedium, sizeof(STGMEDIUM) * cMaxFormats); 66 68 67 for (int i = 0; i < lstFormats.size(); i++) 69 for (int i = 0; 70 ( i < lstFormats.size() 71 && i < cMaxFormats); i++) 68 72 { 69 73 const QString &strFormat = lstFormats.at(i); … … 95 99 } 96 100 97 LogFlowFunc(("Total registered formats: %RU32 (of %d total)\n",101 LogFlowFunc(("Total registered native formats: %RU32 (for %d formats from guest)\n", 98 102 cRegisteredFormats, lstFormats.size())); 99 103 hr = S_OK; … … 290 294 { 291 295 rc = UIDnDDrag::RetrieveData(mSession, 296 mDnDSource, 297 /** @todo Support other actions. */ 292 298 Qt::CopyAction, 293 299 strMIMEType, vaType, mVaData, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.h
r50604 r51476 29 29 /* COM includes: */ 30 30 #include "COMEnums.h" 31 #include "CDndSource.h" 31 32 #include "CSession.h" 32 33 … … 49 50 public: 50 51 51 UIDnDDataObject(CSession &session, const QStringList &lstFormats, QWidget *pParent);52 UIDnDDataObject(CSession &session, CDnDSource &dndSource, const QStringList &lstFormats, QWidget *pParent); 52 53 virtual ~UIDnDDataObject(void); 53 54 … … 87 88 QWidget *mpParent; 88 89 CSession mSession; 90 CDnDSource mDnDSource; 89 91 Status mStatus; 90 92 LONG mRefCount; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp
r51033 r51476 44 44 #endif 45 45 46 UIDnDDrag::UIDnDDrag(CSession &session, 46 UIDnDDrag::UIDnDDrag(CSession &session, 47 CDnDSource &dndSource, 47 48 const QStringList &lstFormats, 48 49 Qt::DropAction defAction, Qt::DropActions actions, 49 50 QWidget *pParent /* = NULL */) 50 51 : m_session(session) 52 , m_dndSource(dndSource) 51 53 , m_lstFormats(lstFormats) 52 54 , m_defAction(defAction) … … 72 74 #ifdef RT_OS_WINDOWS 73 75 UIDnDDropSource *pDropSource = new UIDnDDropSource(m_pParent); 74 UIDnDDataObject *pDataObject = new UIDnDDataObject(m_session, m_ lstFormats, m_pParent);76 UIDnDDataObject *pDataObject = new UIDnDDataObject(m_session, m_dndSource, m_lstFormats, m_pParent); 75 77 76 78 DWORD dwOKEffects = DROPEFFECT_NONE; … … 86 88 87 89 DWORD dwEffect; 90 LogFlowFunc(("dwOKEffects=0x%x\n", dwOKEffects)); 88 91 HRESULT hr = ::DoDragDrop(pDataObject, pDropSource, 89 92 dwOKEffects, &dwEffect); 90 LogFlow ThisFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n",91 93 LogFlowFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n", 94 hr, dwEffect)); 92 95 93 96 if (pDropSource) … … 99 102 100 103 /* pMData is transfered to the QDrag object, so no need for deletion. */ 101 pMData = new UIDnDMimeData(m_session, 104 pMData = new UIDnDMimeData(m_session, m_dndSource, 102 105 m_lstFormats, m_defAction, m_actions, 103 106 m_pParent); … … 129 132 /* static */ 130 133 int UIDnDDrag::RetrieveData(const CSession &session, 134 CDnDSource &dndSource, 131 135 Qt::DropAction dropAction, 132 136 const QString &strMimeType, … … 140 144 CGuest guest = session.GetConsole().GetGuest(); 141 145 142 /* Start getting the data from the guest. First inform the guestwe146 /* Start getting the data from the source. First inform the source we 143 147 * want the data in the specified MIME type. */ 144 CProgress progress = guest.DragGHDropped(strMimeType,145 148 CProgress progress = dndSource.Drop(strMimeType, 149 UIDnDHandler::toVBoxDnDAction(dropAction)); 146 150 if (guest.isOk()) 147 151 { … … 157 161 if (RT_SUCCESS(rc)) 158 162 { 159 /* After the data successfully arrived from the guest, we query it from Main. */ 160 QVector<uint8_t> vecData = guest.DragGHGetData(); 163 /* After we successfully retrieved data from 164 * the source, we query it from Main. */ 165 QVector<uint8_t> vecData = dndSource.ReceiveData(); 161 166 if (!vecData.isEmpty()) 162 167 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.h
r50602 r51476 28 28 #include "CSession.h" 29 29 #include "CConsole.h" 30 #include "CDnDSource.h" 30 31 #include "CGuest.h" 31 32 … … 45 46 public: 46 47 47 UIDnDDrag(CSession &session, 48 UIDnDDrag(CSession &session, CDnDSource &dndSource, 48 49 const QStringList &lstFormats, Qt::DropAction defAction, Qt::DropActions actions, 49 50 QWidget *pParent = NULL); … … 54 55 public: 55 56 56 static int RetrieveData(const CSession &session, Qt::DropAction dropAction, const QString &strMimeType, QVariant::Type vaType, QVariant &vaData, QWidget *pParent);57 static int RetrieveData(const CSession &session, CDnDSource &dndSource, Qt::DropAction dropAction, const QString &strMimeType, QVariant::Type vaType, QVariant &vaData, QWidget *pParent); 57 58 58 59 private: 59 60 60 61 CSession m_session; 62 CDnDSource m_dndSource; 61 63 QStringList m_lstFormats; 62 64 Qt::DropAction m_defAction; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp
r51033 r51476 34 34 #include "UIDnDHandler.h" 35 35 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 36 # include "CDnDSource.h" 36 37 # include "UIDnDDrag.h" 37 38 #endif … … 39 40 40 41 /* COM includes: */ 42 #include "CConsole.h" 43 #include "CDnDTarget.h" 44 #include "CGuest.h" 41 45 #include "CSession.h" 42 #include "CConsole.h" 43 #include "CGuest.h" 46 47 44 48 45 49 UIDnDHandler *UIDnDHandler::m_pInstance = NULL; 46 50 47 51 UIDnDHandler::UIDnDHandler(void) 48 : mMode(Unknown)49 52 { 50 53 } 51 54 52 55 /* 53 * Host -> Guest 54 */ 55 56 Qt::DropAction UIDnDHandler::dragHGEnter(CGuest &guest, ulong screenId, int x, int y, 57 Qt::DropAction proposedAction, Qt::DropActions possibleActions, 58 const QMimeData *pMimeData, QWidget * /* pParent = NULL */) 59 { 60 if (mMode == GH) /* Wrong mode? Bail out. */ 61 return Qt::IgnoreAction; 62 56 * Frontend -> Target. 57 */ 58 59 Qt::DropAction UIDnDHandler::dragEnter(CDnDTarget &dndTarget, ulong screenId, int x, int y, 60 Qt::DropAction proposedAction, Qt::DropActions possibleActions, 61 const QMimeData *pMimeData, QWidget * /* pParent = NULL */) 62 { 63 63 LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n", 64 64 screenId, x, y, toVBoxDnDAction(proposedAction))); 65 65 66 66 /* Ask the guest for starting a DnD event. */ 67 KDragAndDropAction result = guest.DragHGEnter(screenId, 68 x, 69 y, 70 toVBoxDnDAction(proposedAction), 71 toVBoxDnDActions(possibleActions), 72 pMimeData->formats().toVector()); 67 KDnDAction result = dndTarget.Enter(screenId, 68 x, 69 y, 70 toVBoxDnDAction(proposedAction), 71 toVBoxDnDActions(possibleActions), 72 pMimeData->formats().toVector()); 73 73 74 /* Set the DnD action returned by the guest. */ 74 75 return toQtDnDAction(result); 75 76 } 76 77 77 Qt::DropAction UIDnDHandler::dragHGMove(CGuest &guest, ulong screenId, int x, int y, 78 Qt::DropAction proposedAction, Qt::DropActions possibleActions, 79 const QMimeData *pMimeData, QWidget * /* pParent = NULL */) 80 { 81 if (mMode == GH) /* Wrong mode? Bail out. */ 82 return Qt::IgnoreAction; 83 78 Qt::DropAction UIDnDHandler::dragMove(CDnDTarget &dndTarget, ulong screenId, int x, int y, 79 Qt::DropAction proposedAction, Qt::DropActions possibleActions, 80 const QMimeData *pMimeData, QWidget * /* pParent = NULL */) 81 { 84 82 #ifdef DEBUG_andy 85 83 LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n", … … 89 87 /* Notify the guest that the mouse has been moved while doing 90 88 * a drag'n drop operation. */ 91 KD ragAndDropAction result = guest.DragHGMove(screenId,92 93 94 95 96 89 KDnDAction result = dndTarget.Move(screenId, 90 x, 91 y, 92 toVBoxDnDAction(proposedAction), 93 toVBoxDnDActions(possibleActions), 94 pMimeData->formats().toVector()); 97 95 /* Set the DnD action returned by the guest. */ 98 96 return toQtDnDAction(result); 99 97 } 100 98 101 Qt::DropAction UIDnDHandler::drag HGDrop(CGuest &guest, ulong screenId, int x, int y,102 Qt::DropAction proposedAction, Qt::DropActions possibleActions,103 const QMimeData *pMimeData, QWidget *pParent /* = NULL */)104 { 105 if (mMode == GH) /* Wrong mode? Bail out. */ 106 return Qt::IgnoreAction;99 Qt::DropAction UIDnDHandler::dragDrop(CSession &session, CDnDTarget &dndTarget, 100 ulong screenId, int x, int y, 101 Qt::DropAction proposedAction, Qt::DropActions possibleActions, 102 const QMimeData *pMimeData, QWidget *pParent /* = NULL */) 103 { 104 CGuest guest = session.GetConsole().GetGuest(); 107 105 108 106 LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n", … … 112 110 QString format; 113 111 /* Ask the guest for dropping data. */ 114 KD ragAndDropAction result = guest.DragHGDrop(screenId,115 116 117 118 119 112 KDnDAction result = dndTarget.Drop(screenId, 113 x, 114 y, 115 toVBoxDnDAction(proposedAction), 116 toVBoxDnDActions(possibleActions), 117 pMimeData->formats().toVector(), format); 120 118 /* Has the guest accepted the drop event? */ 121 if (result != KD ragAndDropAction_Ignore)119 if (result != KDnDAction_Ignore) 122 120 { 123 121 /* Get the actual MIME data in the requested format. */ 122 AssertPtr(pMimeData); 124 123 const QByteArray &d = pMimeData->data(format); 125 124 if ( !d.isEmpty() … … 131 130 memcpy(dv.data(), d.constData(), d.size()); 132 131 133 CProgress progress = guest.DragHGPutData(screenId, format, dv);132 CProgress progress = dndTarget.SendData(screenId, format, dv); 134 133 if (guest.isOk()) 135 134 { … … 142 141 { 143 142 msgCenter().cannotDropData(progress, pParent); 144 result = KD ragAndDropAction_Ignore;143 result = KDnDAction_Ignore; 145 144 } 146 145 } … … 148 147 { 149 148 msgCenter().cannotDropData(guest, pParent); 150 result = KD ragAndDropAction_Ignore;149 result = KDnDAction_Ignore; 151 150 } 152 151 } … … 156 155 } 157 156 158 void UIDnDHandler::dragHGLeave(CGuest &guest, ulong screenId, QWidget * /* pParent = NULL */) 159 { 160 if (mMode == GH) /* Wrong mode? Bail out. */ 161 return; 162 157 void UIDnDHandler::dragLeave(CDnDTarget &dndTarget, 158 ulong screenId, QWidget * /* pParent = NULL */) 159 { 163 160 LogFlowFunc(("screenId=%RU32\n", screenId)); 164 guest.DragHGLeave(screenId); 165 } 166 167 int UIDnDHandler::dragGHPending(CSession &session, ulong screenId, QWidget *pParent /* = NULL */) 161 dndTarget.Leave(screenId); 162 } 163 164 /* 165 * Source -> Frontend. 166 */ 167 168 int UIDnDHandler::dragIsPending(CSession &session, CDnDSource &dndSource, 169 ulong screenId, QWidget *pParent /* = NULL */) 168 170 { 169 171 int rc; 170 172 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 171 if (mMode == HG) /* Wrong mode? Bail out. */172 return VERR_WRONG_ORDER;173 174 173 /* 175 * How this works: Host is asking the guest if there is any DnD176 * operation pending, when the mouse leaves the guest window 177 * (DragGHPending). On return there is some info about a running DnD178 * operation (or defaultAction is KDragAndDropAction_Ignore if not). With174 * How this works: Source is asking the target if there is any DnD 175 * operation pending, when the mouse leaves the guest window. On 176 * return there is some info about a running DnD operation 177 * (or defaultAction is KDnDAction_Ignore if not). With 179 178 * this information we create a Qt QDrag object with our own QMimeType 180 179 * implementation and call exec. Please note, this *blocks* until the DnD … … 183 182 CGuest guest = session.GetConsole().GetGuest(); 184 183 QVector<QString> vecFmtGuest; 185 QVector<KD ragAndDropAction> vecActions;186 KD ragAndDropAction defaultAction = guest.DragGHPending(screenId, vecFmtGuest, vecActions);184 QVector<KDnDAction> vecActions; 185 KDnDAction defaultAction = dndSource.DragIsPending(screenId, vecFmtGuest, vecActions); 187 186 LogFlowFunc(("defaultAction=%d, numFormats=%d\n", defaultAction, vecFmtGuest.size())); 188 187 189 188 QStringList lstFmtNative; 190 if (defaultAction != KD ragAndDropAction_Ignore)189 if (defaultAction != KDnDAction_Ignore) 191 190 { 192 191 /* … … 234 233 if (!lstFmtNative.isEmpty()) 235 234 { 236 UIDnDDrag *pDrag = new UIDnDDrag(session, lstFmtNative, 237 toQtDnDAction(defaultAction), 238 toQtDnDActions(vecActions), pParent); 239 rc = pDrag->DoDragDrop(); 240 241 delete pDrag; 235 try 236 { 237 UIDnDDrag *pDrag = new UIDnDDrag(session, dndSource, lstFmtNative, 238 toQtDnDAction(defaultAction), 239 toQtDnDActions(vecActions), pParent); 240 rc = pDrag->DoDragDrop(); 241 242 delete pDrag; 243 } 244 catch (std::bad_alloc &) 245 { 246 rc = VERR_NO_MEMORY; 247 } 242 248 } 243 else 244 rc = V INF_SUCCESS;249 else /* No format data from the guest arrived yet. */ 250 rc = VERR_NO_DATA; 245 251 #else /* !VBOX_WITH_DRAG_AND_DROP_GH */ 246 252 NOREF(session); … … 260 266 261 267 /* static */ 262 KD ragAndDropAction UIDnDHandler::toVBoxDnDAction(Qt::DropAction action)268 KDnDAction UIDnDHandler::toVBoxDnDAction(Qt::DropAction action) 263 269 { 264 270 if (action == Qt::CopyAction) 265 return KD ragAndDropAction_Copy;271 return KDnDAction_Copy; 266 272 if (action == Qt::MoveAction) 267 return KD ragAndDropAction_Move;273 return KDnDAction_Move; 268 274 if (action == Qt::LinkAction) 269 return KD ragAndDropAction_Link;270 271 return KD ragAndDropAction_Ignore;275 return KDnDAction_Link; 276 277 return KDnDAction_Ignore; 272 278 } 273 279 274 280 /* static */ 275 QVector<KD ragAndDropAction> UIDnDHandler::toVBoxDnDActions(Qt::DropActions actions)276 { 277 QVector<KD ragAndDropAction> vbActions;281 QVector<KDnDAction> UIDnDHandler::toVBoxDnDActions(Qt::DropActions actions) 282 { 283 QVector<KDnDAction> vbActions; 278 284 if (actions.testFlag(Qt::IgnoreAction)) 279 vbActions << KD ragAndDropAction_Ignore;285 vbActions << KDnDAction_Ignore; 280 286 if (actions.testFlag(Qt::CopyAction)) 281 vbActions << KD ragAndDropAction_Copy;287 vbActions << KDnDAction_Copy; 282 288 if (actions.testFlag(Qt::MoveAction)) 283 vbActions << KD ragAndDropAction_Move;289 vbActions << KDnDAction_Move; 284 290 if (actions.testFlag(Qt::LinkAction)) 285 vbActions << KD ragAndDropAction_Link;291 vbActions << KDnDAction_Link; 286 292 287 293 return vbActions; … … 289 295 290 296 /* static */ 291 Qt::DropAction UIDnDHandler::toQtDnDAction(KD ragAndDropAction action)297 Qt::DropAction UIDnDHandler::toQtDnDAction(KDnDAction action) 292 298 { 293 299 Qt::DropAction dropAct = Qt::IgnoreAction; 294 if (action == KD ragAndDropAction_Copy)300 if (action == KDnDAction_Copy) 295 301 dropAct = Qt::CopyAction; 296 if (action == KD ragAndDropAction_Move)302 if (action == KDnDAction_Move) 297 303 dropAct = Qt::MoveAction; 298 if (action == KD ragAndDropAction_Link)304 if (action == KDnDAction_Link) 299 305 dropAct = Qt::LinkAction; 300 306 … … 304 310 305 311 /* static */ 306 Qt::DropActions UIDnDHandler::toQtDnDActions(const QVector<KD ragAndDropAction> &vecActions)312 Qt::DropActions UIDnDHandler::toQtDnDActions(const QVector<KDnDAction> &vecActions) 307 313 { 308 314 Qt::DropActions dropActs = Qt::IgnoreAction; … … 311 317 switch (vecActions.at(i)) 312 318 { 313 case KD ragAndDropAction_Ignore:319 case KDnDAction_Ignore: 314 320 dropActs |= Qt::IgnoreAction; 315 321 break; 316 case KD ragAndDropAction_Copy:322 case KDnDAction_Copy: 317 323 dropActs |= Qt::CopyAction; 318 324 break; 319 case KD ragAndDropAction_Move:325 case KDnDAction_Move: 320 326 dropActs |= Qt::MoveAction; 321 327 break; 322 case KD ragAndDropAction_Link:328 case KDnDAction_Link: 323 329 dropActs |= Qt::LinkAction; 324 330 break; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.h
r50460 r51476 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIDnDHandler class declaration 5 * UIDnDHandler class declaration. 6 6 */ 7 7 … … 26 26 /* Forward declarations: */ 27 27 class QMimeData; 28 class CDnDSource; 29 class CDnDTarget; 30 class CGuest; 28 31 class CSession; 29 class CGuest;30 32 class UIDnDMimeData; 31 33 … … 37 39 38 40 /* Singleton factory. */ 39 static UIDnDHandler *instance(void)41 static UIDnDHandler *instance(void) 40 42 { 41 43 if (!m_pInstance) … … 56 58 * Current operation mode. 57 59 */ 58 enum Mode60 enum Direction 59 61 { 60 62 /** Unknown mode. */ 61 63 Unknown = 0, 62 64 /** Host to guest. */ 63 H G,65 HostToGuest, 64 66 /** Guest to host. */ 65 GH 67 GuestToHost 68 /** @todo Implement guest to guest. */ 66 69 }; 67 70 68 /* Host -> Guest. */69 Qt::DropAction dragHGEnter(CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);70 Qt::DropAction dragHGMove (CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);71 Qt::DropAction dragHGDrop (CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);72 void dragHGLeave(CGuest &guest, ulong screenId, QWidget *pParent = NULL);71 /* Frontend -> Target. */ 72 Qt::DropAction dragEnter(CDnDTarget &dndTarget, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL); 73 Qt::DropAction dragMove (CDnDTarget &dndTarget, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL); 74 Qt::DropAction dragDrop (CSession &session, CDnDTarget &dndTarget, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL); 75 void dragLeave(CDnDTarget &dndTarget, ulong screenId, QWidget *pParent = NULL); 73 76 74 /* Guest -> Host. */75 int dragGHPending(CSession &session, ulong screenId, QWidget *pParent = NULL);77 /* Source -> Frontend. */ 78 int dragIsPending(CSession &session, CDnDSource &dndSource, ulong screenId, QWidget *pParent = NULL); 76 79 77 80 public: 78 81 79 static KD ragAndDropAction toVBoxDnDAction(Qt::DropAction action);80 static QVector<KD ragAndDropAction> toVBoxDnDActions(Qt::DropActions actions);81 static Qt::DropAction toQtDnDAction(KDragAndDropAction action);82 static Qt::DropActions toQtDnDActions(const QVector<KDragAndDropAction> &vecActions);82 static KDnDAction toVBoxDnDAction(Qt::DropAction action); 83 static QVector<KDnDAction> toVBoxDnDActions(Qt::DropActions actions); 84 static Qt::DropAction toQtDnDAction(KDnDAction action); 85 static Qt::DropActions toQtDnDActions(const QVector<KDnDAction> &vecActions); 83 86 84 87 private: 85 static UIDnDHandler *m_pInstance;86 88 87 89 UIDnDHandler(void); 88 90 virtual ~UIDnDHandler(void) {} 89 91 90 /** The current operation mode. */ 91 Mode mMode; 92 private: 93 94 /** Static pointer to singleton instance. */ 95 static UIDnDHandler *m_pInstance; 92 96 }; 93 97 94 #define gDnD UIDnDHandler::instance() 98 /** Gets the singleton instance of the drag'n drop UI helper class. */ 99 #define DnDHandler() UIDnDHandler::instance() 95 100 96 101 #endif /* ___UIDnDHandler_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp
r51033 r51476 38 38 #include "UIMessageCenter.h" 39 39 40 UIDnDMimeData::UIDnDMimeData(CSession &session, 40 UIDnDMimeData::UIDnDMimeData(CSession &session, 41 CDnDSource &dndSource, 41 42 QStringList formats, 42 43 Qt::DropAction defAction, Qt::DropActions actions, 43 44 QWidget *pParent) 44 45 : m_Session(session) 46 , m_DnDSource(dndSource) 45 47 , m_lstFormats(formats) 46 48 , m_defAction(defAction) … … 109 111 110 112 QVariant UIDnDMimeData::retrieveData(const QString &strMIMEType, 111 QVariant::Type vaType) const113 QVariant::Type vaType) 112 114 { 113 115 LogFlowFunc(("m_enmState=%d, mimeType=%s, type=%d (%s)\n", … … 165 167 { 166 168 rc = UIDnDDrag::RetrieveData(m_Session, 169 m_DnDSource, 167 170 m_defAction, 168 171 strMIMEType, vaType, m_vaData, … … 198 201 LogFlowFunc(("MouseMove: x=%d, y=%d\n", 199 202 pMouseEvent->globalX(), pMouseEvent->globalY())); 200 203 201 204 return true; 202 205 /* Never reached. */ … … 207 210 LogFlowFunc(("MouseButtonRelease\n")); 208 211 m_enmState = Dropped; 209 212 210 213 return true; 211 214 /* Never reached. */ … … 220 223 m_enmState = Canceled; 221 224 } 222 225 223 226 return true; 224 227 /* Never reached. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h
r50734 r51476 26 26 /* COM includes: */ 27 27 #include "COMEnums.h" 28 #include "CConsole.h" 29 #include "CDnDSource.h" 30 #include "CGuest.h" 28 31 #include "CSession.h" 29 #include "CConsole.h"30 #include "CGuest.h"31 32 32 33 #include "UIDnDHandler.h" … … 61 62 public: 62 63 63 UIDnDMimeData(CSession &session, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent);64 UIDnDMimeData(CSession &session, CDnDSource &dndSource, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent); 64 65 65 66 public: … … 78 79 virtual bool hasFormat(const QString &mimeType) const; 79 80 80 virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;81 virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type); 81 82 82 83 #ifndef RT_OS_WINDOWS … … 98 99 99 100 CSession m_Session; 101 CDnDSource m_DnDSource; 100 102 QStringList m_lstFormats; 101 103 Qt::DropAction m_defAction; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r51398 r51476 5 5 6 6 /* 7 * Copyright (C) 2010-201 3Oracle Corporation7 * Copyright (C) 2010-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 729 729 { 730 730 foreach (QAction *pAction, m_pDragAndDropActions->actions()) 731 pAction->setText(gpConverter->toString(pAction->data().value<KD ragAndDropMode>()));731 pAction->setText(gpConverter->toString(pAction->data().value<KDnDMode>())); 732 732 } 733 733 } … … 1864 1864 { 1865 1865 m_pDragAndDropActions = new QActionGroup(this); 1866 for (int i = KD ragAndDropMode_Disabled; i < KDragAndDropMode_Max; ++i)1866 for (int i = KDnDMode_Disabled; i < KDnDMode_Max; ++i) 1867 1867 { 1868 KD ragAndDropMode mode = (KDragAndDropMode)i;1868 KDnDMode mode = (KDnDMode)i; 1869 1869 QAction *pAction = new QAction(gpConverter->toString(mode), m_pDragAndDropActions); 1870 1870 pMenu->addAction(pAction); 1871 1871 pAction->setData(QVariant::fromValue(mode)); 1872 1872 pAction->setCheckable(true); 1873 pAction->setChecked(session().GetMachine().GetD ragAndDropMode() == mode);1873 pAction->setChecked(session().GetMachine().GetDnDMode() == mode); 1874 1874 } 1875 1875 connect(m_pDragAndDropActions, SIGNAL(triggered(QAction*)), … … 1879 1879 else 1880 1880 foreach (QAction *pAction, m_pDragAndDropActions->actions()) 1881 if (pAction->data().value<KD ragAndDropMode>() == session().GetMachine().GetDragAndDropMode())1881 if (pAction->data().value<KDnDMode>() == session().GetMachine().GetDnDMode()) 1882 1882 pAction->setChecked(true); 1883 1883 } … … 1961 1961 { 1962 1962 /* Assign new mode (without save): */ 1963 KD ragAndDropMode mode = pAction->data().value<KDragAndDropMode>();1964 session().GetMachine().SetD ragAndDropMode(mode);1963 KDnDMode mode = pAction->data().value<KDnDMode>(); 1964 session().GetMachine().SetDnDMode(mode); 1965 1965 } 1966 1966 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r51467 r51476 61 61 #include "CFramebuffer.h" 62 62 #ifdef VBOX_WITH_DRAG_AND_DROP 63 # include "CDnDSource.h" 64 # include "CDnDTarget.h" 63 65 # include "CGuest.h" 66 # include "CGuestDnDTarget.h" 67 # include "CGuestDnDSource.h" 64 68 #endif /* VBOX_WITH_DRAG_AND_DROP */ 65 69 … … 1160 1164 void UIMachineView::dragEnterEvent(QDragEnterEvent *pEvent) 1161 1165 { 1162 /* The guest object to talk to. */ 1166 AssertPtrReturnVoid(pEvent); 1167 1168 /* Get mouse-pointer location. */ 1169 const QPoint &cpnt = viewportToContents(pEvent->pos()); 1170 1163 1171 CGuest guest = session().GetConsole().GetGuest(); 1164 1165 /* Get mouse-pointer location */ 1166 const QPoint &cpnt = viewportToContents(pEvent->pos()); 1167 1168 /* Ask the guest for starting a DnD event. */ 1169 Qt::DropAction result = gDnD->dragHGEnter(guest, 1170 screenId(), 1171 frameBuffer()->convertHostXTo(cpnt.x()), 1172 frameBuffer()->convertHostYTo(cpnt.y()), 1173 pEvent->proposedAction(), 1174 pEvent->possibleActions(), 1175 pEvent->mimeData(), this); 1172 CGuestDnDTarget dndTarget = guest.GetDnDTarget(); 1173 1174 /* Ask the target for starting a DnD event. */ 1175 Qt::DropAction result = DnDHandler()->dragEnter(static_cast<CDnDTarget>(dndTarget), 1176 screenId(), 1177 frameBuffer()->convertHostXTo(cpnt.x()), 1178 frameBuffer()->convertHostYTo(cpnt.y()), 1179 pEvent->proposedAction(), 1180 pEvent->possibleActions(), 1181 pEvent->mimeData(), this /* pParent */); 1176 1182 1177 1183 /* Set the DnD action returned by the guest. */ … … 1182 1188 void UIMachineView::dragMoveEvent(QDragMoveEvent *pEvent) 1183 1189 { 1184 /* The guest object to talk to. */ 1190 AssertPtrReturnVoid(pEvent); 1191 1192 /* Get mouse-pointer location. */ 1193 const QPoint &cpnt = viewportToContents(pEvent->pos()); 1194 1185 1195 CGuest guest = session().GetConsole().GetGuest(); 1186 1187 /* Get mouse-pointer location */ 1188 const QPoint &cpnt = viewportToContents(pEvent->pos()); 1196 CGuestDnDTarget dndTarget = guest.GetDnDTarget(); 1189 1197 1190 1198 /* Ask the guest for moving the drop cursor. */ 1191 Qt::DropAction result = gDnD->dragHGMove(guest,1192 screenId(),1193 frameBuffer()->convertHostXTo(cpnt.x()),1194 frameBuffer()->convertHostYTo(cpnt.y()),1195 pEvent->proposedAction(),1196 pEvent->possibleActions(),1197 pEvent->mimeData(), this);1199 Qt::DropAction result = DnDHandler()->dragMove(static_cast<CDnDTarget>(dndTarget), 1200 screenId(), 1201 frameBuffer()->convertHostXTo(cpnt.x()), 1202 frameBuffer()->convertHostYTo(cpnt.y()), 1203 pEvent->proposedAction(), 1204 pEvent->possibleActions(), 1205 pEvent->mimeData(), this /* pParent */); 1198 1206 1199 1207 /* Set the DnD action returned by the guest. */ … … 1204 1212 void UIMachineView::dragLeaveEvent(QDragLeaveEvent *pEvent) 1205 1213 { 1206 /* The guest object to talk to. */ 1214 AssertPtrReturnVoid(pEvent); 1215 1207 1216 CGuest guest = session().GetConsole().GetGuest(); 1217 CGuestDnDTarget dndTarget = guest.GetDnDTarget(); 1208 1218 1209 1219 /* Ask the guest for stopping this DnD event. */ 1210 gDnD->dragHGLeave(guest, screenId(), this); 1220 DnDHandler()->dragLeave(static_cast<CDnDTarget>(dndTarget), 1221 screenId(), this /* pParent */); 1211 1222 pEvent->accept(); 1212 1223 } 1213 1224 1225 void UIMachineView::dragIsPending(void) 1226 { 1227 /* At the moment we only support guest->host DnD. */ 1228 /** @todo Add guest->guest DnD functionality here by getting 1229 * the source of guest B (when copying from B to A). */ 1230 CGuest guest = session().GetConsole().GetGuest(); 1231 CDnDSource &dndSource = static_cast<CDnDSource>(guest.GetDnDSource()); 1232 1233 /* Check for a pending DnD event within the guest and if so, handle all the 1234 * magic. */ 1235 DnDHandler()->dragIsPending(session(), dndSource, screenId(), this /* pParent */); 1236 } 1237 1214 1238 void UIMachineView::dropEvent(QDropEvent *pEvent) 1215 1239 { 1216 /* The guest object to talk to. */ 1240 AssertPtrReturnVoid(pEvent); 1241 1242 /* Get mouse-pointer location. */ 1243 const QPoint &cpnt = viewportToContents(pEvent->pos()); 1244 1217 1245 CGuest guest = session().GetConsole().GetGuest(); 1218 1219 /* Get mouse-pointer location */ 1220 const QPoint &cpnt = viewportToContents(pEvent->pos()); 1246 CGuestDnDTarget dndTarget = guest.GetDnDTarget(); 1221 1247 1222 1248 /* Ask the guest for dropping data. */ 1223 Qt::DropAction result = gDnD->dragHGDrop(guest, 1224 screenId(), 1225 frameBuffer()->convertHostXTo(cpnt.x()), 1226 frameBuffer()->convertHostYTo(cpnt.y()), 1227 pEvent->proposedAction(), 1228 pEvent->possibleActions(), 1229 pEvent->mimeData(), this); 1249 Qt::DropAction result = DnDHandler()->dragDrop(session(), 1250 static_cast<CDnDTarget>(dndTarget), 1251 screenId(), 1252 frameBuffer()->convertHostXTo(cpnt.x()), 1253 frameBuffer()->convertHostYTo(cpnt.y()), 1254 pEvent->proposedAction(), 1255 pEvent->possibleActions(), 1256 pEvent->mimeData(), this /* pParent */); 1230 1257 1231 1258 /* Set the DnD action returned by the guest. */ … … 1233 1260 pEvent->accept(); 1234 1261 } 1235 1236 void UIMachineView::handleGHDnd(void)1237 {1238 /* The guest object to talk to. */1239 CGuest guest = session().GetConsole().GetGuest();1240 1241 /* Check for a pending DnD event within the guest and if so, handle all the1242 * magic. */1243 gDnD->dragGHPending(session(), screenId(), this);1244 }1245 1262 #endif /* VBOX_WITH_DRAG_AND_DROP */ 1246 1263 … … 1249 1266 bool UIMachineView::winEvent(MSG *pMsg, long* /* piResult */) 1250 1267 { 1251 /* Check if some system event should be filtered-out. 1252 * Returning 'true' means filtering-out, 1253 * Returning 'false' means passing event to Qt. */ 1254 bool fResult = false; /* Pass to Qt by default: */ 1268 AssertPtrReturn(pMsg, false); 1269 1270 /* Check if some system event should be filtered out. 1271 * Returning @c true means filtering-out, 1272 * Returning @c false means passing event to Qt. */ 1273 bool fResult = false; /* Pass to Qt by default. */ 1255 1274 switch (pMsg->message) 1256 1275 { … … 1260 1279 case WM_SYSKEYUP: 1261 1280 { 1262 /* Filter using keyboard-filter: */ 1263 bool fKeyboardFilteringResult = machineLogic()->keyboardHandler()->winEventFilter(pMsg, screenId()); 1264 /* Keyboard filter rules the result: */ 1281 /* Filter using keyboard filter? */ 1282 bool fKeyboardFilteringResult = 1283 machineLogic()->keyboardHandler()->winEventFilter(pMsg, screenId()); 1284 /* Keyboard filter rules the result? */ 1265 1285 fResult = fKeyboardFilteringResult; 1266 1286 break; … … 1269 1289 break; 1270 1290 } 1271 /* Return result: */ 1291 1272 1292 return fResult; 1273 1293 } … … 1277 1297 bool UIMachineView::x11Event(XEvent *pEvent) 1278 1298 { 1279 /* Check if some system event should be filtered-out. 1280 * Returning 'true' means filtering-out, 1281 * Returning 'false' means passing event to Qt. */ 1282 bool fResult = false; /* Pass to Qt by default: */ 1299 AssertPtrReturn(pEvent, false); 1300 1301 /* Check if some system event should be filtered out. 1302 * Returning @c true means filtering-out, 1303 * Returning @c false means passing event to Qt. */ 1304 bool fResult = false; /* Pass to Qt by default. */ 1283 1305 switch (pEvent->type) 1284 1306 { … … 1288 1310 case XKeyRelease: 1289 1311 { 1290 /* Filter using keyboard-filter: */ 1291 bool fKeyboardFilteringResult = machineLogic()->keyboardHandler()->x11EventFilter(pEvent, screenId()); 1292 /* Filter using mouse-filter: */ 1293 bool fMouseFilteringResult = machineLogic()->mouseHandler()->x11EventFilter(pEvent, screenId()); 1294 /* If at least one of filters wants to filter event out then the result is 'true': */ 1312 /* Filter using keyboard-filter? */ 1313 bool fKeyboardFilteringResult = 1314 machineLogic()->keyboardHandler()->x11EventFilter(pEvent, screenId()); 1315 /* Filter using mouse-filter? */ 1316 bool fMouseFilteringResult = 1317 machineLogic()->mouseHandler()->x11EventFilter(pEvent, screenId()); 1318 /* If at least one of filters wants to filter event out then the result is true. */ 1295 1319 fResult = fKeyboardFilteringResult || fMouseFilteringResult; 1296 1320 break; … … 1299 1323 break; 1300 1324 } 1301 /* Return result: */ 1325 1302 1326 return fResult; 1303 1327 } 1304 1328 1305 #endif 1306 1329 #endif /* Q_WS_X11 */ 1330 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
r51436 r51476 39 39 class UIMachineWindow; 40 40 class UIFrameBuffer; 41 #ifdef VBOX_WITH_DRAG_AND_DROP 42 class CDnDTarget; 43 #endif 41 44 class CSession; 42 45 … … 217 220 void dragLeaveEvent(QDragLeaveEvent *pEvent); 218 221 void dragMoveEvent(QDragMoveEvent *pEvent); 222 void dragIsPending(void); 219 223 void dropEvent(QDropEvent *pEvent); 220 221 void handleGHDnd();222 224 #endif /* VBOX_WITH_DRAG_AND_DROP */ 223 225 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r51339 r51476 7 7 8 8 /* 9 * Copyright (C) 2010-201 2Oracle Corporation9 * Copyright (C) 2010-2014 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 936 936 || cpnt.y() > iCh - 1) 937 937 { 938 bool fHandle dGHDnD938 bool fHandleDnDPending 939 939 = RT_BOOL(mouseButtons.testFlag(Qt::LeftButton)); 940 if (fHandle dGHDnD)941 { 942 m_views[uScreenId]-> handleGHDnd();940 if (fHandleDnDPending) 941 { 942 m_views[uScreenId]->dragIsPending(); 943 943 return true; 944 944 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r48576 r51476 7 7 8 8 /* 9 * Copyright (C) 2006-201 2Oracle Corporation9 * Copyright (C) 2006-2014 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 44 44 45 45 /* Drag'n'drop mode */ 46 mCbDragAndDrop->addItem (""); /* KD ragAndDropMode_Disabled */47 mCbDragAndDrop->addItem (""); /* KD ragAndDropMode_HostToGuest */48 mCbDragAndDrop->addItem (""); /* KD ragAndDropMode_GuestToHost */49 mCbDragAndDrop->addItem (""); /* KD ragAndDropMode_Bidirectional */46 mCbDragAndDrop->addItem (""); /* KDnDMode_Disabled */ 47 mCbDragAndDrop->addItem (""); /* KDnDMode_HostToGuest */ 48 mCbDragAndDrop->addItem (""); /* KDnDMode_GuestToHost */ 49 mCbDragAndDrop->addItem (""); /* KDnDMode_Bidirectional */ 50 50 51 51 #ifdef Q_WS_MAC … … 115 115 generalData.m_strSnapshotsHomeDir = QFileInfo(m_machine.GetSettingsFilePath()).absolutePath(); 116 116 generalData.m_clipboardMode = m_machine.GetClipboardMode(); 117 generalData.m_d ragAndDropMode = m_machine.GetDragAndDropMode();117 generalData.m_dndMode = m_machine.GetDnDMode(); 118 118 generalData.m_strDescription = m_machine.GetDescription(); 119 119 … … 141 141 mPsSnapshot->setHomeDir(generalData.m_strSnapshotsHomeDir); 142 142 mCbClipboard->setCurrentIndex(generalData.m_clipboardMode); 143 mCbDragAndDrop->setCurrentIndex(generalData.m_d ragAndDropMode);143 mCbDragAndDrop->setCurrentIndex(generalData.m_dndMode); 144 144 mTeDescription->setPlainText(generalData.m_strDescription); 145 145 … … 166 166 generalData.m_strSnapshotsFolder = mPsSnapshot->path(); 167 167 generalData.m_clipboardMode = (KClipboardMode)mCbClipboard->currentIndex(); 168 generalData.m_d ragAndDropMode = (KDragAndDropMode)mCbDragAndDrop->currentIndex();168 generalData.m_dndMode = (KDnDMode)mCbDragAndDrop->currentIndex(); 169 169 generalData.m_strDescription = mTeDescription->toPlainText().isEmpty() ? 170 170 QString::null : mTeDescription->toPlainText(); … … 192 192 /* Advanced tab: */ 193 193 m_machine.SetClipboardMode(generalData.m_clipboardMode); 194 m_machine.SetD ragAndDropMode(generalData.m_dragAndDropMode);194 m_machine.SetDnDMode(generalData.m_dndMode); 195 195 m_machine.SetExtraData(GUI_SaveMountedAtRuntime, generalData.m_fSaveMountedAtRuntime ? "yes" : "no"); 196 196 m_machine.SetExtraData(GUI_ShowMiniToolBar, generalData.m_fShowMiniToolBar ? "yes" : "no"); … … 292 292 293 293 /* Drag'n'drop mode */ 294 mCbDragAndDrop->setItemText (0, gpConverter->toString (KD ragAndDropMode_Disabled));295 mCbDragAndDrop->setItemText (1, gpConverter->toString (KD ragAndDropMode_HostToGuest));296 mCbDragAndDrop->setItemText (2, gpConverter->toString (KD ragAndDropMode_GuestToHost));297 mCbDragAndDrop->setItemText (3, gpConverter->toString (KD ragAndDropMode_Bidirectional));294 mCbDragAndDrop->setItemText (0, gpConverter->toString (KDnDMode_Disabled)); 295 mCbDragAndDrop->setItemText (1, gpConverter->toString (KDnDMode_HostToGuest)); 296 mCbDragAndDrop->setItemText (2, gpConverter->toString (KDnDMode_GuestToHost)); 297 mCbDragAndDrop->setItemText (3, gpConverter->toString (KDnDMode_Bidirectional)); 298 298 } 299 299 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h
r47944 r51476 6 6 7 7 /* 8 * Copyright (C) 2006-201 2Oracle Corporation8 * Copyright (C) 2006-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 37 37 , m_strSnapshotsHomeDir(QString()) 38 38 , m_clipboardMode(KClipboardMode_Disabled) 39 , m_d ragAndDropMode(KDragAndDropMode_Disabled)39 , m_dndMode(KDnDMode_Disabled) 40 40 , m_strDescription(QString()) {} 41 41 /* Functions: */ … … 50 50 (m_strSnapshotsHomeDir == other.m_strSnapshotsHomeDir) && 51 51 (m_clipboardMode == other.m_clipboardMode) && 52 (m_d ragAndDropMode == other.m_dragAndDropMode) &&52 (m_dndMode == other.m_dndMode) && 53 53 (m_strDescription == other.m_strDescription); 54 54 } … … 65 65 QString m_strSnapshotsHomeDir; 66 66 KClipboardMode m_clipboardMode; 67 KD ragAndDropMode m_dragAndDropMode;67 KDnDMode m_dndMode; 68 68 QString m_strDescription; 69 69 }; -
trunk/src/VBox/Main/Makefile.kmk
r51436 r51476 747 747 ifdef VBOX_WITH_DRAG_AND_DROP 748 748 VBoxC_SOURCES += \ 749 src-client/GuestDnDImpl.cpp 749 src-client/GuestDnDPrivate.cpp \ 750 src-client/GuestDnDSourceImpl.cpp \ 751 src-client/GuestDnDTargetImpl.cpp 750 752 endif 751 753 ifdef VBOX_WITH_XPCOM -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r51440 r51476 1175 1175 1176 1176 <enum 1177 name="D ragAndDropMode"1178 uuid=" b618ea0e-b6fb-4f8d-97f7-5e237e49b547"1177 name="DnDMode" 1178 uuid="07af8800-f936-4b33-9172-cd400e83c148" 1179 1179 > 1180 1180 <desc> … … 4204 4204 <interface 4205 4205 name="IMachine" extends="$unknown" 4206 uuid="4 80cf695-2d8d-4256-9c7c-cce4184fa048"4206 uuid="45b0357d-28f4-4f90-b02c-13f2940efdda" 4207 4207 wsmap="managed" 4208 4208 wrap-hint-server-addinterfaces="IInternalMachineControl" … … 4790 4790 </attribute> 4791 4791 4792 <attribute name="d ragAndDropMode" type="DragAndDropMode">4793 <desc> 4794 Which mode is allowed for drag'n'drop.4792 <attribute name="dnDMode" type="DnDMode"> 4793 <desc> 4794 Sets or retrieves the current drag'n drop mode. 4795 4795 </desc> 4796 4796 </attribute> … … 10351 10351 10352 10352 <enum 10353 name="D ragAndDropAction"10354 uuid=" 47f3b162-c107-4fcd-bfa7-54b8135c441e"10353 name="DnDAction" 10354 uuid="17609e74-778e-4d0e-8827-35f5230f287b" 10355 10355 > 10356 10356 <desc> 10357 Possible actions within an Drag and Drop operation.10357 Possible actions of a drag'n drop operation. 10358 10358 </desc> 10359 10359 … … 10389 10389 </const> 10390 10390 </enum> 10391 10392 <interface 10393 name="IDnDSource" extends="$unknown" 10394 uuid="6bdc3f97-f6df-4357-b252-5fa16e0c1e24" 10395 wsmap="managed" 10396 > 10397 <desc>Abstract interface for handling drag'n drop sources.</desc> 10398 10399 <method name="dragIsPending"> 10400 <desc> 10401 Ask the source if there is any drag and drop operation pending. 10402 If no drag and drop operation is pending currently, DnDAction_Ignore is returned. 10403 10404 <result name="VBOX_E_VM_ERROR"> 10405 VMM device is not available. 10406 </result> 10407 </desc> 10408 <param name="screenId" type="unsigned long" dir="in"> 10409 <desc>The screen ID where the drag and drop event occurred.</desc> 10410 </param> 10411 <param name="formats" type="wstring" dir="out" safearray="yes"> 10412 <desc>On return the supported mime types.</desc> 10413 </param> 10414 <param name="allowedActions" type="DnDAction" dir="out" safearray="yes"> 10415 <desc>On return the actions which are allowed.</desc> 10416 </param> 10417 <param name="defaultAction" type="DnDAction" dir="return"> 10418 <desc>On return the default action to use.</desc> 10419 </param> 10420 </method> 10421 10422 <method name="drop"> 10423 <desc> 10424 Informs the source that a drop event occurred for a pending 10425 drag and drop operation. 10426 10427 <result name="VBOX_E_VM_ERROR"> 10428 VMM device is not available. 10429 </result> 10430 </desc> 10431 10432 <param name="format" type="wstring" dir="in"> 10433 <desc>The mime type the data must be in.</desc> 10434 </param> 10435 <param name="action" type="DnDAction" dir="in"> 10436 <desc>The action to use.</desc> 10437 </param> 10438 <param name="progress" type="IProgress" dir="return"> 10439 <desc>Progress object to track the operation completion.</desc> 10440 </param> 10441 </method> 10442 10443 <method name="receiveData"> 10444 <desc> 10445 Receive the data of a previously drag and drop event from the source. 10446 10447 <result name="VBOX_E_VM_ERROR"> 10448 VMM device is not available. 10449 </result> 10450 10451 </desc> 10452 10453 <param name="data" type="octet" safearray="yes" dir="return"> 10454 <desc>The actual data.</desc> 10455 </param> 10456 </method> 10457 10458 </interface> 10459 10460 <interface 10461 name="IGuestDnDSource" extends="IDnDSource" 10462 uuid="280955c0-de67-4297-8179-6274a82a2fc0" 10463 wsmap="managed" 10464 > 10465 10466 <desc> 10467 Implementation of the <link to="IDnDSource" /> object 10468 for source drag'n drop operations on the guest. 10469 </desc> 10470 </interface> 10471 10472 <interface 10473 name="IDnDTarget" extends="$unknown" 10474 uuid="50862c12-7618-4542-a7c7-6a21de2644f7" 10475 wsmap="managed" 10476 > 10477 <desc>Abstract interface for handling drag'n drop targets.</desc> 10478 10479 <method name="enter"> 10480 <desc> 10481 Informs the target about a drag and drop enter event. 10482 10483 <result name="VBOX_E_VM_ERROR"> 10484 VMM device is not available. 10485 </result> 10486 </desc> 10487 <param name="screenId" type="unsigned long" dir="in"> 10488 <desc>The screen ID where the drag and drop event occurred.</desc> 10489 </param> 10490 <param name="y" type="unsigned long" dir="in"> 10491 <desc>Y-position of the event.</desc> 10492 </param> 10493 <param name="x" type="unsigned long" dir="in"> 10494 <desc>X-position of the event.</desc> 10495 </param> 10496 <param name="defaultAction" type="DnDAction" dir="in"> 10497 <desc>The default action to use.</desc> 10498 </param> 10499 <param name="allowedActions" type="DnDAction" dir="in" safearray="yes"> 10500 <desc>The actions which are allowed.</desc> 10501 </param> 10502 <param name="formats" type="wstring" dir="in" safearray="yes"> 10503 <desc>The supported MIME types.</desc> 10504 </param> 10505 <param name="resultAction" type="DnDAction" dir="return"> 10506 <desc>The resulting action of this event.</desc> 10507 </param> 10508 </method> 10509 10510 <method name="move"> 10511 <desc> 10512 Informs the target about a drag and drop move event. 10513 10514 <result name="VBOX_E_VM_ERROR"> 10515 VMM device is not available. 10516 </result> 10517 </desc> 10518 <param name="screenId" type="unsigned long" dir="in"> 10519 <desc>The screen ID where the drag and drop event occurred.</desc> 10520 </param> 10521 <param name="x" type="unsigned long" dir="in"> 10522 <desc>X-position of the event.</desc> 10523 </param> 10524 <param name="y" type="unsigned long" dir="in"> 10525 <desc>Y-position of the event.</desc> 10526 </param> 10527 <param name="defaultAction" type="DnDAction" dir="in"> 10528 <desc>The default action to use.</desc> 10529 </param> 10530 <param name="allowedActions" type="DnDAction" dir="in" safearray="yes"> 10531 <desc>The actions which are allowed.</desc> 10532 </param> 10533 <param name="formats" type="wstring" dir="in" safearray="yes"> 10534 <desc>The supported MIME types.</desc> 10535 </param> 10536 <param name="resultAction" type="DnDAction" dir="return"> 10537 <desc>The resulting action of this event.</desc> 10538 </param> 10539 </method> 10540 10541 <method name="leave"> 10542 <desc> 10543 Informs the target about a drag and drop leave event. 10544 10545 <result name="VBOX_E_VM_ERROR"> 10546 VMM device is not available. 10547 </result> 10548 </desc> 10549 <param name="screenId" type="unsigned long" dir="in"> 10550 <desc>The screen ID where the drag and drop event occurred.</desc> 10551 </param> 10552 </method> 10553 10554 <method name="drop"> 10555 <desc> 10556 Informs the target about a drop event. 10557 10558 <result name="VBOX_E_VM_ERROR"> 10559 VMM device is not available. 10560 </result> 10561 10562 </desc> 10563 <param name="screenId" type="unsigned long" dir="in"> 10564 <desc>The screen ID where the Drag and Drop event occurred.</desc> 10565 </param> 10566 <param name="x" type="unsigned long" dir="in"> 10567 <desc>X-position of the event.</desc> 10568 </param> 10569 <param name="y" type="unsigned long" dir="in"> 10570 <desc>Y-position of the event.</desc> 10571 </param> 10572 <param name="defaultAction" type="DnDAction" dir="in"> 10573 <desc>The default action to use.</desc> 10574 </param> 10575 <param name="allowedActions" type="DnDAction" dir="in" safearray="yes"> 10576 <desc>The actions which are allowed.</desc> 10577 </param> 10578 <param name="formats" type="wstring" dir="in" safearray="yes"> 10579 <desc>The supported MIME types.</desc> 10580 </param> 10581 <param name="format" type="wstring" dir="out"> 10582 <desc>The resulting format of this event.</desc> 10583 </param> 10584 <param name="resultAction" type="DnDAction" dir="return"> 10585 <desc>The resulting action of this event.</desc> 10586 </param> 10587 </method> 10588 10589 <method name="sendData"> 10590 <desc> 10591 Sends data to the target. 10592 10593 <result name="VBOX_E_VM_ERROR"> 10594 VMM device is not available. 10595 </result> 10596 10597 </desc> 10598 <param name="screenId" type="unsigned long" dir="in"> 10599 <desc>The screen ID where the drag and drop event occurred.</desc> 10600 </param> 10601 <param name="format" type="wstring" dir="in"> 10602 <desc>The MIME type the data is in.</desc> 10603 </param> 10604 <param name="data" type="octet" dir="in" safearray="yes"> 10605 <desc>The actual data.</desc> 10606 </param> 10607 <param name="progress" type="IProgress" dir="return"> 10608 <desc>Progress object to track the operation completion.</desc> 10609 </param> 10610 </method> 10611 10612 </interface> 10613 10614 <interface 10615 name="IGuestDnDTarget" extends="IDnDTarget" 10616 uuid="50ce4b51-0ff7-46b7-a138-3c6e5ac946b4" 10617 wsmap="managed" 10618 > 10619 10620 <desc> 10621 Implementation of the <link to="IDnDTarget" /> object 10622 for target drag'n drop operations on the guest. 10623 </desc> 10624 </interface> 10391 10625 10392 10626 <interface … … 11882 12116 <interface 11883 12117 name="IGuest" extends="$unknown" 11884 uuid=" 8011a1b1-6adb-4ffb-a37e-20abdaee4650"12118 uuid="97927199-7e1f-4094-97ab-92333e727843" 11885 12119 wsmap="managed" 11886 12120 > … … 11930 12164 </attribute> 11931 12165 12166 <attribute name="dnDSource" type="IGuestDnDSource" readonly="yes"> 12167 <desc> 12168 TODO 12169 </desc> 12170 </attribute> 12171 12172 <attribute name="dnDTarget" type="IGuestDnDTarget" readonly="yes"> 12173 <desc> 12174 TODO 12175 </desc> 12176 </attribute> 12177 11932 12178 <attribute name="eventSource" type="IEventSource" readonly="yes"> 11933 12179 <desc> … … 12060 12306 not be supported by all versions of the Additions. 12061 12307 </desc> 12062 </param>12063 </method>12064 12065 <method name="dragHGEnter">12066 <desc>12067 Informs the guest about a Drag and Drop enter event.12068 12069 This is used in Host - Guest direction.12070 12071 <result name="VBOX_E_VM_ERROR">12072 VMM device is not available.12073 </result>12074 12075 </desc>12076 <param name="screenId" type="unsigned long" dir="in">12077 <desc>The screen id where the Drag and Drop event occurred.</desc>12078 </param>12079 <param name="y" type="unsigned long" dir="in">12080 <desc>y-position of the event.</desc>12081 </param>12082 <param name="x" type="unsigned long" dir="in">12083 <desc>x-position of the event.</desc>12084 </param>12085 <param name="defaultAction" type="DragAndDropAction" dir="in">12086 <desc>The default action to use.</desc>12087 </param>12088 <param name="allowedActions" type="DragAndDropAction" dir="in" safearray="yes">12089 <desc>The actions which are allowed.</desc>12090 </param>12091 <param name="formats" type="wstring" dir="in" safearray="yes">12092 <desc>The supported mime types.</desc>12093 </param>12094 <param name="resultAction" type="DragAndDropAction" dir="return">12095 <desc>The resulting action of this event.</desc>12096 </param>12097 </method>12098 12099 <method name="dragHGMove">12100 <desc>12101 Informs the guest about a Drag and Drop move event.12102 12103 This is used in Host - Guest direction.12104 12105 <result name="VBOX_E_VM_ERROR">12106 VMM device is not available.12107 </result>12108 12109 </desc>12110 <param name="screenId" type="unsigned long" dir="in">12111 <desc>The screen id where the Drag and Drop event occurred.</desc>12112 </param>12113 <param name="x" type="unsigned long" dir="in">12114 <desc>x-position of the event.</desc>12115 </param>12116 <param name="y" type="unsigned long" dir="in">12117 <desc>y-position of the event.</desc>12118 </param>12119 <param name="defaultAction" type="DragAndDropAction" dir="in">12120 <desc>The default action to use.</desc>12121 </param>12122 <param name="allowedActions" type="DragAndDropAction" dir="in" safearray="yes">12123 <desc>The actions which are allowed.</desc>12124 </param>12125 <param name="formats" type="wstring" dir="in" safearray="yes">12126 <desc>The supported mime types.</desc>12127 </param>12128 <param name="resultAction" type="DragAndDropAction" dir="return">12129 <desc>The resulting action of this event.</desc>12130 </param>12131 </method>12132 12133 <method name="dragHGLeave">12134 <desc>12135 Informs the guest about a Drag and Drop leave event.12136 12137 This is used in Host - Guest direction.12138 12139 <result name="VBOX_E_VM_ERROR">12140 VMM device is not available.12141 </result>12142 12143 </desc>12144 <param name="screenId" type="unsigned long" dir="in">12145 <desc>The screen id where the Drag and Drop event occurred.</desc>12146 </param>12147 </method>12148 12149 <method name="dragHGDrop">12150 <desc>12151 Informs the guest about a drop event.12152 12153 This is used in Host - Guest direction.12154 12155 <result name="VBOX_E_VM_ERROR">12156 VMM device is not available.12157 </result>12158 12159 </desc>12160 <param name="screenId" type="unsigned long" dir="in">12161 <desc>The screen id where the Drag and Drop event occurred.</desc>12162 </param>12163 <param name="x" type="unsigned long" dir="in">12164 <desc>x-position of the event.</desc>12165 </param>12166 <param name="y" type="unsigned long" dir="in">12167 <desc>y-position of the event.</desc>12168 </param>12169 <param name="defaultAction" type="DragAndDropAction" dir="in">12170 <desc>The default action to use.</desc>12171 </param>12172 <param name="allowedActions" type="DragAndDropAction" dir="in" safearray="yes">12173 <desc>The actions which are allowed.</desc>12174 </param>12175 <param name="formats" type="wstring" dir="in" safearray="yes">12176 <desc>The supported mime types.</desc>12177 </param>12178 <param name="format" type="wstring" dir="out">12179 <desc>The resulting format of this event.</desc>12180 </param>12181 <param name="resultAction" type="DragAndDropAction" dir="return">12182 <desc>The resulting action of this event.</desc>12183 </param>12184 </method>12185 12186 <method name="dragHGPutData">12187 <desc>12188 Informs the guest about a drop data event.12189 12190 This is used in Host - Guest direction.12191 12192 <result name="VBOX_E_VM_ERROR">12193 VMM device is not available.12194 </result>12195 12196 </desc>12197 <param name="screenId" type="unsigned long" dir="in">12198 <desc>The screen id where the Drag and Drop event occurred.</desc>12199 </param>12200 <param name="format" type="wstring" dir="in">12201 <desc>The mime type the data is in.</desc>12202 </param>12203 <param name="data" type="octet" dir="in" safearray="yes">12204 <desc>The actual data.</desc>12205 </param>12206 <param name="progress" type="IProgress" dir="return">12207 <desc>Progress object to track the operation completion.</desc>12208 </param>12209 </method>12210 12211 <method name="dragGHPending">12212 <desc>12213 Ask the guest if there is any Drag and Drop operation pending in the guest.12214 12215 If no Drag and Drop operation is pending currently, Ignore is returned.12216 12217 This is used in Guest - Host direction.12218 12219 <result name="VBOX_E_VM_ERROR">12220 VMM device is not available.12221 </result>12222 12223 </desc>12224 <param name="screenId" type="unsigned long" dir="in">12225 <desc>The screen id where the Drag and Drop event occurred.</desc>12226 </param>12227 <param name="formats" type="wstring" dir="out" safearray="yes">12228 <desc>On return the supported mime types.</desc>12229 </param>12230 <param name="allowedActions" type="DragAndDropAction" dir="out" safearray="yes">12231 <desc>On return the actions which are allowed.</desc>12232 </param>12233 <param name="defaultAction" type="DragAndDropAction" dir="return">12234 <desc>On return the default action to use.</desc>12235 </param>12236 </method>12237 12238 <method name="dragGHDropped">12239 <desc>12240 Informs the guest that a drop event occurred for a pending Drag and Drop event.12241 12242 This is used in Guest - Host direction.12243 12244 <result name="VBOX_E_VM_ERROR">12245 VMM device is not available.12246 </result>12247 12248 </desc>12249 12250 <param name="format" type="wstring" dir="in">12251 <desc>The mime type the data must be in.</desc>12252 </param>12253 <param name="action" type="DragAndDropAction" dir="in">12254 <desc>The action to use.</desc>12255 </param>12256 <param name="progress" type="IProgress" dir="return">12257 <desc>Progress object to track the operation completion.</desc>12258 </param>12259 </method>12260 12261 <method name="dragGHGetData">12262 <desc>12263 Fetch the data of a previously Drag and Drop event from the guest.12264 12265 This is used in Guest - Host direction.12266 12267 <result name="VBOX_E_VM_ERROR">12268 VMM device is not available.12269 </result>12270 12271 </desc>12272 12273 <param name="data" type="octet" safearray="yes" dir="return">12274 <desc>The actual data.</desc>12275 12308 </param> 12276 12309 </method> … … 15600 15633 15601 15634 <method name="getScreenResolution"> 15602 <desc>Queries display width, height and color depth for given screen.</desc> 15635 <desc> 15636 Queries certain attributes such as display width, height, color depth 15637 and the X and Y origin for a given guest screen. 15638 15639 The parameters @a xOrigin and @a yOrigin return the X and Y 15640 coordinates of the framebuffer's origin. 15641 15642 All return parameters are optional.</desc> 15603 15643 <param name="screenId" type="unsigned long" dir="in"/> 15604 15644 <param name="width" type="unsigned long" dir="out"/> … … 15611 15651 <method name="attachFramebuffer"> 15612 15652 <desc> 15613 Sets the graphics update starget for a screen.15653 Sets the graphics update target for a screen. 15614 15654 </desc> 15615 15655 <param name="screenId" type="unsigned long" dir="in"/> … … 18013 18053 </method> 18014 18054 18015 <method name="onD ragAndDropModeChange">18016 <desc> 18017 Notification when the drag'n 'drop mode changes.18018 </desc> 18019 <param name="d ragAndDropMode" type="DragAndDropMode" dir="in">18020 <desc>The new mode for drag'n 'drop.</desc>18055 <method name="onDnDModeChange"> 18056 <desc> 18057 Notification when the drag'n drop mode changes. 18058 </desc> 18059 <param name="dndMode" type="DnDMode" dir="in"> 18060 <desc>The new mode for drag'n drop.</desc> 18021 18061 </param> 18022 18062 </method> … … 19806 19846 <enum 19807 19847 name="VBoxEventType" 19808 uuid=" 5248e377-e578-47d7-b07b-84b1db6db8a8"19848 uuid="1622f8d2-6c76-4410-9e78-86e083046efc" 19809 19849 > 19810 19850 … … 20069 20109 </desc> 20070 20110 </const> 20071 <const name="OnD ragAndDropModeChanged" value="73">20072 <desc> 20073 See <link to="ID ragAndDropModeChangedEvent">IDragAndDropModeChangedEvent</link>.20111 <const name="OnDnDModeChanged" value="73"> 20112 <desc> 20113 See <link to="IDnDModeChangedEvent">IDnDModeChangedEvent</link>. 20074 20114 </desc> 20075 20115 </const> … … 20958 20998 20959 20999 <interface 20960 name="ID ragAndDropModeChangedEvent" extends="IEvent"20961 uuid=" e90b8850-ac8e-4dff-8059-4100ae2c3c3d"20962 wsmap="managed" autogen="VBoxEvent" id="OnD ragAndDropModeChanged"21000 name="IDnDModeChangedEvent" extends="IEvent" 21001 uuid="b55cf856-1f8b-4692-abb4-462429fae5e9" 21002 wsmap="managed" autogen="VBoxEvent" id="OnDnDModeChanged" 20963 21003 > 20964 21004 <desc> 20965 Notification when the drag'n 'drop mode changes.21005 Notification when the drag'n drop mode changes. 20966 21006 </desc> 20967 <attribute name="d ragAndDropMode" type="DragAndDropMode" readonly="yes">20968 <desc> 20969 The new drag'n 'drop mode.21007 <attribute name="dndMode" type="DnDMode" readonly="yes"> 21008 <desc> 21009 The new drag'n drop mode. 20970 21010 </desc> 20971 21011 </attribute> -
trunk/src/VBox/Main/include/ConsoleImpl.h
r51342 r51476 220 220 HRESULT onCPUExecutionCapChange(ULONG aExecutionCap); 221 221 HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode); 222 HRESULT onD ragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);222 HRESULT onDnDModeChange(DnDMode_T aDnDMode); 223 223 HRESULT onVRDEServerChange(BOOL aRestart); 224 224 HRESULT onVideoCaptureChange(); … … 699 699 700 700 void changeClipboardMode(ClipboardMode_T aClipboardMode); 701 void changeDragAndDropMode(DragAndDropMode_T aDragAndDropMode);701 int changeDnDMode(DnDMode_T aDnDMode); 702 702 703 703 #ifdef VBOX_WITH_USB -
trunk/src/VBox/Main/include/DisplayImpl.h
r51460 r51476 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 66 66 uint16_t flags; 67 67 68 /* for saving the rectangles arrived during fb resize is in progress. */68 /** For saving the rectangles arrived during fb resize is in progress. */ 69 69 PRTRECT mpSavedVisibleRegion; 70 70 uint32_t mcSavedVisibleRegion; … … 74 74 volatile uint32_t u32ResizeStatus; 75 75 76 /* The Framebuffer has default format and must be updates immediately. */76 /** The framebuffer has default format and must be updates immediately. */ 77 77 bool fDefaultFormat; 78 78 -
trunk/src/VBox/Main/include/GuestDnDPrivate.h
r51474 r51476 1 /* $Id$ */ 1 2 /** @file 2 * Definition of GuestDnD 3 * Private guest drag and drop code, used by GuestDnDTarget + 4 * GuestDnDSource. 3 5 */ 4 6 … … 15 17 */ 16 18 17 #ifndef ____H_GUESTDND 18 #define ____H_GUESTDND 19 #ifndef ____H_GUESTDNDPRIVATE 20 #define ____H_GUESTDNDPRIVATE 19 21 20 /* Forward declaration of the d-pointer. */ 21 class GuestDnDPrivate; 22 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 23 class DnDGuestResponse; 24 #endif 22 #include "VBox/hgcmsvc.h" /* For PVBOXHGCMSVCPARM. */ 25 23 24 /* Forward prototype declarations. */ 25 class Guest; 26 class Progress; 27 28 /** 29 * Class for handling drag'n drop responses from 30 * the guest side. 31 */ 32 class GuestDnDResponse 33 { 34 35 public: 36 37 GuestDnDResponse(const ComObjPtr<Guest>& pGuest); 38 39 virtual ~GuestDnDResponse(void); 40 41 public: 42 43 int notifyAboutGuestResponse(void); 44 int waitForGuestResponse(RTMSINTERVAL msTimeout = 500); 45 46 void setDefAction(uint32_t a) { m_defAction = a; } 47 uint32_t defAction(void) const { return m_defAction; } 48 49 void setAllActions(uint32_t a) { m_allActions = a; } 50 uint32_t allActions() const { return m_allActions; } 51 52 void setFormat(const Utf8Str &strFormat) { m_strFormat = strFormat; } 53 Utf8Str format(void) const { return m_strFormat; } 54 55 void setDropDir(const Utf8Str &strDropDir) { m_strDropDir = strDropDir; } 56 Utf8Str dropDir(void) const { return m_strDropDir; } 57 58 int dataAdd(const void *pvData, uint32_t cbData, uint32_t *pcbCurSize); 59 int dataSetStatus(size_t cbDataAdd, size_t cbDataTotal = 0); 60 void reset(void); 61 const void *data(void) { return m_pvData; } 62 size_t size(void) const { return m_cbData; } 63 64 int setProgress(unsigned uPercentage, uint32_t uState, int rcOp = VINF_SUCCESS); 65 HRESULT resetProgress(const ComObjPtr<Guest>& pParent); 66 HRESULT queryProgressTo(IProgress **ppProgress); 67 68 int writeToFile(const char *pszPath, size_t cbPath, void *pvData, size_t cbData, uint32_t fMode); 69 70 public: 71 72 Utf8Str errorToString(const ComObjPtr<Guest>& pGuest, int guestRc); 73 74 private: 75 RTSEMEVENT m_EventSem; 76 uint32_t m_defAction; 77 uint32_t m_allActions; 78 Utf8Str m_strFormat; 79 80 /** The actual MIME data.*/ 81 void *m_pvData; 82 /** Size (in bytes) of MIME data. */ 83 uint32_t m_cbData; 84 85 size_t m_cbDataCurrent; 86 size_t m_cbDataTotal; 87 /** Dropped files directory on the host. */ 88 Utf8Str m_strDropDir; 89 /** The handle of the currently opened file being written to 90 * or read from. */ 91 RTFILE m_hFile; 92 Utf8Str m_strFile; 93 94 ComObjPtr<Guest> m_parent; 95 ComObjPtr<Progress> m_progress; 96 }; 97 98 /** 99 * Private singleton class for the guest's DnD 100 * implementation. Can't be instanciated directly, only via 101 * the factory pattern. 102 */ 26 103 class GuestDnD 27 104 { 28 105 public: 106 107 static GuestDnD *createInstance(const ComObjPtr<Guest>& pGuest) 108 { 109 Assert(NULL == GuestDnD::s_pInstance); 110 GuestDnD::s_pInstance = new GuestDnD(pGuest); 111 return GuestDnD::s_pInstance; 112 } 113 114 static void destroyInstance(void) 115 { 116 if (GuestDnD::s_pInstance) 117 { 118 delete GuestDnD::s_pInstance; 119 GuestDnD::s_pInstance = NULL; 120 } 121 } 122 123 static inline GuestDnD *getInstance(void) 124 { 125 AssertPtr(GuestDnD::s_pInstance); 126 return GuestDnD::s_pInstance; 127 } 128 129 protected: 130 29 131 GuestDnD(const ComObjPtr<Guest>& pGuest); 30 ~GuestDnD();132 virtual ~GuestDnD(void); 31 133 32 /* Host -> Guest */ 33 HRESULT dragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction); 34 HRESULT dragHGMove(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction); 35 HRESULT dragHGLeave(ULONG uScreenId); 36 HRESULT dragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction); 37 HRESULT dragHGPutData(ULONG uScreenId, IN_BSTR wstrFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress); 134 public: 38 135 39 /* Guest -> Host */ 40 HRESULT dragGHPending(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction); 41 HRESULT dragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action, IProgress **ppProgress); 42 HRESULT dragGHGetData(ComSafeArrayOut(BYTE, data)); 136 /** @name Public helper functions. 137 * @{ */ 138 int adjustScreenCoordinates(ULONG uScreenId, ULONG *puX, ULONG *puY) const; 139 int hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const; 140 GuestDnDResponse *response(void) { return m_pResponse; } 141 std::vector<com::Utf8Str> supportedFormats(void) const { return m_strSupportedFormats; } 142 /** @} */ 43 143 44 /* Guest response */ 45 static DECLCALLBACK(int) notifyGuestDragAndDropEvent(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms); 144 public: 145 146 /** @name Static low-level HGCM callback handler. 147 * @{ */ 148 static DECLCALLBACK(int) notifyDnDDispatcher(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms); 149 /** @} */ 150 151 /** @name Static helper methods. 152 * @{ */ 153 static com::Utf8Str toFormatString(const std::vector<com::Utf8Str> &lstSupportedFormats, const std::vector<com::Utf8Str> &lstFormats); 154 static void toFormatVector(const std::vector<com::Utf8Str> &lstSupportedFormats, const com::Utf8Str &strFormats, std::vector<com::Utf8Str> &vecformats); 155 static DnDAction_T toMainAction(uint32_t uAction); 156 static void toMainActions(uint32_t uActions, std::vector<DnDAction_T> &vecActions); 157 static uint32_t toHGCMAction(DnDAction_T enmAction); 158 static void toHGCMActions(DnDAction_T enmDefAction, uint32_t *puDefAction, const std::vector<DnDAction_T> vecAllowedActions, uint32_t *puAllowedActions); 159 /** @} */ 160 161 protected: 162 163 /** @name Singleton properties. 164 * @{ */ 165 /** List of supported MIME types (formats). */ 166 std::vector<com::Utf8Str> m_strSupportedFormats; 167 /** Pointer to guest implementation. */ 168 const ComObjPtr<Guest> m_pGuest; 169 /** The current (last) response from the guest. At the 170 * moment we only support only response a time (ARQ-style). */ 171 GuestDnDResponse *m_pResponse; 172 /** @} */ 46 173 47 174 protected: 48 175 49 176 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 50 int onGHSendData(DnDGuestResponse *pResp, const void *pvData, size_t cbData, size_t cbTotalSize); 51 int onGHSendDir(DnDGuestResponse *pResp, const char *pszPath, size_t cbPath, uint32_t fMode); 52 int onGHSendFile(DnDGuestResponse *pResp, const char *pszPath, size_t cbPath, void *pvData, size_t cbData, uint32_t fMode); 177 /** @name Dispatch handlers for the HGCM callbacks. 178 * @{ */ 179 int onGHSendData(GuestDnDResponse *pResp, const void *pvData, size_t cbData, size_t cbTotalSize); 180 int onGHSendDir(GuestDnDResponse *pResp, const char *pszPath, size_t cbPath, uint32_t fMode); 181 int onGHSendFile(GuestDnDResponse *pResp, const char *pszPath, size_t cbPath, void *pvData, size_t cbData, uint32_t fMode); 182 /** @} */ 53 183 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 54 184 55 185 private: 56 186 57 /* d-pointer */ 58 GuestDnDPrivate *d_ptr; 59 60 friend class GuestDnDPrivate; 187 /** Staic pointer to singleton instance. */ 188 static GuestDnD *s_pInstance; 61 189 }; 62 190 63 #endif /* ____H_GUESTDND */ 191 /** Access to the GuestDnD's singleton instance. */ 192 #define GuestDnDInst() GuestDnD::getInstance() 64 193 194 #endif /* ____H_GUESTDNDPRIVATE */ 195 -
trunk/src/VBox/Main/include/GuestImpl.h
r47310 r51476 4 4 5 5 /* 6 * Copyright (C) 2006-201 3Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 #include "AdditionsFacilityImpl.h" 27 27 #include "GuestCtrlImplPrivate.h" 28 #ifdef VBOX_WITH_DRAG_AND_DROP 29 # include "GuestDnDSourceImpl.h" 30 # include "GuestDnDTargetImpl.h" 31 #endif 28 32 #include "GuestSessionImpl.h" 29 33 #include "HGCM.h" 30 31 #ifdef VBOX_WITH_DRAG_AND_DROP32 class GuestDnD;33 #endif34 34 35 35 typedef enum … … 48 48 49 49 class Console; 50 #ifdef VBOX_WITH_GUEST_CONTROL51 class Progress;52 #endif53 50 54 51 class ATL_NO_VTABLE Guest : … … 77 74 78 75 // IGuest properties. 79 STDMETHOD(COMGETTER(OSTypeId)) 80 STDMETHOD(COMGETTER(AdditionsRunLevel)) 76 STDMETHOD(COMGETTER(OSTypeId))(BSTR *aOSTypeId); 77 STDMETHOD(COMGETTER(AdditionsRunLevel))(AdditionsRunLevelType_T *aRunLevel); 81 78 STDMETHOD(COMGETTER(AdditionsVersion))(BSTR *a_pbstrAdditionsVersion); 82 79 STDMETHOD(COMGETTER(AdditionsRevision))(ULONG *a_puAdditionsRevision); 80 STDMETHOD(COMGETTER(DnDSource))(IGuestDnDSource ** aSource); 81 STDMETHOD(COMGETTER(DnDTarget))(IGuestDnDTarget ** aTarget); 83 82 STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource); 84 STDMETHOD(COMGETTER(Facilities)) 85 STDMETHOD(COMGETTER(Sessions)) 83 STDMETHOD(COMGETTER(Facilities))(ComSafeArrayOut(IAdditionsFacility *, aFacilities)); 84 STDMETHOD(COMGETTER(Sessions))(ComSafeArrayOut(IGuestSession *, aSessions)); 86 85 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize); 87 86 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize); … … 93 92 STDMETHOD(SetCredentials)(IN_BSTR aUsername, IN_BSTR aPassword, 94 93 IN_BSTR aDomain, BOOL aAllowInteractiveLogon); 95 // Drag'n drop support.96 STDMETHOD(DragHGEnter)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction);97 STDMETHOD(DragHGMove)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction);98 STDMETHOD(DragHGLeave)(ULONG uScreenId);99 STDMETHOD(DragHGDrop)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction);100 STDMETHOD(DragHGPutData)(ULONG uScreenId, IN_BSTR strFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress);101 STDMETHOD(DragGHPending)(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction);102 STDMETHOD(DragGHDropped)(IN_BSTR strFormat, DragAndDropAction_T action, IProgress **ppProgress);103 STDMETHOD(DragGHGetData)(ComSafeArrayOut(BYTE, data));104 94 // Guest control. 105 95 STDMETHOD(CreateSession)(IN_BSTR aUser, IN_BSTR aPassword, IN_BSTR aDomain, IN_BSTR aSessionName, IGuestSession **aGuestSession); … … 129 119 bool facilityIsActive(VBoxGuestFacilityType enmFacility); 130 120 void facilityUpdate(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS); 121 ComObjPtr<Console> getConsole(void) { return mParent; } 131 122 void setAdditionsStatus(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS); 132 123 void onUserStateChange(Bstr aUser, Bstr aDomain, VBoxGuestUserState enmState, const uint8_t *puDetails, uint32_t cbDetails); … … 142 133 int dispatchToSession(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 143 134 uint32_t getAdditionsVersion(void) { return mData.mAdditionsVersionFull; } 144 Console *getConsole(void) { return mParent; }145 135 int sessionRemove(GuestSession *pSession); 146 136 int sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds, ComObjPtr<GuestSession> &pGuestSession); … … 170 160 { } 171 161 172 Bstr mOSTypeId;173 FacilityMap mFacilityMap;174 AdditionsRunLevelType_T mAdditionsRunLevel;175 uint32_t mAdditionsVersionFull;176 Bstr mAdditionsVersionNew;177 uint32_t mAdditionsRevision;178 uint32_t mAdditionsFeatures;179 Bstr mInterfaceVersion;180 GuestSessions mGuestSessions;181 uint32_t mNextSessionID;162 Bstr mOSTypeId; 163 FacilityMap mFacilityMap; 164 AdditionsRunLevelType_T mAdditionsRunLevel; 165 uint32_t mAdditionsVersionFull; 166 Bstr mAdditionsVersionNew; 167 uint32_t mAdditionsRevision; 168 uint32_t mAdditionsFeatures; 169 Bstr mInterfaceVersion; 170 GuestSessions mGuestSessions; 171 uint32_t mNextSessionID; 182 172 } mData; 183 173 … … 192 182 BOOL mfPageFusionEnabled; 193 183 194 Console *mParent;184 const ComObjPtr<Console> mParent; 195 185 196 186 #ifdef VBOX_WITH_GUEST_CONTROL … … 206 196 207 197 #ifdef VBOX_WITH_DRAG_AND_DROP 208 GuestDnD *m_pGuestDnD; 209 friend class GuestDnD; 210 friend class GuestDnDPrivate; 211 #endif 212 213 RTTIMERLR mStatTimer; 214 uint32_t mMagic; 198 /** The guest's DnD source. */ 199 const ComObjPtr<GuestDnDSource> mDnDSource; 200 /** The guest's DnD target. */ 201 const ComObjPtr<GuestDnDTarget> mDnDTarget; 202 #endif 203 204 RTTIMERLR mStatTimer; 205 uint32_t mMagic; /** @todo r=andy Rename this to something more meaningful. */ 215 206 }; 216 #define GUEST_MAGIC 0xCEED2006u 207 #define GUEST_MAGIC 0xCEED2006u /** @todo r=andy Not very well defined!? */ 217 208 218 209 #endif // ____H_GUESTIMPL -
trunk/src/VBox/Main/include/MachineImpl.h
r50996 r51476 297 297 298 298 ClipboardMode_T mClipboardMode; 299 D ragAndDropMode_T mDragAndDropMode;299 DnDMode_T mDnDMode; 300 300 301 301 typedef std::map<Utf8Str, GuestProperty> GuestPropertyMap; … … 473 473 STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode); 474 474 STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode); 475 STDMETHOD(COMGETTER(D ragAndDropMode))(DragAndDropMode_T *aDragAndDropMode);476 STDMETHOD(COMSETTER(D ragAndDropMode))(DragAndDropMode_T aDragAndDropMode);475 STDMETHOD(COMGETTER(DnDMode))(DnDMode_T *aDnDMode); 476 STDMETHOD(COMSETTER(DnDMode))(DnDMode_T aDnDMode); 477 477 STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern); 478 478 STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern); … … 749 749 virtual HRESULT onSharedFolderChange() { return S_OK; } 750 750 virtual HRESULT onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; } 751 virtual HRESULT onD ragAndDropModeChange(DragAndDropMode_T /* aDragAndDropMode */) { return S_OK; }751 virtual HRESULT onDnDModeChange(DnDMode_T /* aDnDMode */) { return S_OK; } 752 752 virtual HRESULT onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; } 753 753 virtual HRESULT onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */, BOOL /* silent */) { return S_OK; } … … 1139 1139 HRESULT onSharedFolderChange(); 1140 1140 HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode); 1141 HRESULT onD ragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);1141 HRESULT onDnDModeChange(DnDMode_T aDnDMode); 1142 1142 HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup); 1143 1143 HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent); -
trunk/src/VBox/Main/include/SessionImpl.h
r48431 r51476 4 4 5 5 /* 6 * Copyright (C) 2006-201 3Oracle Corporation6 * Copyright (C) 2006-2014 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 92 92 STDMETHOD(OnSharedFolderChange)(BOOL aGlobal); 93 93 STDMETHOD(OnClipboardModeChange)(ClipboardMode_T aClipboardMode); 94 STDMETHOD(OnD ragAndDropModeChange)(DragAndDropMode_T aDragAndDropMode);94 STDMETHOD(OnDnDModeChange)(DnDMode_T aDnDMode); 95 95 STDMETHOD(OnUSBDeviceAttach)(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs); 96 96 STDMETHOD(OnUSBDeviceDetach)(IN_BSTR aId, IVirtualBoxErrorInfo *aError); -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r51412 r51476 5076 5076 5077 5077 /** 5078 * Called by IInternalSessionControl::OnD ragAndDropModeChange().5078 * Called by IInternalSessionControl::OnDnDModeChange(). 5079 5079 * 5080 5080 * @note Locks this object for writing. 5081 5081 */ 5082 HRESULT Console::onD ragAndDropModeChange(DragAndDropMode_T aDragAndDropMode)5082 HRESULT Console::onDnDModeChange(DnDMode_T aDnDMode) 5083 5083 { 5084 5084 LogFlowThisFunc(("\n")); … … 5098 5098 || mMachineState == MachineState_Teleporting 5099 5099 || mMachineState == MachineState_LiveSnapshotting) 5100 changeD ragAndDropMode(aDragAndDropMode);5100 changeDnDMode(aDnDMode); 5101 5101 else 5102 5102 rc = setInvalidMachineStateError(); … … 5108 5108 { 5109 5109 alock.release(); 5110 fireD ragAndDropModeChangedEvent(mEventSource, aDragAndDropMode);5110 fireDnDModeChangedEvent(mEventSource, aDnDMode); 5111 5111 } 5112 5112 … … 8348 8348 * Changes the drag'n_drop mode. 8349 8349 * 8350 * @param aD ragAndDropMode new drag'n'drop mode.8350 * @param aDnDMode new drag'n'drop mode. 8351 8351 */ 8352 void Console::changeDragAndDropMode(DragAndDropMode_T aDragAndDropMode)8352 int Console::changeDnDMode(DnDMode_T aDnDMode) 8353 8353 { 8354 8354 VMMDev *pVMMDev = m_pVMMDev; 8355 Assert (pVMMDev);8355 AssertPtrReturn(pVMMDev, VERR_INVALID_POINTER); 8356 8356 8357 8357 VBOXHGCMSVCPARM parm; 8358 RT_ZERO(parm); 8358 8359 parm.type = VBOX_HGCM_SVC_PARM_32BIT; 8359 8360 8360 switch (aD ragAndDropMode)8361 switch (aDnDMode) 8361 8362 { 8362 8363 default: 8363 case D ragAndDropMode_Disabled:8364 LogRel((" Drag'n'drop mode: Off\n"));8364 case DnDMode_Disabled: 8365 LogRel(("Changed drag'n drop mode to: Off\n")); 8365 8366 parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_OFF; 8366 8367 break; 8367 case D ragAndDropMode_GuestToHost:8368 LogRel((" Drag'n'drop mode: Guest to Host\n"));8368 case DnDMode_GuestToHost: 8369 LogRel(("Changed drag'n drop mode to: Guest to Host\n")); 8369 8370 parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_GUEST_TO_HOST; 8370 8371 break; 8371 case D ragAndDropMode_HostToGuest:8372 LogRel((" Drag'n'drop mode: Host to Guest\n"));8372 case DnDMode_HostToGuest: 8373 LogRel(("Changed drag'n drop mode to: Host to Guest\n")); 8373 8374 parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_HOST_TO_GUEST; 8374 8375 break; 8375 case D ragAndDropMode_Bidirectional:8376 LogRel((" Drag'n'drop mode: Bidirectional\n"));8376 case DnDMode_Bidirectional: 8377 LogRel(("Changed drag'n drop mode to: Bidirectional\n")); 8377 8378 parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_BIDIRECTIONAL; 8378 8379 break; 8379 8380 } 8380 8381 8381 pVMMDev->hgcmHostCall("VBoxDragAndDropSvc", DragAndDropSvc::HOST_DND_SET_MODE, 1, &parm); 8382 int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc", 8383 DragAndDropSvc::HOST_DND_SET_MODE, 1, &parm); 8384 LogFlowFunc(("rc=%Rrc\n", rc)); 8385 return rc; 8382 8386 } 8383 8387 -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r51441 r51476 24 24 * Header Files * 25 25 *******************************************************************************/ 26 / / for some reason Windows burns in sdk\...\winsock.h if this isn't included first26 /* For some reason Windows burns in sdk\...\winsock.h if this isn't included first. */ 27 27 #include "VBox/com/ptr.h" 28 28 … … 33 33 #endif 34 34 #ifdef VBOX_WITH_DRAG_AND_DROP 35 # include "GuestDnD Impl.h"35 # include "GuestDnDPrivate.h" 36 36 #endif 37 37 #include "VMMDev.h" … … 65 65 #include <VBox/err.h> 66 66 #include <VBox/param.h> 67 #include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach */68 #include <VBox/vmm/pdmusb.h> /* For PDMR3UsbCreateEmulatedDevice */67 #include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach. */ 68 #include <VBox/vmm/pdmusb.h> /* For PDMR3UsbCreateEmulatedDevice. */ 69 69 #include <VBox/version.h> 70 70 #include <VBox/HostServices/VBoxClipboardSvc.h> … … 77 77 # include <VBox/com/defs.h> 78 78 # include <VBox/com/array.h> 79 # include "HGCM.h" /** @todo it should be possible to register a service80 *extension using a VMMDev callback. */79 # include "HGCM.h" /** @todo It should be possible to register a service 80 * extension using a VMMDev callback. */ 81 81 # include <vector> 82 82 #endif /* VBOX_WITH_GUEST_PROPS */ … … 2780 2780 2781 2781 /* 2782 * Clipboard2782 * Shared Clipboard. 2783 2783 */ 2784 2784 { … … 2790 2790 /* Load the service */ 2791 2791 rc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard"); 2792 2793 2792 if (RT_FAILURE(rc)) 2794 2793 { 2795 LogRel((" VBoxSharedClipboard is not available. rc =%Rrc\n", rc));2794 LogRel(("Shared clipboard is not available, rc=%Rrc\n", rc)); 2796 2795 /* That is not a fatal failure. */ 2797 2796 rc = VINF_SUCCESS; … … 2799 2798 else 2800 2799 { 2800 LogRel(("Shared clipboard service loaded.\n")); 2801 2801 2802 changeClipboardMode(mode); 2802 2803 … … 2805 2806 parm.type = VBOX_HGCM_SVC_PARM_32BIT; 2806 2807 parm.setUInt32(!useHostClipboard()); 2807 pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS, 1, &parm); 2808 2809 Log(("Set VBoxSharedClipboard mode\n")); 2808 pVMMDev->hgcmHostCall("VBoxSharedClipboard", 2809 VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS, 1, &parm); 2810 2810 } 2811 2811 } … … 2813 2813 2814 2814 /* 2815 * HGCM HostChannel 2815 * HGCM HostChannel. 2816 2816 */ 2817 2817 { … … 2824 2824 { 2825 2825 rc = pVMMDev->hgcmLoadService("VBoxHostChannel", "VBoxHostChannel"); 2826 2827 2826 if (RT_FAILURE(rc)) 2828 2827 { 2829 LogRel(("VBoxHostChannel is not available . rc =%Rrc\n", rc));2828 LogRel(("VBoxHostChannel is not available, rc=%Rrc\n", rc)); 2830 2829 /* That is not a fatal failure. */ 2831 2830 rc = VINF_SUCCESS; … … 2836 2835 #ifdef VBOX_WITH_DRAG_AND_DROP 2837 2836 /* 2838 * Drag & Drop2837 * Drag'n Drop. 2839 2838 */ 2840 2839 { 2841 D ragAndDropMode_T mode = DragAndDropMode_Disabled;2842 hrc = pMachine->COMGETTER(D ragAndDropMode)(&mode);H();2840 DnDMode_T enmMode = DnDMode_Disabled; 2841 hrc = pMachine->COMGETTER(DnDMode)(&enmMode); H(); 2843 2842 2844 2843 /* Load the service */ 2845 2844 rc = pVMMDev->hgcmLoadService("VBoxDragAndDropSvc", "VBoxDragAndDropSvc"); 2846 2847 2845 if (RT_FAILURE(rc)) 2848 2846 { 2849 LogRel((" VBoxDragAndDropService is not available. rc =%Rrc\n", rc));2847 LogRel(("Drag'n drop service is not available, rc=%Rrc\n", rc)); 2850 2848 /* That is not a fatal failure. */ 2851 2849 rc = VINF_SUCCESS; … … 2855 2853 HGCMSVCEXTHANDLE hDummy; 2856 2854 rc = HGCMHostRegisterServiceExtension(&hDummy, "VBoxDragAndDropSvc", 2857 &GuestDnD::notify GuestDragAndDropEvent,2858 getGuest());2855 &GuestDnD::notifyDnDDispatcher, 2856 GuestDnDInst()); 2859 2857 if (RT_FAILURE(rc)) 2860 Log(("Cannot register VBoxDragAndDropSvc extension !\n"));2858 Log(("Cannot register VBoxDragAndDropSvc extension, rc=%Rrc\n", rc)); 2861 2859 else 2862 2860 { 2863 changeDragAndDropMode(mode);2864 Log(("VBoxDragAndDropSvc loaded\n"));2861 LogRel(("Drag'n drop service loaded.\n")); 2862 rc = changeDnDMode(enmMode); 2865 2863 } 2866 2864 } … … 2870 2868 #ifdef VBOX_WITH_CROGL 2871 2869 /* 2872 * crOpenGL 2870 * crOpenGL. 2873 2871 */ 2874 2872 { 2875 2873 BOOL fEnabled3D = false; 2876 hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled3D); H();2874 hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled3D); H(); 2877 2875 2878 2876 if (fEnabled3D) … … 2887 2885 "or disable 3D acceleration in the VM settings")); 2888 2886 2889 /* Load the service */2887 /* Load the service. */ 2890 2888 rc = pVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL"); 2891 2889 if (RT_FAILURE(rc)) 2892 2890 { 2893 LogRel(("Failed to load Shared OpenGL service 2891 LogRel(("Failed to load Shared OpenGL service, rc=%Rrc\n", rc)); 2894 2892 /* That is not a fatal failure. */ 2895 2893 rc = VINF_SUCCESS; … … 2913 2911 parm.u.pointer.addr = pVM; 2914 2912 parm.u.pointer.size = sizeof(pVM); 2915 rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VM, SHCRGL_CPARMS_SET_VM, &parm); 2913 rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", 2914 SHCRGL_HOST_FN_SET_VM, SHCRGL_CPARMS_SET_VM, &parm); 2916 2915 if (!RT_SUCCESS(rc)) 2917 2916 AssertMsgFailed(("SHCRGL_HOST_FN_SET_VM failed with %Rrc\n", rc)); 2918 2917 } 2919 2920 2918 } 2921 2919 } … … 2924 2922 #ifdef VBOX_WITH_GUEST_PROPS 2925 2923 /* 2926 * Guest property service 2924 * Guest property service. 2927 2925 */ 2928 2929 2926 rc = configGuestProperties(this, pUVM); 2930 2927 #endif /* VBOX_WITH_GUEST_PROPS defined */ … … 2932 2929 #ifdef VBOX_WITH_GUEST_CONTROL 2933 2930 /* 2934 * Guest control service 2931 * Guest control service. 2935 2932 */ 2936 2937 2933 rc = configGuestControl(this); 2938 2934 #endif /* VBOX_WITH_GUEST_CONTROL defined */ … … 5620 5616 Log(("Cannot register VBoxGuestControlSvc extension!\n")); 5621 5617 else 5622 Log (("VBoxGuestControlSvc loaded\n"));5618 LogRel(("Guest Control service loaded.\n")); 5623 5619 } 5624 5620 -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r51461 r51476 2364 2364 } 2365 2365 2366 2367 2366 // IDisplay methods 2368 2367 ///////////////////////////////////////////////////////////////////////////// 2369 STDMETHODIMP Display::GetScreenResolution 2370 ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel,2371 LONG *aXOrigin, LONG *aYOrigin)2372 { 2373 LogRelFlowFunc(("aScreenId = %d\n", aScreenId));2368 STDMETHODIMP Display::GetScreenResolution(ULONG aScreenId, 2369 ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel, 2370 LONG *aXOrigin, LONG *aYOrigin) 2371 { 2372 LogRelFlowFunc(("aScreenId=%RU32\n", aScreenId)); 2374 2373 2375 2374 AutoCaller autoCaller(this); … … 2446 2445 (PFNRT)changeFramebuffer, 3, this, aFramebuffer, aScreenId); 2447 2446 2447 ComAssertRCRet(vrc, E_FAIL); 2448 2448 alock.acquire(); 2449 2449 2450 ComAssertRCRet (vrc, E_FAIL);2451 2452 2450 #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL) 2453 {2454 BOOL is3denabled;2455 mParent->machine()->COMGETTER(Accelerate3DEnabled)(&is3denabled);2456 2457 if (is3denabled)2458 {2459 VBOXCRCMDCTL_HGCM data;2460 2461 2462 2463 2464 2465 2466 2467 2468 crCtlSubmitSync(&data.Hdr, sizeof(data));2469 2470 alock.acquire(); 2471 }2451 BOOL fIs3DEnabled; 2452 HRESULT hr = mParent->machine()->COMGETTER(Accelerate3DEnabled)(&fIs3DEnabled); 2453 ComAssertComRC(hr); 2454 if (fIs3DEnabled) 2455 { 2456 VBOXCRCMDCTL_HGCM data; 2457 RT_ZERO(data); 2458 data.Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM; 2459 data.Hdr.u32Function = SHCRGL_HOST_FN_SCREEN_CHANGED; 2460 2461 data.aParms[0].type = VBOX_HGCM_SVC_PARM_32BIT; 2462 data.aParms[0].u.uint32 = aScreenId; 2463 2464 alock.release(); 2465 2466 vrc = crCtlSubmitSync(&data.Hdr, sizeof(data)); 2467 AssertRC(vrc); 2468 2469 alock.acquire(); 2472 2470 } 2473 2471 #endif /* #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL) */ … … 2476 2474 { 2477 2475 /* No VM is created (VM is powered off), do a direct call */ 2478 int vrc = changeFramebuffer 2479 ComAssertRCRet 2476 int vrc = changeFramebuffer(this, aFramebuffer, aScreenId); 2477 ComAssertRCRet(vrc, E_FAIL); 2480 2478 } 2481 2479 … … 2605 2603 IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin) 2606 2604 { 2607 LogRelFlowFunc(("aScreenId = %d\n", aScreenId));2605 LogRelFlowFunc(("aScreenId=%ld\n", aScreenId)); 2608 2606 2609 2607 CheckComArgOutPointerValid(aFramebuffer); … … 2617 2615 return E_INVALIDARG; 2618 2616 2619 /* @todo this should be actually done on EMT. */2617 /** @todo This should be actually done on EMT. */ 2620 2618 DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId]; 2621 2622 *aFramebuffer = pFBInfo->pFramebuffer; 2619 AssertPtr(pFBInfo); 2620 2621 *aFramebuffer = pFBInfo->pFramebuffer; /** @todo r=andy Race prone? Use a ComPtr instead? */ 2623 2622 if (*aFramebuffer) 2624 (*aFramebuffer)->AddRef 2623 (*aFramebuffer)->AddRef(); 2625 2624 if (aXOrigin) 2626 2625 *aXOrigin = pFBInfo->xOrigin; … … 2643 2642 2644 2643 /* 2645 * Do some rough checks for valid input 2644 * Do some rough checks for valid input. 2646 2645 */ 2647 2646 ULONG width = aWidth; -
trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp
r51420 r51476 1 1 /* $Id$ */ 2 2 /** @file 3 * VirtualBox COM class implementation: Guest Drag and Drop parts 3 * Private guest drag and drop code, used by GuestDnDTarget + 4 * GuestDnDSource. 4 5 */ 5 6 … … 22 23 # include "ConsoleImpl.h" 23 24 # include "ProgressImpl.h" 24 # include "GuestDnDImpl.h" 25 # include "GuestDnDPrivate.h" 26 27 # include <algorithm> 25 28 26 29 # include <iprt/dir.h> … … 32 35 # include <VMMDev.h> 33 36 34 # include <VBox/com/list.h>35 37 # include <VBox/GuestHost/DragAndDrop.h> 36 38 # include <VBox/HostServices/DragAndDropSvc.h> 37 39 38 40 # ifdef LOG_GROUP 39 #undef LOG_GROUP41 # undef LOG_GROUP 40 42 # endif 41 43 # define LOG_GROUP LOG_GROUP_GUEST_DND 42 44 # include <VBox/log.h> 43 45 44 /* How does this work: 46 /** 47 * Overview: 45 48 * 46 49 * Drag and Drop is handled over the internal HGCM service for the host <-> … … 73 76 * The guest has to respond with an action it would accept, so the GUI could 74 77 * change the cursor. 75 * 2. On drop, first a drop event is sen d. If this is accepted a drop data78 * 2. On drop, first a drop event is sent. If this is accepted a drop data 76 79 * event follows. This blocks the GUI and shows some progress indicator. 77 80 * … … 86 89 * 87 90 * Some hints: 88 * m_s strAllowedMimeTypes here in this file defines the allowed mime-types.91 * m_strSupportedFormats here in this file defines the allowed mime-types. 89 92 * This is necessary because we need special handling for some of the 90 93 * mime-types. E.g. for URI lists we need to transfer the actual dirs and … … 141 144 * onces. 142 145 * 143 * Todo: 144 * - Dragging out of the guest (partly done) 145 * - ESC doesn't really work (on Windows guests it's already implemented) 146 * - transfer of URIs (that is the files and patching of the data) 147 * - testing in a multi monitor setup 146 ** @todo 147 * - ESC doesn't really work (on Windows guests it's already implemented) 148 148 * ... in any case it seems a little bit difficult to handle from the Qt 149 149 * side. Maybe also a host specific implementation becomes necessary ... 150 150 * this would be really worst ofc. 151 * - Win guest support (maybe there have to be done a mapping between the 152 * official mime-types and Win Clipboard formats (see QWindowsMime, for an 153 * idea), for VBox internally only mime-types should be used) 154 * - EOL handling on text (should be shared with the clipboard code) 155 * - add configuration (GH, HG, Bidirectional, None), like for the clipboard 156 * - HG->GH and GH->HG-switch: Handle the case the user drags something out of 157 * the guest and than return to the source view (or another window in the 158 * multiple guest screen scenario). 159 * - add support for more mime-types (especially images, csv) 160 * - test unusual behavior: 151 * - Add support for more mime-types (especially images, csv) 152 * - Test unusual behavior: 161 153 * - DnD service crash in the guest during a DnD op (e.g. crash of VBoxClient or X11) 162 * - not expected order of the events between HGCM and the guest154 * - Not expected order of the events between HGCM and the guest 163 155 * - Security considerations: We transfer a lot of memory between the guest and 164 156 * the host and even allow the creation of dirs/files. Maybe there should be 165 157 * limits introduced to preventing DOS attacks or filling up all the memory 166 158 * (both in the host and the guest). 167 * - test, test, test ...168 159 */ 169 160 170 class DnDGuestResponse 171 { 172 173 public: 174 175 DnDGuestResponse(const ComObjPtr<Guest>& pGuest); 176 177 virtual ~DnDGuestResponse(void); 178 179 public: 180 181 int notifyAboutGuestResponse(void); 182 int waitForGuestResponse(RTMSINTERVAL msTimeout = 500); 183 184 void setDefAction(uint32_t a) { m_defAction = a; } 185 uint32_t defAction(void) const { return m_defAction; } 186 187 void setAllActions(uint32_t a) { m_allActions = a; } 188 uint32_t allActions() const { return m_allActions; } 189 190 void setFormat(const Utf8Str &strFormat) { m_strFormat = strFormat; } 191 Utf8Str format(void) const { return m_strFormat; } 192 193 void setDropDir(const Utf8Str &strDropDir) { m_strDropDir = strDropDir; } 194 Utf8Str dropDir(void) const { return m_strDropDir; } 195 196 int dataAdd(const void *pvData, uint32_t cbData, uint32_t *pcbCurSize); 197 int dataSetStatus(size_t cbDataAdd, size_t cbDataTotal = 0); 198 void reset(void); 199 const void *data(void) { return m_pvData; } 200 size_t size(void) const { return m_cbData; } 201 202 int setProgress(unsigned uPercentage, uint32_t uState, int rcOp = VINF_SUCCESS); 203 HRESULT resetProgress(const ComObjPtr<Guest>& pParent); 204 HRESULT queryProgressTo(IProgress **ppProgress); 205 206 int writeToFile(const char *pszPath, size_t cbPath, void *pvData, size_t cbData, uint32_t fMode); 207 208 public: 209 210 Utf8Str errorToString(const ComObjPtr<Guest>& pGuest, int guestRc); 211 212 private: 213 RTSEMEVENT m_EventSem; 214 uint32_t m_defAction; 215 uint32_t m_allActions; 216 Utf8Str m_strFormat; 217 218 /** The actual MIME data.*/ 219 void *m_pvData; 220 /** Size (in bytes) of MIME data. */ 221 uint32_t m_cbData; 222 223 size_t m_cbDataCurrent; 224 size_t m_cbDataTotal; 225 /** Dropped files directory on the host. */ 226 Utf8Str m_strDropDir; 227 /** The handle of the currently opened file being written to 228 * or read from. */ 229 RTFILE m_hFile; 230 Utf8Str m_strFile; 231 232 ComObjPtr<Guest> m_parent; 233 ComObjPtr<Progress> m_progress; 234 }; 235 236 /** @todo This class needs a major cleanup. Later. */ 237 class GuestDnDPrivate 238 { 239 private: 240 241 /** @todo Currently we only support one response. Maybe this needs to be extended at some time. */ 242 GuestDnDPrivate(GuestDnD *q, const ComObjPtr<Guest>& pGuest) 243 : q_ptr(q) 244 , p(pGuest) 245 , m_pDnDResponse(new DnDGuestResponse(pGuest)) 246 {} 247 virtual ~GuestDnDPrivate(void) { delete m_pDnDResponse; } 248 249 DnDGuestResponse *response(void) const { return m_pDnDResponse; } 250 251 HRESULT adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const; 252 int hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const; 253 254 /* Static helpers. */ 255 static RTCString toFormatString(ComSafeArrayIn(IN_BSTR, formats)); 256 static void toFormatSafeArray(const RTCString &strFormats, ComSafeArrayOut(BSTR, formats)); 257 258 static DragAndDropAction_T toMainAction(uint32_t uAction); 259 static void toMainActions(uint32_t uActions, ComSafeArrayOut(DragAndDropAction_T, actions)); 260 static uint32_t toHGCMAction(DragAndDropAction_T action); 261 static void toHGCMActions(DragAndDropAction_T inDefAction, uint32_t *pOutDefAction, 262 ComSafeArrayIn(DragAndDropAction_T, inAllowedActions), 263 uint32_t *pOutAllowedActions); 264 265 /* Private q and parent pointer */ 266 GuestDnD *q_ptr; 267 ComObjPtr<Guest> p; 268 269 /* Private helper members. */ 270 static const RTCList<RTCString> m_sstrAllowedMimeTypes; 271 DnDGuestResponse *m_pDnDResponse; 272 273 friend class GuestDnD; 274 }; 275 276 /* What mime-types are supported by VirtualBox. 277 * Note: If you add something here, make sure you test it with all guest OS's! 278 ** @todo Make this MIME list configurable / extendable (by extra data?). Currently 279 * this is done hardcoded on every guest platform (POSIX/Windows). 280 */ 281 /* static */ 282 const RTCList<RTCString> GuestDnDPrivate::m_sstrAllowedMimeTypes = RTCList<RTCString>() 283 /* Uri's */ 284 << "text/uri-list" 285 /* Text */ 286 << "text/plain;charset=utf-8" 287 << "UTF8_STRING" 288 << "text/plain" 289 << "COMPOUND_TEXT" 290 << "TEXT" 291 << "STRING" 292 /* OpenOffice formates */ 293 << "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"" 294 << "application/x-openoffice-drawing;windows_formatname=\"Drawing Format\""; 295 296 DnDGuestResponse::DnDGuestResponse(const ComObjPtr<Guest>& pGuest) 297 : m_EventSem(NIL_RTSEMEVENT) 298 , m_defAction(0) 299 , m_allActions(0) 300 , m_pvData(0) 301 , m_cbData(0) 302 , m_cbDataCurrent(0) 303 , m_cbDataTotal(0) 304 , m_hFile(NIL_RTFILE) 305 , m_parent(pGuest) 161 GuestDnDResponse::GuestDnDResponse(const ComObjPtr<Guest>& pGuest) 162 : m_EventSem(NIL_RTSEMEVENT) 163 , m_defAction(0) 164 , m_allActions(0) 165 , m_pvData(0) 166 , m_cbData(0) 167 , m_cbDataCurrent(0) 168 , m_cbDataTotal(0) 169 , m_hFile(NIL_RTFILE) 170 , m_parent(pGuest) 306 171 { 307 172 int rc = RTSemEventCreate(&m_EventSem); … … 309 174 } 310 175 311 DnDGuestResponse::~DnDGuestResponse(void)176 GuestDnDResponse::~GuestDnDResponse(void) 312 177 { 313 178 reset(); … … 317 182 } 318 183 319 int DnDGuestResponse::dataAdd(const void *pvData, uint32_t cbData,184 int GuestDnDResponse::dataAdd(const void *pvData, uint32_t cbData, 320 185 uint32_t *pcbCurSize) 321 186 { … … 344 209 345 210 /* static */ 346 Utf8Str DnDGuestResponse::errorToString(const ComObjPtr<Guest>& pGuest, int guestRc)211 Utf8Str GuestDnDResponse::errorToString(const ComObjPtr<Guest>& pGuest, int guestRc) 347 212 { 348 213 Utf8Str strError; … … 377 242 } 378 243 379 int DnDGuestResponse::notifyAboutGuestResponse(void)244 int GuestDnDResponse::notifyAboutGuestResponse(void) 380 245 { 381 246 return RTSemEventSignal(m_EventSem); 382 247 } 383 248 384 void DnDGuestResponse::reset(void)249 void GuestDnDResponse::reset(void) 385 250 { 386 251 LogFlowThisFuncEnter(); … … 409 274 } 410 275 411 HRESULT DnDGuestResponse::resetProgress(const ComObjPtr<Guest>& pParent)276 HRESULT GuestDnDResponse::resetProgress(const ComObjPtr<Guest>& pParent) 412 277 { 413 278 m_progress.setNull(); … … 422 287 } 423 288 424 int DnDGuestResponse::setProgress(unsigned uPercentage,289 int GuestDnDResponse::setProgress(unsigned uPercentage, 425 290 uint32_t uState, int rcOp /* = VINF_SUCCESS */) 426 291 { … … 440 305 COM_IIDOF(IGuest), 441 306 m_parent->getComponentName(), 442 DnDGuestResponse::errorToString(m_parent, rcOp).c_str());307 GuestDnDResponse::errorToString(m_parent, rcOp).c_str()); 443 308 reset(); 444 309 } … … 465 330 } 466 331 467 int DnDGuestResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */)332 int GuestDnDResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */) 468 333 { 469 334 if (cbDataTotal) … … 506 371 } 507 372 508 HRESULT DnDGuestResponse::queryProgressTo(IProgress **ppProgress)373 HRESULT GuestDnDResponse::queryProgressTo(IProgress **ppProgress) 509 374 { 510 375 return m_progress.queryInterfaceTo(ppProgress); 511 376 } 512 377 513 int DnDGuestResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */)378 int GuestDnDResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */) 514 379 { 515 380 int rc = RTSemEventWait(m_EventSem, msTimeout); … … 520 385 } 521 386 522 int DnDGuestResponse::writeToFile(const char *pszPath, size_t cbPath,387 int GuestDnDResponse::writeToFile(const char *pszPath, size_t cbPath, 523 388 void *pvData, size_t cbData, uint32_t fMode) 524 389 { … … 575 440 /////////////////////////////////////////////////////////////////////////////// 576 441 577 HRESULT GuestDnDPrivate::adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const 578 { 442 GuestDnD* GuestDnD::s_pInstance = NULL; 443 444 GuestDnD::GuestDnD(const ComObjPtr<Guest> &pGuest) 445 : m_pGuest(pGuest) 446 { 447 LogFlowFuncEnter(); 448 449 m_pResponse = new GuestDnDResponse(pGuest); 450 451 /* List of supported MIME types. 452 * Note: If you add something here, make sure you test it with all supported guest OSes! 453 ** @todo Make this MIME list configurable / extendable (by extra data?). Currently 454 * this is done hardcoded on every guest platform (*NIX/Windows). 455 */ 456 const com::Utf8Str arrEntries[] = { 457 "text/uri-list", 458 /* Text */ 459 "text/plain;charset=utf-8", 460 "UTF8_STRING", 461 "text/plain", 462 "COMPOUND_TEXT", 463 "TEXT", 464 "STRING", 465 /* OpenOffice formats */ 466 "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"", 467 "application/x-openoffice-drawing;windows_formatname=\"Drawing Format\"", 468 }; 469 470 for (size_t i = 0; i < RT_ELEMENTS(arrEntries); i++) 471 m_strSupportedFormats.push_back(arrEntries[0]); 472 } 473 474 GuestDnD::~GuestDnD(void) 475 { 476 LogFlowFuncEnter(); 477 478 if (m_pResponse) 479 delete m_pResponse; 480 } 481 482 int GuestDnD::adjustScreenCoordinates(ULONG uScreenId, ULONG *puX, ULONG *puY) const 483 { 484 /** @todo r=andy Save the current screen's shifting coordinates to speed things up. 485 * Only query for new offsets when the screen ID has changed. */ 486 579 487 /* For multi-monitor support we need to add shift values to the coordinates 580 488 * (depending on the screen number). */ 489 ComObjPtr<Console> pConsole = m_pGuest->getConsole(); 581 490 ComPtr<IDisplay> pDisplay; 582 HRESULT hr = p ->mParent->COMGETTER(Display)(pDisplay.asOutParam());491 HRESULT hr = pConsole->COMGETTER(Display)(pDisplay.asOutParam()); 583 492 if (FAILED(hr)) 584 493 return hr; … … 590 499 return hr; 591 500 592 *puX += xShift; 593 *puY += yShift; 594 595 return hr; 596 } 597 598 int GuestDnDPrivate::hostCall(uint32_t u32Function, uint32_t cParms, 599 PVBOXHGCMSVCPARM paParms) const 600 { 601 VMMDev *pVMMDev = NULL; 602 { 603 /* Make sure mParent is valid, so set the read lock while using. 604 * Do not keep this lock while doing the actual call, because in the meanwhile 605 * another thread could request a write lock which would be a bad idea ... */ 606 AutoReadLock alock(p COMMA_LOCKVAL_SRC_POS); 607 608 /* Forward the information to the VMM device. */ 609 AssertPtr(p->mParent); 610 pVMMDev = p->mParent->getVMMDev(); 611 } 612 501 if (puX) 502 *puX += xShift; 503 if (puY) 504 *puY += yShift; 505 506 #ifdef DEBUG_andy 507 LogFlowFunc(("uScreenId=%RU32, x=%RU32, y=%RU32\n", 508 uScreenId, puX ? *puX : 0, puY ? *puY : 0)); 509 #endif 510 return VINF_SUCCESS; 511 } 512 513 int GuestDnD::hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const 514 { 515 Assert(!m_pGuest.isNull()); 516 ComObjPtr<Console> pConsole = m_pGuest->getConsole(); 517 518 /* Forward the information to the VMM device. */ 519 Assert(!pConsole.isNull()); 520 VMMDev *pVMMDev = pConsole->getVMMDev(); 613 521 if (!pVMMDev) 614 throw p->setError(VBOX_E_VM_ERROR, 615 p->tr("VMM device is not available (is the VM running?)")); 616 617 LogFlowFunc(("hgcmHostCall uMsg=%RU32, cParms=%RU32\n", u32Function, cParms)); 618 int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc", 619 u32Function, 522 return VERR_COM_OBJECT_NOT_FOUND; 523 524 int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc", u32Function, 620 525 cParms, paParms); 621 if (RT_FAILURE(rc)) 622 { 623 LogFlowFunc(("hgcmHostCall failed with rc=%Rrc\n", rc)); 624 throw p->setError(VBOX_E_IPRT_ERROR, 625 p->tr("hgcmHostCall failed (%Rrc)"), rc); 626 } 627 526 LogFlowFunc(("uMsg=%RU32, cParms=%RU32, rc=%Rrc\n", 527 u32Function, cParms, rc)); 628 528 return rc; 629 529 } 630 530 631 531 /* static */ 632 RTCString GuestDnDPrivate::toFormatString(ComSafeArrayIn(IN_BSTR, formats)) 633 { 634 const RTCList<Utf8Str> formatList(ComSafeArrayInArg(formats)); 635 RTCStringstrFormat;636 for (size_t i = 0; i < formatList.size(); ++i)637 { 638 const RTCString &f = formatList.at(i);532 com::Utf8Str GuestDnD::toFormatString(const std::vector<com::Utf8Str> &lstSupportedFormats, 533 const std::vector<com::Utf8Str> &lstFormats) 534 { 535 com::Utf8Str strFormat; 536 for (size_t i = 0; i < lstFormats.size(); ++i) 537 { 538 const com::Utf8Str &f = lstFormats.at(i); 639 539 /* Only keep allowed format types. */ 640 if (m_sstrAllowedMimeTypes.contains(f)) 540 if (std::find(lstSupportedFormats.begin(), 541 lstSupportedFormats.end(), f) != lstSupportedFormats.end()) 641 542 strFormat += f + "\r\n"; 642 543 } 544 643 545 return strFormat; 644 546 } 645 547 646 548 /* static */ 647 void GuestDnDPrivate::toFormatSafeArray(const RTCString &strFormats, ComSafeArrayOut(BSTR, formats)) 648 { 649 RTCList<RTCString> list = strFormats.split("\r\n"); 549 void GuestDnD::toFormatVector(const std::vector<com::Utf8Str> &lstSupportedFormats, 550 const com::Utf8Str &strFormats, 551 std::vector<com::Utf8Str> &vecformats) 552 { 553 RTCList<RTCString> lstFormats = strFormats.split("\r\n"); 650 554 size_t i = 0; 651 while (i < l ist.size())555 while (i < lstFormats.size()) 652 556 { 653 557 /* Only keep allowed format types. */ 654 if (!m_sstrAllowedMimeTypes.contains(list.at(i))) 655 list.removeAt(i); 558 if (std::find(lstSupportedFormats.begin(), 559 lstSupportedFormats.end(), lstFormats.at(i)) == lstSupportedFormats.end()) 560 lstFormats.removeAt(i); 656 561 else 657 562 ++i; 658 563 } 659 /* Create a safe array out of the cleaned list. */ 660 com::SafeArray<BSTR> sfaFormats(list.size()); 661 for (i = 0; i < list.size(); ++i) 662 { 663 const RTCString &f = list.at(i); 664 if (m_sstrAllowedMimeTypes.contains(f)) 665 { 666 Bstr bstr(f); 667 bstr.detachTo(&sfaFormats[i]); 668 } 669 } 670 sfaFormats.detachTo(ComSafeArrayOutArg(formats)); 564 565 for (i = 0; i < lstFormats.size(); i++) 566 { 567 const Utf8Str &f = lstFormats.at(i); 568 if (std::find(lstSupportedFormats.begin(), 569 lstSupportedFormats.end(), f) != lstSupportedFormats.end()) 570 vecformats.push_back(lstFormats[i]); 571 } 671 572 } 672 573 673 574 /* static */ 674 uint32_t GuestDnDPrivate::toHGCMAction(DragAndDropAction_T action) 675 { 676 uint32_t a = DND_IGNORE_ACTION; 677 switch (action) 678 { 679 case DragAndDropAction_Copy: a = DND_COPY_ACTION; break; 680 case DragAndDropAction_Move: a = DND_MOVE_ACTION; break; 681 case DragAndDropAction_Link: /* For now it doesn't seems useful to allow a link 682 action between host & guest. Maybe later! */ 683 case DragAndDropAction_Ignore: /* Ignored */ break; 684 default: AssertMsgFailed(("Action %u not recognized!\n", action)); break; 685 } 686 return a; 575 uint32_t GuestDnD::toHGCMAction(DnDAction_T enmAction) 576 { 577 uint32_t uAction = DND_IGNORE_ACTION; 578 switch (enmAction) 579 { 580 case DnDAction_Copy: 581 uAction = DND_COPY_ACTION; 582 break; 583 case DnDAction_Move: 584 uAction = DND_MOVE_ACTION; 585 break; 586 case DnDAction_Link: 587 /* For now it doesn't seems useful to allow a link 588 action between host & guest. Later? */ 589 case DnDAction_Ignore: 590 /* Ignored. */ 591 break; 592 default: 593 AssertMsgFailed(("Action %RU32 not recognized!\n", enmAction)); 594 break; 595 } 596 597 return uAction; 687 598 } 688 599 689 600 /* static */ 690 void GuestDnDPrivate::toHGCMActions(DragAndDropAction_T inDefAction, 691 uint32_t *pOutDefAction, 692 ComSafeArrayIn(DragAndDropAction_T, inAllowedActions), 693 uint32_t *pOutAllowedActions) 694 { 695 const com::SafeArray<DragAndDropAction_T> sfaInActions(ComSafeArrayInArg(inAllowedActions)); 696 697 /* Defaults */ 698 *pOutDefAction = toHGCMAction(inDefAction);; 699 *pOutAllowedActions = DND_IGNORE_ACTION; 700 701 /* First convert the allowed actions to a bit array. */ 702 for (size_t i = 0; i < sfaInActions.size(); ++i) 703 *pOutAllowedActions |= toHGCMAction(sfaInActions[i]); 704 705 /* Second check if the default action is a valid action and if not so try 706 * to find an allowed action. */ 707 if (isDnDIgnoreAction(*pOutDefAction)) 708 { 709 if (hasDnDCopyAction(*pOutAllowedActions)) 710 *pOutDefAction = DND_COPY_ACTION; 711 else if (hasDnDMoveAction(*pOutAllowedActions)) 712 *pOutDefAction = DND_MOVE_ACTION; 601 void GuestDnD::toHGCMActions(DnDAction_T enmDefAction, 602 uint32_t *puDefAction, 603 const std::vector<DnDAction_T> vecAllowedActions, 604 uint32_t *puAllowedActions) 605 { 606 if (puDefAction) 607 *puDefAction = toHGCMAction(enmDefAction); 608 if (puAllowedActions) 609 { 610 *puAllowedActions = DND_IGNORE_ACTION; 611 612 /* First convert the allowed actions to a bit array. */ 613 for (size_t i = 0; i < vecAllowedActions.size(); ++i) 614 *puAllowedActions |= toHGCMAction(vecAllowedActions[i]); 615 616 /* Second check if the default action is a valid action and if not so try 617 * to find an allowed action. */ 618 if (isDnDIgnoreAction(*puAllowedActions)) 619 { 620 if (hasDnDCopyAction(*puAllowedActions)) 621 *puAllowedActions = DND_COPY_ACTION; 622 else if (hasDnDMoveAction(*puAllowedActions)) 623 *puAllowedActions = DND_MOVE_ACTION; 624 } 713 625 } 714 626 } 715 627 716 628 /* static */ 717 D ragAndDropAction_T GuestDnDPrivate::toMainAction(uint32_t uAction)629 DnDAction_T GuestDnD::toMainAction(uint32_t uAction) 718 630 { 719 631 /* For now it doesn't seems useful to allow a 720 632 * link action between host & guest. Maybe later! */ 721 return (isDnDCopyAction(uAction) ? (D ragAndDropAction_T)DragAndDropAction_Copy :722 isDnDMoveAction(uAction) ? (D ragAndDropAction_T)DragAndDropAction_Move :723 (D ragAndDropAction_T)DragAndDropAction_Ignore);633 return (isDnDCopyAction(uAction) ? (DnDAction_T)DnDAction_Copy : 634 isDnDMoveAction(uAction) ? (DnDAction_T)DnDAction_Move : 635 (DnDAction_T)DnDAction_Ignore); 724 636 } 725 637 726 638 /* static */ 727 void GuestDnD Private::toMainActions(uint32_t uActions,728 ComSafeArrayOut(DragAndDropAction_T, actions))639 void GuestDnD::toMainActions(uint32_t uActions, 640 std::vector<DnDAction_T> &vecActions) 729 641 { 730 642 /* For now it doesn't seems useful to allow a 731 643 * link action between host & guest. Maybe later! */ 732 RTCList<D ragAndDropAction_T> list;644 RTCList<DnDAction_T> lstActions; 733 645 if (hasDnDCopyAction(uActions)) 734 l ist.append(DragAndDropAction_Copy);646 lstActions.append(DnDAction_Copy); 735 647 if (hasDnDMoveAction(uActions)) 736 list.append(DragAndDropAction_Move); 737 738 com::SafeArray<DragAndDropAction_T> sfaActions(list.size()); 739 for (size_t i = 0; i < list.size(); ++i) 740 sfaActions[i] = list.at(i); 741 sfaActions.detachTo(ComSafeArrayOutArg(actions)); 742 } 743 744 GuestDnD::GuestDnD(const ComObjPtr<Guest>& pGuest) 745 : d_ptr(new GuestDnDPrivate(this, pGuest)) 746 { 747 } 748 749 GuestDnD::~GuestDnD(void) 750 { 751 delete d_ptr; 752 } 753 754 HRESULT GuestDnD::dragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY, 755 DragAndDropAction_T defaultAction, 756 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 757 ComSafeArrayIn(IN_BSTR, formats), 758 DragAndDropAction_T *pResultAction) 759 { 760 DPTR(GuestDnD); 761 const ComObjPtr<Guest> &p = d->p; 762 763 /* Default is ignoring */ 764 *pResultAction = DragAndDropAction_Ignore; 765 766 /* Check & convert the drag & drop actions */ 767 uint32_t uDefAction = 0; 768 uint32_t uAllowedActions = 0; 769 d->toHGCMActions(defaultAction, &uDefAction, ComSafeArrayInArg(allowedActions), &uAllowedActions); 770 /* If there is no usable action, ignore this request. */ 771 if (isDnDIgnoreAction(uDefAction)) 772 return S_OK; 773 774 /* Make a flat data string out of the mime-type list. */ 775 RTCString strFormats = d->toFormatString(ComSafeArrayInArg(formats)); 776 /* If there is no valid mime-type, ignore this request. */ 777 if (strFormats.isEmpty()) 778 return S_OK; 779 780 HRESULT hr = S_OK; 781 782 try 783 { 784 /* Adjust the coordinates in a multi-monitor setup. */ 785 d->adjustCoords(uScreenId, &uX, &uY); 786 787 VBOXHGCMSVCPARM paParms[7]; 788 int i = 0; 789 paParms[i++].setUInt32(uScreenId); 790 paParms[i++].setUInt32(uX); 791 paParms[i++].setUInt32(uY); 792 paParms[i++].setUInt32(uDefAction); 793 paParms[i++].setUInt32(uAllowedActions); 794 paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1); 795 paParms[i++].setUInt32(strFormats.length() + 1); 796 797 d->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_ENTER, 798 i, 799 paParms); 800 801 DnDGuestResponse *pResp = d->response(); 802 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 803 return S_OK; 804 805 /* Copy the response info */ 806 *pResultAction = d->toMainAction(pResp->defAction()); 807 LogFlowFunc(("*pResultAction=%ld\n", *pResultAction)); 808 } 809 catch (HRESULT hr2) 810 { 811 hr = hr2; 812 } 813 814 return hr; 815 } 816 817 HRESULT GuestDnD::dragHGMove(ULONG uScreenId, ULONG uX, ULONG uY, 818 DragAndDropAction_T defaultAction, 819 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 820 ComSafeArrayIn(IN_BSTR, formats), 821 DragAndDropAction_T *pResultAction) 822 { 823 DPTR(GuestDnD); 824 const ComObjPtr<Guest> &p = d->p; 825 826 /* Default is ignoring */ 827 *pResultAction = DragAndDropAction_Ignore; 828 829 /* Check & convert the drag & drop actions */ 830 uint32_t uDefAction = 0; 831 uint32_t uAllowedActions = 0; 832 d->toHGCMActions(defaultAction, &uDefAction, ComSafeArrayInArg(allowedActions), &uAllowedActions); 833 /* If there is no usable action, ignore this request. */ 834 if (isDnDIgnoreAction(uDefAction)) 835 return S_OK; 836 837 /* Make a flat data string out of the mime-type list. */ 838 RTCString strFormats = d->toFormatString(ComSafeArrayInArg(formats)); 839 /* If there is no valid mime-type, ignore this request. */ 840 if (strFormats.isEmpty()) 841 return S_OK; 842 843 HRESULT hr = S_OK; 844 845 try 846 { 847 /* Adjust the coordinates in a multi-monitor setup. */ 848 d->adjustCoords(uScreenId, &uX, &uY); 849 850 VBOXHGCMSVCPARM paParms[7]; 851 int i = 0; 852 paParms[i++].setUInt32(uScreenId); 853 paParms[i++].setUInt32(uX); 854 paParms[i++].setUInt32(uY); 855 paParms[i++].setUInt32(uDefAction); 856 paParms[i++].setUInt32(uAllowedActions); 857 paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1); 858 paParms[i++].setUInt32(strFormats.length() + 1); 859 860 d->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_MOVE, 861 i, 862 paParms); 863 864 DnDGuestResponse *pResp = d->response(); 865 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 866 return S_OK; 867 868 /* Copy the response info */ 869 *pResultAction = d->toMainAction(pResp->defAction()); 870 LogFlowFunc(("*pResultAction=%ld\n", *pResultAction)); 871 } 872 catch (HRESULT hr2) 873 { 874 hr = hr2; 875 } 876 877 return hr; 878 } 879 880 HRESULT GuestDnD::dragHGLeave(ULONG uScreenId) 881 { 882 DPTR(GuestDnD); 883 const ComObjPtr<Guest> &p = d->p; 884 885 HRESULT hr = S_OK; 886 887 try 888 { 889 d->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_LEAVE, 890 0, 891 NULL); 892 893 DnDGuestResponse *pResp = d->response(); 894 pResp->waitForGuestResponse(); 895 } 896 catch (HRESULT hr2) 897 { 898 hr = hr2; 899 } 900 901 return hr; 902 } 903 904 HRESULT GuestDnD::dragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, 905 DragAndDropAction_T defaultAction, 906 ComSafeArrayIn(DragAndDropAction_T, allowedActions), 907 ComSafeArrayIn(IN_BSTR, formats), 908 BSTR *pstrFormat, 909 DragAndDropAction_T *pResultAction) 910 { 911 DPTR(GuestDnD); 912 const ComObjPtr<Guest> &p = d->p; 913 914 /* Default is ignoring */ 915 *pResultAction = DragAndDropAction_Ignore; 916 917 /* Check & convert the drag & drop actions */ 918 uint32_t uDefAction = 0; 919 uint32_t uAllowedActions = 0; 920 d->toHGCMActions(defaultAction, &uDefAction, ComSafeArrayInArg(allowedActions), &uAllowedActions); 921 /* If there is no usable action, ignore this request. */ 922 if (isDnDIgnoreAction(uDefAction)) 923 return S_OK; 924 925 /* Make a flat data string out of the mime-type list. */ 926 RTCString strFormats = d->toFormatString(ComSafeArrayInArg(formats)); 927 /* If there is no valid mime-type, ignore this request. */ 928 if (strFormats.isEmpty()) 929 return S_OK; 930 931 HRESULT hr = S_OK; 932 933 try 934 { 935 /* Adjust the coordinates in a multi-monitor setup. */ 936 d->adjustCoords(uScreenId, &uX, &uY); 937 938 VBOXHGCMSVCPARM paParms[7]; 939 int i = 0; 940 paParms[i++].setUInt32(uScreenId); 941 paParms[i++].setUInt32(uX); 942 paParms[i++].setUInt32(uY); 943 paParms[i++].setUInt32(uDefAction); 944 paParms[i++].setUInt32(uAllowedActions); 945 paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1); 946 paParms[i++].setUInt32(strFormats.length() + 1); 947 948 d->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_DROPPED, 949 i, 950 paParms); 951 952 DnDGuestResponse *pResp = d->response(); 953 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 954 return S_OK; 955 956 /* Get the resulting action from the guest. */ 957 *pResultAction = d->toMainAction(pResp->defAction()); 958 959 LogFlowFunc(("resFormat=%s, resAction=%RU32\n", 960 pResp->format().c_str(), pResp->defAction())); 961 962 Bstr(pResp->format()).cloneTo(pstrFormat); 963 } 964 catch (HRESULT hr2) 965 { 966 hr = hr2; 967 } 968 969 return hr; 970 } 971 972 HRESULT GuestDnD::dragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat, 973 ComSafeArrayIn(BYTE, data), IProgress **ppProgress) 974 { 975 DPTR(GuestDnD); 976 const ComObjPtr<Guest> &p = d->p; 977 978 HRESULT hr = S_OK; 979 980 try 981 { 982 Utf8Str strFormat(bstrFormat); 983 com::SafeArray<BYTE> sfaData(ComSafeArrayInArg(data)); 984 985 VBOXHGCMSVCPARM paParms[5]; 986 int i = 0; 987 paParms[i++].setUInt32(uScreenId); 988 paParms[i++].setPointer((void*)strFormat.c_str(), (uint32_t)strFormat.length() + 1); 989 paParms[i++].setUInt32((uint32_t)strFormat.length() + 1); 990 paParms[i++].setPointer((void*)sfaData.raw(), (uint32_t)sfaData.size()); 991 paParms[i++].setUInt32((uint32_t)sfaData.size()); 992 993 DnDGuestResponse *pResp = d->response(); 994 /* Reset any old progress status. */ 995 pResp->resetProgress(p); 996 997 /* Note: The actual data transfer of files/directoies is performed by the 998 * DnD host service. */ 999 d->hostCall(DragAndDropSvc::HOST_DND_HG_SND_DATA, 1000 i, 1001 paParms); 1002 1003 /* Query the progress object to the caller. */ 1004 pResp->queryProgressTo(ppProgress); 1005 } 1006 catch (HRESULT hr2) 1007 { 1008 hr = hr2; 1009 } 1010 1011 return hr; 1012 } 1013 1014 #ifdef VBOX_WITH_DRAG_AND_DROP_GH 1015 HRESULT GuestDnD::dragGHPending(ULONG uScreenId, 1016 ComSafeArrayOut(BSTR, formats), 1017 ComSafeArrayOut(DragAndDropAction_T, allowedActions), 1018 DragAndDropAction_T *pDefaultAction) 1019 { 1020 DPTR(GuestDnD); 1021 const ComObjPtr<Guest> &p = d->p; 1022 1023 /* Default is ignoring */ 1024 *pDefaultAction = DragAndDropAction_Ignore; 1025 1026 HRESULT hr = S_OK; 1027 1028 try 1029 { 1030 VBOXHGCMSVCPARM paParms[1]; 1031 int i = 0; 1032 paParms[i++].setUInt32(uScreenId); 1033 1034 d->hostCall(DragAndDropSvc::HOST_DND_GH_REQ_PENDING, 1035 i, 1036 paParms); 1037 1038 DnDGuestResponse *pResp = d->response(); 1039 if (pResp->waitForGuestResponse() == VERR_TIMEOUT) 1040 return S_OK; 1041 1042 if (isDnDIgnoreAction(pResp->defAction())) 1043 return S_OK; 1044 1045 /* Fetch the default action to use. */ 1046 *pDefaultAction = d->toMainAction(pResp->defAction()); 1047 d->toFormatSafeArray(pResp->format(), ComSafeArrayOutArg(formats)); 1048 d->toMainActions(pResp->allActions(), ComSafeArrayOutArg(allowedActions)); 1049 1050 LogFlowFunc(("*pDefaultAction=0x%x\n", *pDefaultAction)); 1051 } 1052 catch (HRESULT hr2) 1053 { 1054 hr = hr2; 1055 } 1056 1057 return hr; 1058 } 1059 1060 HRESULT GuestDnD::dragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action, 1061 IProgress **ppProgress) 1062 { 1063 DPTR(GuestDnD); 1064 const ComObjPtr<Guest> &p = d->p; 1065 1066 Utf8Str strFormat(bstrFormat); 1067 HRESULT hr = S_OK; 1068 1069 uint32_t uAction = d->toHGCMAction(action); 1070 /* If there is no usable action, ignore this request. */ 1071 if (isDnDIgnoreAction(uAction)) 1072 return S_OK; 1073 1074 const char *pcszFormat = strFormat.c_str(); 1075 bool fNeedsDropDir = DnDMIMENeedsDropDir(pcszFormat, strlen(pcszFormat)); 1076 LogFlowFunc(("strFormat=%s, uAction=0x%x, fNeedsDropDir=%RTbool\n", 1077 pcszFormat, uAction, fNeedsDropDir)); 1078 1079 DnDGuestResponse *pResp = d->response(); 1080 AssertPtr(pResp); 1081 1082 /* Reset any old data. */ 1083 pResp->reset(); 1084 pResp->resetProgress(p); 1085 1086 /* Set the format we are going to retrieve to have it around 1087 * when retrieving the data later. */ 1088 pResp->setFormat(strFormat); 1089 1090 if (fNeedsDropDir) 1091 { 1092 char szDropDir[RTPATH_MAX]; 1093 int rc = DnDDirCreateDroppedFiles(szDropDir, sizeof(szDropDir)); 1094 if (RT_FAILURE(rc)) 1095 return p->setError(VBOX_E_IPRT_ERROR, 1096 p->tr("Unable to create the temporary drag'n drop directory \"%s\" (%Rrc)\n"), 1097 szDropDir, rc); 1098 LogFlowFunc(("Dropped files directory on the host is: %s\n", szDropDir)); 1099 1100 pResp->setDropDir(szDropDir); 1101 } 1102 1103 try 1104 { 1105 VBOXHGCMSVCPARM paParms[3]; 1106 int i = 0; 1107 paParms[i++].setPointer((void*)strFormat.c_str(), (uint32_t)strFormat.length() + 1); 1108 paParms[i++].setUInt32((uint32_t)strFormat.length() + 1); 1109 paParms[i++].setUInt32(uAction); 1110 1111 d->hostCall(DragAndDropSvc::HOST_DND_GH_EVT_DROPPED, 1112 i, 1113 paParms); 1114 1115 /* Query the progress object to the caller. */ 1116 pResp->queryProgressTo(ppProgress); 1117 } 1118 catch (HRESULT hr2) 1119 { 1120 hr = hr2; 1121 } 1122 1123 return hr; 1124 } 1125 1126 HRESULT GuestDnD::dragGHGetData(ComSafeArrayOut(BYTE, data)) 1127 { 1128 DPTR(GuestDnD); 1129 const ComObjPtr<Guest> &p = d->p; 1130 1131 HRESULT hr = S_OK; 1132 1133 DnDGuestResponse *pResp = d->response(); 1134 if (pResp) 1135 { 1136 com::SafeArray<BYTE> sfaData; 1137 1138 size_t cbData = pResp->size(); 1139 if (cbData) 1140 { 1141 const void *pvData = pResp->data(); 1142 AssertPtr(pvData); 1143 1144 Utf8Str strFormat = pResp->format(); 1145 LogFlowFunc(("strFormat=%s, cbData=%zu, pvData=0x%p\n", 1146 strFormat.c_str(), cbData, pvData)); 1147 1148 if (DnDMIMEHasFileURLs(strFormat.c_str(), strFormat.length())) 1149 { 1150 LogFlowFunc(("strDropDir=%s\n", pResp->dropDir().c_str())); 1151 1152 DnDURIList lstURI; 1153 int rc2 = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */); 1154 if (RT_SUCCESS(rc2)) 1155 { 1156 Utf8Str strURIs = lstURI.RootToString(pResp->dropDir()); 1157 size_t cbURIs = strURIs.length(); 1158 if (sfaData.resize(cbURIs + 1 /* Include termination */)) 1159 memcpy(sfaData.raw(), strURIs.c_str(), cbURIs); 1160 else 1161 hr = E_OUTOFMEMORY; 1162 } 1163 else 1164 hr = VBOX_E_IPRT_ERROR; 1165 1166 LogFlowFunc(("Found %zu root URIs, rc=%Rrc\n", lstURI.RootCount(), rc2)); 1167 } 1168 else 1169 { 1170 /* Copy the data into a safe array of bytes. */ 1171 if (sfaData.resize(cbData)) 1172 memcpy(sfaData.raw(), pvData, cbData); 1173 else 1174 hr = E_OUTOFMEMORY; 1175 } 1176 } 1177 1178 /* Detach in any case, regardless of data size. */ 1179 sfaData.detachTo(ComSafeArrayOutArg(data)); 1180 1181 /* Delete the data. */ 1182 pResp->reset(); 1183 } 1184 else 1185 hr = VBOX_E_INVALID_OBJECT_STATE; 1186 1187 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); 1188 return hr; 1189 } 1190 1191 int GuestDnD::onGHSendData(DnDGuestResponse *pResp, 1192 const void *pvData, size_t cbData, 1193 size_t cbTotalSize) 1194 { 1195 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 1196 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 1197 AssertReturn(cbData, VERR_INVALID_PARAMETER); 1198 AssertReturn(cbTotalSize, VERR_INVALID_PARAMETER); 1199 1200 int rc = pResp->dataAdd(pvData, cbData, NULL /* Current size */); 1201 if (RT_SUCCESS(rc)) 1202 rc = pResp->dataSetStatus(cbData, cbTotalSize); 1203 1204 LogFlowFuncLeaveRC(rc); 1205 return rc; 1206 } 1207 1208 int GuestDnD::onGHSendDir(DnDGuestResponse *pResp, 1209 const char *pszPath, size_t cbPath, 1210 uint32_t fMode) 1211 { 1212 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 1213 AssertPtrReturn(pszPath, VERR_INVALID_POINTER); 1214 AssertReturn(cbPath, VERR_INVALID_PARAMETER); 1215 1216 LogFlowFunc(("pszPath=%s, cbPath=%zu, fMode=0x%x\n", 1217 pszPath, cbPath, fMode)); 1218 1219 int rc; 1220 char *pszDir = RTPathJoinA(pResp->dropDir().c_str(), pszPath); 1221 if (pszDir) 1222 { 1223 rc = RTDirCreateFullPath(pszDir, fMode); 1224 RTStrFree(pszDir); 1225 } 1226 else 1227 rc = VERR_NO_MEMORY; 1228 1229 if (RT_SUCCESS(rc)) 1230 rc = pResp->dataSetStatus(cbPath); 1231 1232 LogFlowFuncLeaveRC(rc); 1233 return rc; 1234 } 1235 1236 int GuestDnD::onGHSendFile(DnDGuestResponse *pResp, 1237 const char *pszPath, size_t cbPath, 1238 void *pvData, size_t cbData, uint32_t fMode) 1239 { 1240 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 1241 AssertPtrReturn(pszPath, VERR_INVALID_POINTER); 1242 AssertReturn(cbPath, VERR_INVALID_PARAMETER); 1243 1244 LogFlowFunc(("pszPath=%s, cbPath=%zu, fMode=0x%x\n", 1245 pszPath, cbPath, fMode)); 1246 1247 int rc = pResp->writeToFile(pszPath, cbPath, pvData, cbData, fMode); 1248 1249 LogFlowFuncLeaveRC(rc); 1250 return rc; 1251 } 1252 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 648 lstActions.append(DnDAction_Move); 649 650 for (size_t i = 0; i < lstActions.size(); ++i) 651 vecActions.push_back(lstActions.at(i)); 652 } 1253 653 1254 654 /* static */ 1255 DECLCALLBACK(int) GuestDnD::notify GuestDragAndDropEvent(void *pvExtension, uint32_t u32Function,1256 655 DECLCALLBACK(int) GuestDnD::notifyDnDDispatcher(void *pvExtension, uint32_t u32Function, 656 void *pvParms, uint32_t cbParms) 1257 657 { 1258 658 LogFlowFunc(("pvExtension=%p, u32Function=%RU32, pvParms=%p, cbParms=%RU32\n", 1259 659 pvExtension, u32Function, pvParms, cbParms)); 1260 660 1261 ComObjPtr<Guest> pGuest = reinterpret_cast<Guest*>(pvExtension); 1262 if (!pGuest->m_pGuestDnD) 1263 return VINF_SUCCESS; 1264 1265 GuestDnD *pGuestDnD = pGuest->m_pGuestDnD; 1266 AssertPtr(pGuestDnD); 1267 1268 GuestDnDPrivate *d = static_cast<GuestDnDPrivate*>(pGuest->m_pGuestDnD->d_ptr); 1269 const ComObjPtr<Guest> &p = d->p; 1270 1271 DnDGuestResponse *pResp = d->response(); 1272 if (pResp == NULL) 1273 return VERR_INVALID_PARAMETER; 1274 1275 int rc = VINF_SUCCESS; 661 GuestDnD *pGuestDnD = reinterpret_cast<GuestDnD*>(pvExtension); 662 AssertPtrReturn(pGuestDnD, VERR_INVALID_POINTER); 663 664 GuestDnDResponse *pResp = pGuestDnD->m_pResponse; 665 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 666 667 int rc; 1276 668 switch (u32Function) 1277 669 { … … 1314 706 } 1315 707 1316 # ifdef VBOX_WITH_DRAG_AND_DROP_GH708 # ifdef VBOX_WITH_DRAG_AND_DROP_GH 1317 709 case DragAndDropSvc::GUEST_DND_GH_ACK_PENDING: 1318 710 { … … 1378 770 break; 1379 771 } 1380 # endif /* VBOX_WITH_DRAG_AND_DROP_GH */772 # endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 1381 773 default: 1382 774 rc = VERR_NOT_SUPPORTED; /* Tell the guest. */ … … 1387 779 return rc; 1388 780 } 781 782 # ifdef VBOX_WITH_DRAG_AND_DROP_GH 783 int GuestDnD::onGHSendData(GuestDnDResponse *pResp, 784 const void *pvData, size_t cbData, size_t cbTotalSize) 785 { 786 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 787 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 788 AssertReturn(cbData, VERR_INVALID_PARAMETER); 789 AssertReturn(cbTotalSize, VERR_INVALID_PARAMETER); 790 791 int rc = pResp->dataAdd(pvData, cbData, NULL /* Current size */); 792 if (RT_SUCCESS(rc)) 793 rc = pResp->dataSetStatus(cbData, cbTotalSize); 794 795 LogFlowFuncLeaveRC(rc); 796 return rc; 797 } 798 799 int GuestDnD::onGHSendDir(GuestDnDResponse *pResp, 800 const char *pszPath, size_t cbPath, uint32_t fMode) 801 { 802 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 803 AssertPtrReturn(pszPath, VERR_INVALID_POINTER); 804 AssertReturn(cbPath, VERR_INVALID_PARAMETER); 805 806 LogFlowFunc(("pszPath=%s, cbPath=%zu, fMode=0x%x\n", 807 pszPath, cbPath, fMode)); 808 809 int rc; 810 char *pszDir = RTPathJoinA(pResp->dropDir().c_str(), pszPath); 811 if (pszDir) 812 { 813 rc = RTDirCreateFullPath(pszDir, fMode); 814 RTStrFree(pszDir); 815 } 816 else 817 rc = VERR_NO_MEMORY; 818 819 if (RT_SUCCESS(rc)) 820 rc = pResp->dataSetStatus(cbPath); 821 822 LogFlowFuncLeaveRC(rc); 823 return rc; 824 } 825 826 int GuestDnD::onGHSendFile(GuestDnDResponse *pResp, 827 const char *pszPath, size_t cbPath, 828 void *pvData, size_t cbData, uint32_t fMode) 829 { 830 AssertPtrReturn(pResp, VERR_INVALID_POINTER); 831 AssertPtrReturn(pszPath, VERR_INVALID_POINTER); 832 AssertReturn(cbPath, VERR_INVALID_PARAMETER); 833 834 LogFlowFunc(("pszPath=%s, cbPath=%zu, fMode=0x%x\n", 835 pszPath, cbPath, fMode)); 836 837 int rc = pResp->writeToFile(pszPath, cbPath, 838 pvData, cbData, fMode); 839 LogFlowFuncLeaveRC(rc); 840 return rc; 841 } 842 # endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 843 1389 844 #endif /* VBOX_WITH_DRAG_AND_DROP */ 1390 845 -
trunk/src/VBox/Main/src-client/GuestImpl.cpp
r51342 r51476 1 1 /* $Id$ */ 2 2 /** @file 3 * VirtualBox COM class implementation: Guest 3 * VirtualBox COM class implementation: Guest features. 4 4 */ 5 5 … … 23 23 #include "ProgressImpl.h" 24 24 #ifdef VBOX_WITH_DRAG_AND_DROP 25 # include "GuestDnD Impl.h"25 # include "GuestDnDPrivate.h" 26 26 #endif 27 27 #include "VMMDev.h" … … 117 117 #endif 118 118 119 #ifdef VBOX_WITH_DRAG_AND_DROP 119 120 try 120 121 { 121 #ifdef VBOX_WITH_DRAG_AND_DROP 122 m_pGuestDnD = new GuestDnD(this); 123 AssertPtr(m_pGuestDnD); 122 GuestDnD::createInstance(this /* pGuest */); 123 hr = unconst(mDnDSource).createObject(); 124 if (SUCCEEDED(hr)) 125 hr = mDnDSource->init(this /* pGuest */); 126 if (SUCCEEDED(hr)) 127 { 128 hr = unconst(mDnDTarget).createObject(); 129 if (SUCCEEDED(hr)) 130 hr = mDnDTarget->init(this /* pGuest */); 131 } 132 133 LogFlowFunc(("Drag'n drop initializied with hr=%Rhrc\n", hr)); 134 } 135 catch (std::bad_alloc &) 136 { 137 hr = E_OUTOFMEMORY; 138 } 124 139 #endif 125 } 126 catch(std::bad_alloc &) 127 { 128 hr = E_OUTOFMEMORY; 129 } 130 140 141 LogFlowFunc(("hr=%Rhrc\n", hr)); 131 142 return hr; 132 143 } … … 157 168 while (itSessions != mData.mGuestSessions.end()) 158 169 { 159 # ifdef DEBUG170 # ifdef DEBUG 160 171 ULONG cRefs = itSessions->second->AddRef(); 161 172 LogFlowThisFunc(("sessionID=%RU32, cRefs=%RU32\n", itSessions->first, cRefs > 1 ? cRefs - 1 : 0)); 162 173 itSessions->second->Release(); 163 # endif174 # endif 164 175 itSessions->second->uninit(); 165 176 itSessions++; … … 169 180 170 181 #ifdef VBOX_WITH_DRAG_AND_DROP 171 if (m_pGuestDnD) 172 { 173 delete m_pGuestDnD; 174 m_pGuestDnD = NULL; 175 } 182 GuestDnD::destroyInstance(); 183 unconst(mDnDSource).setNull(); 184 unconst(mDnDTarget).setNull(); 176 185 #endif 177 186 … … 495 504 } 496 505 506 STDMETHODIMP Guest::COMGETTER(DnDSource)(IGuestDnDSource ** aSource) 507 { 508 #ifndef VBOX_WITH_DRAG_AND_DROP 509 ReturnComNotImplemented(); 510 #else 511 LogFlowThisFuncEnter(); 512 513 CheckComArgOutPointerValid(aSource); 514 515 AutoCaller autoCaller(this); 516 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 517 518 /* No need to lock - lifetime constant. */ 519 HRESULT hr = mDnDSource.queryInterfaceTo(aSource); 520 521 LogFlowFuncLeaveRC(hr); 522 return hr; 523 #endif /* VBOX_WITH_DRAG_AND_DROP */ 524 } 525 526 STDMETHODIMP Guest::COMGETTER(DnDTarget)(IGuestDnDTarget ** aTarget) 527 { 528 #ifndef VBOX_WITH_DRAG_AND_DROP 529 ReturnComNotImplemented(); 530 #else 531 LogFlowThisFuncEnter(); 532 533 CheckComArgOutPointerValid(aTarget); 534 535 AutoCaller autoCaller(this); 536 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 537 538 /* No need to lock - lifetime constant. */ 539 HRESULT hr = mDnDTarget.queryInterfaceTo(aTarget); 540 541 LogFlowFuncLeaveRC(hr); 542 return hr; 543 #endif /* VBOX_WITH_DRAG_AND_DROP */ 544 } 545 497 546 STDMETHODIMP Guest::COMGETTER(EventSource)(IEventSource ** aEventSource) 498 547 { … … 507 556 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 508 557 509 / / no need to lock - lifetime constant558 /* No need to lock - lifetime constant. */ 510 559 mEventSource.queryInterfaceTo(aEventSource); 511 560 … … 821 870 { 822 871 /** @todo */ 823 return E_NOTIMPL; 872 return E_NOTIMPL; 824 873 } 825 874 else … … 835 884 if (!aAllowInteractiveLogon) 836 885 u32Flags = VMMDEV_SETCREDENTIALS_NOLOCALLOGON; 837 886 838 887 pVMMDevPort->pfnSetCredentials(pVMMDevPort, 839 888 Utf8Str(aUserName).c_str(), … … 848 897 return setError(VBOX_E_VM_ERROR, 849 898 tr("VMM device is not available (is the VM running?)")); 850 }851 852 STDMETHODIMP Guest::DragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY,853 DragAndDropAction_T defaultAction,854 ComSafeArrayIn(DragAndDropAction_T, allowedActions),855 ComSafeArrayIn(IN_BSTR, formats),856 DragAndDropAction_T *pResultAction)857 {858 /* Input validation */859 CheckComArgSafeArrayNotNull(allowedActions);860 CheckComArgSafeArrayNotNull(formats);861 CheckComArgOutPointerValid(pResultAction);862 863 AutoCaller autoCaller(this);864 if (FAILED(autoCaller.rc())) return autoCaller.rc();865 866 #ifdef VBOX_WITH_DRAG_AND_DROP867 return m_pGuestDnD->dragHGEnter(uScreenId, uX, uY, defaultAction,868 ComSafeArrayInArg(allowedActions),869 ComSafeArrayInArg(formats),870 pResultAction);871 #else /* VBOX_WITH_DRAG_AND_DROP */872 ReturnComNotImplemented();873 #endif /* !VBOX_WITH_DRAG_AND_DROP */874 }875 876 STDMETHODIMP Guest::DragHGMove(ULONG uScreenId, ULONG uX, ULONG uY,877 DragAndDropAction_T defaultAction,878 ComSafeArrayIn(DragAndDropAction_T, allowedActions),879 ComSafeArrayIn(IN_BSTR, formats),880 DragAndDropAction_T *pResultAction)881 {882 /* Input validation */883 CheckComArgSafeArrayNotNull(allowedActions);884 CheckComArgSafeArrayNotNull(formats);885 CheckComArgOutPointerValid(pResultAction);886 887 AutoCaller autoCaller(this);888 if (FAILED(autoCaller.rc())) return autoCaller.rc();889 890 #ifdef VBOX_WITH_DRAG_AND_DROP891 return m_pGuestDnD->dragHGMove(uScreenId, uX, uY, defaultAction,892 ComSafeArrayInArg(allowedActions),893 ComSafeArrayInArg(formats),894 pResultAction);895 #else /* VBOX_WITH_DRAG_AND_DROP */896 ReturnComNotImplemented();897 #endif /* !VBOX_WITH_DRAG_AND_DROP */898 }899 900 STDMETHODIMP Guest::DragHGLeave(ULONG uScreenId)901 {902 AutoCaller autoCaller(this);903 if (FAILED(autoCaller.rc())) return autoCaller.rc();904 905 #ifdef VBOX_WITH_DRAG_AND_DROP906 return m_pGuestDnD->dragHGLeave(uScreenId);907 #else /* VBOX_WITH_DRAG_AND_DROP */908 ReturnComNotImplemented();909 #endif /* !VBOX_WITH_DRAG_AND_DROP */910 }911 912 STDMETHODIMP Guest::DragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY,913 DragAndDropAction_T defaultAction,914 ComSafeArrayIn(DragAndDropAction_T, allowedActions),915 ComSafeArrayIn(IN_BSTR, formats),916 BSTR *pstrFormat, DragAndDropAction_T *pResultAction)917 {918 /* Input validation */919 CheckComArgSafeArrayNotNull(allowedActions);920 CheckComArgSafeArrayNotNull(formats);921 CheckComArgOutPointerValid(pstrFormat);922 CheckComArgOutPointerValid(pResultAction);923 924 AutoCaller autoCaller(this);925 if (FAILED(autoCaller.rc())) return autoCaller.rc();926 927 #ifdef VBOX_WITH_DRAG_AND_DROP928 return m_pGuestDnD->dragHGDrop(uScreenId, uX, uY,929 defaultAction,930 ComSafeArrayInArg(allowedActions),931 ComSafeArrayInArg(formats),932 pstrFormat, pResultAction);933 #else /* VBOX_WITH_DRAG_AND_DROP */934 ReturnComNotImplemented();935 #endif /* !VBOX_WITH_DRAG_AND_DROP */936 }937 938 STDMETHODIMP Guest::DragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat,939 ComSafeArrayIn(BYTE, data),940 IProgress **ppProgress)941 {942 /* Input validation */943 CheckComArgStrNotEmptyOrNull(bstrFormat);944 CheckComArgSafeArrayNotNull(data);945 CheckComArgOutPointerValid(ppProgress);946 947 AutoCaller autoCaller(this);948 if (FAILED(autoCaller.rc())) return autoCaller.rc();949 950 #ifdef VBOX_WITH_DRAG_AND_DROP951 return m_pGuestDnD->dragHGPutData(uScreenId, bstrFormat,952 ComSafeArrayInArg(data), ppProgress);953 #else /* VBOX_WITH_DRAG_AND_DROP */954 ReturnComNotImplemented();955 #endif /* !VBOX_WITH_DRAG_AND_DROP */956 }957 958 STDMETHODIMP Guest::DragGHPending(ULONG uScreenId,959 ComSafeArrayOut(BSTR, formats),960 ComSafeArrayOut(DragAndDropAction_T, allowedActions),961 DragAndDropAction_T *pDefaultAction)962 {963 /* Input validation */964 CheckComArgSafeArrayNotNull(formats);965 CheckComArgSafeArrayNotNull(allowedActions);966 CheckComArgOutPointerValid(pDefaultAction);967 968 AutoCaller autoCaller(this);969 if (FAILED(autoCaller.rc())) return autoCaller.rc();970 971 #if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH)972 return m_pGuestDnD->dragGHPending(uScreenId,973 ComSafeArrayOutArg(formats),974 ComSafeArrayOutArg(allowedActions),975 pDefaultAction);976 #else /* VBOX_WITH_DRAG_AND_DROP */977 ReturnComNotImplemented();978 #endif /* !VBOX_WITH_DRAG_AND_DROP */979 }980 981 STDMETHODIMP Guest::DragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action,982 IProgress **ppProgress)983 {984 /* Input validation */985 CheckComArgStrNotEmptyOrNull(bstrFormat);986 CheckComArgOutPointerValid(ppProgress);987 988 AutoCaller autoCaller(this);989 if (FAILED(autoCaller.rc())) return autoCaller.rc();990 991 #if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH)992 return m_pGuestDnD->dragGHDropped(bstrFormat, action, ppProgress);993 #else /* VBOX_WITH_DRAG_AND_DROP */994 ReturnComNotImplemented();995 #endif /* !VBOX_WITH_DRAG_AND_DROP */996 }997 998 STDMETHODIMP Guest::DragGHGetData(ComSafeArrayOut(BYTE, data))999 {1000 /* Input validation */1001 CheckComArgSafeArrayNotNull(data);1002 1003 AutoCaller autoCaller(this);1004 if (FAILED(autoCaller.rc())) return autoCaller.rc();1005 1006 #if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH)1007 return m_pGuestDnD->dragGHGetData(ComSafeArrayOutArg(data));1008 #else /* VBOX_WITH_DRAG_AND_DROP */1009 ReturnComNotImplemented();1010 #endif /* !VBOX_WITH_DRAG_AND_DROP */1011 899 } 1012 900 -
trunk/src/VBox/Main/src-client/SessionImpl.cpp
r51236 r51476 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 784 784 } 785 785 786 STDMETHODIMP Session::OnD ragAndDropModeChange(DragAndDropMode_T aDragAndDropMode)787 { 788 LogFlowThisFunc(("\n")); 789 790 AutoCaller autoCaller(this); 791 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 792 793 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 794 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 795 #ifndef VBOX_COM_INPROC_API_CLIENT 796 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 797 798 return mConsole->onD ragAndDropModeChange(aDragAndDropMode);786 STDMETHODIMP Session::OnDnDModeChange(DnDMode_T aDragAndDropMode) 787 { 788 LogFlowThisFunc(("\n")); 789 790 AutoCaller autoCaller(this); 791 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 792 793 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 794 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 795 #ifndef VBOX_COM_INPROC_API_CLIENT 796 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 797 798 return mConsole->onDnDModeChange(aDragAndDropMode); 799 799 #else 800 800 return S_OK; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r51190 r51476 199 199 200 200 mClipboardMode = ClipboardMode_Disabled; 201 mD ragAndDropMode = DragAndDropMode_Disabled;201 mDnDMode = DnDMode_Disabled; 202 202 mGuestPropertyNotificationPatterns = ""; 203 203 … … 3036 3036 } 3037 3037 3038 STDMETHODIMP Machine::COMGETTER(D ragAndDropMode)(DragAndDropMode_T *aDragAndDropMode)3039 { 3040 CheckComArgOutPointerValid(aD ragAndDropMode);3038 STDMETHODIMP Machine::COMGETTER(DnDMode)(DnDMode_T *aDnDMode) 3039 { 3040 CheckComArgOutPointerValid(aDnDMode); 3041 3041 3042 3042 AutoCaller autoCaller(this); … … 3045 3045 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 3046 3046 3047 *aD ragAndDropMode = mHWData->mDragAndDropMode;3048 3049 return S_OK; 3050 } 3051 3052 STDMETHODIMP Machine::COMSETTER(D ragAndDropMode)(DragAndDropMode_T aDragAndDropMode)3047 *aDnDMode = mHWData->mDnDMode; 3048 3049 return S_OK; 3050 } 3051 3052 STDMETHODIMP Machine::COMSETTER(DnDMode)(DnDMode_T aDnDMode) 3053 3053 { 3054 3054 HRESULT rc = S_OK; … … 3060 3060 3061 3061 alock.release(); 3062 rc = onD ragAndDropModeChange(aDragAndDropMode);3062 rc = onDnDModeChange(aDnDMode); 3063 3063 alock.acquire(); 3064 3064 if (FAILED(rc)) return rc; … … 3066 3066 setModified(IsModified_MachineData); 3067 3067 mHWData.backup(); 3068 mHWData->mD ragAndDropMode = aDragAndDropMode;3068 mHWData->mDnDMode = aDnDMode; 3069 3069 3070 3070 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ … … 9515 9515 9516 9516 // drag'n'drop 9517 mHWData->mD ragAndDropMode = data.dragAndDropMode;9517 mHWData->mDnDMode = data.dndMode; 9518 9518 9519 9519 // guest settings … … 10808 10808 10809 10809 // drag'n'drop 10810 data.d ragAndDropMode = mHWData->mDragAndDropMode;10810 data.dndMode = mHWData->mDnDMode; 10811 10811 10812 10812 /* Guest */ … … 14470 14470 * @note Locks this object for reading. 14471 14471 */ 14472 HRESULT SessionMachine::onD ragAndDropModeChange(DragAndDropMode_T aDragAndDropMode)14472 HRESULT SessionMachine::onDnDModeChange(DnDMode_T aDnDMode) 14473 14473 { 14474 14474 LogFlowThisFunc(("\n")); … … 14487 14487 return S_OK; 14488 14488 14489 return directControl->OnD ragAndDropModeChange(aDragAndDropMode);14489 return directControl->OnDnDModeChange(aDnDMode); 14490 14490 } 14491 14491 -
trunk/src/VBox/Main/xml/Settings.cpp
r51418 r51476 1930 1930 fEmulatedUSBCardReader(false), 1931 1931 clipboardMode(ClipboardMode_Disabled), 1932 d ragAndDropMode(DragAndDropMode_Disabled),1932 dndMode(DnDMode_Disabled), 1933 1933 ulMemoryBalloonSize(0), 1934 1934 fPageFusionEnabled(false) … … 2013 2013 && (llSharedFolders == h.llSharedFolders) 2014 2014 && (clipboardMode == h.clipboardMode) 2015 && (d ragAndDropMode == h.dragAndDropMode)2015 && (dndMode == h.dndMode) 2016 2016 && (ulMemoryBalloonSize == h.ulMemoryBalloonSize) 2017 2017 && (fPageFusionEnabled == h.fPageFusionEnabled) … … 3208 3208 { 3209 3209 if (strTemp == "Disabled") 3210 hw.d ragAndDropMode = DragAndDropMode_Disabled;3210 hw.dndMode = DnDMode_Disabled; 3211 3211 else if (strTemp == "HostToGuest") 3212 hw.d ragAndDropMode = DragAndDropMode_HostToGuest;3212 hw.dndMode = DnDMode_HostToGuest; 3213 3213 else if (strTemp == "GuestToHost") 3214 hw.d ragAndDropMode = DragAndDropMode_GuestToHost;3214 hw.dndMode = DnDMode_GuestToHost; 3215 3215 else if (strTemp == "Bidirectional") 3216 hw.d ragAndDropMode = DragAndDropMode_Bidirectional;3216 hw.dndMode = DnDMode_Bidirectional; 3217 3217 else 3218 3218 throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in DragAndDrop/@mode attribute"), strTemp.c_str()); … … 4682 4682 xml::ElementNode *pelmDragAndDrop = pelmHardware->createChild("DragAndDrop"); 4683 4683 const char *pcszDragAndDrop; 4684 switch (hw.d ragAndDropMode)4685 { 4686 default: /*case D ragAndDropMode_Disabled:*/ pcszDragAndDrop = "Disabled"; break;4687 case D ragAndDropMode_HostToGuest: pcszDragAndDrop = "HostToGuest"; break;4688 case D ragAndDropMode_GuestToHost: pcszDragAndDrop = "GuestToHost"; break;4689 case D ragAndDropMode_Bidirectional: pcszDragAndDrop = "Bidirectional"; break;4684 switch (hw.dndMode) 4685 { 4686 default: /*case DnDMode_Disabled:*/ pcszDragAndDrop = "Disabled"; break; 4687 case DnDMode_HostToGuest: pcszDragAndDrop = "HostToGuest"; break; 4688 case DnDMode_GuestToHost: pcszDragAndDrop = "GuestToHost"; break; 4689 case DnDMode_Bidirectional: pcszDragAndDrop = "Bidirectional"; break; 4690 4690 } 4691 4691 pelmDragAndDrop->setAttribute("mode", pcszDragAndDrop);
Note:
See TracChangeset
for help on using the changeset viewer.