VirtualBox

Changeset 50460 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Feb 14, 2014 9:46:58 AM (11 years ago)
Author:
vboxsync
Message:

DnD: Update.

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestDnDImpl.cpp

    r50265 r50460  
    2424# include "GuestDnDImpl.h"
    2525
     26# include <iprt/dir.h>
     27# include <iprt/path.h>
     28# include <iprt/stream.h>
     29# include <iprt/semaphore.h>
     30# include <iprt/cpp/utils.h>
     31
    2632# include <VMMDev.h>
    2733
    2834# include <VBox/com/list.h>
     35# include <VBox/GuestHost/DragAndDrop.h>
    2936# include <VBox/HostServices/DragAndDropSvc.h>
    3037
     
    3441# define LOG_GROUP LOG_GROUP_GUEST_DND
    3542# include <VBox/log.h>
    36 
    37 # include <iprt/stream.h>
    38 # include <iprt/semaphore.h>
    39 # include <iprt/cpp/utils.h>
    4043
    4144/* How does this work:
     
    209212};
    210213
     214/** @todo This class needs a major cleanup. Later. */
    211215class GuestDnDPrivate
    212216{
    213217private:
    214     /* todo: currently we only support one response. Maybe this needs to be extended at some time. */
     218
     219    /** @todo Currently we only support one response. Maybe this needs to be extended at some time. */
    215220    GuestDnDPrivate(GuestDnD *q, const ComObjPtr<Guest>& pGuest)
    216221        : q_ptr(q)
     
    225230    void hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;
    226231
    227     /* Static helper */
     232    /* Static helpers. */
    228233    static RTCString           toFormatString(ComSafeArrayIn(IN_BSTR, formats));
    229234    static void                toFormatSafeArray(const RTCString &strFormats, ComSafeArrayOut(BSTR, formats));
     
    238243    ComObjPtr<Guest>                 p;
    239244
    240     /* Private helper members */
     245    /* Private helper members. */
    241246    static const RTCList<RTCString>  m_sstrAllowedMimeTypes;
    242247    DnDGuestResponse                *m_pDnDResponse;
     
    396401    ComPtr<IDisplay> pDisplay;
    397402    HRESULT rc = p->mParent->COMGETTER(Display)(pDisplay.asOutParam());
    398     if (FAILED(rc)) throw rc;
     403    if (FAILED(rc))
     404        throw rc;
     405
    399406    ComPtr<IFramebuffer> pFramebuffer;
    400407    LONG xShift, yShift;
    401     rc = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(), &xShift, &yShift);
    402     if (FAILED(rc)) throw rc;
     408    rc = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(),
     409                                  &xShift, &yShift);
     410    if (FAILED(rc))
     411        throw rc;
     412
    403413    *puX += xShift;
    404414    *puY += yShift;
     
    696706}
    697707
    698 HRESULT GuestDnD::dragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction)
     708HRESULT GuestDnD::dragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY,
     709                             DragAndDropAction_T defaultAction,
     710                             ComSafeArrayIn(DragAndDropAction_T, allowedActions),
     711                             ComSafeArrayIn(IN_BSTR, formats),
     712                             BSTR *pstrFormat,
     713                             DragAndDropAction_T *pResultAction)
    699714{
    700715    DPTR(GuestDnD);
     
    783798        pDnD->resetProgress(p);
    784799
     800        /* Note: The actual data transfer of files/directoies is performed by the
     801         *       DnD host service. */
    785802        d->hostCall(DragAndDropSvc::HOST_DND_HG_SND_DATA,
    786803                    i,
     
    854871
    855872    Utf8Str strFormat(bstrFormat);
    856     HRESULT rc = S_OK;
     873    HRESULT hr = S_OK;
    857874
    858875    uint32_t uAction = d->toHGCMAction(action);
     
    861878        return S_OK;
    862879
     880    const char *pcszFormat = strFormat.c_str();
     881    LogFlowFunc(("strFormat=%s, uAction=0x%x\n", pcszFormat, uAction));
     882    if (DnDMIMENeedsDropDir(pcszFormat, strlen(pcszFormat)))
     883    {
     884        char szDropDir[RTPATH_MAX];
     885        int rc = DnDDirCreateDroppedFiles(szDropDir, sizeof(szDropDir));
     886        if (RT_FAILURE(rc))
     887            return p->setError(VBOX_E_IPRT_ERROR,
     888                               p->tr("Unable to create the temporary drag'n drop directory \"%s\" (%Rrc)\n"),
     889                               szDropDir, rc);
     890        LogFlowFunc(("Dropped files directory on the host is: %s\n", szDropDir));
     891    }
     892
    863893    try
    864894    {
    865         LogFlowFunc(("strFormat=%s, uAction=0x%x\n", strFormat.c_str(), uAction));
    866 
    867895        VBOXHGCMSVCPARM paParms[3];
    868896        int i = 0;
     
    872900
    873901        DnDGuestResponse *pDnD = d->response();
     902
    874903        /* Reset any old data and the progress status. */
    875904        pDnD->reset();
     
    885914    catch (HRESULT rc2)
    886915    {
    887         rc = rc2;
    888     }
    889 
    890     return rc;
     916        hr = rc2;
     917    }
     918
     919    return hr;
    891920}
    892921
     
    906935        if (cbData)
    907936        {
    908             /* Copy the data into an safe array of bytes. */
     937            /* Copy the data into a safe array of bytes. */
    909938            const void *pvData = pDnD->data();
    910939            if (sfaData.resize(cbData))
     
    10061035            if (RT_SUCCESS(rc))
    10071036            {
     1037                /** @todo Store pCBData->cbAllSize in the guest's response struct
     1038                 *        if not set already. */
    10081039                uint32_t cbTotalSize = pCBData->cbAllSize;
    10091040                unsigned int cPercentage;
     
    10151046                /** @todo Don't use anonymous enums. */
    10161047                uint32_t uState = DragAndDropSvc::DND_PROGRESS_RUNNING;
    1017                 if (   pCBData->cbAllSize == cbCurSize
     1048                if (   cbTotalSize == cbCurSize
    10181049                    /* Empty data? Should not happen, but anyway ... */
    1019                     || !pCBData->cbAllSize)
     1050                    || !cbTotalSize)
    10201051                {
    10211052                    uState = DragAndDropSvc::DND_PROGRESS_COMPLETE;
     
    10241055                rc = pResp->setProgress(cPercentage, uState);
    10251056            }
    1026             /* Todo: for now we instantly confirm the cancel. Check if the
    1027              * guest should first clean up stuff itself and than really confirm
    1028              * the cancel request by an extra message. */
     1057
     1058            /** @todo For now we instantly confirm the cancel. Check if the
     1059             *        guest should first clean up stuff itself and than really confirm
     1060             *        the cancel request by an extra message. */
    10291061            if (rc == VERR_CANCELLED)
    10301062                pResp->setProgress(100, DragAndDropSvc::DND_PROGRESS_CANCELLED);
     
    10531085    return rc;
    10541086}
    1055 
    10561087#endif /* VBOX_WITH_DRAG_AND_DROP */
    10571088
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r50370 r50460  
    838838}
    839839
    840 STDMETHODIMP Guest::DragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction)
     840STDMETHODIMP Guest::DragHGEnter(ULONG uScreenId, ULONG uX, ULONG uY,
     841                                DragAndDropAction_T defaultAction,
     842                                ComSafeArrayIn(DragAndDropAction_T, allowedActions),
     843                                ComSafeArrayIn(IN_BSTR, formats),
     844                                DragAndDropAction_T *pResultAction)
    841845{
    842846    /* Input validation */
     
    849853
    850854#ifdef VBOX_WITH_DRAG_AND_DROP
    851     return m_pGuestDnD->dragHGEnter(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pResultAction);
     855    return m_pGuestDnD->dragHGEnter(uScreenId, uX, uY, defaultAction,
     856                                    ComSafeArrayInArg(allowedActions),
     857                                    ComSafeArrayInArg(formats),
     858                                    pResultAction);
    852859#else /* VBOX_WITH_DRAG_AND_DROP */
    853860    ReturnComNotImplemented();
     
    855862}
    856863
    857 STDMETHODIMP Guest::DragHGMove(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction)
     864STDMETHODIMP Guest::DragHGMove(ULONG uScreenId, ULONG uX, ULONG uY,
     865                               DragAndDropAction_T defaultAction,
     866                               ComSafeArrayIn(DragAndDropAction_T, allowedActions),
     867                               ComSafeArrayIn(IN_BSTR, formats),
     868                               DragAndDropAction_T *pResultAction)
    858869{
    859870    /* Input validation */
     
    866877
    867878#ifdef VBOX_WITH_DRAG_AND_DROP
    868     return m_pGuestDnD->dragHGMove(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pResultAction);
     879    return m_pGuestDnD->dragHGMove(uScreenId, uX, uY, defaultAction,
     880                                   ComSafeArrayInArg(allowedActions),
     881                                   ComSafeArrayInArg(formats),
     882                                   pResultAction);
    869883#else /* VBOX_WITH_DRAG_AND_DROP */
    870884    ReturnComNotImplemented();
     
    884898}
    885899
    886 STDMETHODIMP Guest::DragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction)
     900STDMETHODIMP Guest::DragHGDrop(ULONG uScreenId, ULONG uX, ULONG uY,
     901                               DragAndDropAction_T defaultAction,
     902                               ComSafeArrayIn(DragAndDropAction_T, allowedActions),
     903                               ComSafeArrayIn(IN_BSTR, formats),
     904                               BSTR *pstrFormat, DragAndDropAction_T *pResultAction)
    887905{
    888906    /* Input validation */
     
    896914
    897915#ifdef VBOX_WITH_DRAG_AND_DROP
    898     return m_pGuestDnD->dragHGDrop(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pstrFormat, pResultAction);
     916    return m_pGuestDnD->dragHGDrop(uScreenId, uX, uY,
     917                                   defaultAction,
     918                                   ComSafeArrayInArg(allowedActions),
     919                                   ComSafeArrayInArg(formats),
     920                                   pstrFormat, pResultAction);
    899921#else /* VBOX_WITH_DRAG_AND_DROP */
    900922    ReturnComNotImplemented();
     
    902924}
    903925
    904 STDMETHODIMP Guest::DragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress)
     926STDMETHODIMP Guest::DragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat,
     927                                  ComSafeArrayIn(BYTE, data),
     928                                  IProgress **ppProgress)
    905929{
    906930    /* Input validation */
     
    913937
    914938#ifdef VBOX_WITH_DRAG_AND_DROP
    915     return m_pGuestDnD->dragHGPutData(uScreenId, bstrFormat, ComSafeArrayInArg(data), ppProgress);
     939    return m_pGuestDnD->dragHGPutData(uScreenId, bstrFormat,
     940                                      ComSafeArrayInArg(data), ppProgress);
    916941#else /* VBOX_WITH_DRAG_AND_DROP */
    917942    ReturnComNotImplemented();
     
    919944}
    920945
    921 STDMETHODIMP Guest::DragGHPending(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction)
     946STDMETHODIMP Guest::DragGHPending(ULONG uScreenId,
     947                                  ComSafeArrayOut(BSTR, formats),
     948                                  ComSafeArrayOut(DragAndDropAction_T, allowedActions),
     949                                  DragAndDropAction_T *pDefaultAction)
    922950{
    923951    /* Input validation */
     
    930958
    931959#if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH)
    932     return m_pGuestDnD->dragGHPending(uScreenId, ComSafeArrayOutArg(formats), ComSafeArrayOutArg(allowedActions), pDefaultAction);
     960    return m_pGuestDnD->dragGHPending(uScreenId,
     961                                      ComSafeArrayOutArg(formats),
     962                                      ComSafeArrayOutArg(allowedActions),
     963                                      pDefaultAction);
    933964#else /* VBOX_WITH_DRAG_AND_DROP */
    934965    ReturnComNotImplemented();
     
    936967}
    937968
    938 STDMETHODIMP Guest::DragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action, IProgress **ppProgress)
     969STDMETHODIMP Guest::DragGHDropped(IN_BSTR bstrFormat, DragAndDropAction_T action,
     970                                  IProgress **ppProgress)
    939971{
    940972    /* Input validation */
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