Esempio n. 1
0
BOOL CFileTransferDlg::UpdateTransferInfo()
{
    FileTransfer transfer;
    if(TT_GetFileTransferInfo(ttInst, m_nTransferID, &transfer) && !m_bCompleted)
    {
        CString szTransferred;
        szTransferred.Format(_T("%I64d"), transfer.nTransferred);
        
        float percent = 0.0f;
        if(m_nTotalSize>0)
            percent = 100.0f * (float)((double)transfer.nTransferred / (double)m_nTotalSize);
        else
            percent = 100.0f;

        CString szProgress;
        szProgress.Format(_T("%I64d/%I64d - %.2f %%"), transfer.nTransferred, m_nTotalSize, percent);
        m_wndTransferred.SetWindowText(szProgress);
        m_wndProgressBar.SetPos(int(percent));

        DWORD nTotalTime = (::GetTickCount() - m_nStartTime) / 1000;
        CString szThroughput;
        if(nTotalTime>0)
        {
            INT64 nBytesPerSec = transfer.nTransferred/nTotalTime;
            INT64 nBytesLastSec = transfer.nTransferred-m_nLastTransferred;
            if(nBytesPerSec/1024>0 && nBytesLastSec/1024>0)
                szThroughput.Format(_T("%I64d KB/sec, %I64d KB last sec."), nBytesPerSec/1024, nBytesLastSec/1024);
            else
                szThroughput.Format(_T("%I64d bytes/sec, %I64d bytes last sec."), nBytesPerSec, nBytesLastSec);
        }
        else
            szThroughput.Format(_T("%I64d bytes/sec"), (INT64)0);
        //szThroughput.Format(_T("%I64d bytes last sec."),transfer.nTransferred-m_nLastTransferred);
        m_wndThroughput.SetWindowText(szThroughput);
        m_nLastTransferred = transfer.nTransferred;
    }
    else
    {
        if(m_bCompleted)
        {
            CString szProgress;
            szProgress.Format(_T("%I64d/%I64d - %.2f %%"), m_nTotalSize, m_nTotalSize, 100.0f);
            m_wndTransferred.SetWindowText(szProgress);
            m_wndProgressBar.SetPos(100);
        }
        else
        {
        }
        return FALSE;
    }
    return TRUE;
}
Esempio n. 2
0
void FileTransferDlg::timerEvent(QTimerEvent* event)
{
    if(event->timerId() == m_timerid)
    {
        FileTransfer transfer;
        if(!TT_GetFileTransferInfo(ttInst, m_transferid, &transfer))
        {
            killTimer(m_timerid);
            m_timerid = -1;
            QMessageBox::critical(this, tr("File Transfer"), 
                tr("File transfer failed."));
        }
        else
            updateFileTransfer(transfer);
    }
}
Esempio n. 3
0
BOOL CFileTransferDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME),TRUE);

    TRANSLATE(*this, IDD);

    m_wndProgressBar.SetRange(0,100);
    m_wndThroughput.SetWindowText(_T(""));
    m_wndTransferred.SetWindowText(_T(""));
    m_wndFilename.SetWindowText(_T(""));
    m_wndFileSize.SetWindowText(_T(""));

    FileTransfer transfer;
    if(TT_GetFileTransferInfo(ttInst, m_nTransferID, &transfer))
    {
        CString szTotalSize;
        if(m_nTotalSize>1024)
            szTotalSize.Format(_T("%I64d KBytes"), transfer.nFileSize/(INT64)1024);
        else
            szTotalSize.Format(_T("%I64d bytes"), transfer.nFileSize);
        SetWindowText(transfer.szRemoteFileName);
        m_nTotalSize = transfer.nFileSize;
        m_wndFilename.SetWindowText(transfer.szRemoteFileName);
        m_wndFileSize.SetWindowText(szTotalSize);
        m_szLocalFilename = transfer.szLocalFilePath;
    }

    m_nStartTime = ::GetTickCount();

    UpdateTransferInfo();

    SetTimer(1, 1000, NULL);

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}