Пример #1
0
int DnDHGSendDataMessage::progressCallback(size_t cbDone, void *pvUser)
{
    AssertPtrReturn(pvUser, VERR_INVALID_POINTER);

    DnDHGSendDataMessage *pSelf = static_cast<DnDHGSendDataMessage *>(pvUser);
    AssertPtr(pSelf);

    /* How many bytes are transfered already. */
    pSelf->m_cbTransfered += cbDone;

    /* Advance progress info. */
    int rc = VINF_SUCCESS;
    if (   pSelf->m_pfnProgressCallback
        && pSelf->m_cbTotal)
    {
        AssertMsg(pSelf->m_cbTransfered <= pSelf->m_cbTotal,
                  ("More bytes transferred (%zu) than expected (%zu), cbDone=%zu\n",
                   pSelf->m_cbTransfered, pSelf->m_cbTotal, cbDone));

        unsigned uPercentage = (unsigned)((uint64_t)pSelf->m_cbTransfered * 100 / pSelf->m_cbTotal);
        rc = pSelf->m_pfnProgressCallback(RT_MIN(uPercentage, 100),
                                          DragAndDropSvc::DND_PROGRESS_RUNNING,
                                          VINF_SUCCESS /* rc */, pSelf->m_pvProgressUser);
    }

    return rc;
}
Пример #2
0
int DnDHGSendDataMessage::progressCallback(size_t cbDone, void *pvUser)
{
    AssertPtrReturn(pvUser, VERR_INVALID_POINTER);

    DnDHGSendDataMessage *pSelf = static_cast<DnDHGSendDataMessage *>(pvUser);

    /* How many bytes are transfered already. */
    pSelf->m_cbTransfered += cbDone;

    /* Advance progress info */
    if (pSelf->m_pfnProgressCallback)
        return pSelf->m_pfnProgressCallback(100.0 / pSelf->m_cbAll * pSelf->m_cbTransfered, DragAndDropSvc::DND_PROGRESS_RUNNING, pSelf->m_pvProgressUser);
    else
        return VINF_SUCCESS;
}