VirtualBox

Changeset 58245 in vbox


Ignore:
Timestamp:
Oct 14, 2015 2:38:22 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Networking cleanup/rework (part 7): Extend our own network reply object with RTHttp download progress info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp

    r58243 r58245  
    6161#endif
    6262
     63signals:
     64
     65    /** Notifies listeners about download progress change.
     66      * @param iCurrent holds the current amount of bytes downloaded.
     67      * @param iTotal   holds the total amount of bytes to be downloaded. */
     68    void sigDownloadProgress(qint64 iCurrent, qint64 iTotal);
     69
    6370public:
    6471
     
    96103
    97104private:
     105
    98106    /** @name Helpers - HTTP stuff
    99107     * @{ */
     108    int applyConfiguration();
    100109    int applyProxyRules();
    101110    int applyHttpsCertificates();
     
    130139    /** @} */
    131140
     141    /** @name HTTP download progress handling.
     142     * @{ */
     143    /** Redirects download progress callback to particular object which can handle it. */
     144    static void handleProgressChange(RTHTTP hHttp, void *pvUser, uint64_t cbDownloadTotal, uint64_t cbDownloaded);
     145    /** Handles download progress callback. */
     146    void handleProgressChange(uint64_t cbDownloadTotal, uint64_t cbDownloaded);
     147    /** @} */
     148
    132149    /** Holds short descriptive context of thread's current operation. */
    133150    QString m_strContext;
     
    234251    if (m_hHttp != NIL_RTHTTP)
    235252        RTHttpAbort(m_hHttp);
     253}
     254
     255int UINetworkReplyPrivateThread::applyConfiguration()
     256{
     257    /* Install downloading progress callback: */
     258    return RTHttpSetDownloadProgressCallback(m_hHttp, &UINetworkReplyPrivateThread::handleProgressChange, this);
    236259}
    237260
     
    441464    if (RT_SUCCESS(m_iError))
    442465    {
     466        /* Apply configuration: */
     467        if (RT_SUCCESS(m_iError))
     468            m_iError = applyConfiguration();
     469
    443470        /* Apply proxy-rules: */
    444471        if (RT_SUCCESS(m_iError))
     
    790817}
    791818
     819/* static */
     820void UINetworkReplyPrivateThread::handleProgressChange(RTHTTP hHttp, void *pvUser, uint64_t cbDownloadTotal, uint64_t cbDownloaded)
     821{
     822    /* Redirect callback to particular object: */
     823    Q_UNUSED(hHttp);
     824    AssertPtrReturnVoid(pvUser);
     825    static_cast<UINetworkReplyPrivateThread*>(pvUser)->handleProgressChange(cbDownloadTotal, cbDownloaded);
     826}
     827
     828void UINetworkReplyPrivateThread::handleProgressChange(uint64_t cbDownloadTotal, uint64_t cbDownloaded)
     829{
     830    /* Notify listeners about progress change: */
     831    emit sigDownloadProgress(cbDownloaded, cbDownloadTotal);
     832}
     833
    792834#ifndef VBOX_GUI_IN_TST_SSL_CERT_DOWNLOADS
    793835
     
    816858        /* Create and run network-reply thread: */
    817859        m_pThread = new UINetworkReplyPrivateThread(request, type);
     860        connect(m_pThread, SIGNAL(sigDownloadProgress(qint64, qint64)),
     861                this, SIGNAL(downloadProgress(qint64, qint64)), Qt::QueuedConnection);
    818862        connect(m_pThread, SIGNAL(finished()), this, SLOT(sltFinished()));
    819863        m_pThread->start();
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