VirtualBox

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


Ignore:
Timestamp:
Feb 24, 2014 9:07:22 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92425
Message:

DnD: Update, bugfixes.

File:
1 edited

Legend:

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

    r50508 r50561  
    239239    DnDGuestResponse *response(void) const { return m_pDnDResponse; }
    240240
    241     void adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const;
    242     void hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;
     241    HRESULT adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const;
     242    int hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;
    243243
    244244    /* Static helpers. */
     
    310310int DnDGuestResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */)
    311311{
    312     int vrc = RTSemEventWait(m_EventSem, msTimeout);
     312    int rc = RTSemEventWait(m_EventSem, msTimeout);
    313313#ifdef DEBUG_andy
    314     LogFlowFunc(("msTimeout=%RU32, rc=%Rrc\n", msTimeout, vrc));
     314    LogFlowFunc(("msTimeout=%RU32, rc=%Rrc\n", msTimeout, rc));
    315315#endif
    316     return vrc;
     316    return rc;
    317317}
    318318
     
    350350        m_pvData = NULL;
    351351    }
    352 
    353352    m_cbData = 0;
     353
     354    m_cbDataCurrent = 0;
     355    m_cbDataTotal = 0;
    354356}
    355357
     
    377379    {
    378380        BOOL fCompleted;
    379         HRESULT rc = m_progress->COMGETTER(Completed)(&fCompleted);
     381        HRESULT hr = m_progress->COMGETTER(Completed)(&fCompleted);
    380382        if (!fCompleted)
    381383        {
    382384            if (uState == DragAndDropSvc::DND_PROGRESS_ERROR)
    383385            {
    384                 rc = m_progress->notifyComplete(E_FAIL,
     386                hr = m_progress->notifyComplete(E_FAIL,
    385387                                                COM_IIDOF(IGuest),
    386388                                                m_parent->getComponentName(),
    387389                                                m_parent->tr("Drag'n drop guest error (%Rrc)"), rcOp);
     390                reset();
    388391            }
    389392            else if (uState == DragAndDropSvc::DND_PROGRESS_CANCELLED)
    390393            {
    391                 rc = m_progress->Cancel();
    392                 vrc = VERR_CANCELLED;
     394                hr = m_progress->Cancel();
     395                if (SUCCEEDED(hr))
     396                    vrc = VERR_CANCELLED;
     397
     398                reset();
    393399            }
    394400            else /* uState == DragAndDropSvc::DND_PROGRESS_RUNNING */
    395401            {
    396                 rc = m_progress->SetCurrentOperationProgress(uPercentage);
    397 #ifndef DEBUG_andy
    398                 Assert(SUCCEEDED(rc));
    399 #endif
     402                hr = m_progress->SetCurrentOperationProgress(uPercentage);
     403                AssertComRC(hr);
    400404                if (   uState      == DragAndDropSvc::DND_PROGRESS_COMPLETE
    401405                    || uPercentage >= 100)
    402                     rc = m_progress->notifyComplete(S_OK);
     406                    hr = m_progress->notifyComplete(S_OK);
    403407            }
     408        }
     409    }
     410
     411    return vrc;
     412}
     413
     414int DnDGuestResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */)
     415{
     416    if (cbDataTotal)
     417    {
    404418#ifndef DEBUG_andy
    405             Assert(SUCCEEDED(rc));
     419        AssertMsg(m_cbDataTotal <= cbDataTotal, ("New data size must not be smaller (%zu) than old value (%zu)\n",
     420                                                 cbDataTotal, m_cbDataTotal));
    406421#endif
    407         }
    408     }
    409 
    410     return vrc;
    411 }
    412 
    413 int DnDGuestResponse::dataSetStatus(size_t cbDataAdd, size_t cbDataTotal /* = 0 */)
    414 {
    415     if (cbDataTotal)
    416     {
    417         AssertMsg(m_cbDataTotal <= cbDataTotal, ("New data size size must not be smaller (%zu) than old value (%zu)\n",
    418                                                  cbDataTotal, m_cbDataTotal));
     422        LogFlowFunc(("Updating total data size from %zu to %zu\n", m_cbDataTotal, cbDataTotal));
    419423        m_cbDataTotal = cbDataTotal;
    420         LogFlowFunc(("Updating total data size to: %zu\n", m_cbDataTotal));
    421424    }
    422425    AssertMsg(m_cbDataTotal, ("m_cbDataTotal must not be <= 0\n"));
     
    433436    LogFlowFunc(("Updating transfer status (%zu/%zu), status=%ld\n",
    434437                 m_cbDataCurrent, m_cbDataTotal, uStatus));
    435 #endif
    436 
     438#else
    437439    AssertMsg(m_cbDataCurrent <= m_cbDataTotal,
    438440              ("More data transferred (%RU32) than initially announced (%RU32)\n",
    439441              m_cbDataCurrent, m_cbDataTotal));
    440 
     442#endif
    441443    int rc = setProgress(cPercentage, uStatus);
    442444
     
    455457}
    456458
    457 void GuestDnDPrivate::adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const
     459HRESULT GuestDnDPrivate::adjustCoords(ULONG uScreenId, ULONG *puX, ULONG *puY) const
    458460{
    459461    /* For multi-monitor support we need to add shift values to the coordinates
    460462     * (depending on the screen number). */
    461463    ComPtr<IDisplay> pDisplay;
    462     HRESULT rc = p->mParent->COMGETTER(Display)(pDisplay.asOutParam());
    463     if (FAILED(rc))
    464         throw rc;
     464    HRESULT hr = p->mParent->COMGETTER(Display)(pDisplay.asOutParam());
     465    if (FAILED(hr))
     466        return hr;
    465467
    466468    ComPtr<IFramebuffer> pFramebuffer;
    467469    LONG xShift, yShift;
    468     rc = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(),
     470    hr = pDisplay->GetFramebuffer(uScreenId, pFramebuffer.asOutParam(),
    469471                                  &xShift, &yShift);
    470     if (FAILED(rc))
    471         throw rc;
     472    if (FAILED(hr))
     473        return hr;
    472474
    473475    *puX += xShift;
    474476    *puY += yShift;
    475 }
    476 
    477 void GuestDnDPrivate::hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const
    478 {
    479     VMMDev *vmmDev = NULL;
     477
     478    return hr;
     479}
     480
     481int GuestDnDPrivate::hostCall(uint32_t u32Function, uint32_t cParms,
     482                              PVBOXHGCMSVCPARM paParms) const
     483{
     484    VMMDev *pVMMDev = NULL;
    480485    {
    481486        /* Make sure mParent is valid, so set the read lock while using.
     
    486491        /* Forward the information to the VMM device. */
    487492        AssertPtr(p->mParent);
    488         vmmDev = p->mParent->getVMMDev();
    489     }
    490 
    491     if (!vmmDev)
     493        pVMMDev = p->mParent->getVMMDev();
     494    }
     495
     496    if (!pVMMDev)
    492497        throw p->setError(VBOX_E_VM_ERROR,
    493498                          p->tr("VMM device is not available (is the VM running?)"));
    494499
    495500    LogFlowFunc(("hgcmHostCall msg=%RU32, numParms=%RU32\n", u32Function, cParms));
    496     int vrc = vmmDev->hgcmHostCall("VBoxDragAndDropSvc",
     501    int rc = pVMMDev->hgcmHostCall("VBoxDragAndDropSvc",
    497502                                   u32Function,
    498503                                   cParms, paParms);
    499     if (RT_FAILURE(vrc))
    500     {
    501         LogFlowFunc(("hgcmHostCall error: %Rrc\n", vrc));
     504    if (RT_FAILURE(rc))
     505    {
     506        LogFlowFunc(("hgcmHostCall error: %Rrc\n", rc));
    502507        throw p->setError(VBOX_E_VM_ERROR,
    503                           p->tr("hgcmHostCall failed (%Rrc)"), vrc);
    504     }
     508                          p->tr("hgcmHostCall failed (%Rrc)"), rc);
     509    }
     510
     511    return rc;
    505512}
    506513
     
    653660        return S_OK;
    654661
    655     HRESULT rc = S_OK;
     662    HRESULT hr = S_OK;
    656663
    657664    try
     
    674681                    paParms);
    675682
    676         DnDGuestResponse *pDnD = d->response();
     683        DnDGuestResponse *pResp = d->response();
    677684        /* This blocks until the request is answered (or timeout). */
    678         if (pDnD->waitForGuestResponse() == VERR_TIMEOUT)
     685        if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
    679686            return S_OK;
    680687
    681688        /* Copy the response info */
    682         *pResultAction = d->toMainAction(pDnD->defAction());
     689        *pResultAction = d->toMainAction(pResp->defAction());
    683690        LogFlowFunc(("*pResultAction=%ld\n", *pResultAction));
    684691    }
    685     catch (HRESULT rc2)
    686     {
    687         rc = rc2;
    688     }
    689 
    690     return rc;
     692    catch (HRESULT hr2)
     693    {
     694        hr = hr2;
     695    }
     696
     697    return hr;
    691698}
    692699
     
    717724        return S_OK;
    718725
    719     HRESULT rc = S_OK;
     726    HRESULT hr = S_OK;
    720727
    721728    try
     
    738745                    paParms);
    739746
    740         DnDGuestResponse *pDnD = d->response();
     747        DnDGuestResponse *pResp = d->response();
    741748        /* This blocks until the request is answered (or timeout). */
    742         if (pDnD->waitForGuestResponse() == VERR_TIMEOUT)
     749        if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
    743750            return S_OK;
    744751
    745752        /* Copy the response info */
    746         *pResultAction = d->toMainAction(pDnD->defAction());
     753        *pResultAction = d->toMainAction(pResp->defAction());
    747754        LogFlowFunc(("*pResultAction=%ld\n", *pResultAction));
    748755    }
    749     catch (HRESULT rc2)
    750     {
    751         rc = rc2;
    752     }
    753 
    754     return rc;
     756    catch (HRESULT hr2)
     757    {
     758        hr = hr2;
     759    }
     760
     761    return hr;
    755762}
    756763
     
    760767    const ComObjPtr<Guest> &p = d->p;
    761768
    762     HRESULT rc = S_OK;
     769    HRESULT hr = S_OK;
    763770
    764771    try
     
    768775                    NULL);
    769776
    770         DnDGuestResponse *pDnD = d->response();
     777        DnDGuestResponse *pResp = d->response();
    771778        /* This blocks until the request is answered (or timeout). */
    772         pDnD->waitForGuestResponse();
    773     }
    774     catch (HRESULT rc2)
    775     {
    776         rc = rc2;
    777     }
    778 
    779     return rc;
     779        pResp->waitForGuestResponse();
     780    }
     781    catch (HRESULT hr2)
     782    {
     783        hr = hr2;
     784    }
     785
     786    return hr;
    780787}
    781788
     
    807814        return S_OK;
    808815
    809     HRESULT rc = S_OK;
     816    HRESULT hr = S_OK;
    810817
    811818    try
     
    828835                    paParms);
    829836
    830         DnDGuestResponse *pDnD = d->response();
     837        DnDGuestResponse *pResp = d->response();
    831838        /* This blocks until the request is answered (or timeout). */
    832         if (pDnD->waitForGuestResponse() == VERR_TIMEOUT)
     839        if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
    833840            return S_OK;
    834841
    835842        /* Copy the response info */
    836         *pResultAction = d->toMainAction(pDnD->defAction());
    837         Bstr(pDnD->format()).cloneTo(pstrFormat);
     843        *pResultAction = d->toMainAction(pResp->defAction());
     844        Bstr(pResp->format()).cloneTo(pstrFormat);
    838845
    839846        LogFlowFunc(("*pResultAction=%ld\n", *pResultAction));
    840847    }
    841     catch (HRESULT rc2)
    842     {
    843         rc = rc2;
    844     }
    845 
    846     return rc;
     848    catch (HRESULT hr2)
     849    {
     850        hr = hr2;
     851    }
     852
     853    return hr;
    847854}
    848855
     
    853860    const ComObjPtr<Guest> &p = d->p;
    854861
    855     HRESULT rc = S_OK;
     862    HRESULT hr = S_OK;
    856863
    857864    try
     
    868875        paParms[i++].setUInt32((uint32_t)sfaData.size());
    869876
    870         DnDGuestResponse *pDnD = d->response();
     877        DnDGuestResponse *pResp = d->response();
    871878        /* Reset any old progress status. */
    872         pDnD->resetProgress(p);
     879        pResp->resetProgress(p);
    873880
    874881        /* Note: The actual data transfer of files/directoies is performed by the
     
    879886
    880887        /* Query the progress object to the caller. */
    881         pDnD->queryProgressTo(ppProgress);
    882     }
    883     catch (HRESULT rc2)
    884     {
    885         rc = rc2;
    886     }
    887 
    888     return rc;
     888        pResp->queryProgressTo(ppProgress);
     889    }
     890    catch (HRESULT hr2)
     891    {
     892        hr = hr2;
     893    }
     894
     895    return hr;
    889896}
    890897
     
    901908    *pDefaultAction = DragAndDropAction_Ignore;
    902909
    903     HRESULT rc = S_OK;
     910    HRESULT hr = S_OK;
    904911
    905912    try
     
    913920                    paParms);
    914921
    915         DnDGuestResponse *pDnD = d->response();
    916         /* This blocks until the request is answered (or timeout). */
    917         if (pDnD->waitForGuestResponse() == VERR_TIMEOUT)
     922        /* This blocks until the request is answered (or timed out). */
     923        DnDGuestResponse *pResp = d->response();
     924        if (pResp->waitForGuestResponse() == VERR_TIMEOUT)
    918925            return S_OK;
    919926
    920         if (isDnDIgnoreAction(pDnD->defAction()))
     927        if (isDnDIgnoreAction(pResp->defAction()))
    921928            return S_OK;
    922929
    923930        /* Fetch the default action to use. */
    924         *pDefaultAction = d->toMainAction(pDnD->defAction());
    925         /* Convert the formats strings to a vector of strings. */
    926         d->toFormatSafeArray(pDnD->format(), ComSafeArrayOutArg(formats));
    927         /* Convert the action bit field to a vector of actions. */
    928         d->toMainActions(pDnD->allActions(), ComSafeArrayOutArg(allowedActions));
     931        *pDefaultAction = d->toMainAction(pResp->defAction());
     932        d->toFormatSafeArray(pResp->format(), ComSafeArrayOutArg(formats));
     933        d->toMainActions(pResp->allActions(), ComSafeArrayOutArg(allowedActions));
    929934
    930935        LogFlowFunc(("*pDefaultAction=0x%x\n", *pDefaultAction));
    931936    }
    932     catch (HRESULT rc2)
    933     {
    934         rc = rc2;
    935     }
    936 
    937     return rc;
     937    catch (HRESULT hr2)
     938    {
     939        hr = hr2;
     940    }
     941
     942    return hr;
    938943}
    939944
     
    957962                 pcszFormat, uAction, fNeedsDropDir));
    958963
    959     DnDGuestResponse *pDnD = d->response();
    960     AssertPtr(pDnD);
     964    DnDGuestResponse *pResp = d->response();
     965    AssertPtr(pResp);
     966
     967    pResp->reset();
    961968
    962969    if (fNeedsDropDir)
     
    970977        LogFlowFunc(("Dropped files directory on the host is: %s\n", szDropDir));
    971978
    972         pDnD->setDropDir(szDropDir);
     979        pResp->setDropDir(szDropDir);
    973980    }
    974981
     
    982989
    983990        /* Reset any old data and the progress status. */
    984         pDnD->reset();
    985         pDnD->resetProgress(p);
     991        pResp->reset();
     992        pResp->resetProgress(p);
    986993
    987994        d->hostCall(DragAndDropSvc::HOST_DND_GH_EVT_DROPPED,
     
    990997
    991998        /* Query the progress object to the caller. */
    992         pDnD->queryProgressTo(ppProgress);
    993     }
    994     catch (HRESULT rc2)
    995     {
    996         hr = rc2;
     999        pResp->queryProgressTo(ppProgress);
     1000    }
     1001    catch (HRESULT hr2)
     1002    {
     1003        hr = hr2;
    9971004    }
    9981005
     
    10191026
    10201027            Utf8Str strFormat = pResp->format();
    1021             LogFlowFunc(("strFormat=%s, strDropDir=%s\n",
    1022                          strFormat.c_str(), pResp->dropDir().c_str()));
     1028            LogFlowFunc(("strFormat=%s, cbData=%zu, pvData=0x%p\n",
     1029                         strFormat.c_str(), cbData, pvData));
    10231030
    10241031            if (DnDMIMEHasFileURLs(strFormat.c_str(), strFormat.length()))
    10251032            {
     1033                LogFlowFunc(("strDropDir=%s\n", pResp->dropDir().c_str()));
     1034
    10261035                DnDURIList lstURI;
    10271036                int rc2 = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */);
     
    10291038                {
    10301039                    Utf8Str strURIs = lstURI.RootToString(pResp->dropDir());
    1031                     if (sfaData.resize(strURIs.length()))
    1032                         memcpy(sfaData.raw(), strURIs.c_str(), strURIs.length());
     1040                    size_t cbURIs = strURIs.length();
     1041                    if (sfaData.resize(cbURIs + 1 /* Include termination */))
     1042                        memcpy(sfaData.raw(), strURIs.c_str(), cbURIs);
    10331043                    else
    10341044                        hr = E_OUTOFMEMORY;
     
    10491059        }
    10501060
    1051         LogFlowFunc(("cbData=%zu\n", cbData));
    1052 
    10531061        /* Detach in any case, regardless of data size. */
    10541062        sfaData.detachTo(ComSafeArrayOutArg(data));
Note: See TracChangeset for help on using the changeset viewer.

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