Changeset 58425 in vbox
- Timestamp:
- Oct 27, 2015 11:20:26 AM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/net
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkCustomer.cpp
r58423 r58425 42 42 } 43 43 44 void UINetworkCustomer::createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> requests) 44 void UINetworkCustomer::createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> requests, 45 const UserDictionary requestHeaders /* = UserDictionary() */) 45 46 { 46 gNetworkManager->createNetworkRequest(type, requests, this);47 gNetworkManager->createNetworkRequest(type, requests, requestHeaders, this); 47 48 } 48 49 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkCustomer.h
r58423 r58425 55 55 protected: 56 56 57 /** Creates network-request of the passed @a type on the basis of the passed @a requests. */ 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 requests and the @a requestHeaders. */ 58 void createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> requests, 59 const UserDictionary requestHeaders = UserDictionary()); 59 60 60 61 private: -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkDefs.h
r58252 r58425 19 19 #define ___UINetworkDefs_h___ 20 20 21 /* Qt includes: */ 22 #include <QMap> 23 21 24 /** Network request types. */ 22 25 enum UINetworkRequestType … … 26 29 }; 27 30 31 /** User dictionary. */ 32 typedef QMap<QString, QString> UserDictionary; 33 28 34 #endif /* !___UINetworkDefs_h___ */ 29 35 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.cpp
r58423 r58425 108 108 109 109 void UINetworkManager::createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> &requests, 110 UINetworkCustomer *pCustomer)110 const UserDictionary &requestHeaders, UINetworkCustomer *pCustomer) 111 111 { 112 112 /* Create network-request: */ 113 UINetworkRequest *pNetworkRequest = new UINetworkRequest(type, requests, pCustomer, this);113 UINetworkRequest *pNetworkRequest = new UINetworkRequest(type, requests, requestHeaders, pCustomer, this); 114 114 /* Prepare created network-request: */ 115 115 prepareNetworkRequest(pNetworkRequest); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.h
r58423 r58425 82 82 friend class UINetworkCustomer; 83 83 /** Creates network-request of the passed @a type 84 * on the basis of the passed @a requests for the @a pCustomer specified. */84 * on the basis of the passed @a requests and the @a requestHeaders for the @a pCustomer specified. */ 85 85 void createNetworkRequest(UINetworkRequestType type, const QList<QNetworkRequest> &requests, 86 UINetworkCustomer *pCustomer);86 const UserDictionary &requestHeaders, UINetworkCustomer *pCustomer); 87 87 88 88 private: -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp
r58423 r58425 70 70 public: 71 71 72 /** Constructs network-reply thread of the passed @a type for the passed @a request . */73 UINetworkReplyPrivateThread(UINetworkRequestType type, const QNetworkRequest &request );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); 74 74 75 75 /** @name APIs … … 130 130 /** Applies raw headers. 131 131 * @param hHttp Brings the HTTP client instance. 132 * @param headers Brings the list of headers to be applied. 133 * @param request Brings the request which contains values for the headers to be applied. */ 134 static int applyRawHeaders(RTHTTP hHttp, const QList<QByteArray> &headers, const QNetworkRequest &request); 132 * @param headers Brings the map of headers to be applied. */ 133 static int applyRawHeaders(RTHTTP hHttp, const UserDictionary &headers); 135 134 136 135 /** Returns the number of certificates found in a search result array. … … 192 191 const UINetworkRequestType m_type; 193 192 /** Holds the request instance. */ 194 QNetworkRequest m_request; 193 const QNetworkRequest m_request; 194 /** Holds the request headers. */ 195 const UserDictionary m_requestHeaders; 195 196 196 197 /** Holds the IPRT HTTP client instance handle. */ … … 242 243 public: 243 244 244 /** Constructs network-reply private data of the passed @a type for the passed @a request . */245 UINetworkReplyPrivate(UINetworkRequestType type, const QNetworkRequest &request );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 247 /** Destructs reply private data. */ 247 248 ~UINetworkReplyPrivate(); … … 342 343 const QString UINetworkReplyPrivateThread::s_strCertificateFileName = QString("vbox-ssl-cacertificate.crt"); 343 344 344 UINetworkReplyPrivateThread::UINetworkReplyPrivateThread(UINetworkRequestType type, const QNetworkRequest &request )345 UINetworkReplyPrivateThread::UINetworkReplyPrivateThread(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders) 345 346 : m_type(type) 346 347 , m_request(request) 348 , m_requestHeaders(requestHeaders) 347 349 , m_hHttp(NIL_RTHTTP) 348 350 , m_iError(VINF_SUCCESS) … … 501 503 502 504 /* Make sure we have a raw headers at all: */ 503 QList<QByteArray> headers = m_request.rawHeaderList(); 504 if (headers.isEmpty()) 505 if (m_requestHeaders.isEmpty()) 505 506 return VINF_SUCCESS; 506 507 507 508 /* Apply raw headers: */ 508 return applyRawHeaders(m_hHttp, headers, m_request);509 return applyRawHeaders(m_hHttp, m_requestHeaders); 509 510 } 510 511 … … 635 636 636 637 /* static */ 637 int UINetworkReplyPrivateThread::applyRawHeaders(RTHTTP hHttp, const QList<QByteArray> &headers, const QNetworkRequest &request)638 int UINetworkReplyPrivateThread::applyRawHeaders(RTHTTP hHttp, const UserDictionary &headers) 638 639 { 639 640 /* Make sure HTTP is created: */ … … 644 645 QVector<QByteArray> formattedHeaders; 645 646 QVector<const char*> formattedHeaderPointers; 646 foreach (const Q ByteArray &header, headers)647 foreach (const QString &header, headers.keys()) 647 648 { 648 649 /* Prepare formatted representation: */ 649 QString strFormattedString = QString("%1: %2").arg( QString(header), QString(request.rawHeader(header)));650 QString strFormattedString = QString("%1: %2").arg(header, headers.value(header)); 650 651 formattedHeaders << strFormattedString.toAscii(); 651 652 formattedHeaderPointers << formattedHeaders.last().constData(); … … 918 919 *********************************************************************************************************************************/ 919 920 920 UINetworkReplyPrivate::UINetworkReplyPrivate(UINetworkRequestType type, const QNetworkRequest &request )921 UINetworkReplyPrivate::UINetworkReplyPrivate(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders) 921 922 : m_error(UINetworkReply::NoError) 922 923 , m_pThread(0) … … 926 927 927 928 /* Create and run reply thread: */ 928 m_pThread = new UINetworkReplyPrivateThread(type, request );929 m_pThread = new UINetworkReplyPrivateThread(type, request, requestHeaders); 929 930 connect(m_pThread, SIGNAL(sigDownloadProgress(qint64, qint64)), 930 931 this, SIGNAL(downloadProgress(qint64, qint64)), Qt::QueuedConnection); … … 991 992 *********************************************************************************************************************************/ 992 993 993 UINetworkReply::UINetworkReply(UINetworkRequestType type, const QNetworkRequest &request )994 : m_pReply(new UINetworkReplyPrivate(type, request ))994 UINetworkReply::UINetworkReply(UINetworkRequestType type, const QNetworkRequest &request, const UserDictionary &requestHeaders) 995 : m_pReply(new UINetworkReplyPrivate(type, request, requestHeaders)) 995 996 { 996 997 /* Prepare network-reply object connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.h
r58423 r58425 84 84 }; 85 85 86 /** Constructs network-reply of the passed @a type for the passed @a request . */87 UINetworkReply(UINetworkRequestType type, const QNetworkRequest &request );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); 88 88 /** Destructs reply. */ 89 89 ~UINetworkReply(); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.cpp
r58423 r58425 37 37 UINetworkRequest::UINetworkRequest(UINetworkRequestType type, 38 38 const QList<QNetworkRequest> &requests, 39 const UserDictionary &requestHeaders, 39 40 UINetworkCustomer *pCustomer, 40 41 UINetworkManager *pNetworkManager) … … 43 44 , m_uuid(QUuid::createUuid()) 44 45 , m_requests(requests) 46 , m_requestHeaders(requestHeaders) 45 47 , m_iCurrentRequestIndex(0) 46 48 , m_pCustomer(pCustomer) … … 188 190 { 189 191 /* Make network-request: */ 190 m_pReply = new UINetworkReply(m_type, m_request );192 m_pReply = new UINetworkReply(m_type, m_request, m_requestHeaders); 191 193 AssertMsg(m_pReply, ("Unable to make network-request!\n")); 192 194 /* Prepare listeners for m_pReply: */ -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.h
r58423 r58425 58 58 59 59 /** Constructs network-request of the passed @a type 60 * on the basis of the @a requests60 * on the basis of the passed @a requests and the @a requestHeaders 61 61 * for the @a pCustomer and @a pNetworkManager specified. */ 62 62 UINetworkRequest(UINetworkRequestType type, 63 63 const QList<QNetworkRequest> &requests, 64 const UserDictionary &requestHeaders, 64 65 UINetworkCustomer *pCustomer, 65 66 UINetworkManager *pNetworkManager); … … 103 104 QUuid m_uuid; 104 105 QList<QNetworkRequest> m_requests; 106 /** Holds the request headers. */ 107 const UserDictionary m_requestHeaders; 105 108 QNetworkRequest m_request; 106 109 int m_iCurrentRequestIndex; -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
r58423 r58425 198 198 QNetworkRequest request; 199 199 request.setUrl(url); 200 request.setRawHeader("User-Agent", strUserAgent.toAscii()); 201 createNetworkRequest(UINetworkRequestType_GET, QList<QNetworkRequest>() << request); 200 UserDictionary headers; 201 headers["User-Agent"] = strUserAgent; 202 createNetworkRequest(UINetworkRequestType_GET, QList<QNetworkRequest>() << request, headers); 202 203 } 203 204 -
trunk/src/VBox/Frontends/VirtualBox/src/net/tstSSLCertDownloads.cpp
r58423 r58425 45 45 { 46 46 NOREF(hTest); 47 QNetworkRequest Dummy; 48 UINetworkReplyPrivateThread TestObj(UINetworkRequestType_GET, Dummy); 47 QNetworkRequest Dummy1; 48 UserDictionary Dummy2; 49 UINetworkReplyPrivateThread TestObj(UINetworkRequestType_GET, Dummy1, Dummy2); 49 50 50 51 /*
Note:
See TracChangeset
for help on using the changeset viewer.