VirtualBox

Ignore:
Timestamp:
Oct 27, 2015 11:59:56 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103683
Message:

FE/Qt: Networking cleanup/rework (part 24): Get rid of QNetworkRequest, replace it with QUrl.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/net
Files:
11 edited

Legend:

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

    r58423 r58426  
    4343
    4444    /* Send HEAD requests: */
    45     QList<QNetworkRequest> requests;
    46     for (int i = 0; i < m_sources.size(); ++i)
    47         requests << QNetworkRequest(m_sources[i]);
    48 
    49     /* Create network request set: */
    50     createNetworkRequest(UINetworkRequestType_HEAD, requests);
     45    createNetworkRequest(UINetworkRequestType_HEAD, m_sources);
    5146}
    5247
     
    5853
    5954    /* Send GET request: */
    60     QNetworkRequest request(m_source);
    61 
    62     /* Create network request: */
    63     createNetworkRequest(UINetworkRequestType_GET, QList<QNetworkRequest>() << request);
     55    createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << m_source);
    6456}
    6557
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkCustomer.cpp

    r58425 r58426  
    2121
    2222/* Qt includes: */
    23 # include <QNetworkRequest>
     23# include <QUrl>
    2424
    2525/* Local includes: */
     
    4242}
    4343
    44 void UINetworkCustomer::createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> requests,
     44void UINetworkCustomer::createNetworkRequest(UINetworkRequestType type, const QList<QUrl> urls,
    4545                                             const UserDictionary requestHeaders /* = UserDictionary() */)
    4646{
    47     gNetworkManager->createNetworkRequest(type, requests, requestHeaders, this);
     47    gNetworkManager->createNetworkRequest(type, urls, requestHeaders, this);
    4848}
    4949
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkCustomer.h

    r58425 r58426  
    2727/* Forward declarations: */
    2828class UINetworkReply;
    29 class QNetworkRequest;
     29class QUrl;
    3030
    3131/* Interface to access UINetworkManager protected functionality: */
     
    5555protected:
    5656
    57     /** Creates network-request of the passed @a type on the basis of the passed @a requests and the @a requestHeaders. */
    58     void createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> requests,
     57    /** Creates network-request of the passed @a type on the basis of the passed @a urls and the @a requestHeaders. */
     58    void createNetworkRequest(UINetworkRequestType type, const QList<QUrl> urls,
    5959                              const UserDictionary requestHeaders = UserDictionary());
    6060
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.cpp

    r58425 r58426  
    2222/* Global includes: */
    2323# include <QWidget>
     24# include <QUrl>
    2425
    2526/* Local includes: */
     
    107108}
    108109
    109 void UINetworkManager::createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> &requests,
     110void UINetworkManager::createNetworkRequest(UINetworkRequestType type, const QList<QUrl> &urls,
    110111                                            const UserDictionary &requestHeaders, UINetworkCustomer *pCustomer)
    111112{
    112113    /* Create network-request: */
    113     UINetworkRequest *pNetworkRequest = new UINetworkRequest(type, requests, requestHeaders, pCustomer, this);
     114    UINetworkRequest *pNetworkRequest = new UINetworkRequest(type, urls, requestHeaders, pCustomer, this);
    114115    /* Prepare created network-request: */
    115116    prepareNetworkRequest(pNetworkRequest);
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.h

    r58425 r58426  
    1919#define __UINetworkManager_h__
    2020
    21 /* Global includes: */
     21/* Qt includes: */
    2222#include <QNetworkAccessManager>
    2323#include <QUuid>
    24 #include <QMap>
    25 #include <QNetworkRequest>
    2624
    2725/* Local inludes: */
     
    2927
    3028/* Forward declarations: */
     29class QUrl;
    3130class QWidget;
    3231class UINetworkRequest;
     
    8281    friend class UINetworkCustomer;
    8382    /** Creates network-request of the passed @a type
    84       * on the basis of the passed @a requests and the @a requestHeaders for the @a pCustomer specified. */
    85     void createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> &requests,
     83      * on the basis of the passed @a urls and the @a requestHeaders for the @a pCustomer specified. */
     84    void createNetworkRequest(UINetworkRequestType type, const QList<QUrl> &urls,
    8685                              const UserDictionary &requestHeaders, UINetworkCustomer *pCustomer);
    8786
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp

    r58425 r58426  
    2626# include <QRegExp>
    2727# include <QVector>
     28# include <QVariant>
    2829
    2930/* GUI includes: */
     
    7071public:
    7172
    72     /** Constructs network-reply thread of the passed @a type for the passed @a request and @a requestHeaders. */
    73     UINetworkReplyPrivateThread(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders);
     73    /** Constructs network-reply thread of the passed @a type for the passed @a url and @a requestHeaders. */
     74    UINetworkReplyPrivateThread(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders);
    7475
    7576    /** @name APIs
     
    7980
    8081        /** Returns the URL of the reply which is the URL of the request for now. */
    81         QUrl url() const { return m_request.url(); }
     82        const QUrl& url() const { return m_url; }
    8283
    8384        /** Returns the last cached IPRT HTTP error of the reply. */
     
    190191    /** Holds the request type. */
    191192    const UINetworkRequestType m_type;
    192     /** Holds the request instance. */
    193     const QNetworkRequest m_request;
     193    /** Holds the request url. */
     194    const QUrl m_url;
    194195    /** Holds the request headers. */
    195196    const UserDictionary m_requestHeaders;
     
    204205    QByteArray m_reply;
    205206    /** Holds the cached reply headers. */
    206     QMap<QString, QString> m_headers;
     207    UserDictionary m_headers;
    207208
    208209    /** Holds the URLs to root zip files containing certificates we want. */
     
    243244public:
    244245
    245     /** Constructs network-reply private data of the passed @a type for the passed @a request and @a requestHeaders. */
    246     UINetworkReplyPrivate(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders);
     246    /** Constructs network-reply private data of the passed @a type for the passed @a url and @a requestHeaders. */
     247    UINetworkReplyPrivate(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders);
    247248    /** Destructs reply private data. */
    248249    ~UINetworkReplyPrivate();
     
    343344const QString UINetworkReplyPrivateThread::s_strCertificateFileName = QString("vbox-ssl-cacertificate.crt");
    344345
    345 UINetworkReplyPrivateThread::UINetworkReplyPrivateThread(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders)
     346UINetworkReplyPrivateThread::UINetworkReplyPrivateThread(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders)
    346347    : m_type(type)
    347     , m_request(request)
     348    , m_url(url)
    348349    , m_requestHeaders(requestHeaders)
    349350    , m_hHttp(NIL_RTHTTP)
     
    529530            void   *pvResponse = 0;
    530531            size_t  cbResponse = 0;
    531             rc = RTHttpGetHeaderBinary(m_hHttp, m_request.url().toString().toUtf8().constData(), &pvResponse, &cbResponse);
     532            rc = RTHttpGetHeaderBinary(m_hHttp, m_url.toString().toUtf8().constData(), &pvResponse, &cbResponse);
    532533            if (RT_SUCCESS(rc))
    533534            {
     
    556557            void   *pvResponse = 0;
    557558            size_t  cbResponse = 0;
    558             rc = RTHttpGetBinary(m_hHttp, m_request.url().toString().toUtf8().constData(), &pvResponse, &cbResponse);
     559            rc = RTHttpGetBinary(m_hHttp, m_url.toString().toUtf8().constData(), &pvResponse, &cbResponse);
    559560            if (RT_SUCCESS(rc))
    560561            {
     
    919920*********************************************************************************************************************************/
    920921
    921 UINetworkReplyPrivate::UINetworkReplyPrivate(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders)
     922UINetworkReplyPrivate::UINetworkReplyPrivate(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders)
    922923    : m_error(UINetworkReply::NoError)
    923924    , m_pThread(0)
     
    927928
    928929    /* Create and run reply thread: */
    929     m_pThread = new UINetworkReplyPrivateThread(type, request, requestHeaders);
     930    m_pThread = new UINetworkReplyPrivateThread(type, url, requestHeaders);
    930931    connect(m_pThread, SIGNAL(sigDownloadProgress(qint64, qint64)),
    931932            this, SIGNAL(downloadProgress(qint64, qint64)), Qt::QueuedConnection);
     
    992993*********************************************************************************************************************************/
    993994
    994 UINetworkReply::UINetworkReply(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders)
    995     : m_pReply(new UINetworkReplyPrivate(type, request, requestHeaders))
     995UINetworkReply::UINetworkReply(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders)
     996    : m_pReply(new UINetworkReplyPrivate(type, url, requestHeaders))
    996997{
    997998    /* Prepare network-reply object connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.h

    r58425 r58426  
    2121/* Qt includes: */
    2222#include <QPointer>
    23 #include <QNetworkReply>
     23#include <QUrl>
    2424
    2525/* GUI includes: */
     
    8484    };
    8585
    86     /** Constructs network-reply of the passed @a type for the passed @a request and @a requestHeaders. */
    87     UINetworkReply(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders);
     86    /** Constructs network-reply of the passed @a type for the passed @a url and @a requestHeaders. */
     87    UINetworkReply(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders);
    8888    /** Destructs reply. */
    8989    ~UINetworkReply();
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.cpp

    r58425 r58426  
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121
    22 /* Qt includes: */
    23 # include <QNetworkReply>
    24 
    2522/* GUI includes: */
    2623# include "UINetworkRequest.h"
     
    3633
    3734UINetworkRequest::UINetworkRequest(UINetworkRequestType type,
    38                                    const QList<QNetworkRequest> &requests,
     35                                   const QList<QUrl> &urls,
    3936                                   const UserDictionary &requestHeaders,
    4037                                   UINetworkCustomer *pCustomer,
     
    4340    , m_type(type)
    4441    , m_uuid(QUuid::createUuid())
    45     , m_requests(requests)
     42    , m_requests(urls)
    4643    , m_requestHeaders(requestHeaders)
    4744    , m_iCurrentRequestIndex(0)
     
    109106
    110107            /* Choose redirect-source as current: */
    111             m_request.setUrl(redirect);
     108            m_request = redirect;
    112109
    113110            /* Create new network-reply finally: */
     
    131128            cleanupNetworkReply();
    132129
    133             /* Choose next network-request as current: */
     130            /* Choose next url as current: */
    134131            ++m_iCurrentRequestIndex;
    135             m_request = m_requests[m_iCurrentRequestIndex];
     132            m_request = m_requests.at(m_iCurrentRequestIndex);
    136133
    137134            /* Create new network-reply finally: */
     
    154151    cleanupNetworkReply();
    155152
    156     /* Choose first network-request as current: */
     153    /* Choose first url as current: */
    157154    m_iCurrentRequestIndex = 0;
    158     m_request = m_requests[m_iCurrentRequestIndex];
     155    m_request = m_requests.at(m_iCurrentRequestIndex);
    159156
    160157    /* Create new network-reply finally: */
     
    178175    manager()->registerNetworkRequest(this);
    179176
    180     /* Choose first network-request as current: */
     177    /* Choose first url as current: */
    181178    m_iCurrentRequestIndex = 0;
    182     m_request = m_requests[m_iCurrentRequestIndex];
     179    m_request = m_requests.at(m_iCurrentRequestIndex);
    183180
    184181    /* Create network-reply: */
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.h

    r58425 r58426  
    2121/* Qt includes: */
    2222#include <QUuid>
    23 #include <QNetworkRequest>
    2423#include <QPointer>
    2524
     
    5857
    5958    /** Constructs network-request of the passed @a type
    60       * on the basis of the passed @a requests and the @a requestHeaders
     59      * on the basis of the passed @a urls and the @a requestHeaders
    6160      * for the @a pCustomer and @a pNetworkManager specified. */
    6261    UINetworkRequest(UINetworkRequestType type,
    63                      const QList<QNetworkRequest> &requests,
     62                     const QList<QUrl> &urls,
    6463                     const UserDictionary &requestHeaders,
    6564                     UINetworkCustomer *pCustomer,
     
    103102    UINetworkRequestType m_type;
    104103    QUuid m_uuid;
    105     QList<QNetworkRequest> m_requests;
     104    QList<QUrl> m_requests;
    106105    /** Holds the request headers. */
    107106    const UserDictionary m_requestHeaders;
    108     QNetworkRequest m_request;
     107    QUrl m_request;
    109108    int m_iCurrentRequestIndex;
    110109    QString m_strDescription;
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp

    r58425 r58426  
    196196
    197197        /* Send GET request: */
    198         QNetworkRequest request;
    199         request.setUrl(url);
    200198        UserDictionary headers;
    201199        headers["User-Agent"] = strUserAgent;
    202         createNetworkRequest(UINetworkRequestType_GET, QList<QNetworkRequest>() << request, headers);
     200        createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << url, headers);
    203201    }
    204202
  • trunk/src/VBox/Frontends/VirtualBox/src/net/tstSSLCertDownloads.cpp

    r58425 r58426  
    4545{
    4646    NOREF(hTest);
    47     QNetworkRequest Dummy1;
     47    QUrl Dummy1;
    4848    UserDictionary Dummy2;
    4949    UINetworkReplyPrivateThread TestObj(UINetworkRequestType_GET, Dummy1, Dummy2);
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