VirtualBox

Ignore:
Timestamp:
Oct 20, 2015 10:05:12 AM (9 years ago)
Author:
vboxsync
Message:

DnD: Updates/bugfixes:

  • Added separate VBOXDNDDISCONNECTMSG message for letting Main know about client disconnects.
  • Various cleanups and bugfixes.
File:
1 edited

Legend:

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

    r58257 r58329  
    866866    AssertPtrReturn(pMsg,    VERR_INVALID_POINTER);
    867867
    868     DnDURIObject *pObj = pObjCtx->pObjURI;
     868    DnDURIObject *pObj = pObjCtx->getObj();
    869869    AssertPtr(pObj);
    870870
     
    893893    AssertPtrReturn(pMsg,    VERR_INVALID_POINTER);
    894894
    895     DnDURIObject *pObj = pObjCtx->pObjURI;
     895    DnDURIObject *pObj = pObjCtx->getObj();
    896896    AssertPtr(pObj);
    897897
     
    920920        if (mDataBase.m_uProtocolVersion >= 2)
    921921        {
    922             if (!pObjCtx->fHeaderSent)
     922            uint32_t fState = pObjCtx->getState();
     923            if (!(fState & DND_OBJCTX_STATE_HAS_HDR))
    923924            {
    924925                /*
     
    941942                /** @todo Set progress object title to current file being transferred? */
    942943
    943                 pObjCtx->fHeaderSent = true;
     944                pObjCtx->setState(fState | DND_OBJCTX_STATE_HAS_HDR);
    944945            }
    945946            else
     
    972973    AssertPtrReturn(pMsg,    VERR_INVALID_POINTER);
    973974
    974     DnDURIObject *pObj = pObjCtx->pObjURI;
     975    DnDURIObject *pObj = pObjCtx->getObj();
    975976    AssertPtr(pObj);
    976977
     
    10581059    switch (uMsg)
    10591060    {
     1061        case GUEST_DND_CONNECT:
     1062            /* Nothing to do here (yet). */
     1063            break;
     1064
     1065        case GUEST_DND_DISCONNECT:
     1066            rc = VERR_CANCELLED;
     1067            break;
     1068
    10601069        case GUEST_DND_GET_NEXT_HOST_MSG:
    10611070        {
     
    12521261    rc = pCtx->mpResp->setCallback(x, i_sendURIDataCallback, pCtx); \
    12531262    if (RT_FAILURE(rc))                                             \
    1254         break;
     1263        return rc;
    12551264
    12561265#define UNREGISTER_CALLBACK(x)                        \
     
    12671276    if (RT_FAILURE(rc))
    12681277        return rc;
     1278
     1279    /*
     1280     * Register callbacks.
     1281     */
     1282    /* Guest callbacks. */
     1283    REGISTER_CALLBACK(GUEST_DND_CONNECT);
     1284    REGISTER_CALLBACK(GUEST_DND_DISCONNECT);
     1285    REGISTER_CALLBACK(GUEST_DND_GET_NEXT_HOST_MSG);
     1286    REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
     1287    /* Host callbacks. */
     1288    REGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
     1289    if (mDataBase.m_uProtocolVersion >= 2)
     1290        REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
     1291    REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
    12691292
    12701293    do
     
    12761299        GuestDnDURIData *pURI  = &pCtx->mURI;
    12771300
    1278         rc = pURI->fromMetaData(pData->getMeta());
     1301        rc = pURI->fromLocalMetaData(pData->getMeta());
    12791302        if (RT_FAILURE(rc))
    12801303            break;
     
    12911314
    12921315        /*
    1293          * Set the additional size we are going to send after the meta data header + meta data.
    1294          * This additional data will contain the actual file data we want to transfer.
     1316         * Set the estimated data sizes we are going to send.
     1317         * The total size also contains the meta data size.
    12951318         */
    1296         pData->setAdditionalSize(pURI->getURIList().TotalBytes());
    1297 
     1319        const uint32_t cbMeta = pData->getMeta().getSize();
     1320        pData->setEstimatedSize(pURI->getURIList().TotalBytes() + cbMeta /* cbTotal */,
     1321                                                                  cbMeta /* cbMeta  */);
     1322
     1323        /*
     1324         * Set the meta format.
     1325         */
    12981326        void    *pvFmt = (void *)pCtx->mFmtReq.c_str();
    12991327        uint32_t cbFmt = pCtx->mFmtReq.length() + 1;        /* Include terminating zero. */
     
    13261354        if (RT_SUCCESS(rc))
    13271355        {
    1328             /*
    1329              * Register callbacks.
    1330              */
    1331             /* Guest callbacks. */
    1332             REGISTER_CALLBACK(GUEST_DND_GET_NEXT_HOST_MSG);
    1333             REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1334             /* Host callbacks. */
    1335             REGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
    1336             if (mDataBase.m_uProtocolVersion >= 2)
    1337                 REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
    1338             REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
    1339 
    13401356            rc = waitForEvent(&pCtx->mCBEvent, pCtx->mpResp, msTimeout);
    1341             if (RT_FAILURE(rc))
    1342             {
    1343                 if (rc == VERR_CANCELLED)
    1344                     rc = pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED, VINF_SUCCESS);
    1345                 else if (rc != VERR_GSTDND_GUEST_ERROR) /* Guest-side error are already handled in the callback. */
    1346                     rc = pCtx->mpResp->setProgress(100, DND_PROGRESS_ERROR, rc,
    1347                                                    GuestDnDTarget::i_hostErrorToString(rc));
    1348             }
    1349             else
    1350                 rc = pCtx->mpResp->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
    1351 
    1352             /*
    1353              * Unregister callbacks.
    1354              */
    1355             /* Guest callbacks. */
    1356             UNREGISTER_CALLBACK(GUEST_DND_GET_NEXT_HOST_MSG);
    1357             UNREGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1358             /* Host callbacks. */
    1359             UNREGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
    1360             if (mDataBase.m_uProtocolVersion >= 2)
    1361                 UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
    1362             UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
     1357            if (RT_SUCCESS(rc))
     1358                pCtx->mpResp->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
    13631359        }
    13641360
    13651361    } while (0);
     1362
     1363    /*
     1364     * Unregister callbacks.
     1365     */
     1366    /* Guest callbacks. */
     1367    UNREGISTER_CALLBACK(GUEST_DND_CONNECT);
     1368    UNREGISTER_CALLBACK(GUEST_DND_DISCONNECT);
     1369    UNREGISTER_CALLBACK(GUEST_DND_GET_NEXT_HOST_MSG);
     1370    UNREGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
     1371    /* Host callbacks. */
     1372    UNREGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
     1373    if (mDataBase.m_uProtocolVersion >= 2)
     1374        UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
     1375    UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
    13661376
    13671377#undef REGISTER_CALLBACK
    13681378#undef UNREGISTER_CALLBACK
     1379
     1380    if (RT_FAILURE(rc))
     1381    {
     1382        if (rc == VERR_CANCELLED)
     1383            pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED, VINF_SUCCESS);
     1384        else if (rc != VERR_GSTDND_GUEST_ERROR) /* Guest-side error are already handled in the callback. */
     1385            pCtx->mpResp->setProgress(100, DND_PROGRESS_ERROR, rc,
     1386                                      GuestDnDTarget::i_hostErrorToString(rc));
     1387    }
    13691388
    13701389    /*
     
    14011420        return VERR_WRONG_ORDER;
    14021421
    1403     DnDURIObject *pCurObj = objCtx.pObjURI;
     1422    DnDURIObject *pCurObj = objCtx.getObj();
    14041423    AssertPtr(pCurObj);
    14051424
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