VirtualBox

Changeset 55459 in vbox


Ignore:
Timestamp:
Apr 27, 2015 5:17:07 PM (9 years ago)
Author:
vboxsync
Message:

DnD: Bugfixes.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp

    r55422 r55459  
    223223
    224224static int vbglR3DnDHGProcessSendFileMessage(PVBGLR3GUESTDNDCMDCTX pCtx,
    225                                              char     *pszFilename,
    226                                              uint32_t  cbFilename,
    227                                              uint32_t *pcbFilenameRecv,
    228                                              void     *pvData,
    229                                              uint32_t  cbData,
    230                                              uint32_t *pcbDataRecv,
    231                                              uint32_t *pfMode)
     225                                             char                 *pszFilename,
     226                                             uint32_t              cbFilename,
     227                                             uint32_t             *pcbFilenameRecv,
     228                                             void                 *pvData,
     229                                             uint32_t              cbData,
     230                                             uint32_t             *pcbDataRecv,
     231                                             uint32_t             *pfMode)
    232232{
    233233    AssertPtrReturn(pCtx,            VERR_INVALID_POINTER);
     
    248248    {
    249249        Msg.u.v1.pvName.SetPtr(pszFilename, cbFilename);
    250         Msg.u.v1.cbName.SetUInt32(0);
     250        Msg.u.v1.cbName.SetUInt32(cbFilename);
    251251        Msg.u.v1.pvData.SetPtr(pvData, cbData);
    252         Msg.u.v1.cbData.SetUInt32(0);
     252        Msg.u.v1.cbData.SetUInt32(cbData);
    253253        Msg.u.v1.fMode.SetUInt32(0);
    254254
     
    257257    else
    258258    {
     259        Msg.u.v2.uContext.SetUInt32(0); /** @todo Not used yet. */
    259260        Msg.u.v2.pvData.SetPtr(pvData, cbData);
    260         Msg.u.v2.cbData.SetUInt32(0);
    261 
    262         Msg.hdr.cParms = 2;
     261        Msg.u.v2.cbData.SetUInt32(cbData);
     262
     263        Msg.hdr.cParms = 3;
    263264    }
    264265
     
    316317    else
    317318    {
     319        Msg.uContext.SetUInt32(0); /** @todo Not used yet. */
    318320        Msg.pvName.SetPtr(pszFilename, cbFilename);
    319         Msg.cbName.SetUInt32(0);
    320         Msg.uContext.SetUInt32(0); /** @todo Not used yet. */
     321        Msg.cbName.SetUInt32(cbFilename);
    321322        Msg.uFlags.SetUInt32(0);
    322323        Msg.fMode.SetUInt32(0);
     
    345346}
    346347
    347 static int vbglR3DnDHGProcessURIMessages(PVBGLR3GUESTDNDCMDCTX pCtx,
    348                                          uint32_t  *puScreenId,
    349                                          char      *pszFormat,
    350                                          uint32_t   cbFormat,
    351                                          uint32_t  *pcbFormatRecv,
    352                                          void     **ppvData,
    353                                          uint32_t   cbData,
    354                                          size_t    *pcbDataRecv)
     348static int vbglR3DnDHGProcessURIMessages(PVBGLR3GUESTDNDCMDCTX  pCtx,
     349                                         uint32_t              *puScreenId,
     350                                         char                  *pszFormat,
     351                                         uint32_t               cbFormat,
     352                                         uint32_t              *pcbFormatRecv,
     353                                         void                 **ppvData,
     354                                         uint32_t               cbData,
     355                                         size_t                *pcbDataRecv)
    355356{
    356357    AssertPtrReturn(pCtx,        VERR_INVALID_POINTER);
     
    475476                                                           &cbDataRecv,
    476477                                                           &fMode);
    477                     LogFlowFunc(("HOST_DND_HG_SND_FILE pszPathName=%s, cbPathName=%RU32, pvData=0x%p, cbDataRecv=%RU32, fMode=0x%x, rc=%Rrc\n",
     478                    LogFlowFunc(("HOST_DND_HG_SND_FILE_DATA pszPathName=%s, cbPathName=%RU32, pvData=0x%p, cbDataRecv=%RU32, fMode=0x%x, rc=%Rrc\n",
    478479                                 szPathName, cbPathName, pvTmpData, cbDataRecv, fMode, rc));
    479480
  • trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp

    r55422 r55459  
    335335 ******************************************************************************/
    336336
     337#ifdef DEBUG
     338# define VBOX_DND_FN_DECL_LOG(x) inline x
     339#else
     340# define VBOX_DND_FN_DECL_LOG(x) x
     341#endif
     342
    337343/* For now only one DragInstance will exits when the app is running. In the
    338344 * future the support for having more than one D&D operation supported at the
     
    364370    void uninit(void);
    365371    void reset(void);
     372
     373    /* Logging. */
     374    VBOX_DND_FN_DECL_LOG(void) logError(const char *pszFormat, ...);
    366375
    367376    /* X11 message processing. */
     
    628637        if (!m_wndProxy)
    629638        {
     639            LogRel(("DnD: Error creating proxy window\n"));
    630640            rc = VERR_GENERAL_FAILURE;
    631641            break;
     
    654664    LogFlowFuncLeaveRC(rc);
    655665    return rc;
     666}
     667
     668VBOX_DND_FN_DECL_LOG(void) DragInstance::logError(const char *pszFormat, ...)
     669{
     670    va_list args;
     671    va_start(args, pszFormat);
     672    char *psz = NULL;
     673    RTStrAPrintfV(&psz, pszFormat, args);
     674    va_end(args);
     675
     676    AssertPtr(psz);
     677    LogFlowFunc(("%s", psz));
     678    LogRel2(("DnD: %s", psz));
     679
     680    RTStrFree(psz);
    656681}
    657682
     
    10891114    if (   m_mode  != HG
    10901115        || m_state != Dragging)
     1116    {
    10911117        return VERR_INVALID_STATE;
     1118    }
    10921119
    10931120    int rc  = VINF_SUCCESS;
     
    11161143
    11171144        if (RT_UNLIKELY(xrc != Success))
    1118             LogFlowThisFunc(("Error in getting the window property: %s\n", gX11->xErrorToString(xrc).c_str()));
     1145            logError("Error getting properties of cursor window=%#x: %s\n", wndCursor, gX11->xErrorToString(xrc).c_str());
    11191146        else
    11201147        {
    11211148            if (RT_UNLIKELY(pcData == NULL || fmt != 32 || cItems != 1))
    1122                 LogFlowThisFunc(("Wrong properties pcData=%#x, iFmt=%u, cItems=%u\n", pcData, fmt, cItems));
     1149                LogFlowThisFunc(("Wrong properties: pcData=%#x, iFmt=%d, cItems=%ul\n", pcData, fmt, cItems));
    11231150            else
    11241151            {
    11251152                newVer = reinterpret_cast<long*>(pcData)[0];
    1126                 LogFlowThisFunc(("wndCursor=%#x, XdndAware=%u\n", newVer));
     1153                LogFlowThisFunc(("wndCursor=%#x, XdndAware=%ld\n", wndCursor, newVer));
    11271154            }
    11281155
     
    11351162     */
    11361163    if (   wndCursor != m_wndCur
    1137         && m_curVer != -1)
     1164        && m_curVer  != -1)
    11381165    {
    11391166        LogFlowThisFunc(("Leaving window=%#x\n", m_wndCur));
     
    11511178        xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    11521179        if (RT_UNLIKELY(xrc == 0))
    1153             LogFlowThisFunc(("Error sending XA_XdndLeave to old window=%#x\n", m_wndCur));
     1180            logError("DnD: Error sending XA_XdndLeave to old window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xrc).c_str());
    11541181    }
    11551182
     
    11571184     * Do we have a new window which now is under the cursor?
    11581185     */
    1159     if (wndCursor != m_wndCur && newVer != -1)
     1186    if (   wndCursor != m_wndCur
     1187        && newVer    != -1)
    11601188    {
    11611189        LogFlowThisFunc(("Entering window=%#x\n", wndCursor));
     
    11821210        xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    11831211        if (RT_UNLIKELY(xrc == 0))
    1184             LogFlowThisFunc(("Error sending XA_XdndEnter to new window=%#x\n", wndCursor));
     1212            logError("Error sending XA_XdndEnter to new window=%#x: %s\n", wndCursor, gX11->xErrorToString(xrc).c_str());
    11851213    }
    11861214
    11871215    if (newVer != -1)
    11881216    {
    1189         LogFlowThisFunc(("Moving window=%#x, xPos=%RU32, yPos=%RU32\n",
    1190                          wndCursor, u32xPos, u32yPos));
     1217        LogFlowThisFunc(("Moving window=%#x, xPos=%RU32, yPos=%RU32\n", wndCursor, u32xPos, u32yPos));
    11911218
    11921219        /*
     
    12101237        xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    12111238        if (RT_UNLIKELY(xrc == 0))
    1212             LogFlowThisFunc(("Error sending XA_XdndPosition to window=%#x\n", wndCursor));
     1239            logError(("Error sending XA_XdndPosition to current window=%#x: %s\n", wndCursor, gX11->xErrorToString(xrc).c_str()));
    12131240    }
    12141241
     
    12511278    int xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    12521279    if (RT_UNLIKELY(xrc == 0))
    1253         LogFlowThisFunc(("Error sending XA_XdndDrop to window=%#x\n", m_wndCur));
     1280        logError(("Error sending XA_XdndDrop to current window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xrc).c_str()));
    12541281
    12551282    m_wndCur = None;
     
    13101337    int xrc = XSendEvent(s.xselection.display, s.xselection.requestor, True, 0, &s);
    13111338    if (RT_UNLIKELY(xrc == 0))
    1312         LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", s.xselection.requestor));
     1339    {
     1340        logError(("Error sending SelectionNotify event to window=%#x: %s\n",
     1341                  s.xselection.requestor, gX11->xErrorToString(xrc).c_str()));
     1342    }
    13131343
    13141344    return VINF_SUCCESS;
     
    14181448                }
    14191449
    1420                 /* Acknowledge the event by sending a Status msg back to the
    1421                  * window. */
     1450                /*
     1451                 * Acknowledge the event by sending a status message back to the window.
     1452                 */
    14221453                XClientMessageEvent m;
    14231454                RT_ZERO(m);
     
    14341465                                 False, 0, reinterpret_cast<XEvent*>(&m));
    14351466                if (RT_UNLIKELY(xRc == 0))
    1436                     LogFlowThisFunc(("Error sending xEvent\n"));
     1467                {
     1468                    logError(("Error sending enter XA_XdndStatus to current window=%#x: %s\n",
     1469                              m_wndCur, gX11->xErrorToString(xRc).c_str()));
     1470                }
    14371471            }
    14381472            /* Did the source tell us where the cursor currently is? */
     
    14571491                                 False, 0, reinterpret_cast<XEvent*>(&m));
    14581492                if (RT_UNLIKELY(xRc == 0))
    1459                     LogFlowThisFunc(("Error sending xEvent\n"));
     1493                {
     1494                    logError(("Error sending position XA_XdndStatus to current window=%#x: %s\n",
     1495                              m_wndCur, gX11->xErrorToString(xRc).c_str()));
     1496                }
    14601497            }
    14611498            else if (pEventClient->message_type == xAtom(XA_XdndLeave))
     
    16531690                    int xrc = XSendEvent(m_pDisplay, wndSource, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    16541691                    if (RT_UNLIKELY(xrc == 0))
    1655                         LogFlowThisFunc(("Error sending cancel event\n"));
     1692                    {
     1693                        logError(("Error sending XA_XdndFinished to proxy window=%#x: %s\n",
     1694                                  m_wndProxy, gX11->xErrorToString(xrc).c_str()));
     1695                    }
    16561696                }
    16571697
     
    18721912}
    18731913
    1874 void DragInstance::setActionsWindowProperty(Window wndThis,
    1875                                             const RTCList<Atom> &lstActions) const
     1914void DragInstance::setActionsWindowProperty(Window wndThis, const RTCList<Atom> &lstActions) const
    18761915{
    18771916    if (lstActions.isEmpty())
     
    18901929}
    18911930
    1892 void DragInstance::setFormatsWindowProperty(Window wndThis,
    1893                                             Atom property) const
     1931void DragInstance::setFormatsWindowProperty(Window wndThis, Atom property) const
    18941932{
    18951933    if (m_formats.isEmpty())
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r55427 r55459  
    530530    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    531531
    532     HRESULT hr;
     532    HRESULT hr = S_OK;
    533533    int vrc;
    534534
     
    682682    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    683683
    684     RTCString strPath = aFile.GetDestPath();
    685     if (strPath.isEmpty())
     684    RTCString strPathSrc = aFile.GetSourcePath();
     685    if (strPathSrc.isEmpty())
    686686        return VERR_INVALID_PARAMETER;
    687687
     
    689689
    690690    LogFlowFunc(("Sending \"%s\" (%RU32 bytes buffer) using protocol v%RU32 ...\n",
    691                  aFile.GetDestPath().c_str(), m_cbBlockSize, mData.mProtocolVersion));
     691                 strPathSrc.c_str(), m_cbBlockSize, mData.mProtocolVersion));
     692
     693    bool fOpen = aFile.IsOpen();
     694    if (!fOpen)
     695    {
     696        LogFlowFunc(("Opening \"%s\" ...\n", strPathSrc.c_str()));
     697        rc = aFile.OpenEx(strPathSrc, DnDURIObject::File, DnDURIObject::Source,
     698                          RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 0 /* fFlags */);           
     699    }
    692700
    693701    bool fSendFileData = false;
    694     if (mData.mProtocolVersion >= 2)
    695     {
    696         if (!aFile.IsOpen())
    697         {
    698             rc = aFile.OpenEx(aFile.GetSourcePath(), DnDURIObject::File, DnDURIObject::Source,
    699                               RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 0 /* fFlags */);
    700             if (RT_SUCCESS(rc))
     702    if (RT_SUCCESS(rc))
     703    {
     704        if (mData.mProtocolVersion >= 2)
     705        {
     706            if (!fOpen)
    701707            {
    702708                /*
     
    706712                 */
    707713                pMsg->setType(DragAndDropSvc::HOST_DND_HG_SND_FILE_HDR);
    708                 pMsg->setNextUInt32(0);                                /* context ID */
    709                 pMsg->setNextString(strPath.c_str());                  /* pvName */
    710                 pMsg->setNextUInt32((uint32_t)(strPath.length() + 1)); /* cbName */
    711                 pMsg->setNextUInt32(0);                                /* uFlags */
    712                 pMsg->setNextUInt32(aFile.GetMode());                  /* fMode */
    713                 pMsg->setNextUInt64(aFile.GetSize());                  /* uSize */
     714                pMsg->setNextUInt32(0);                                            /* context ID */
     715                rc = pMsg->setNextString(aFile.GetDestPath().c_str());             /* pvName */
     716                AssertRC(rc);
     717                pMsg->setNextUInt32((uint32_t)(aFile.GetDestPath().length() + 1)); /* cbName */
     718                pMsg->setNextUInt32(0);                                            /* uFlags */
     719                pMsg->setNextUInt32(aFile.GetMode());                              /* fMode */
     720                pMsg->setNextUInt64(aFile.GetSize());                              /* uSize */
    714721
    715722                LogFlowFunc(("Sending file header ...\n"));
    716723            }
    717         }
    718         else
    719         {
    720             /* File header was sent, so only send the actual file data. */
     724            else
     725            {
     726                /* File header was sent, so only send the actual file data. */
     727                fSendFileData = true;
     728            }
     729        }
     730        else /* Protocol v1. */
     731        {
     732            /* Always send the file data, every time. */
    721733            fSendFileData = true;
    722734        }
    723     }
    724     else /* Protocol v1. */
    725     {
    726         /* Always send the file data, every time. */
    727         fSendFileData = true;
    728735    }
    729736
     
    766773    if (mData.mProtocolVersion <= 1)
    767774    {
    768         pMsg->setNextUInt32(0);                                              /* context ID */
    769775        pMsg->setNextString(aFile.GetSourcePath().c_str());                  /* pvName */
    770776        pMsg->setNextUInt32((uint32_t)(aFile.GetSourcePath().length() + 1)); /* cbName */
     777    }
     778    else
     779    {
     780        /* Protocol version 2 also sends the context ID. Currently unused. */
     781        pMsg->setNextUInt32(0);                                              /* context ID */
    771782    }
    772783
     
    869880            AssertReturn(DragAndDropSvc::CB_MAGIC_DND_HG_GET_NEXT_HOST_MSG_DATA == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER);
    870881
     882            LogFlowFunc(("pCBData->uMsg=%RU32, paParms=%p, cParms=%RU32\n", pCBData->uMsg, pCBData->paParms, pCBData->cParms));
     883
    871884            GuestDnDMsg *pMsg = pThis->nextMsg();
    872885            if (pMsg)
     
    884897                if (RT_SUCCESS(rc))
    885898                {
    886                     LogFlowFunc(("Sending uMsg=%RU32, cParms=%RU32 ...\n", uMsg, pCBData->cParms));
     899                    LogFlowFunc(("Returning uMsg=%RU32\n", uMsg));
    887900                    rc = HGCM::Message::copyParms(pMsg->getCount(), pMsg->getParms(), pCBData->paParms);
    888901                    if (RT_SUCCESS(rc))
     
    891904                        pThis->removeNext();
    892905                    }
     906                    else
     907                        LogFlowFunc(("Copying parameters failed with rc=%Rrc\n", rc));
    893908                }
    894909            }
     
    896911                rc = VERR_NO_DATA;
    897912
    898             LogFlowFunc(("Returning msg %RU32, rc=%Rrc\n", uMsg, rc));
     913            LogFlowFunc(("Processing next message ended with rc=%Rrc\n", rc));
    899914            break;
    900915        }
     
    9921007            break;
    9931008
     1009        pCtx->mURI.cbProcessed = 0;
     1010        pCtx->mURI.cProcessed  = 0;
     1011        pCtx->mURI.cbToProcess = lstURI.TotalBytes();
     1012
    9941013        /*
    9951014         * The first message always is the meta info for the data. The meta
     
    10441063#undef UNREGISTER_CALLBACK
    10451064
     1065    /* Destroy temporary scratch buffer. */
    10461066    if (pvBuf)
    10471067        RTMemFree(pvBuf);
     
    10551075int GuestDnDTarget::i_sendURIDataLoop(PSENDDATACTX pCtx, GuestDnDMsg *pMsg)
    10561076{
    1057     AssertPtrReturn(pCtx,  VERR_INVALID_POINTER);
     1077    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    10581078
    10591079    DnDURIList &lstURI = pCtx->mURI.lstURI;
     
    10611081    int rc;
    10621082
    1063     uint64_t cbTotal = pCtx->mURI.lstURI.TotalBytes();
     1083    uint64_t cbTotal = pCtx->mURI.cbToProcess;
    10641084    uint8_t uPercent = pCtx->mURI.cbProcessed * 100 / (cbTotal ? cbTotal : 1);
    1065     Assert(uPercent <= 100);
    10661085
    10671086    LogFlowFunc(("%RU64 / %RU64 -- %RU8%%\n", pCtx->mURI.cbProcessed, cbTotal, uPercent));
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