VirtualBox

Changeset 90527 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 5, 2021 11:24:33 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Move request uuid stuff to appropriate place from UINetworkRequest to UINetworkRequestManager.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/networking
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequest.cpp

    r90526 r90527  
    4444    , m_pCustomer(pCustomer)
    4545    , m_pNetworkManager(pNetworkManager)
    46     , m_uuid(QUuid::createUuid())
    4746    , m_iUrlIndex(-1)
    4847    , m_fRunning(false)
     
    6362void UINetworkRequest::sltHandleNetworkReplyProgress(qint64 iReceived, qint64 iTotal)
    6463{
    65     /* Notify common network-request listeners: */
    66     emit sigProgress(m_uuid, iReceived, iTotal);
    67     /* Notify own network-request listeners: */
     64    /* Notify network-request listeners: */
    6865    emit sigProgress(iReceived, iTotal);
    6966}
     
    8178    if (m_pReply->error() == UINetworkReply::NoError)
    8279    {
    83         /* Notify own network-request listeners: */
     80        /* Notify network-request listeners: */
    8481        emit sigFinished();
    85         /* Notify common network-request listeners: */
    86         emit sigFinished(m_uuid);
    8782    }
    8883    /* If network-request was canceled: */
    8984    else if (m_pReply->error() == UINetworkReply::OperationCanceledError)
    9085    {
    91         /* Notify network-manager: */
    92         emit sigCanceled(m_uuid);
     86        /* Notify network-request listeners: */
     87        emit sigCanceled();
    9388    }
    9489    /* If some other error occured: */
     
    143138            else
    144139            {
    145                 /* Notify own network-request listeners: */
     140                /* Notify network-request listeners: */
    146141                emit sigFailed(m_pReply->errorString());
    147                 /* Notify common network-request listeners: */
    148                 emit sigFailed(m_uuid, m_pReply->errorString());
    149142            }
    150143        }
     
    173166            m_pReply->abort();
    174167        else
    175             emit sigCanceled(m_uuid);
     168            emit sigCanceled();
    176169    }
    177170}
     
    206199        m_fRunning = true;
    207200
    208         /* Notify common network-request listeners: */
    209         emit sigStarted(m_uuid);
    210         /* Notify own network-request listeners: */
     201        /* Notify network-request listeners: */
    211202        emit sigStarted();
    212203    }
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequest.h

    r90525 r90527  
    2525#include <QObject>
    2626#include <QPointer>
    27 #include <QUuid>
    2827
    2928/* GUI inludes: */
     
    4544signals:
    4645
    47     /** Notifies common UINetworkRequestManager about progress with @a uId changed.
    48       * @param  iReceived  Holds the amount of bytes received.
    49       * @param  iTotal     Holds the amount of total bytes to receive. */
    50     void sigProgress(const QUuid &uId, qint64 iReceived, qint64 iTotal);
    51     /** Notifies UINetworkRequestManager about progress with @a uId started. */
    52     void sigStarted(const QUuid &uId);
    53     /** Notifies UINetworkRequestManager about progress with @a uId canceled. */
    54     void sigCanceled(const QUuid &uId);
    55     /** Notifies UINetworkRequestManager about progress with @a uId finished. */
    56     void sigFinished(const QUuid &uId);
    57     /** Notifies UINetworkRequestManager about progress with @a uId failed with @a strError. */
    58     void sigFailed(const QUuid &uId, const QString &strError);
    59 
    60     /** Notifies own UINetworkRequestWidget about progress changed.
    61       * @param  iReceived  Holds the amount of bytes received.
    62       * @param  iTotal     Holds the amount of total bytes to receive. */
     46    /** Notifies listener about progress changed.
     47      * @param  iReceived  Brings the amount of bytes received.
     48      * @param  iTotal     Brings the amount of total bytes to receive. */
    6349    void sigProgress(qint64 iReceived, qint64 iTotal);
    64     /** Notifies own UINetworkRequestWidget about progress started. */
     50    /** Notifies listener about progress started. */
    6551    void sigStarted();
    66     /** Notifies own UINetworkRequestWidget about progress finished. */
     52    /** Notifies listener about progress canceled. */
     53    void sigCanceled();
     54    /** Notifies listener about progress finished. */
    6755    void sigFinished();
    68     /** Notifies own UINetworkRequestWidget about progress failed with @a strError. */
     56    /** Notifies listener about progress failed.
     57      * @param  strError  Brings the error progress failed with . */
    6958    void sigFailed(const QString &strError);
    7059
     
    9382    /** Returns the request manager. */
    9483    UINetworkRequestManager *manager() const { return m_pNetworkManager; }
    95     /** Returns unique request QUuid. */
    96     const QUuid &uuid() const { return m_uuid; }
    9784    /** Returns the request reply. */
    9885    UINetworkReply *reply() { return m_pReply; }
     
    138125    /** Holds the request manager. */
    139126    UINetworkRequestManager    *m_pNetworkManager;
    140     /** Holds unique request QUuid. */
    141     const QUuid                 m_uuid;
    142127
    143128    /** Holds current request url. */
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequestManager.cpp

    r90526 r90527  
    9999{
    100100    /* Configure request listeners: */
    101     connect(pNetworkRequest, static_cast<void(UINetworkRequest::*)(const QUuid&, qint64, qint64)>(&UINetworkRequest::sigProgress),
     101    connect(pNetworkRequest, &UINetworkRequest::sigProgress,
    102102            this, &UINetworkRequestManager::sltHandleNetworkRequestProgress);
    103103    connect(pNetworkRequest, &UINetworkRequest::sigCanceled,
    104104            this, &UINetworkRequestManager::sltHandleNetworkRequestCancel);
    105     connect(pNetworkRequest, static_cast<void(UINetworkRequest::*)(const QUuid&)>(&UINetworkRequest::sigFinished),
     105    connect(pNetworkRequest, &UINetworkRequest::sigFinished,
    106106            this, &UINetworkRequestManager::sltHandleNetworkRequestFinish);
    107     connect(pNetworkRequest, static_cast<void(UINetworkRequest::*)(const QUuid &uuid, const QString &strError)>(&UINetworkRequest::sigFailed),
     107    connect(pNetworkRequest, &UINetworkRequest::sigFailed,
    108108            this, &UINetworkRequestManager::sltHandleNetworkRequestFailure);
    109109
     110    /* [Re]generate ID until unique: */
     111    QUuid uId = QUuid::createUuid();
     112    while (m_requests.contains(uId))
     113        uId = QUuid::createUuid();
     114
    110115    /* Add request to map: */
    111     m_requests.insert(pNetworkRequest->uuid(), pNetworkRequest);
     116    m_requests.insert(uId, pNetworkRequest);
    112117
    113118    /* Add network-request widget to network-manager dialog: */
    114     m_pNetworkManagerDialog->addNetworkRequestWidget(pNetworkRequest);
     119    m_pNetworkManagerDialog->addNetworkRequestWidget(uId, pNetworkRequest);
    115120}
    116121
     
    139144}
    140145
    141 void UINetworkRequestManager::sltHandleNetworkRequestProgress(const QUuid &uId, qint64 iReceived, qint64 iTotal)
    142 {
    143     /* Make sure we have this request registered: */
    144     AssertReturnVoid(!uId.isNull());
    145     AssertReturnVoid(m_requests.contains(uId));
    146     UINetworkRequest *pNetworkRequest = m_requests.value(uId);
    147     AssertPtrReturnVoid(pNetworkRequest);
     146void UINetworkRequestManager::sltHandleNetworkRequestProgress(qint64 iReceived, qint64 iTotal)
     147{
     148    /* Make sure we have this request registered: */
     149    UINetworkRequest *pNetworkRequest = qobject_cast<UINetworkRequest*>(sender());
     150    AssertPtrReturnVoid(pNetworkRequest);
     151    const QUuid uId = m_requests.key(pNetworkRequest);
     152    AssertReturnVoid(!uId.isNull());
    148153
    149154    /* Delegate request to customer: */
     
    153158}
    154159
    155 void UINetworkRequestManager::sltHandleNetworkRequestCancel(const QUuid &uId)
    156 {
    157     /* Make sure we have this request registered: */
    158     AssertReturnVoid(!uId.isNull());
    159     AssertReturnVoid(m_requests.contains(uId));
    160     UINetworkRequest *pNetworkRequest = m_requests.value(uId);
    161     AssertPtrReturnVoid(pNetworkRequest);
     160void UINetworkRequestManager::sltHandleNetworkRequestCancel()
     161{
     162    /* Make sure we have this request registered: */
     163    UINetworkRequest *pNetworkRequest = qobject_cast<UINetworkRequest*>(sender());
     164    AssertPtrReturnVoid(pNetworkRequest);
     165    const QUuid uId = m_requests.key(pNetworkRequest);
     166    AssertReturnVoid(!uId.isNull());
    162167
    163168    /* Delegate request to customer: */
     
    170175}
    171176
    172 void UINetworkRequestManager::sltHandleNetworkRequestFinish(const QUuid &uId)
    173 {
    174     /* Make sure we have this request registered: */
    175     AssertReturnVoid(!uId.isNull());
    176     AssertReturnVoid(m_requests.contains(uId));
    177     UINetworkRequest *pNetworkRequest = m_requests.value(uId);
    178     AssertPtrReturnVoid(pNetworkRequest);
     177void UINetworkRequestManager::sltHandleNetworkRequestFinish()
     178{
     179    /* Make sure we have this request registered: */
     180    UINetworkRequest *pNetworkRequest = qobject_cast<UINetworkRequest*>(sender());
     181    AssertPtrReturnVoid(pNetworkRequest);
     182    const QUuid uId = m_requests.key(pNetworkRequest);
     183    AssertReturnVoid(!uId.isNull());
    179184
    180185    /* Delegate request to customer: */
     
    187192}
    188193
    189 void UINetworkRequestManager::sltHandleNetworkRequestFailure(const QUuid &uId, const QString &)
    190 {
    191     /* Make sure we have this request registered: */
    192     AssertReturnVoid(!uId.isNull());
    193     AssertReturnVoid(m_requests.contains(uId));
    194     UINetworkRequest *pNetworkRequest = m_requests.value(uId);
    195     AssertPtrReturnVoid(pNetworkRequest);
     194void UINetworkRequestManager::sltHandleNetworkRequestFailure(const QString &)
     195{
     196    /* Make sure we have this request registered: */
     197    UINetworkRequest *pNetworkRequest = qobject_cast<UINetworkRequest*>(sender());
     198    AssertPtrReturnVoid(pNetworkRequest);
     199    const QUuid uId = m_requests.key(pNetworkRequest);
     200    AssertReturnVoid(!uId.isNull());
    196201
    197202    /* Delegate request to customer: */
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequestManager.h

    r90526 r90527  
    101101private slots:
    102102
    103     /** Handles progress for @a iReceived amount of bytes among @a iTotal for request specified by @a uId. */
    104     void sltHandleNetworkRequestProgress(const QUuid &uId, qint64 iReceived, qint64 iTotal);
    105     /** Handles canceling of request specified by @a uId. */
    106     void sltHandleNetworkRequestCancel(const QUuid &uId);
    107     /** Handles finishing of request specified by @a uId. */
    108     void sltHandleNetworkRequestFinish(const QUuid &uId);
    109     /** Handles @a strError of request specified by @a uId. */
    110     void sltHandleNetworkRequestFailure(const QUuid &uId, const QString &strError);
     103    /** Handles progress for @a iReceived amount of bytes among @a iTotal. */
     104    void sltHandleNetworkRequestProgress(qint64 iReceived, qint64 iTotal);
     105    /** Handles request canceling. */
     106    void sltHandleNetworkRequestCancel();
     107    /** Handles request finishing. */
     108    void sltHandleNetworkRequestFinish();
     109    /** Handles request @a strError. */
     110    void sltHandleNetworkRequestFailure(const QString &strError);
    111111
    112112private:
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequestManagerWindow.cpp

    r86996 r90527  
    9292}
    9393
    94 void UINetworkRequestManagerWindow::addNetworkRequestWidget(UINetworkRequest *pNetworkRequest)
     94void UINetworkRequestManagerWindow::addNetworkRequestWidget(const QUuid &uuid, UINetworkRequest *pNetworkRequest)
    9595{
    9696    /* Make sure network-request is really exists: */
     
    100100    UINetworkRequestWidget *pNetworkRequestWidget = new UINetworkRequestWidget(this, pNetworkRequest);
    101101    m_pWidgetsLayout->addWidget(pNetworkRequestWidget);
    102     m_widgets.insert(pNetworkRequest->uuid(), pNetworkRequestWidget);
     102    m_widgets.insert(uuid, pNetworkRequestWidget);
    103103
    104104    /* Hide label: */
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequestManagerWindow.h

    r86996 r90527  
    6464    friend class UINetworkRequest;
    6565    /** Adds network-request widget. */
    66     void addNetworkRequestWidget(UINetworkRequest *pNetworkRequest);
     66    void addNetworkRequestWidget(const QUuid &uuid, UINetworkRequest *pNetworkRequest);
    6767    /** Removes network-request widget. */
    6868    void removeNetworkRequestWidget(const QUuid &uuid);
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