VirtualBox

Changeset 74439 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 24, 2018 12:30:47 PM (6 years ago)
Author:
vboxsync
Message:

DnD: Added typedefs for DNDACTION and DNDACTIONLIST to emphasize usage, did some renaming to clean things up.

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestDnDPrivate.h

    r71398 r74439  
    2626#include <VBox/hgcmsvc.h> /* For PVBOXHGCMSVCPARM. */
    2727#include <VBox/GuestHost/DragAndDrop.h>
     28#include <VBox/GuestHost/DragAndDropDefs.h>
    2829#include <VBox/HostServices/DragAndDropSvc.h>
    2930
     
    797798     *  Needed to tell the guest if data has to be
    798799     *  deleted e.g. when moving instead of copying. */
    799     uint32_t                            mAction;
     800    VBOXDNDACTION                       mAction;
    800801    /** Drag'n drop received from the guest.
    801802     *  This can be arbitrary data or an URI list. */
     
    986987    int waitForGuestResponse(RTMSINTERVAL msTimeout = 500) const;
    987988
    988     void setAllActions(uint32_t a) { m_allActions = a; }
    989     uint32_t allActions(void) const { return m_allActions; }
    990 
    991     void setDefAction(uint32_t a) { m_defAction = a; }
    992     uint32_t defAction(void) const { return m_defAction; }
     989    void setActionsAllowed(VBOXDNDACTIONLIST a) { m_dndLstActionsAllowed = a; }
     990    VBOXDNDACTIONLIST getActionsAllowed(void) const { return m_dndLstActionsAllowed; }
     991
     992    void setActionDefault(VBOXDNDACTION a) { m_dndActionDefault = a; }
     993    VBOXDNDACTION getActionDefault(void) const { return m_dndActionDefault; }
    993994
    994995    void setFormats(const GuestDnDMIMEList &lstFormats) { m_lstFormats = lstFormats; }
     
    10181019    /** Default action to perform in case of a
    10191020     *  successful drop. */
    1020     uint32_t              m_defAction;
    1021     /** Actions supported by the guest in case of
    1022      *  a successful drop. */
    1023     uint32_t              m_allActions;
     1021    VBOXDNDACTION         m_dndActionDefault;
     1022    /** Actions supported by the guest in case of a successful drop. */
     1023    VBOXDNDACTIONLIST     m_dndLstActionsAllowed;
    10241024    /** Format(s) requested/supported from the guest. */
    10251025    GuestDnDMIMEList      m_lstFormats;
     
    10941094    static GuestDnDMIMEList         toFilteredFormatList(const GuestDnDMIMEList &lstFormatsSupported, const GuestDnDMIMEList &lstFormatsWanted);
    10951095    static GuestDnDMIMEList         toFilteredFormatList(const GuestDnDMIMEList &lstFormatsSupported, const com::Utf8Str &strFormatsWanted);
    1096     static DnDAction_T              toMainAction(uint32_t uAction);
    1097     static std::vector<DnDAction_T> toMainActions(uint32_t uActions);
    1098     static uint32_t                 toHGCMAction(DnDAction_T enmAction);
    1099     static void                     toHGCMActions(DnDAction_T enmDefAction, uint32_t *puDefAction, const std::vector<DnDAction_T> vecAllowedActions, uint32_t *puAllowedActions);
     1096    static DnDAction_T              toMainAction(VBOXDNDACTION dndAction);
     1097    static std::vector<DnDAction_T> toMainActions(VBOXDNDACTIONLIST dndActionList);
     1098    static VBOXDNDACTION            toHGCMAction(DnDAction_T enmAction);
     1099    static void                     toHGCMActions(DnDAction_T enmDefAction, VBOXDNDACTION *pDefAction, const std::vector<DnDAction_T> vecAllowedActions, VBOXDNDACTIONLIST *pLstAllowedActions);
    11001100    /** @}  */
    11011101
  • trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp

    r74411 r74439  
    188188GuestDnDResponse::GuestDnDResponse(const ComObjPtr<Guest>& pGuest)
    189189    : m_EventSem(NIL_RTSEMEVENT)
    190     , m_defAction(0)
    191     , m_allActions(0)
     190    , m_dndActionDefault(0)
     191    , m_dndLstActionsAllowed(0)
    192192    , m_pParent(pGuest)
    193193{
     
    214214    LogFlowThisFuncEnter();
    215215
    216     m_defAction  = 0;
    217     m_allActions = 0;
     216    m_dndActionDefault     = 0;
     217    m_dndLstActionsAllowed = 0;
    218218
    219219    m_lstFormats.clear();
     
    384384            AssertReturn(DragAndDropSvc::CB_MAGIC_DND_HG_ACK_OP == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
    385385
    386             setDefAction(pCBData->uAction);
     386            setActionDefault(pCBData->uAction);
    387387            rc = notifyAboutGuestResponse();
    388388            break;
     
    453453            {
    454454                setFormats   (GuestDnD::toFormatList(pCBData->pszFormat));
    455                 setDefAction (pCBData->uDefAction);
    456                 setAllActions(pCBData->uAllActions);
     455                setActionDefault (pCBData->uDefAction);
     456                setActionsAllowed(pCBData->uAllActions);
    457457
    458458                rc = VINF_SUCCESS;
     
    671671
    672672/* static */
    673 uint32_t GuestDnD::toHGCMAction(DnDAction_T enmAction)
    674 {
    675     uint32_t uAction = VBOX_DND_ACTION_IGNORE;
     673VBOXDNDACTION GuestDnD::toHGCMAction(DnDAction_T enmAction)
     674{
     675    VBOXDNDACTION dndAction = VBOX_DND_ACTION_IGNORE;
    676676    switch (enmAction)
    677677    {
    678678        case DnDAction_Copy:
    679             uAction = VBOX_DND_ACTION_COPY;
     679            dndAction = VBOX_DND_ACTION_COPY;
    680680            break;
    681681        case DnDAction_Move:
    682             uAction = VBOX_DND_ACTION_MOVE;
     682            dndAction = VBOX_DND_ACTION_MOVE;
    683683            break;
    684684        case DnDAction_Link:
     
    693693    }
    694694
    695     return uAction;
     695    return dndAction;
    696696}
    697697
    698698/* static */
    699 void GuestDnD::toHGCMActions(DnDAction_T                    enmDefAction,
    700                              uint32_t                      *puDefAction,
    701                              const std::vector<DnDAction_T> vecAllowedActions,
    702                              uint32_t                      *puAllowedActions)
    703 {
    704     uint32_t uAllowedActions = VBOX_DND_ACTION_IGNORE;
    705     uint32_t uDefAction      = toHGCMAction(enmDefAction);
    706 
    707     if (!vecAllowedActions.empty())
     699void GuestDnD::toHGCMActions(DnDAction_T                    enmDnDActionDefault,
     700                             VBOXDNDACTION                 *pDnDActionDefault,
     701                             const std::vector<DnDAction_T> vecDnDActionsAllowed,
     702                             VBOXDNDACTIONLIST             *pDnDLstActionsAllowed)
     703{
     704    VBOXDNDACTIONLIST dndLstActionsAllowed = VBOX_DND_ACTION_IGNORE;
     705    VBOXDNDACTION     dndActionDefault     = toHGCMAction(enmDnDActionDefault);
     706
     707    if (!vecDnDActionsAllowed.empty())
    708708    {
    709709        /* First convert the allowed actions to a bit array. */
    710         for (size_t i = 0; i < vecAllowedActions.size(); i++)
    711             uAllowedActions |= toHGCMAction(vecAllowedActions[i]);
     710        for (size_t i = 0; i < vecDnDActionsAllowed.size(); i++)
     711            dndLstActionsAllowed |= toHGCMAction(vecDnDActionsAllowed[i]);
    712712
    713713        /*
     
    715715         * set allowed actions, preferring copy, move (in that order).
    716716         */
    717         if (isDnDIgnoreAction(uDefAction))
    718         {
    719             if (hasDnDCopyAction(uAllowedActions))
    720                 uDefAction = VBOX_DND_ACTION_COPY;
    721             else if (hasDnDMoveAction(uAllowedActions))
    722                 uDefAction = VBOX_DND_ACTION_MOVE;
    723         }
    724     }
    725 
    726     if (puDefAction)
    727         *puDefAction      = uDefAction;
    728     if (puAllowedActions)
    729         *puAllowedActions = uAllowedActions;
     717        if (isDnDIgnoreAction(dndActionDefault))
     718        {
     719            if (hasDnDCopyAction(dndLstActionsAllowed))
     720                dndActionDefault = VBOX_DND_ACTION_COPY;
     721            else if (hasDnDMoveAction(dndLstActionsAllowed))
     722                dndActionDefault = VBOX_DND_ACTION_MOVE;
     723        }
     724    }
     725
     726    if (pDnDActionDefault)
     727        *pDnDActionDefault     = dndActionDefault;
     728    if (pDnDLstActionsAllowed)
     729        *pDnDLstActionsAllowed = dndLstActionsAllowed;
    730730}
    731731
    732732/* static */
    733 DnDAction_T GuestDnD::toMainAction(uint32_t uAction)
     733DnDAction_T GuestDnD::toMainAction(VBOXDNDACTION dndAction)
    734734{
    735735    /* For now it doesn't seems useful to allow a
    736736     * link action between host & guest. Maybe later! */
    737     return isDnDCopyAction(uAction) ? DnDAction_Copy
    738          : isDnDMoveAction(uAction) ? DnDAction_Move
    739          :                            DnDAction_Ignore;
     737    return isDnDCopyAction(dndAction) ? DnDAction_Copy
     738         : isDnDMoveAction(dndAction) ? DnDAction_Move
     739         :                              DnDAction_Ignore;
    740740}
    741741
    742742/* static */
    743 std::vector<DnDAction_T> GuestDnD::toMainActions(uint32_t uActions)
     743std::vector<DnDAction_T> GuestDnD::toMainActions(VBOXDNDACTIONLIST dndActionList)
    744744{
    745745    std::vector<DnDAction_T> vecActions;
     
    748748     * link action between host & guest. Maybe later! */
    749749    RTCList<DnDAction_T> lstActions;
    750     if (hasDnDCopyAction(uActions))
     750    if (hasDnDCopyAction(dndActionList))
    751751        lstActions.append(DnDAction_Copy);
    752     if (hasDnDMoveAction(uActions))
     752    if (hasDnDMoveAction(dndActionList))
    753753        lstActions.append(DnDAction_Move);
    754754
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r74361 r74439  
    279279
    280280        if (   fFetchResult
    281             && isDnDIgnoreAction(pResp->defAction()))
     281            && isDnDIgnoreAction(pResp->getActionDefault()))
    282282            fFetchResult = false;
    283283
     
    299299
    300300                aFormats            = lstFiltered;
    301                 aAllowedActions     = GuestDnD::toMainActions(pResp->allActions());
     301                aAllowedActions     = GuestDnD::toMainActions(pResp->getActionsAllowed());
    302302                if (aDefaultAction)
    303                     *aDefaultAction = GuestDnD::toMainAction(pResp->defAction());
     303                    *aDefaultAction = GuestDnD::toMainAction(pResp->getActionDefault());
    304304
    305305                /* Apply the (filtered) formats list. */
     
    310310        }
    311311
    312         LogFlowFunc(("fFetchResult=%RTbool, allActions=0x%x\n", fFetchResult, pResp->allActions()));
     312        LogFlowFunc(("fFetchResult=%RTbool, lstActionsAllowed=0x%x\n", fFetchResult, pResp->getActionsAllowed()));
    313313    }
    314314
     
    337337        return setError(E_INVALIDARG, tr("Specified format '%s' is not supported"), aFormat.c_str());
    338338
    339     uint32_t uAction = GuestDnD::toHGCMAction(aAction);
    340     if (isDnDIgnoreAction(uAction)) /* If there is no usable action, ignore this request. */
     339    VBOXDNDACTION dndAction = GuestDnD::toHGCMAction(aAction);
     340    if (isDnDIgnoreAction(dndAction)) /* If there is no usable action, ignore this request. */
    341341        return S_OK;
    342342
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r74411 r74439  
    274274    DnDAction_T resAction = DnDAction_Ignore;
    275275
    276     /* Check & convert the drag & drop actions */
    277     uint32_t uDefAction      = 0;
    278     uint32_t uAllowedActions = 0;
    279     GuestDnD::toHGCMActions(aDefaultAction, &uDefAction,
    280                             aAllowedActions, &uAllowedActions);
     276    /* Check & convert the drag & drop actions. */
     277    VBOXDNDACTION     dndActionDefault     = 0;
     278    VBOXDNDACTIONLIST dndActionListAllowed = 0;
     279    GuestDnD::toHGCMActions(aDefaultAction, &dndActionDefault,
     280                            aAllowedActions, &dndActionListAllowed);
     281
    281282    /* If there is no usable action, ignore this request. */
    282     if (isDnDIgnoreAction(uDefAction))
     283    if (isDnDIgnoreAction(dndActionDefault))
    283284        return S_OK;
    284285
     
    316317        Msg.setNextUInt32(aX);
    317318        Msg.setNextUInt32(aY);
    318         Msg.setNextUInt32(uDefAction);
    319         Msg.setNextUInt32(uAllowedActions);
     319        Msg.setNextUInt32(dndActionDefault);
     320        Msg.setNextUInt32(dndActionListAllowed);
    320321        Msg.setNextPointer((void *)strFormats.c_str(), cbFormats);
    321322        Msg.setNextUInt32(cbFormats);
     
    326327            GuestDnDResponse *pResp = GuestDnDInst()->response();
    327328            if (pResp && RT_SUCCESS(pResp->waitForGuestResponse()))
    328                 resAction = GuestDnD::toMainAction(pResp->defAction());
     329                resAction = GuestDnD::toMainAction(pResp->getActionDefault());
    329330        }
    330331    }
     
    363364
    364365    /* Check & convert the drag & drop actions. */
    365     uint32_t uDefAction      = 0;
    366     uint32_t uAllowedActions = 0;
    367     GuestDnD::toHGCMActions(aDefaultAction, &uDefAction,
    368                             aAllowedActions, &uAllowedActions);
     366    VBOXDNDACTION     dndActionDefault     = 0;
     367    VBOXDNDACTIONLIST dndActionListAllowed = 0;
     368    GuestDnD::toHGCMActions(aDefaultAction, &dndActionDefault,
     369                            aAllowedActions, &dndActionListAllowed);
     370
    369371    /* If there is no usable action, ignore this request. */
    370     if (isDnDIgnoreAction(uDefAction))
     372    if (isDnDIgnoreAction(dndActionDefault))
    371373        return S_OK;
    372374
     
    393395        Msg.setNextUInt32(aX);
    394396        Msg.setNextUInt32(aY);
    395         Msg.setNextUInt32(uDefAction);
    396         Msg.setNextUInt32(uAllowedActions);
     397        Msg.setNextUInt32(dndActionDefault);
     398        Msg.setNextUInt32(dndActionListAllowed);
    397399        Msg.setNextPointer((void *)strFormats.c_str(), cbFormats);
    398400        Msg.setNextUInt32(cbFormats);
     
    403405            GuestDnDResponse *pResp = GuestDnDInst()->response();
    404406            if (pResp && RT_SUCCESS(pResp->waitForGuestResponse()))
    405                 resAction = GuestDnD::toMainAction(pResp->defAction());
     407                resAction = GuestDnD::toMainAction(pResp->getActionDefault());
    406408        }
    407409    }
     
    480482
    481483    /* Check & convert the drag & drop actions to HGCM codes. */
    482     uint32_t uDefAction      = VBOX_DND_ACTION_IGNORE;
    483     uint32_t uAllowedActions = 0;
    484     GuestDnD::toHGCMActions(aDefaultAction,  &uDefAction,
    485                             aAllowedActions, &uAllowedActions);
     484    VBOXDNDACTION     dndActionDefault     = VBOX_DND_ACTION_IGNORE;
     485    VBOXDNDACTIONLIST dndActionListAllowed = 0;
     486    GuestDnD::toHGCMActions(aDefaultAction,  &dndActionDefault,
     487                            aAllowedActions, &dndActionListAllowed);
     488
    486489    /* If there is no usable action, ignore this request. */
    487     if (isDnDIgnoreAction(uDefAction))
     490    if (isDnDIgnoreAction(dndActionDefault))
    488491    {
    489492        aFormat = "";
     
    514517        Msg.setNextUInt32(aX);
    515518        Msg.setNextUInt32(aY);
    516         Msg.setNextUInt32(uDefAction);
    517         Msg.setNextUInt32(uAllowedActions);
     519        Msg.setNextUInt32(dndActionDefault);
     520        Msg.setNextUInt32(dndActionListAllowed);
    518521        Msg.setNextPointer((void*)strFormats.c_str(), cbFormats);
    519522        Msg.setNextUInt32(cbFormats);
     
    528531            if (RT_SUCCESS(vrc))
    529532            {
    530                 resAction = GuestDnD::toMainAction(pResp->defAction());
     533                resAction = GuestDnD::toMainAction(pResp->getActionDefault());
    531534
    532535                GuestDnDMIMEList lstFormats = pResp->formats();
     
    534537                {
    535538                    aFormat = lstFormats.at(0);
    536                     LogFlowFunc(("resFormat=%s, resAction=%RU32\n", aFormat.c_str(), pResp->defAction()));
     539                    LogFlowFunc(("resFormat=%s, resAction=%RU32\n", aFormat.c_str(), pResp->getActionDefault()));
    537540                }
    538541                else
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