VirtualBox

Changeset 51476 in vbox


Ignore:
Timestamp:
May 30, 2014 2:58:02 PM (11 years ago)
Author:
vboxsync
Message:

DnD: API overhaul; now using IDnDTarget + IDnDSource. Renamed DragAndDrop* enumerations to DnD*. Also rewrote some internal code.

Location:
trunk
Files:
4 added
41 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/user_ChangeLogImpl.xml

    r50744 r51476  
    25662566
    25672567      <listitem>
    2568         <para>Added experimental support for Drag'n'drop from the host to
     2568        <para>Added experimental support for drag'n'drop from the host to
    25692569          Linux guests. Support for more guests and for guest-to-host is
    25702570          planned. (bug #81)</para>
  • trunk/include/VBox/log.h

    r51436 r51476  
    44
    55/*
    6  * Copyright (C) 2006-2013 Oracle Corporation
     6 * Copyright (C) 2006-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    340340    /** Main group, IDisplaySourceBitmap. */
    341341    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,
    344348    /** Main group, IEmulatedUSB. */
    345349    LOG_GROUP_MAIN_EMULATEDUSB,
     
    378382    /** Main group, IGuestDirectory. */
    379383    LOG_GROUP_MAIN_GUESTDIRECTORY,
     384    /** Main group, IGuestDnDSource. */
     385    LOG_GROUP_MAIN_GUESTDNDSOURCE,
     386    /** Main group, IGuestDnDTarget. */
     387    LOG_GROUP_MAIN_GUESTDNDTARGET,
    380388    /** Main group, IGuestErrorInfo. */
    381389    LOG_GROUP_MAIN_GUESTERRORINFO,
     
    901909    "MAIN_DISPLAY", \
    902910    "MAIN_DISPLAYSOURCEBITMAP", \
    903     "MAIN_DRAGANDDROPMODECHANGEDEVENT", \
     911    "MAIN_DNDMODECHANGEDEVENT", \
     912    "MAIN_DNDSOURCE", \
     913    "MAIN_DNDTARGET", \
    904914    "MAIN_EMULATEDUSB",   \
    905915    "MAIN_EVENT",   \
     
    920930    "MAIN_GUEST",   \
    921931    "MAIN_GUESTDIRECTORY", \
     932    "MAIN_GUESTDNDSOURCE", \
     933    "MAIN_GUESTDNDTARGET", \
    922934    "MAIN_GUESTERRORINFO", \
    923935    "MAIN_GUESTFILE", \
  • trunk/include/VBox/settings.h

    r50996 r51476  
    934934    SharedFoldersList   llSharedFolders;
    935935    ClipboardMode_T     clipboardMode;
    936     DragAndDropMode_T   dragAndDropMode;
     936    DnDMode_T           dndMode;
    937937
    938938    uint32_t            ulMemoryBalloonSize;
  • trunk/src/VBox

  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp

    r51206 r51476  
    668668    /*
    669669     * Install our allowed MIME types.
    670      ** @todo See todo for m_sstrAllowedMimeTypes in GuestDnDImpl.cpp.
     670     ** @todo Also see GuestDnDPrivate.cpp.
    671671     */
    672672    const RTCList<RTCString> lstAllowedMimeTypes = RTCList<RTCString>()
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDataObject.cpp

    r51469 r51476  
    3434
    3535#ifdef DEBUG
    36  /* Enable the following line to get much more debug output about
    37   * (un)known clipboard formats. */
    38  //#define VBOX_DND_DEBUG_FORMATS
     36  /* Enable the following line to get much more debug output about
     37   * (un)known clipboard formats. */
     38//# define VBOX_DND_DEBUG_FORMATS
    3939#endif
    4040
     
    206206        return DV_E_FORMATETC;
    207207
    208     LogFlowFunc(("pFormatEtc=%p, pMedium=%p\n", pFormatEtc, pMedium));
    209 
    210208    FORMATETC *pThisFormat = &mpFormatEtc[lIndex];
    211209    AssertPtr(pThisFormat);
     
    213211    STGMEDIUM *pThisMedium = &mpStgMedium[lIndex];
    214212    AssertPtr(pThisMedium);
     213
     214    LogFlowFunc(("Using pThisFormat=%p, pThisMedium=%p\n", pThisFormat, pThisMedium));
    215215
    216216    HRESULT hr = DV_E_FORMATETC;
     
    288288                if (pMedium->hGlobal)
    289289                {
    290                     /** @todo Not working yet -- needs URI to plain ASCII conversion. */
    291 
    292290                    char *pcDst  = (char *)GlobalLock(pMedium->hGlobal);
    293291                    memcpy(pcDst, mpvData, mcbData);
     
    486484const char* VBoxDnDDataObject::ClipboardFormatToString(CLIPFORMAT fmt)
    487485{
    488 #ifdef VBOX_DND_DEBUG_FORMATS
     486#if 0
    489487    char szFormat[128];
    490488    if (GetClipboardFormatName(fmt, szFormat, sizeof(szFormat)))
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropSource.cpp

    r51469 r51476  
    100100STDMETHODIMP VBoxDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState)
    101101{
    102 #ifndef DEBUG_andy
     102#if 1
    103103    LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, muCurAction=%RU32\n",
    104104                 fEscapePressed, dwKeyState, mdwCurEffect, muCurAction));
     
    111111        muCurAction = DND_IGNORE_ACTION;
    112112
     113        LogFlowFunc(("Canceled\n"));
    113114        return DRAGDROP_S_CANCEL;
    114115    }
     
    116117    /* Left mouse button released? Start "drop" action. */
    117118    if ((dwKeyState & MK_LBUTTON) == 0)
     119    {
     120        LogFlowFunc(("Dropping ...\n"));
    118121        return DRAGDROP_S_DROP;
     122    }
    119123
    120124    /* No change, just continue. */
     
    132136    uint32_t uAction = DND_IGNORE_ACTION;
    133137
    134 #ifndef DEBUG_andy
     138#if 1
    135139    LogFlowFunc(("dwEffect=0x%x\n", dwEffect));
    136140#endif
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r48538 r51476  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    198198            }
    199199
    200             DragAndDropMode_T mode;
     200            DnDMode_T mode;
    201201            if (!strcmp(a->argv[2], "disabled"))
    202                 mode = DragAndDropMode_Disabled;
     202                mode = DnDMode_Disabled;
    203203            else if (!strcmp(a->argv[2], "hosttoguest"))
    204                 mode = DragAndDropMode_HostToGuest;
     204                mode = DnDMode_HostToGuest;
    205205            else if (!strcmp(a->argv[2], "guesttohost"))
    206                 mode = DragAndDropMode_GuestToHost;
     206                mode = DnDMode_GuestToHost;
    207207            else if (!strcmp(a->argv[2], "bidirectional"))
    208                 mode = DragAndDropMode_Bidirectional;
     208                mode = DnDMode_Bidirectional;
    209209            else
    210210            {
     
    214214            if (SUCCEEDED(rc))
    215215            {
    216                 CHECK_ERROR_BREAK(sessionMachine, COMSETTER(DragAndDropMode)(mode));
     216                CHECK_ERROR_BREAK(sessionMachine, COMSETTER(DnDMode)(mode));
    217217            }
    218218        }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r51384 r51476  
    16101610    {
    16111611        const char *psz = "Unknown";
    1612         DragAndDropMode_T enmMode;
    1613         rc = machine->COMGETTER(DragAndDropMode)(&enmMode);
     1612        DnDMode_T enmMode;
     1613        rc = machine->COMGETTER(DnDMode)(&enmMode);
    16141614        switch (enmMode)
    16151615        {
    1616             case DragAndDropMode_Disabled:
     1616            case DnDMode_Disabled:
    16171617                if (details == VMINFO_MACHINEREADABLE)
    16181618                    psz = "disabled";
     
    16201620                    psz = "disabled";
    16211621                break;
    1622             case DragAndDropMode_HostToGuest:
     1622            case DnDMode_HostToGuest:
    16231623                if (details == VMINFO_MACHINEREADABLE)
    16241624                    psz = "hosttoguest";
     
    16261626                    psz = "HostToGuest";
    16271627                break;
    1628             case DragAndDropMode_GuestToHost:
     1628            case DnDMode_GuestToHost:
    16291629                if (details == VMINFO_MACHINEREADABLE)
    16301630                    psz = "guesttohost";
     
    16321632                    psz = "GuestToHost";
    16331633                break;
    1634             case DragAndDropMode_Bidirectional:
     1634            case DnDMode_Bidirectional:
    16351635                if (details == VMINFO_MACHINEREADABLE)
    16361636                    psz = "bidirectional";
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r51259 r51476  
    21682168            case MODIFYVM_DRAGANDDROP:
    21692169            {
    2170                 DragAndDropMode_T mode;
     2170                DnDMode_T mode;
    21712171                if (!RTStrICmp(ValueUnion.psz, "disabled"))
    2172                     mode = DragAndDropMode_Disabled;
     2172                    mode = DnDMode_Disabled;
    21732173                else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
    2174                     mode = DragAndDropMode_HostToGuest;
     2174                    mode = DnDMode_HostToGuest;
    21752175                else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
    2176                     mode = DragAndDropMode_GuestToHost;
     2176                    mode = DnDMode_GuestToHost;
    21772177                else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
    2178                     mode = DragAndDropMode_Bidirectional;
     2178                    mode = DnDMode_Bidirectional;
    21792179                else
    21802180                {
     
    21842184                if (SUCCEEDED(rc))
    21852185                {
    2186                     CHECK_ERROR(machine, COMSETTER(DragAndDropMode)(mode));
     2186                    CHECK_ERROR(machine, COMSETTER(DnDMode)(mode));
    21872187                }
    21882188                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.cpp

    r51410 r51476  
    606606        QString strClipboardMode = gpConverter->toString(m.GetClipboardMode());
    607607        /* Determine Drag&Drop mode: */
    608         QString strDragAndDropMode = gpConverter->toString(m.GetDragAndDropMode());
     608        QString strDnDMode = gpConverter->toString(m.GetDnDMode());
    609609
    610610        /* Deterine virtualization attributes: */
     
    658658        strResult += formatValue(tr("VM Uptime"), strUptime, iMaxLength);
    659659        strResult += formatValue(tr("Clipboard Mode"), strClipboardMode, iMaxLength);
    660         strResult += formatValue(tr("Drag'n'Drop Mode"), strDragAndDropMode, iMaxLength);
     660        strResult += formatValue(tr("Drag'n'Drop Mode"), strDnDMode, iMaxLength);
    661661        strResult += formatValue(VBoxGlobal::tr("VT-x/AMD-V", "details report"), strVirtualization, iMaxLength);
    662662        strResult += formatValue(VBoxGlobal::tr("Nested Paging", "details report"), strNestedPaging, iMaxLength);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r51401 r51476  
    66
    77/*
    8  * Copyright (C) 2012 Oracle Corporation
     8 * Copyright (C) 2012-2014 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8888template<> bool canConvert<KDeviceType>();
    8989template<> bool canConvert<KClipboardMode>();
    90 template<> bool canConvert<KDragAndDropMode>();
     90template<> bool canConvert<KDnDMode>();
    9191template<> bool canConvert<KPointingHIDType>();
    9292template<> bool canConvert<KMediumType>();
     
    161161template<> QString toString(const KDeviceType &type);
    162162template<> QString toString(const KClipboardMode &mode);
    163 template<> QString toString(const KDragAndDropMode &mode);
     163template<> QString toString(const KDnDMode &mode);
    164164template<> QString toString(const KPointingHIDType &type);
    165165template<> QString toString(const KMediumType &type);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp

    r50041 r51476  
    77
    88/*
    9  * Copyright (C) 2012-2013 Oracle Corporation
     9 * Copyright (C) 2012-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434template<> bool canConvert<KDeviceType>() { return true; }
    3535template<> bool canConvert<KClipboardMode>() { return true; }
    36 template<> bool canConvert<KDragAndDropMode>() { return true; }
     36template<> bool canConvert<KDnDMode>() { return true; }
    3737template<> bool canConvert<KPointingHIDType>() { return true; }
    3838template<> bool canConvert<KMediumType>() { return true; }
     
    202202}
    203203
    204 /* QString <= KDragAndDropMode: */
    205 template<> QString toString(const KDragAndDropMode &mode)
     204/* QString <= KDnDMode: */
     205template<> QString toString(const KDnDMode &mode)
    206206{
    207207    switch (mode)
    208208    {
    209         case KDragAndDropMode_Disabled:      return QApplication::translate("VBoxGlobal", "Disabled", "DragAndDropType");
    210         case KDragAndDropMode_HostToGuest:   return QApplication::translate("VBoxGlobal", "Host To Guest", "DragAndDropType");
    211         case KDragAndDropMode_GuestToHost:   return QApplication::translate("VBoxGlobal", "Guest To Host", "DragAndDropType");
    212         case KDragAndDropMode_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");
    213213        default: AssertMsgFailed(("No text for %d", mode)); break;
    214214    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp

    r50604 r51476  
    4141
    4242UIDnDDataObject::UIDnDDataObject(CSession &session,
     43                                 CDnDSource &dndSource,
    4344                                 const QStringList &lstFormats,
    4445                                 QWidget *pParent)
    4546    : mSession(session),
     47      mDnDSource(dndSource),
    4648      mpParent(pParent),
    4749      mStatus(Uninitialized),
     
    6567        RT_BZERO(mpStgMedium, sizeof(STGMEDIUM) * cMaxFormats);
    6668
    67         for (int i = 0; i < lstFormats.size(); i++)
     69        for (int i = 0;
     70             (   i < lstFormats.size()
     71              && i < cMaxFormats); i++)
    6872        {
    6973            const QString &strFormat = lstFormats.at(i);
     
    9599        }
    96100
    97         LogFlowFunc(("Total registered formats: %RU32 (of %d total)\n",
     101        LogFlowFunc(("Total registered native formats: %RU32 (for %d formats from guest)\n",
    98102                     cRegisteredFormats, lstFormats.size()));
    99103        hr = S_OK;
     
    290294        {
    291295            rc = UIDnDDrag::RetrieveData(mSession,
     296                                         mDnDSource,
     297                                         /** @todo Support other actions. */
    292298                                         Qt::CopyAction,
    293299                                         strMIMEType, vaType, mVaData,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.h

    r50604 r51476  
    2929/* COM includes: */
    3030#include "COMEnums.h"
     31#include "CDndSource.h"
    3132#include "CSession.h"
    3233
     
    4950public:
    5051
    51     UIDnDDataObject(CSession &session, const QStringList &lstFormats, QWidget *pParent);
     52    UIDnDDataObject(CSession &session, CDnDSource &dndSource, const QStringList &lstFormats, QWidget *pParent);
    5253    virtual ~UIDnDDataObject(void);
    5354
     
    8788    QWidget    *mpParent;
    8889    CSession    mSession;
     90    CDnDSource  mDnDSource;
    8991    Status      mStatus;
    9092    LONG        mRefCount;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp

    r51033 r51476  
    4444#endif
    4545
    46 UIDnDDrag::UIDnDDrag(CSession &session,
     46UIDnDDrag::UIDnDDrag(CSession &session,
     47                     CDnDSource &dndSource,
    4748                     const QStringList &lstFormats,
    4849                     Qt::DropAction defAction, Qt::DropActions actions,
    4950                     QWidget *pParent /* = NULL */)
    5051    : m_session(session)
     52    , m_dndSource(dndSource)
    5153    , m_lstFormats(lstFormats)
    5254    , m_defAction(defAction)
     
    7274#ifdef RT_OS_WINDOWS
    7375    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);
    7577
    7678    DWORD dwOKEffects = DROPEFFECT_NONE;
     
    8688
    8789    DWORD dwEffect;
     90    LogFlowFunc(("dwOKEffects=0x%x\n", dwOKEffects));
    8891    HRESULT hr = ::DoDragDrop(pDataObject, pDropSource,
    8992                              dwOKEffects, &dwEffect);
    90     LogFlowThisFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n",
    91                      hr, dwEffect));
     93    LogFlowFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n",
     94                 hr, dwEffect));
    9295
    9396    if (pDropSource)
     
    99102
    100103    /* 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,
    102105                               m_lstFormats, m_defAction, m_actions,
    103106                               m_pParent);
     
    129132/* static */
    130133int UIDnDDrag::RetrieveData(const CSession &session,
     134                            CDnDSource &dndSource,
    131135                            Qt::DropAction dropAction,
    132136                            const QString &strMimeType,
     
    140144    CGuest guest = session.GetConsole().GetGuest();
    141145
    142     /* Start getting the data from the guest. First inform the guest we
     146    /* Start getting the data from the source. First inform the source we
    143147     * want the data in the specified MIME type. */
    144     CProgress progress = guest.DragGHDropped(strMimeType,
    145                                              UIDnDHandler::toVBoxDnDAction(dropAction));
     148    CProgress progress = dndSource.Drop(strMimeType,
     149                                        UIDnDHandler::toVBoxDnDAction(dropAction));
    146150    if (guest.isOk())
    147151    {
     
    157161            if (RT_SUCCESS(rc))
    158162            {
    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();
    161166                if (!vecData.isEmpty())
    162167                {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.h

    r50602 r51476  
    2828#include "CSession.h"
    2929#include "CConsole.h"
     30#include "CDnDSource.h"
    3031#include "CGuest.h"
    3132
     
    4546public:
    4647
    47     UIDnDDrag(CSession &session,
     48    UIDnDDrag(CSession &session, CDnDSource &dndSource,
    4849              const QStringList &lstFormats, Qt::DropAction defAction, Qt::DropActions actions,
    4950              QWidget *pParent = NULL);
     
    5455public:
    5556
    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);
    5758
    5859private:
    5960
    6061    CSession          m_session;
     62    CDnDSource        m_dndSource;
    6163    QStringList       m_lstFormats;
    6264    Qt::DropAction    m_defAction;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp

    r51033 r51476  
    3434#include "UIDnDHandler.h"
    3535#ifdef VBOX_WITH_DRAG_AND_DROP_GH
     36# include "CDnDSource.h"
    3637# include "UIDnDDrag.h"
    3738#endif
     
    3940
    4041/* COM includes: */
     42#include "CConsole.h"
     43#include "CDnDTarget.h"
     44#include "CGuest.h"
    4145#include "CSession.h"
    42 #include "CConsole.h"
    43 #include "CGuest.h"
     46
     47
    4448
    4549UIDnDHandler *UIDnDHandler::m_pInstance = NULL;
    4650
    4751UIDnDHandler::UIDnDHandler(void)
    48     : mMode(Unknown)
    4952{
    5053}
    5154
    5255/*
    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
     59Qt::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{
    6363    LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n",
    6464                 screenId, x, y, toVBoxDnDAction(proposedAction)));
    6565
    6666    /* 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
    7374    /* Set the DnD action returned by the guest. */
    7475    return toQtDnDAction(result);
    7576}
    7677
    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 
     78Qt::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{
    8482#ifdef DEBUG_andy
    8583    LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n",
     
    8987    /* Notify the guest that the mouse has been moved while doing
    9088     * a drag'n drop operation. */
    91     KDragAndDropAction result = guest.DragHGMove(screenId,
    92                                                  x,
    93                                                  y,
    94                                                  toVBoxDnDAction(proposedAction),
    95                                                  toVBoxDnDActions(possibleActions),
    96                                                  pMimeData->formats().toVector());
     89    KDnDAction result = dndTarget.Move(screenId,
     90                                       x,
     91                                       y,
     92                                       toVBoxDnDAction(proposedAction),
     93                                       toVBoxDnDActions(possibleActions),
     94                                       pMimeData->formats().toVector());
    9795    /* Set the DnD action returned by the guest. */
    9896    return toQtDnDAction(result);
    9997}
    10098
    101 Qt::DropAction UIDnDHandler::dragHGDrop(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;
     99Qt::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();
    107105
    108106    LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n",
     
    112110    QString format;
    113111    /* Ask the guest for dropping data. */
    114     KDragAndDropAction result = guest.DragHGDrop(screenId,
    115                                                  x,
    116                                                  y,
    117                                                  toVBoxDnDAction(proposedAction),
    118                                                  toVBoxDnDActions(possibleActions),
    119                                                  pMimeData->formats().toVector(), format);
     112    KDnDAction result = dndTarget.Drop(screenId,
     113                                       x,
     114                                       y,
     115                                       toVBoxDnDAction(proposedAction),
     116                                       toVBoxDnDActions(possibleActions),
     117                                       pMimeData->formats().toVector(), format);
    120118    /* Has the guest accepted the drop event? */
    121     if (result != KDragAndDropAction_Ignore)
     119    if (result != KDnDAction_Ignore)
    122120    {
    123121        /* Get the actual MIME data in the requested format. */
     122        AssertPtr(pMimeData);
    124123        const QByteArray &d = pMimeData->data(format);
    125124        if (   !d.isEmpty()
     
    131130            memcpy(dv.data(), d.constData(), d.size());
    132131
    133             CProgress progress = guest.DragHGPutData(screenId, format, dv);
     132            CProgress progress = dndTarget.SendData(screenId, format, dv);
    134133            if (guest.isOk())
    135134            {
     
    142141                {
    143142                    msgCenter().cannotDropData(progress, pParent);
    144                     result = KDragAndDropAction_Ignore;
     143                    result = KDnDAction_Ignore;
    145144                }
    146145            }
     
    148147            {
    149148                msgCenter().cannotDropData(guest, pParent);
    150                 result = KDragAndDropAction_Ignore;
     149                result = KDnDAction_Ignore;
    151150            }
    152151        }
     
    156155}
    157156
    158 void UIDnDHandler::dragHGLeave(CGuest &guest, ulong screenId, QWidget * /* pParent = NULL */)
    159 {
    160     if (mMode == GH) /* Wrong mode? Bail out. */
    161         return;
    162 
     157void UIDnDHandler::dragLeave(CDnDTarget &dndTarget,
     158                             ulong screenId, QWidget * /* pParent = NULL */)
     159{
    163160    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
     168int UIDnDHandler::dragIsPending(CSession &session, CDnDSource &dndSource,
     169                                ulong screenId, QWidget *pParent /* = NULL */)
    168170{
    169171    int rc;
    170172#ifdef VBOX_WITH_DRAG_AND_DROP_GH
    171     if (mMode == HG) /* Wrong mode? Bail out. */
    172         return VERR_WRONG_ORDER;
    173 
    174173    /*
    175      * How this works: Host is asking the guest if there is any DnD
    176      * operation pending, when the mouse leaves the guest window
    177      * (DragGHPending). On return there is some info about a running DnD
    178      * operation (or defaultAction is KDragAndDropAction_Ignore if not). With
     174     * 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
    179178     * this information we create a Qt QDrag object with our own QMimeType
    180179     * implementation and call exec. Please note, this *blocks* until the DnD
     
    183182    CGuest guest = session.GetConsole().GetGuest();
    184183    QVector<QString> vecFmtGuest;
    185     QVector<KDragAndDropAction> vecActions;
    186     KDragAndDropAction defaultAction = guest.DragGHPending(screenId, vecFmtGuest, vecActions);
     184    QVector<KDnDAction> vecActions;
     185    KDnDAction defaultAction = dndSource.DragIsPending(screenId, vecFmtGuest, vecActions);
    187186    LogFlowFunc(("defaultAction=%d, numFormats=%d\n", defaultAction, vecFmtGuest.size()));
    188187
    189188    QStringList lstFmtNative;
    190     if (defaultAction != KDragAndDropAction_Ignore)
     189    if (defaultAction != KDnDAction_Ignore)
    191190    {
    192191        /*
     
    234233    if (!lstFmtNative.isEmpty())
    235234    {
    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        }
    242248    }
    243     else
    244         rc = VINF_SUCCESS;
     249    else /* No format data from the guest arrived yet. */
     250        rc = VERR_NO_DATA;
    245251#else /* !VBOX_WITH_DRAG_AND_DROP_GH */
    246252    NOREF(session);
     
    260266
    261267/* static */
    262 KDragAndDropAction UIDnDHandler::toVBoxDnDAction(Qt::DropAction action)
     268KDnDAction UIDnDHandler::toVBoxDnDAction(Qt::DropAction action)
    263269{
    264270    if (action == Qt::CopyAction)
    265         return KDragAndDropAction_Copy;
     271        return KDnDAction_Copy;
    266272    if (action == Qt::MoveAction)
    267         return KDragAndDropAction_Move;
     273        return KDnDAction_Move;
    268274    if (action == Qt::LinkAction)
    269         return KDragAndDropAction_Link;
    270 
    271     return KDragAndDropAction_Ignore;
     275        return KDnDAction_Link;
     276
     277    return KDnDAction_Ignore;
    272278}
    273279
    274280/* static */
    275 QVector<KDragAndDropAction> UIDnDHandler::toVBoxDnDActions(Qt::DropActions actions)
    276 {
    277     QVector<KDragAndDropAction> vbActions;
     281QVector<KDnDAction> UIDnDHandler::toVBoxDnDActions(Qt::DropActions actions)
     282{
     283    QVector<KDnDAction> vbActions;
    278284    if (actions.testFlag(Qt::IgnoreAction))
    279         vbActions << KDragAndDropAction_Ignore;
     285        vbActions << KDnDAction_Ignore;
    280286    if (actions.testFlag(Qt::CopyAction))
    281         vbActions << KDragAndDropAction_Copy;
     287        vbActions << KDnDAction_Copy;
    282288    if (actions.testFlag(Qt::MoveAction))
    283         vbActions << KDragAndDropAction_Move;
     289        vbActions << KDnDAction_Move;
    284290    if (actions.testFlag(Qt::LinkAction))
    285         vbActions << KDragAndDropAction_Link;
     291        vbActions << KDnDAction_Link;
    286292
    287293    return vbActions;
     
    289295
    290296/* static */
    291 Qt::DropAction UIDnDHandler::toQtDnDAction(KDragAndDropAction action)
     297Qt::DropAction UIDnDHandler::toQtDnDAction(KDnDAction action)
    292298{
    293299    Qt::DropAction dropAct = Qt::IgnoreAction;
    294     if (action == KDragAndDropAction_Copy)
     300    if (action == KDnDAction_Copy)
    295301        dropAct = Qt::CopyAction;
    296     if (action == KDragAndDropAction_Move)
     302    if (action == KDnDAction_Move)
    297303        dropAct = Qt::MoveAction;
    298     if (action == KDragAndDropAction_Link)
     304    if (action == KDnDAction_Link)
    299305        dropAct = Qt::LinkAction;
    300306
     
    304310
    305311/* static */
    306 Qt::DropActions UIDnDHandler::toQtDnDActions(const QVector<KDragAndDropAction> &vecActions)
     312Qt::DropActions UIDnDHandler::toQtDnDActions(const QVector<KDnDAction> &vecActions)
    307313{
    308314    Qt::DropActions dropActs = Qt::IgnoreAction;
     
    311317        switch (vecActions.at(i))
    312318        {
    313             case KDragAndDropAction_Ignore:
     319            case KDnDAction_Ignore:
    314320                dropActs |= Qt::IgnoreAction;
    315321                break;
    316             case KDragAndDropAction_Copy:
     322            case KDnDAction_Copy:
    317323                dropActs |= Qt::CopyAction;
    318324                break;
    319             case KDragAndDropAction_Move:
     325            case KDnDAction_Move:
    320326                dropActs |= Qt::MoveAction;
    321327                break;
    322             case KDragAndDropAction_Link:
     328            case KDnDAction_Link:
    323329                dropActs |= Qt::LinkAction;
    324330                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.h

    r50460 r51476  
    33 *
    44 * VBox frontends: Qt GUI ("VirtualBox"):
    5  * UIDnDHandler class declaration
     5 * UIDnDHandler class declaration.
    66 */
    77
     
    2626/* Forward declarations: */
    2727class QMimeData;
     28class CDnDSource;
     29class CDnDTarget;
     30class CGuest;
    2831class CSession;
    29 class CGuest;
    3032class UIDnDMimeData;
    3133
     
    3739
    3840    /* Singleton factory. */
    39     static UIDnDHandler* instance(void)
     41    static UIDnDHandler *instance(void)
    4042    {
    4143        if (!m_pInstance)
     
    5658     * Current operation mode.
    5759     */
    58     enum Mode
     60    enum Direction
    5961    {
    6062        /** Unknown mode. */
    6163        Unknown = 0,
    6264        /** Host to guest. */
    63         HG,
     65        HostToGuest,
    6466        /** Guest to host. */
    65         GH
     67        GuestToHost
     68        /** @todo Implement guest to guest. */
    6669    };
    6770
    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);
    7376
    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);
    7679
    7780public:
    7881
    79     static KDragAndDropAction          toVBoxDnDAction(Qt::DropAction action);
    80     static QVector<KDragAndDropAction> 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);
    8386
    8487private:
    85     static UIDnDHandler *m_pInstance;
    8688
    8789    UIDnDHandler(void);
    8890    virtual ~UIDnDHandler(void) {}
    8991
    90     /** The current operation mode. */
    91     Mode mMode;
     92private:
     93
     94    /** Static pointer to singleton instance. */
     95    static UIDnDHandler *m_pInstance;
    9296};
    9397
    94 #define gDnD UIDnDHandler::instance()
     98/** Gets the singleton instance of the drag'n drop UI helper class. */
     99#define DnDHandler() UIDnDHandler::instance()
    95100
    96101#endif /* ___UIDnDHandler_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp

    r51033 r51476  
    3838#include "UIMessageCenter.h"
    3939
    40 UIDnDMimeData::UIDnDMimeData(CSession &session,
     40UIDnDMimeData::UIDnDMimeData(CSession &session,
     41                             CDnDSource &dndSource,
    4142                             QStringList formats,
    4243                             Qt::DropAction defAction, Qt::DropActions actions,
    4344                             QWidget *pParent)
    4445    : m_Session(session)
     46    , m_DnDSource(dndSource)
    4547    , m_lstFormats(formats)
    4648    , m_defAction(defAction)
     
    109111
    110112QVariant UIDnDMimeData::retrieveData(const QString &strMIMEType,
    111                                      QVariant::Type vaType) const
     113                                     QVariant::Type vaType)
    112114{
    113115    LogFlowFunc(("m_enmState=%d, mimeType=%s, type=%d (%s)\n",
     
    165167    {
    166168        rc = UIDnDDrag::RetrieveData(m_Session,
     169                                     m_DnDSource,
    167170                                     m_defAction,
    168171                                     strMIMEType, vaType, m_vaData,
     
    198201                LogFlowFunc(("MouseMove: x=%d, y=%d\n",
    199202                             pMouseEvent->globalX(), pMouseEvent->globalY()));
    200                
     203
    201204                return true;
    202205                /* Never reached. */
     
    207210                LogFlowFunc(("MouseButtonRelease\n"));
    208211                m_enmState = Dropped;
    209                
     212
    210213                return true;
    211214                /* Never reached. */
     
    220223                    m_enmState = Canceled;
    221224                }
    222                
     225
    223226                return true;
    224227                /* Never reached. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h

    r50734 r51476  
    2626/* COM includes: */
    2727#include "COMEnums.h"
     28#include "CConsole.h"
     29#include "CDnDSource.h"
     30#include "CGuest.h"
    2831#include "CSession.h"
    29 #include "CConsole.h"
    30 #include "CGuest.h"
    3132
    3233#include "UIDnDHandler.h"
     
    6162public:
    6263
    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);
    6465
    6566public:
     
    7879    virtual bool hasFormat(const QString &mimeType) const;
    7980
    80     virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
     81    virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type);
    8182
    8283#ifndef RT_OS_WINDOWS
     
    9899
    99100    CSession          m_Session;
     101    CDnDSource        m_DnDSource;
    100102    QStringList       m_lstFormats;
    101103    Qt::DropAction    m_defAction;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r51398 r51476  
    55
    66/*
    7  * Copyright (C) 2010-2013 Oracle Corporation
     7 * Copyright (C) 2010-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    729729    {
    730730        foreach (QAction *pAction, m_pDragAndDropActions->actions())
    731             pAction->setText(gpConverter->toString(pAction->data().value<KDragAndDropMode>()));
     731            pAction->setText(gpConverter->toString(pAction->data().value<KDnDMode>()));
    732732    }
    733733}
     
    18641864    {
    18651865        m_pDragAndDropActions = new QActionGroup(this);
    1866         for (int i = KDragAndDropMode_Disabled; i < KDragAndDropMode_Max; ++i)
     1866        for (int i = KDnDMode_Disabled; i < KDnDMode_Max; ++i)
    18671867        {
    1868             KDragAndDropMode mode = (KDragAndDropMode)i;
     1868            KDnDMode mode = (KDnDMode)i;
    18691869            QAction *pAction = new QAction(gpConverter->toString(mode), m_pDragAndDropActions);
    18701870            pMenu->addAction(pAction);
    18711871            pAction->setData(QVariant::fromValue(mode));
    18721872            pAction->setCheckable(true);
    1873             pAction->setChecked(session().GetMachine().GetDragAndDropMode() == mode);
     1873            pAction->setChecked(session().GetMachine().GetDnDMode() == mode);
    18741874        }
    18751875        connect(m_pDragAndDropActions, SIGNAL(triggered(QAction*)),
     
    18791879    else
    18801880        foreach (QAction *pAction, m_pDragAndDropActions->actions())
    1881             if (pAction->data().value<KDragAndDropMode>() == session().GetMachine().GetDragAndDropMode())
     1881            if (pAction->data().value<KDnDMode>() == session().GetMachine().GetDnDMode())
    18821882                pAction->setChecked(true);
    18831883}
     
    19611961{
    19621962    /* Assign new mode (without save): */
    1963     KDragAndDropMode mode = pAction->data().value<KDragAndDropMode>();
    1964     session().GetMachine().SetDragAndDropMode(mode);
     1963    KDnDMode mode = pAction->data().value<KDnDMode>();
     1964    session().GetMachine().SetDnDMode(mode);
    19651965}
    19661966
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r51467 r51476  
    6161#include "CFramebuffer.h"
    6262#ifdef VBOX_WITH_DRAG_AND_DROP
     63# include "CDnDSource.h"
     64# include "CDnDTarget.h"
    6365# include "CGuest.h"
     66# include "CGuestDnDTarget.h"
     67# include "CGuestDnDSource.h"
    6468#endif /* VBOX_WITH_DRAG_AND_DROP */
    6569
     
    11601164void UIMachineView::dragEnterEvent(QDragEnterEvent *pEvent)
    11611165{
    1162     /* The guest object to talk to. */
     1166    AssertPtrReturnVoid(pEvent);
     1167
     1168    /* Get mouse-pointer location. */
     1169    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1170
    11631171    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 */);
    11761182
    11771183    /* Set the DnD action returned by the guest. */
     
    11821188void UIMachineView::dragMoveEvent(QDragMoveEvent *pEvent)
    11831189{
    1184     /* The guest object to talk to. */
     1190    AssertPtrReturnVoid(pEvent);
     1191
     1192    /* Get mouse-pointer location. */
     1193    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1194
    11851195    CGuest guest = session().GetConsole().GetGuest();
    1186 
    1187     /* Get mouse-pointer location */
    1188     const QPoint &cpnt = viewportToContents(pEvent->pos());
     1196    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
    11891197
    11901198    /* 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 */);
    11981206
    11991207    /* Set the DnD action returned by the guest. */
     
    12041212void UIMachineView::dragLeaveEvent(QDragLeaveEvent *pEvent)
    12051213{
    1206     /* The guest object to talk to. */
     1214    AssertPtrReturnVoid(pEvent);
     1215
    12071216    CGuest guest = session().GetConsole().GetGuest();
     1217    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
    12081218
    12091219    /* 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 */);
    12111222    pEvent->accept();
    12121223}
    12131224
     1225void 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
    12141238void UIMachineView::dropEvent(QDropEvent *pEvent)
    12151239{
    1216     /* The guest object to talk to. */
     1240    AssertPtrReturnVoid(pEvent);
     1241
     1242    /* Get mouse-pointer location. */
     1243    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1244
    12171245    CGuest guest = session().GetConsole().GetGuest();
    1218 
    1219     /* Get mouse-pointer location */
    1220     const QPoint &cpnt = viewportToContents(pEvent->pos());
     1246    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
    12211247
    12221248    /* 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 */);
    12301257
    12311258    /* Set the DnD action returned by the guest. */
     
    12331260    pEvent->accept();
    12341261}
    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 the
    1242      * magic. */
    1243     gDnD->dragGHPending(session(), screenId(), this);
    1244 }
    12451262#endif /* VBOX_WITH_DRAG_AND_DROP */
    12461263
     
    12491266bool UIMachineView::winEvent(MSG *pMsg, long* /* piResult */)
    12501267{
    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. */
    12551274    switch (pMsg->message)
    12561275    {
     
    12601279        case WM_SYSKEYUP:
    12611280        {
    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? */
    12651285            fResult = fKeyboardFilteringResult;
    12661286            break;
     
    12691289            break;
    12701290    }
    1271     /* Return result: */
     1291
    12721292    return fResult;
    12731293}
     
    12771297bool UIMachineView::x11Event(XEvent *pEvent)
    12781298{
    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. */
    12831305    switch (pEvent->type)
    12841306    {
     
    12881310        case XKeyRelease:
    12891311        {
    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. */
    12951319            fResult = fKeyboardFilteringResult || fMouseFilteringResult;
    12961320            break;
     
    12991323            break;
    13001324    }
    1301     /* Return result: */
     1325
    13021326    return fResult;
    13031327}
    13041328
    1305 #endif
    1306 
     1329#endif /* Q_WS_X11 */
     1330
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r51436 r51476  
    3939class UIMachineWindow;
    4040class UIFrameBuffer;
     41#ifdef VBOX_WITH_DRAG_AND_DROP
     42 class CDnDTarget;
     43#endif
    4144class CSession;
    4245
     
    217220    void dragLeaveEvent(QDragLeaveEvent *pEvent);
    218221    void dragMoveEvent(QDragMoveEvent *pEvent);
     222    void dragIsPending(void);
    219223    void dropEvent(QDropEvent *pEvent);
    220 
    221     void handleGHDnd();
    222224#endif /* VBOX_WITH_DRAG_AND_DROP */
    223225
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r51339 r51476  
    77
    88/*
    9  * Copyright (C) 2010-2012 Oracle Corporation
     9 * Copyright (C) 2010-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    936936                || cpnt.y() > iCh - 1)
    937937            {
    938                 bool fHandledGHDnD
     938                bool fHandleDnDPending
    939939                    = RT_BOOL(mouseButtons.testFlag(Qt::LeftButton));
    940                 if (fHandledGHDnD)
    941                 {
    942                     m_views[uScreenId]->handleGHDnd();
     940                if (fHandleDnDPending)
     941                {
     942                    m_views[uScreenId]->dragIsPending();
    943943                    return true;
    944944                }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r48576 r51476  
    77
    88/*
    9  * Copyright (C) 2006-2012 Oracle Corporation
     9 * Copyright (C) 2006-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444
    4545    /* Drag'n'drop mode */
    46     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_Disabled */
    47     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_HostToGuest */
    48     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_GuestToHost */
    49     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_Bidirectional */
     46    mCbDragAndDrop->addItem (""); /* KDnDMode_Disabled */
     47    mCbDragAndDrop->addItem (""); /* KDnDMode_HostToGuest */
     48    mCbDragAndDrop->addItem (""); /* KDnDMode_GuestToHost */
     49    mCbDragAndDrop->addItem (""); /* KDnDMode_Bidirectional */
    5050
    5151#ifdef Q_WS_MAC
     
    115115    generalData.m_strSnapshotsHomeDir = QFileInfo(m_machine.GetSettingsFilePath()).absolutePath();
    116116    generalData.m_clipboardMode = m_machine.GetClipboardMode();
    117     generalData.m_dragAndDropMode = m_machine.GetDragAndDropMode();
     117    generalData.m_dndMode = m_machine.GetDnDMode();
    118118    generalData.m_strDescription = m_machine.GetDescription();
    119119
     
    141141    mPsSnapshot->setHomeDir(generalData.m_strSnapshotsHomeDir);
    142142    mCbClipboard->setCurrentIndex(generalData.m_clipboardMode);
    143     mCbDragAndDrop->setCurrentIndex(generalData.m_dragAndDropMode);
     143    mCbDragAndDrop->setCurrentIndex(generalData.m_dndMode);
    144144    mTeDescription->setPlainText(generalData.m_strDescription);
    145145
     
    166166    generalData.m_strSnapshotsFolder = mPsSnapshot->path();
    167167    generalData.m_clipboardMode = (KClipboardMode)mCbClipboard->currentIndex();
    168     generalData.m_dragAndDropMode = (KDragAndDropMode)mCbDragAndDrop->currentIndex();
     168    generalData.m_dndMode = (KDnDMode)mCbDragAndDrop->currentIndex();
    169169    generalData.m_strDescription = mTeDescription->toPlainText().isEmpty() ?
    170170                                   QString::null : mTeDescription->toPlainText();
     
    192192            /* Advanced tab: */
    193193            m_machine.SetClipboardMode(generalData.m_clipboardMode);
    194             m_machine.SetDragAndDropMode(generalData.m_dragAndDropMode);
     194            m_machine.SetDnDMode(generalData.m_dndMode);
    195195            m_machine.SetExtraData(GUI_SaveMountedAtRuntime, generalData.m_fSaveMountedAtRuntime ? "yes" : "no");
    196196            m_machine.SetExtraData(GUI_ShowMiniToolBar, generalData.m_fShowMiniToolBar ? "yes" : "no");
     
    292292
    293293    /* Drag'n'drop mode */
    294     mCbDragAndDrop->setItemText (0, gpConverter->toString (KDragAndDropMode_Disabled));
    295     mCbDragAndDrop->setItemText (1, gpConverter->toString (KDragAndDropMode_HostToGuest));
    296     mCbDragAndDrop->setItemText (2, gpConverter->toString (KDragAndDropMode_GuestToHost));
    297     mCbDragAndDrop->setItemText (3, gpConverter->toString (KDragAndDropMode_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));
    298298}
    299299
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r47944 r51476  
    66
    77/*
    8  * Copyright (C) 2006-2012 Oracle Corporation
     8 * Copyright (C) 2006-2014 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3737        , m_strSnapshotsHomeDir(QString())
    3838        , m_clipboardMode(KClipboardMode_Disabled)
    39         , m_dragAndDropMode(KDragAndDropMode_Disabled)
     39        , m_dndMode(KDnDMode_Disabled)
    4040        , m_strDescription(QString()) {}
    4141    /* Functions: */
     
    5050               (m_strSnapshotsHomeDir == other.m_strSnapshotsHomeDir) &&
    5151               (m_clipboardMode == other.m_clipboardMode) &&
    52                (m_dragAndDropMode == other.m_dragAndDropMode) &&
     52               (m_dndMode == other.m_dndMode) &&
    5353               (m_strDescription == other.m_strDescription);
    5454    }
     
    6565    QString m_strSnapshotsHomeDir;
    6666    KClipboardMode m_clipboardMode;
    67     KDragAndDropMode m_dragAndDropMode;
     67    KDnDMode m_dndMode;
    6868    QString m_strDescription;
    6969};
  • trunk/src/VBox/Main/Makefile.kmk

    r51436 r51476  
    747747ifdef VBOX_WITH_DRAG_AND_DROP
    748748 VBoxC_SOURCES += \
    749         src-client/GuestDnDImpl.cpp
     749        src-client/GuestDnDPrivate.cpp \
     750        src-client/GuestDnDSourceImpl.cpp \
     751        src-client/GuestDnDTargetImpl.cpp
    750752endif
    751753ifdef VBOX_WITH_XPCOM
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r51440 r51476  
    11751175
    11761176  <enum
    1177     name="DragAndDropMode"
    1178     uuid="b618ea0e-b6fb-4f8d-97f7-5e237e49b547"
     1177    name="DnDMode"
     1178    uuid="07af8800-f936-4b33-9172-cd400e83c148"
    11791179    >
    11801180    <desc>
     
    42044204  <interface
    42054205    name="IMachine" extends="$unknown"
    4206     uuid="480cf695-2d8d-4256-9c7c-cce4184fa048"
     4206    uuid="45b0357d-28f4-4f90-b02c-13f2940efdda"
    42074207    wsmap="managed"
    42084208    wrap-hint-server-addinterfaces="IInternalMachineControl"
     
    47904790    </attribute>
    47914791
    4792     <attribute name="dragAndDropMode" 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.
    47954795      </desc>
    47964796    </attribute>
     
    1035110351
    1035210352  <enum
    10353     name="DragAndDropAction"
    10354     uuid="47f3b162-c107-4fcd-bfa7-54b8135c441e"
     10353    name="DnDAction"
     10354    uuid="17609e74-778e-4d0e-8827-35f5230f287b"
    1035510355  >
    1035610356    <desc>
    10357       Possible actions within an Drag and Drop operation.
     10357      Possible actions of a drag'n drop operation.
    1035810358    </desc>
    1035910359
     
    1038910389    </const>
    1039010390  </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>
    1039110625
    1039210626  <interface
     
    1188212116  <interface
    1188312117    name="IGuest" extends="$unknown"
    11884     uuid="8011a1b1-6adb-4ffb-a37e-20abdaee4650"
     12118    uuid="97927199-7e1f-4094-97ab-92333e727843"
    1188512119    wsmap="managed"
    1188612120    >
     
    1193012164    </attribute>
    1193112165
     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
    1193212178    <attribute name="eventSource" type="IEventSource" readonly="yes">
    1193312179      <desc>
     
    1206012306          not be supported by all versions of the Additions.
    1206112307        </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>
    1227512308      </param>
    1227612309    </method>
     
    1560015633
    1560115634    <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>
    1560315643      <param name="screenId" type="unsigned long" dir="in"/>
    1560415644      <param name="width" type="unsigned long" dir="out"/>
     
    1561115651    <method name="attachFramebuffer">
    1561215652      <desc>
    15613         Sets the graphics updates target for a screen.
     15653        Sets the graphics update target for a screen.
    1561415654      </desc>
    1561515655      <param name="screenId" type="unsigned long" dir="in"/>
     
    1801318053    </method>
    1801418054
    18015     <method name="onDragAndDropModeChange">
    18016       <desc>
    18017         Notification when the drag'n'drop mode changes.
    18018       </desc>
    18019       <param name="dragAndDropMode" 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>
    1802118061      </param>
    1802218062    </method>
     
    1980619846  <enum
    1980719847    name="VBoxEventType"
    19808     uuid="5248e377-e578-47d7-b07b-84b1db6db8a8"
     19848    uuid="1622f8d2-6c76-4410-9e78-86e083046efc"
    1980919849    >
    1981019850
     
    2006920109      </desc>
    2007020110    </const>
    20071     <const name="OnDragAndDropModeChanged" value="73">
    20072       <desc>
    20073         See <link to="IDragAndDropModeChangedEvent">IDragAndDropModeChangedEvent</link>.
     20111    <const name="OnDnDModeChanged" value="73">
     20112      <desc>
     20113        See <link to="IDnDModeChangedEvent">IDnDModeChangedEvent</link>.
    2007420114      </desc>
    2007520115    </const>
     
    2095820998
    2095920999  <interface
    20960     name="IDragAndDropModeChangedEvent" extends="IEvent"
    20961     uuid="e90b8850-ac8e-4dff-8059-4100ae2c3c3d"
    20962     wsmap="managed" autogen="VBoxEvent" id="OnDragAndDropModeChanged"
     21000    name="IDnDModeChangedEvent" extends="IEvent"
     21001    uuid="b55cf856-1f8b-4692-abb4-462429fae5e9"
     21002    wsmap="managed" autogen="VBoxEvent" id="OnDnDModeChanged"
    2096321003    >
    2096421004    <desc>
    20965       Notification when the drag'n'drop mode changes.
     21005      Notification when the drag'n drop mode changes.
    2096621006    </desc>
    20967     <attribute name="dragAndDropMode" 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.
    2097021010      </desc>
    2097121011    </attribute>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r51342 r51476  
    220220    HRESULT onCPUExecutionCapChange(ULONG aExecutionCap);
    221221    HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
    222     HRESULT onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);
     222    HRESULT onDnDModeChange(DnDMode_T aDnDMode);
    223223    HRESULT onVRDEServerChange(BOOL aRestart);
    224224    HRESULT onVideoCaptureChange();
     
    699699
    700700    void changeClipboardMode(ClipboardMode_T aClipboardMode);
    701     void changeDragAndDropMode(DragAndDropMode_T aDragAndDropMode);
     701    int changeDnDMode(DnDMode_T aDnDMode);
    702702
    703703#ifdef VBOX_WITH_USB
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r51460 r51476  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6666    uint16_t flags;
    6767
    68     /* for saving the rectangles arrived during fb resize is in progress. */
     68    /** For saving the rectangles arrived during fb resize is in progress. */
    6969    PRTRECT mpSavedVisibleRegion;
    7070    uint32_t mcSavedVisibleRegion;
     
    7474    volatile uint32_t u32ResizeStatus;
    7575
    76     /* The Framebuffer has default format and must be updates immediately. */
     76    /** The framebuffer has default format and must be updates immediately. */
    7777    bool fDefaultFormat;
    7878
  • trunk/src/VBox/Main/include/GuestDnDPrivate.h

    r51474 r51476  
     1/* $Id$ */
    12/** @file
    2  * Definition of GuestDnD
     3 * Private guest drag and drop code, used by GuestDnDTarget +
     4 * GuestDnDSource.
    35 */
    46
     
    1517 */
    1618
    17 #ifndef ____H_GUESTDND
    18 #define ____H_GUESTDND
     19#ifndef ____H_GUESTDNDPRIVATE
     20#define ____H_GUESTDNDPRIVATE
    1921
    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. */
    2523
     24/* Forward prototype declarations. */
     25class Guest;
     26class Progress;
     27
     28/**
     29 * Class for handling drag'n drop responses from
     30 * the guest side.
     31 */
     32class GuestDnDResponse
     33{
     34
     35public:
     36
     37    GuestDnDResponse(const ComObjPtr<Guest>& pGuest);
     38
     39    virtual ~GuestDnDResponse(void);
     40
     41public:
     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
     70public:
     71
     72    Utf8Str errorToString(const ComObjPtr<Guest>& pGuest, int guestRc);
     73
     74private:
     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 */
    26103class GuestDnD
    27104{
    28105public:
     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
     129protected:
     130
    29131    GuestDnD(const ComObjPtr<Guest>& pGuest);
    30     ~GuestDnD();
     132    virtual ~GuestDnD(void);
    31133
    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);
     134public:
    38135
    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    /** @}  */
    43143
    44     /* Guest response */
    45     static DECLCALLBACK(int) notifyGuestDragAndDropEvent(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
     144public:
     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
     161protected:
     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    /** @}  */
    46173
    47174protected:
    48175
    49176#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    /** @}  */
    53183#endif /* VBOX_WITH_DRAG_AND_DROP_GH */
    54184
    55185private:
    56186
    57     /* d-pointer */
    58     GuestDnDPrivate *d_ptr;
    59 
    60     friend class GuestDnDPrivate;
     187    /** Staic pointer to singleton instance. */
     188    static GuestDnD           *s_pInstance;
    61189};
    62190
    63 #endif /* ____H_GUESTDND */
     191/** Access to the GuestDnD's singleton instance. */
     192#define GuestDnDInst() GuestDnD::getInstance()
    64193
     194#endif /* ____H_GUESTDNDPRIVATE */
     195
  • trunk/src/VBox/Main/include/GuestImpl.h

    r47310 r51476  
    44
    55/*
    6  * Copyright (C) 2006-2013 Oracle Corporation
     6 * Copyright (C) 2006-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626#include "AdditionsFacilityImpl.h"
    2727#include "GuestCtrlImplPrivate.h"
     28#ifdef VBOX_WITH_DRAG_AND_DROP
     29# include "GuestDnDSourceImpl.h"
     30# include "GuestDnDTargetImpl.h"
     31#endif
    2832#include "GuestSessionImpl.h"
    2933#include "HGCM.h"
    30 
    31 #ifdef VBOX_WITH_DRAG_AND_DROP
    32 class GuestDnD;
    33 #endif
    3434
    3535typedef enum
     
    4848
    4949class Console;
    50 #ifdef VBOX_WITH_GUEST_CONTROL
    51 class Progress;
    52 #endif
    5350
    5451class ATL_NO_VTABLE Guest :
     
    7774
    7875    // IGuest properties.
    79     STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
    80     STDMETHOD(COMGETTER(AdditionsRunLevel)) (AdditionsRunLevelType_T *aRunLevel);
     76    STDMETHOD(COMGETTER(OSTypeId))(BSTR *aOSTypeId);
     77    STDMETHOD(COMGETTER(AdditionsRunLevel))(AdditionsRunLevelType_T *aRunLevel);
    8178    STDMETHOD(COMGETTER(AdditionsVersion))(BSTR *a_pbstrAdditionsVersion);
    8279    STDMETHOD(COMGETTER(AdditionsRevision))(ULONG *a_puAdditionsRevision);
     80    STDMETHOD(COMGETTER(DnDSource))(IGuestDnDSource ** aSource);
     81    STDMETHOD(COMGETTER(DnDTarget))(IGuestDnDTarget ** aTarget);
    8382    STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);
    84     STDMETHOD(COMGETTER(Facilities)) (ComSafeArrayOut(IAdditionsFacility *, aFacilities));
    85     STDMETHOD(COMGETTER(Sessions)) (ComSafeArrayOut(IGuestSession *, aSessions));
     83    STDMETHOD(COMGETTER(Facilities))(ComSafeArrayOut(IAdditionsFacility *, aFacilities));
     84    STDMETHOD(COMGETTER(Sessions))(ComSafeArrayOut(IGuestSession *, aSessions));
    8685    STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
    8786    STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
     
    9392    STDMETHOD(SetCredentials)(IN_BSTR aUsername, IN_BSTR aPassword,
    9493                              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));
    10494    // Guest control.
    10595    STDMETHOD(CreateSession)(IN_BSTR aUser, IN_BSTR aPassword, IN_BSTR aDomain, IN_BSTR aSessionName, IGuestSession **aGuestSession);
     
    129119    bool facilityIsActive(VBoxGuestFacilityType enmFacility);
    130120    void facilityUpdate(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
     121    ComObjPtr<Console> getConsole(void) { return mParent; }
    131122    void setAdditionsStatus(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
    132123    void onUserStateChange(Bstr aUser, Bstr aDomain, VBoxGuestUserState enmState, const uint8_t *puDetails, uint32_t cbDetails);
     
    142133    int         dispatchToSession(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
    143134    uint32_t    getAdditionsVersion(void) { return mData.mAdditionsVersionFull; }
    144     Console    *getConsole(void) { return mParent; }
    145135    int         sessionRemove(GuestSession *pSession);
    146136    int         sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds, ComObjPtr<GuestSession> &pGuestSession);
     
    170160        { }
    171161
    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;
    182172    } mData;
    183173
     
    192182    BOOL                            mfPageFusionEnabled;
    193183
    194     Console                        *mParent;
     184    const ComObjPtr<Console>        mParent;
    195185
    196186#ifdef VBOX_WITH_GUEST_CONTROL
     
    206196
    207197#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. */
    215206};
    216 #define GUEST_MAGIC 0xCEED2006u
     207#define GUEST_MAGIC 0xCEED2006u /** @todo r=andy Not very well defined!? */
    217208
    218209#endif // ____H_GUESTIMPL
  • trunk/src/VBox/Main/include/MachineImpl.h

    r50996 r51476  
    297297
    298298        ClipboardMode_T     mClipboardMode;
    299         DragAndDropMode_T   mDragAndDropMode;
     299        DnDMode_T           mDnDMode;
    300300
    301301        typedef std::map<Utf8Str, GuestProperty> GuestPropertyMap;
     
    473473    STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode);
    474474    STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode);
    475     STDMETHOD(COMGETTER(DragAndDropMode))(DragAndDropMode_T *aDragAndDropMode);
    476     STDMETHOD(COMSETTER(DragAndDropMode))(DragAndDropMode_T aDragAndDropMode);
     475    STDMETHOD(COMGETTER(DnDMode))(DnDMode_T *aDnDMode);
     476    STDMETHOD(COMSETTER(DnDMode))(DnDMode_T aDnDMode);
    477477    STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern);
    478478    STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
     
    749749    virtual HRESULT onSharedFolderChange() { return S_OK; }
    750750    virtual HRESULT onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
    751     virtual HRESULT onDragAndDropModeChange(DragAndDropMode_T /* aDragAndDropMode */) { return S_OK; }
     751    virtual HRESULT onDnDModeChange(DnDMode_T /* aDnDMode */) { return S_OK; }
    752752    virtual HRESULT onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
    753753    virtual HRESULT onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */, BOOL /* silent */) { return S_OK; }
     
    11391139    HRESULT onSharedFolderChange();
    11401140    HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
    1141     HRESULT onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);
     1141    HRESULT onDnDModeChange(DnDMode_T aDnDMode);
    11421142    HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
    11431143    HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
  • trunk/src/VBox/Main/include/SessionImpl.h

    r48431 r51476  
    44
    55/*
    6  * Copyright (C) 2006-2013 Oracle Corporation
     6 * Copyright (C) 2006-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9292    STDMETHOD(OnSharedFolderChange)(BOOL aGlobal);
    9393    STDMETHOD(OnClipboardModeChange)(ClipboardMode_T aClipboardMode);
    94     STDMETHOD(OnDragAndDropModeChange)(DragAndDropMode_T aDragAndDropMode);
     94    STDMETHOD(OnDnDModeChange)(DnDMode_T aDnDMode);
    9595    STDMETHOD(OnUSBDeviceAttach)(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
    9696    STDMETHOD(OnUSBDeviceDetach)(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r51412 r51476  
    50765076
    50775077/**
    5078  * Called by IInternalSessionControl::OnDragAndDropModeChange().
     5078 * Called by IInternalSessionControl::OnDnDModeChange().
    50795079 *
    50805080 * @note Locks this object for writing.
    50815081 */
    5082 HRESULT Console::onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode)
     5082HRESULT Console::onDnDModeChange(DnDMode_T aDnDMode)
    50835083{
    50845084    LogFlowThisFunc(("\n"));
     
    50985098            || mMachineState == MachineState_Teleporting
    50995099            || mMachineState == MachineState_LiveSnapshotting)
    5100             changeDragAndDropMode(aDragAndDropMode);
     5100            changeDnDMode(aDnDMode);
    51015101        else
    51025102            rc = setInvalidMachineStateError();
     
    51085108    {
    51095109        alock.release();
    5110         fireDragAndDropModeChangedEvent(mEventSource, aDragAndDropMode);
     5110        fireDnDModeChangedEvent(mEventSource, aDnDMode);
    51115111    }
    51125112
     
    83488348 * Changes the drag'n_drop mode.
    83498349 *
    8350  * @param aDragAndDropMode  new drag'n'drop mode.
     8350 * @param aDnDMode  new drag'n'drop mode.
    83518351 */
    8352 void Console::changeDragAndDropMode(DragAndDropMode_T aDragAndDropMode)
     8352int Console::changeDnDMode(DnDMode_T aDnDMode)
    83538353{
    83548354    VMMDev *pVMMDev = m_pVMMDev;
    8355     Assert(pVMMDev);
     8355    AssertPtrReturn(pVMMDev, VERR_INVALID_POINTER);
    83568356
    83578357    VBOXHGCMSVCPARM parm;
     8358    RT_ZERO(parm);
    83588359    parm.type = VBOX_HGCM_SVC_PARM_32BIT;
    83598360
    8360     switch (aDragAndDropMode)
     8361    switch (aDnDMode)
    83618362    {
    83628363        default:
    8363         case DragAndDropMode_Disabled:
    8364             LogRel(("Drag'n'drop mode: Off\n"));
     8364        case DnDMode_Disabled:
     8365            LogRel(("Changed drag'n drop mode to: Off\n"));
    83658366            parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_OFF;
    83668367            break;
    8367         case DragAndDropMode_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"));
    83698370            parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_GUEST_TO_HOST;
    83708371            break;
    8371         case DragAndDropMode_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"));
    83738374            parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_HOST_TO_GUEST;
    83748375            break;
    8375         case DragAndDropMode_Bidirectional:
    8376             LogRel(("Drag'n'drop mode: Bidirectional\n"));
     8376        case DnDMode_Bidirectional:
     8377            LogRel(("Changed drag'n drop mode to: Bidirectional\n"));
    83778378            parm.u.uint32 = VBOX_DRAG_AND_DROP_MODE_BIDIRECTIONAL;
    83788379            break;
    83798380    }
    83808381
    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;
    83828386}
    83838387
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r51441 r51476  
    2424*   Header Files                                                               *
    2525*******************************************************************************/
    26 // for some reason Windows burns in sdk\...\winsock.h if this isn't included first
     26/* For some reason Windows burns in sdk\...\winsock.h if this isn't included first. */
    2727#include "VBox/com/ptr.h"
    2828
     
    3333#endif
    3434#ifdef VBOX_WITH_DRAG_AND_DROP
    35 # include "GuestDnDImpl.h"
     35# include "GuestDnDPrivate.h"
    3636#endif
    3737#include "VMMDev.h"
     
    6565#include <VBox/err.h>
    6666#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. */
    6969#include <VBox/version.h>
    7070#include <VBox/HostServices/VBoxClipboardSvc.h>
     
    7777# include <VBox/com/defs.h>
    7878# include <VBox/com/array.h>
    79 # include "HGCM.h" /** @todo it should be possible to register a service
    80                           * extension using a VMMDev callback. */
     79# include "HGCM.h" /** @todo It should be possible to register a service
     80                    *        extension using a VMMDev callback. */
    8181# include <vector>
    8282#endif /* VBOX_WITH_GUEST_PROPS */
     
    27802780
    27812781        /*
    2782          * Clipboard
     2782         * Shared Clipboard.
    27832783         */
    27842784        {
     
    27902790                /* Load the service */
    27912791                rc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
    2792 
    27932792                if (RT_FAILURE(rc))
    27942793                {
    2795                     LogRel(("VBoxSharedClipboard is not available. rc = %Rrc\n", rc));
     2794                    LogRel(("Shared clipboard is not available, rc=%Rrc\n", rc));
    27962795                    /* That is not a fatal failure. */
    27972796                    rc = VINF_SUCCESS;
     
    27992798                else
    28002799                {
     2800                    LogRel(("Shared clipboard service loaded.\n"));
     2801
    28012802                    changeClipboardMode(mode);
    28022803
     
    28052806                    parm.type = VBOX_HGCM_SVC_PARM_32BIT;
    28062807                    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);
    28102810                }
    28112811            }
     
    28132813
    28142814        /*
    2815          * HGCM HostChannel
     2815         * HGCM HostChannel.
    28162816         */
    28172817        {
     
    28242824            {
    28252825                rc = pVMMDev->hgcmLoadService("VBoxHostChannel", "VBoxHostChannel");
    2826 
    28272826                if (RT_FAILURE(rc))
    28282827                {
    2829                     LogRel(("VBoxHostChannel is not available. rc = %Rrc\n", rc));
     2828                    LogRel(("VBoxHostChannel is not available, rc=%Rrc\n", rc));
    28302829                    /* That is not a fatal failure. */
    28312830                    rc = VINF_SUCCESS;
     
    28362835#ifdef VBOX_WITH_DRAG_AND_DROP
    28372836        /*
    2838          * Drag & Drop
     2837         * Drag'n Drop.
    28392838         */
    28402839        {
    2841             DragAndDropMode_T mode = DragAndDropMode_Disabled;
    2842             hrc = pMachine->COMGETTER(DragAndDropMode)(&mode);                              H();
     2840            DnDMode_T enmMode = DnDMode_Disabled;
     2841            hrc = pMachine->COMGETTER(DnDMode)(&enmMode);                                   H();
    28432842
    28442843            /* Load the service */
    28452844            rc = pVMMDev->hgcmLoadService("VBoxDragAndDropSvc", "VBoxDragAndDropSvc");
    2846 
    28472845            if (RT_FAILURE(rc))
    28482846            {
    2849                 LogRel(("VBoxDragAndDropService is not available. rc = %Rrc\n", rc));
     2847                LogRel(("Drag'n drop service is not available, rc=%Rrc\n", rc));
    28502848                /* That is not a fatal failure. */
    28512849                rc = VINF_SUCCESS;
     
    28552853                HGCMSVCEXTHANDLE hDummy;
    28562854                rc = HGCMHostRegisterServiceExtension(&hDummy, "VBoxDragAndDropSvc",
    2857                                                       &GuestDnD::notifyGuestDragAndDropEvent,
    2858                                                       getGuest());
     2855                                                      &GuestDnD::notifyDnDDispatcher,
     2856                                                      GuestDnDInst());
    28592857                if (RT_FAILURE(rc))
    2860                     Log(("Cannot register VBoxDragAndDropSvc extension!\n"));
     2858                    Log(("Cannot register VBoxDragAndDropSvc extension, rc=%Rrc\n", rc));
    28612859                else
    28622860                {
    2863                     changeDragAndDropMode(mode);
    2864                     Log(("VBoxDragAndDropSvc loaded\n"));
     2861                    LogRel(("Drag'n drop service loaded.\n"));
     2862                    rc = changeDnDMode(enmMode);
    28652863                }
    28662864            }
     
    28702868#ifdef VBOX_WITH_CROGL
    28712869        /*
    2872          * crOpenGL
     2870         * crOpenGL.
    28732871         */
    28742872        {
    28752873            BOOL fEnabled3D = false;
    2876             hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled3D); H();
     2874            hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled3D);                    H();
    28772875
    28782876            if (fEnabled3D)
     
    28872885                               "or disable 3D acceleration in the VM settings"));
    28882886
    2889                 /* Load the service */
     2887                /* Load the service. */
    28902888                rc = pVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
    28912889                if (RT_FAILURE(rc))
    28922890                {
    2893                     LogRel(("Failed to load Shared OpenGL service %Rrc\n", rc));
     2891                    LogRel(("Failed to load Shared OpenGL service, rc=%Rrc\n", rc));
    28942892                    /* That is not a fatal failure. */
    28952893                    rc = VINF_SUCCESS;
     
    29132911                    parm.u.pointer.addr = pVM;
    29142912                    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);
    29162915                    if (!RT_SUCCESS(rc))
    29172916                        AssertMsgFailed(("SHCRGL_HOST_FN_SET_VM failed with %Rrc\n", rc));
    29182917                }
    2919 
    29202918            }
    29212919        }
     
    29242922#ifdef VBOX_WITH_GUEST_PROPS
    29252923        /*
    2926          * Guest property service
     2924         * Guest property service.
    29272925         */
    2928 
    29292926        rc = configGuestProperties(this, pUVM);
    29302927#endif /* VBOX_WITH_GUEST_PROPS defined */
     
    29322929#ifdef VBOX_WITH_GUEST_CONTROL
    29332930        /*
    2934          * Guest control service
     2931         * Guest control service.
    29352932         */
    2936 
    29372933        rc = configGuestControl(this);
    29382934#endif /* VBOX_WITH_GUEST_CONTROL defined */
     
    56205616            Log(("Cannot register VBoxGuestControlSvc extension!\n"));
    56215617        else
    5622             Log(("VBoxGuestControlSvc loaded\n"));
     5618            LogRel(("Guest Control service loaded.\n"));
    56235619    }
    56245620
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r51461 r51476  
    23642364}
    23652365
    2366 
    23672366// IDisplay methods
    23682367/////////////////////////////////////////////////////////////////////////////
    2369 STDMETHODIMP Display::GetScreenResolution (ULONG aScreenId,
    2370     ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel,
    2371     LONG *aXOrigin, LONG *aYOrigin)
    2372 {
    2373     LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
     2368STDMETHODIMP Display::GetScreenResolution(ULONG aScreenId,
     2369                                          ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel,
     2370                                          LONG *aXOrigin, LONG *aYOrigin)
     2371{
     2372    LogRelFlowFunc(("aScreenId=%RU32\n", aScreenId));
    23742373
    23752374    AutoCaller autoCaller(this);
     
    24462445                                   (PFNRT)changeFramebuffer, 3, this, aFramebuffer, aScreenId);
    24472446
     2447        ComAssertRCRet(vrc, E_FAIL);
    24482448        alock.acquire();
    24492449
    2450         ComAssertRCRet (vrc, E_FAIL);
    2451 
    24522450#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                 data.Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
    2461                 data.Hdr.u32Function = SHCRGL_HOST_FN_SCREEN_CHANGED;
    2462 
    2463                 data.aParms[0].type = VBOX_HGCM_SVC_PARM_32BIT;
    2464                 data.aParms[0].u.uint32 = aScreenId;
    2465 
    2466                 alock.release();
    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();
    24722470        }
    24732471#endif /* #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL) */
     
    24762474    {
    24772475        /* No VM is created (VM is powered off), do a direct call */
    2478         int vrc = changeFramebuffer (this, aFramebuffer, aScreenId);
    2479         ComAssertRCRet (vrc, E_FAIL);
     2476        int vrc = changeFramebuffer(this, aFramebuffer, aScreenId);
     2477        ComAssertRCRet(vrc, E_FAIL);
    24802478    }
    24812479
     
    26052603                                     IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin)
    26062604{
    2607     LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
     2605    LogRelFlowFunc(("aScreenId=%ld\n", aScreenId));
    26082606
    26092607    CheckComArgOutPointerValid(aFramebuffer);
     
    26172615        return E_INVALIDARG;
    26182616
    2619     /* @todo this should be actually done on EMT. */
     2617    /** @todo This should be actually done on EMT. */
    26202618    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? */
    26232622    if (*aFramebuffer)
    2624         (*aFramebuffer)->AddRef ();
     2623        (*aFramebuffer)->AddRef();
    26252624    if (aXOrigin)
    26262625        *aXOrigin = pFBInfo->xOrigin;
     
    26432642
    26442643    /*
    2645      * Do some rough checks for valid input
     2644     * Do some rough checks for valid input.
    26462645     */
    26472646    ULONG width  = aWidth;
  • trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp

    r51420 r51476  
    11/* $Id$ */
    22/** @file
    3  * VirtualBox COM class implementation: Guest Drag and Drop parts
     3 * Private guest drag and drop code, used by GuestDnDTarget +
     4 * GuestDnDSource.
    45 */
    56
     
    2223# include "ConsoleImpl.h"
    2324# include "ProgressImpl.h"
    24 # include "GuestDnDImpl.h"
     25# include "GuestDnDPrivate.h"
     26
     27# include <algorithm>
    2528
    2629# include <iprt/dir.h>
     
    3235# include <VMMDev.h>
    3336
    34 # include <VBox/com/list.h>
    3537# include <VBox/GuestHost/DragAndDrop.h>
    3638# include <VBox/HostServices/DragAndDropSvc.h>
    3739
    3840# ifdef LOG_GROUP
    39  # undef LOG_GROUP
     41# undef LOG_GROUP
    4042# endif
    4143# define LOG_GROUP LOG_GROUP_GUEST_DND
    4244# include <VBox/log.h>
    4345
    44 /* How does this work:
     46/**
     47 * Overview:
    4548 *
    4649 * Drag and Drop is handled over the internal HGCM service for the host <->
     
    7376 *    The guest has to respond with an action it would accept, so the GUI could
    7477 *    change the cursor.
    75  * 2. On drop, first a drop event is send. If this is accepted a drop data
     78 * 2. On drop, first a drop event is sent. If this is accepted a drop data
    7679 *    event follows. This blocks the GUI and shows some progress indicator.
    7780 *
     
    8689 *
    8790 * Some hints:
    88  * m_sstrAllowedMimeTypes here in this file defines the allowed mime-types.
     91 * m_strSupportedFormats here in this file defines the allowed mime-types.
    8992 * This is necessary because we need special handling for some of the
    9093 * mime-types. E.g. for URI lists we need to transfer the actual dirs and
     
    141144 * onces.
    142145 *
    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)
    148148 *   ... in any case it seems a little bit difficult to handle from the Qt
    149149 *   side. Maybe also a host specific implementation becomes necessary ...
    150150 *   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:
    161153 *   - 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 guest
     154 *   - Not expected order of the events between HGCM and the guest
    163155 * - Security considerations: We transfer a lot of memory between the guest and
    164156 *   the host and even allow the creation of dirs/files. Maybe there should be
    165157 *   limits introduced to preventing DOS attacks or filling up all the memory
    166158 *   (both in the host and the guest).
    167  * - test, test, test ...
    168159 */
    169160
    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)
     161GuestDnDResponse::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)
    306171{
    307172    int rc = RTSemEventCreate(&m_EventSem);
     
    309174}
    310175
    311 DnDGuestResponse::~DnDGuestResponse(void)
     176GuestDnDResponse::~GuestDnDResponse(void)
    312177{
    313178    reset();
     
    317182}
    318183
    319 int DnDGuestResponse::dataAdd(const void *pvData, uint32_t cbData,
     184int GuestDnDResponse::dataAdd(const void *pvData, uint32_t cbData,
    320185                              uint32_t *pcbCurSize)
    321186{
     
    344209
    345210/* static */
    346 Utf8Str DnDGuestResponse::errorToString(const ComObjPtr<Guest>& pGuest, int guestRc)
     211Utf8Str GuestDnDResponse::errorToString(const ComObjPtr<Guest>& pGuest, int guestRc)
    347212{
    348213    Utf8Str strError;
     
    377242}
    378243
    379 int DnDGuestResponse::notifyAboutGuestResponse(void)
     244int GuestDnDResponse::notifyAboutGuestResponse(void)
    380245{
    381246    return RTSemEventSignal(m_EventSem);
    382247}
    383248
    384 void DnDGuestResponse::reset(void)
     249void GuestDnDResponse::reset(void)
    385250{
    386251    LogFlowThisFuncEnter();
     
    409274}
    410275
    411 HRESULT DnDGuestResponse::resetProgress(const ComObjPtr<Guest>& pParent)
     276HRESULT GuestDnDResponse::resetProgress(const ComObjPtr<Guest>& pParent)
    412277{
    413278    m_progress.setNull();
     
    422287}
    423288
    424 int DnDGuestResponse::setProgress(unsigned uPercentage,
     289int GuestDnDResponse::setProgress(unsigned uPercentage,
    425290                                  uint32_t uState, int rcOp /* = VINF_SUCCESS */)
    426291{
     
    440305                                                  COM_IIDOF(IGuest),
    441306                                                  m_parent->getComponentName(),
    442                                                   DnDGuestResponse::errorToString(m_parent, rcOp).c_str());
     307                                                  GuestDnDResponse::errorToString(m_parent, rcOp).c_str());
    443308                reset();
    444309            }
     
    465330}
    466331
    467 int DnDGuestResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */)
     332int GuestDnDResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */)
    468333{
    469334    if (cbDataTotal)
     
    506371}
    507372
    508 HRESULT DnDGuestResponse::queryProgressTo(IProgress **ppProgress)
     373HRESULT GuestDnDResponse::queryProgressTo(IProgress **ppProgress)
    509374{
    510375    return m_progress.queryInterfaceTo(ppProgress);
    511376}
    512377
    513 int DnDGuestResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */)
     378int GuestDnDResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */)
    514379{
    515380    int rc = RTSemEventWait(m_EventSem, msTimeout);
     
    520385}
    521386
    522 int DnDGuestResponse::writeToFile(const char *pszPath, size_t cbPath,
     387int GuestDnDResponse::writeToFile(const char *pszPath, size_t cbPath,
    523388                                  void *pvData, size_t cbData, uint32_t fMode)
    524389{
     
    575440///////////////////////////////////////////////////////////////////////////////
    576441
    577 HRESULT GuestDnDPrivate::adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const
    578 {
     442GuestDnD* GuestDnD::s_pInstance = NULL;
     443
     444GuestDnD::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
     474GuestDnD::~GuestDnD(void)
     475{
     476    LogFlowFuncEnter();
     477
     478    if (m_pResponse)
     479        delete m_pResponse;
     480}
     481
     482int 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
    579487    /* For multi-monitor support we need to add shift values to the coordinates
    580488     * (depending on the screen number). */
     489    ComObjPtr<Console> pConsole = m_pGuest->getConsole();
    581490    ComPtr<IDisplay> pDisplay;
    582     HRESULT hr = p->mParent->COMGETTER(Display)(pDisplay.asOutParam());
     491    HRESULT hr = pConsole->COMGETTER(Display)(pDisplay.asOutParam());
    583492    if (FAILED(hr))
    584493        return hr;
     
    590499        return hr;
    591500
    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
     513int 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();
    613521    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,
    620525                                   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));
    628528    return rc;
    629529}
    630530
    631531/* static */
    632 RTCString GuestDnDPrivate::toFormatString(ComSafeArrayIn(IN_BSTR, formats))
    633 {
    634     const RTCList<Utf8Str> formatList(ComSafeArrayInArg(formats));
    635     RTCString strFormat;
    636     for (size_t i = 0; i < formatList.size(); ++i)
    637     {
    638         const RTCString &f = formatList.at(i);
     532com::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);
    639539        /* Only keep allowed format types. */
    640         if (m_sstrAllowedMimeTypes.contains(f))
     540        if (std::find(lstSupportedFormats.begin(),
     541                      lstSupportedFormats.end(), f) != lstSupportedFormats.end())
    641542            strFormat += f + "\r\n";
    642543    }
     544
    643545    return strFormat;
    644546}
    645547
    646548/* static */
    647 void GuestDnDPrivate::toFormatSafeArray(const RTCString &strFormats, ComSafeArrayOut(BSTR, formats))
    648 {
    649     RTCList<RTCString> list = strFormats.split("\r\n");
     549void 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");
    650554    size_t i = 0;
    651     while (i < list.size())
     555    while (i < lstFormats.size())
    652556    {
    653557        /* 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);
    656561        else
    657562            ++i;
    658563    }
    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    }
    671572}
    672573
    673574/* 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;
     575uint32_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;
    687598}
    688599
    689600/* 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;
     601void 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        }
    713625    }
    714626}
    715627
    716628/* static */
    717 DragAndDropAction_T GuestDnDPrivate::toMainAction(uint32_t uAction)
     629DnDAction_T GuestDnD::toMainAction(uint32_t uAction)
    718630{
    719631    /* For now it doesn't seems useful to allow a
    720632     * link action between host & guest. Maybe later! */
    721     return (isDnDCopyAction(uAction) ? (DragAndDropAction_T)DragAndDropAction_Copy :
    722             isDnDMoveAction(uAction) ? (DragAndDropAction_T)DragAndDropAction_Move :
    723             (DragAndDropAction_T)DragAndDropAction_Ignore);
     633    return (isDnDCopyAction(uAction) ? (DnDAction_T)DnDAction_Copy :
     634            isDnDMoveAction(uAction) ? (DnDAction_T)DnDAction_Move :
     635            (DnDAction_T)DnDAction_Ignore);
    724636}
    725637
    726638/* static */
    727 void GuestDnDPrivate::toMainActions(uint32_t uActions,
    728                                     ComSafeArrayOut(DragAndDropAction_T, actions))
     639void GuestDnD::toMainActions(uint32_t uActions,
     640                             std::vector<DnDAction_T> &vecActions)
    729641{
    730642    /* For now it doesn't seems useful to allow a
    731643     * link action between host & guest. Maybe later! */
    732     RTCList<DragAndDropAction_T> list;
     644    RTCList<DnDAction_T> lstActions;
    733645    if (hasDnDCopyAction(uActions))
    734         list.append(DragAndDropAction_Copy);
     646        lstActions.append(DnDAction_Copy);
    735647    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}
    1253653
    1254654/* static */
    1255 DECLCALLBACK(int) GuestDnD::notifyGuestDragAndDropEvent(void *pvExtension, uint32_t u32Function,
    1256                                                         void *pvParms, uint32_t cbParms)
     655DECLCALLBACK(int) GuestDnD::notifyDnDDispatcher(void *pvExtension, uint32_t u32Function,
     656                                                void *pvParms, uint32_t cbParms)
    1257657{
    1258658    LogFlowFunc(("pvExtension=%p, u32Function=%RU32, pvParms=%p, cbParms=%RU32\n",
    1259659                 pvExtension, u32Function, pvParms, cbParms));
    1260660
    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;
    1276668    switch (u32Function)
    1277669    {
     
    1314706        }
    1315707
    1316 #ifdef VBOX_WITH_DRAG_AND_DROP_GH
     708# ifdef VBOX_WITH_DRAG_AND_DROP_GH
    1317709        case DragAndDropSvc::GUEST_DND_GH_ACK_PENDING:
    1318710        {
     
    1378770            break;
    1379771        }
    1380 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */
     772# endif /* VBOX_WITH_DRAG_AND_DROP_GH */
    1381773        default:
    1382774            rc = VERR_NOT_SUPPORTED; /* Tell the guest. */
     
    1387779    return rc;
    1388780}
     781
     782# ifdef VBOX_WITH_DRAG_AND_DROP_GH
     783int 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
     799int 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
     826int 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
    1389844#endif /* VBOX_WITH_DRAG_AND_DROP */
    1390845
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r51342 r51476  
    11/* $Id$ */
    22/** @file
    3  * VirtualBox COM class implementation: Guest
     3 * VirtualBox COM class implementation: Guest features.
    44 */
    55
     
    2323#include "ProgressImpl.h"
    2424#ifdef VBOX_WITH_DRAG_AND_DROP
    25 # include "GuestDnDImpl.h"
     25# include "GuestDnDPrivate.h"
    2626#endif
    2727#include "VMMDev.h"
     
    117117#endif
    118118
     119#ifdef VBOX_WITH_DRAG_AND_DROP
    119120    try
    120121    {
    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    }
    124139#endif
    125     }
    126     catch(std::bad_alloc &)
    127     {
    128         hr = E_OUTOFMEMORY;
    129     }
    130 
     140
     141    LogFlowFunc(("hr=%Rhrc\n", hr));
    131142    return hr;
    132143}
     
    157168    while (itSessions != mData.mGuestSessions.end())
    158169    {
    159 #ifdef DEBUG
     170# ifdef DEBUG
    160171        ULONG cRefs = itSessions->second->AddRef();
    161172        LogFlowThisFunc(("sessionID=%RU32, cRefs=%RU32\n", itSessions->first, cRefs > 1 ? cRefs - 1 : 0));
    162173        itSessions->second->Release();
    163 #endif
     174# endif
    164175        itSessions->second->uninit();
    165176        itSessions++;
     
    169180
    170181#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();
    176185#endif
    177186
     
    495504}
    496505
     506STDMETHODIMP 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
     526STDMETHODIMP 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
    497546STDMETHODIMP Guest::COMGETTER(EventSource)(IEventSource ** aEventSource)
    498547{
     
    507556    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    508557
    509     // no need to lock - lifetime constant
     558    /* No need to lock - lifetime constant. */
    510559    mEventSource.queryInterfaceTo(aEventSource);
    511560
     
    821870    {
    822871        /** @todo */
    823         return E_NOTIMPL;   
     872        return E_NOTIMPL;
    824873    }
    825874    else
     
    835884                if (!aAllowInteractiveLogon)
    836885                    u32Flags = VMMDEV_SETCREDENTIALS_NOLOCALLOGON;
    837    
     886
    838887                pVMMDevPort->pfnSetCredentials(pVMMDevPort,
    839888                                               Utf8Str(aUserName).c_str(),
     
    848897    return setError(VBOX_E_VM_ERROR,
    849898                    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_DROP
    867     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_DROP
    891     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_DROP
    906     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_DROP
    928     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_DROP
    951     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 */
    1011899}
    1012900
  • trunk/src/VBox/Main/src-client/SessionImpl.cpp

    r51236 r51476  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    784784}
    785785
    786 STDMETHODIMP Session::OnDragAndDropModeChange(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->onDragAndDropModeChange(aDragAndDropMode);
     786STDMETHODIMP 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);
    799799#else
    800800    return S_OK;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r51190 r51476  
    199199
    200200    mClipboardMode = ClipboardMode_Disabled;
    201     mDragAndDropMode = DragAndDropMode_Disabled;
     201    mDnDMode = DnDMode_Disabled;
    202202    mGuestPropertyNotificationPatterns = "";
    203203
     
    30363036}
    30373037
    3038 STDMETHODIMP Machine::COMGETTER(DragAndDropMode)(DragAndDropMode_T *aDragAndDropMode)
    3039 {
    3040     CheckComArgOutPointerValid(aDragAndDropMode);
     3038STDMETHODIMP Machine::COMGETTER(DnDMode)(DnDMode_T *aDnDMode)
     3039{
     3040    CheckComArgOutPointerValid(aDnDMode);
    30413041
    30423042    AutoCaller autoCaller(this);
     
    30453045    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    30463046
    3047     *aDragAndDropMode = mHWData->mDragAndDropMode;
    3048 
    3049     return S_OK;
    3050 }
    3051 
    3052 STDMETHODIMP Machine::COMSETTER(DragAndDropMode)(DragAndDropMode_T aDragAndDropMode)
     3047    *aDnDMode = mHWData->mDnDMode;
     3048
     3049    return S_OK;
     3050}
     3051
     3052STDMETHODIMP Machine::COMSETTER(DnDMode)(DnDMode_T aDnDMode)
    30533053{
    30543054    HRESULT rc = S_OK;
     
    30603060
    30613061    alock.release();
    3062     rc = onDragAndDropModeChange(aDragAndDropMode);
     3062    rc = onDnDModeChange(aDnDMode);
    30633063    alock.acquire();
    30643064    if (FAILED(rc)) return rc;
     
    30663066    setModified(IsModified_MachineData);
    30673067    mHWData.backup();
    3068     mHWData->mDragAndDropMode = aDragAndDropMode;
     3068    mHWData->mDnDMode = aDnDMode;
    30693069
    30703070    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
     
    95159515
    95169516        // drag'n'drop
    9517         mHWData->mDragAndDropMode = data.dragAndDropMode;
     9517        mHWData->mDnDMode = data.dndMode;
    95189518
    95199519        // guest settings
     
    1080810808
    1080910809        // drag'n'drop
    10810         data.dragAndDropMode = mHWData->mDragAndDropMode;
     10810        data.dndMode = mHWData->mDnDMode;
    1081110811
    1081210812        /* Guest */
     
    1447014470 * @note Locks this object for reading.
    1447114471 */
    14472 HRESULT SessionMachine::onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode)
     14472HRESULT SessionMachine::onDnDModeChange(DnDMode_T aDnDMode)
    1447314473{
    1447414474    LogFlowThisFunc(("\n"));
     
    1448714487        return S_OK;
    1448814488
    14489     return directControl->OnDragAndDropModeChange(aDragAndDropMode);
     14489    return directControl->OnDnDModeChange(aDnDMode);
    1449014490}
    1449114491
  • trunk/src/VBox/Main/xml/Settings.cpp

    r51418 r51476  
    19301930          fEmulatedUSBCardReader(false),
    19311931          clipboardMode(ClipboardMode_Disabled),
    1932           dragAndDropMode(DragAndDropMode_Disabled),
     1932          dndMode(DnDMode_Disabled),
    19331933          ulMemoryBalloonSize(0),
    19341934          fPageFusionEnabled(false)
     
    20132013                  && (llSharedFolders           == h.llSharedFolders)
    20142014                  && (clipboardMode             == h.clipboardMode)
    2015                   && (dragAndDropMode           == h.dragAndDropMode)
     2015                  && (dndMode           == h.dndMode)
    20162016                  && (ulMemoryBalloonSize       == h.ulMemoryBalloonSize)
    20172017                  && (fPageFusionEnabled        == h.fPageFusionEnabled)
     
    32083208            {
    32093209                if (strTemp == "Disabled")
    3210                     hw.dragAndDropMode = DragAndDropMode_Disabled;
     3210                    hw.dndMode = DnDMode_Disabled;
    32113211                else if (strTemp == "HostToGuest")
    3212                     hw.dragAndDropMode = DragAndDropMode_HostToGuest;
     3212                    hw.dndMode = DnDMode_HostToGuest;
    32133213                else if (strTemp == "GuestToHost")
    3214                     hw.dragAndDropMode = DragAndDropMode_GuestToHost;
     3214                    hw.dndMode = DnDMode_GuestToHost;
    32153215                else if (strTemp == "Bidirectional")
    3216                     hw.dragAndDropMode = DragAndDropMode_Bidirectional;
     3216                    hw.dndMode = DnDMode_Bidirectional;
    32173217                else
    32183218                    throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in DragAndDrop/@mode attribute"), strTemp.c_str());
     
    46824682    xml::ElementNode *pelmDragAndDrop = pelmHardware->createChild("DragAndDrop");
    46834683    const char *pcszDragAndDrop;
    4684     switch (hw.dragAndDropMode)
    4685     {
    4686         default: /*case DragAndDropMode_Disabled:*/ pcszDragAndDrop = "Disabled"; break;
    4687         case DragAndDropMode_HostToGuest: pcszDragAndDrop = "HostToGuest"; break;
    4688         case DragAndDropMode_GuestToHost: pcszDragAndDrop = "GuestToHost"; break;
    4689         case DragAndDropMode_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;
    46904690    }
    46914691    pelmDragAndDrop->setAttribute("mode", pcszDragAndDrop);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette