Changeset 78665 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 22, 2019 3:27:01 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/net
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloader.cpp
r76606 r78665 44 44 45 45 /* Send GET request: */ 46 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << m_source );46 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << m_source, m_strTarget); 47 47 } 48 48 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkCustomer.cpp
r76606 r78665 31 31 32 32 void UINetworkCustomer::createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> urls, 33 const QString &strTarget /* = QString() */, 33 34 const UserDictionary requestHeaders /* = UserDictionary() */) 34 35 { 35 gNetworkManager->createNetworkRequest(enmType, urls, requestHeaders, this);36 gNetworkManager->createNetworkRequest(enmType, urls, strTarget, requestHeaders, this); 36 37 } 37 38 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkCustomer.h
r76581 r78665 59 59 protected: 60 60 61 /** Creates network-request of the passed @a type on the basis of the passed @a urls and the @a requestHeaders. */62 void createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> urls, 61 /** Creates network-request of the passed @a type on the basis of the passed @a urls, @a strTarget and the @a requestHeaders. */ 62 void createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> urls, const QString &strTarget = QString(), 63 63 const UserDictionary requestHeaders = UserDictionary()); 64 64 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.cpp
r76825 r78665 102 102 } 103 103 104 void UINetworkManager::createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> &urls, 104 void UINetworkManager::createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> &urls, const QString &strTarget, 105 105 const UserDictionary &requestHeaders, UINetworkCustomer *pCustomer) 106 106 { 107 107 /* Create network-request: */ 108 UINetworkRequest *pNetworkRequest = new UINetworkRequest(enmType, urls, requestHeaders, pCustomer, this);108 UINetworkRequest *pNetworkRequest = new UINetworkRequest(enmType, urls, strTarget, requestHeaders, pCustomer, this); 109 109 /* Prepare created network-request: */ 110 110 prepareNetworkRequest(pNetworkRequest); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkManager.h
r76581 r78665 87 87 88 88 /** Creates network-request of the passed @a type 89 * on the basis of the passed @a urls and the @a requestHeaders for the @a pCustomer specified. */90 void createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> &urls, 89 * on the basis of the passed @a urls, @a strTarget and the @a requestHeaders for the @a pCustomer specified. */ 90 void createNetworkRequest(UINetworkRequestType enmType, const QList<QUrl> &urls, const QString &strTarget, 91 91 const UserDictionary &requestHeaders, UINetworkCustomer *pCustomer); 92 92 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp
r78066 r78665 65 65 66 66 /** Constructs network-reply thread of the passed @a type for the passed @a url and @a requestHeaders. */ 67 UINetworkReplyPrivateThread(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders);67 UINetworkReplyPrivateThread(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders); 68 68 69 69 /** @name APIs … … 184 184 /** Holds the request url. */ 185 185 const QUrl m_url; 186 /** Holds the request target. */ 187 const QString m_strTarget; 186 188 /** Holds the request headers. */ 187 189 const UserDictionary m_requestHeaders; … … 236 238 237 239 /** Constructs network-reply private data of the passed @a type for the passed @a url and @a requestHeaders. */ 238 UINetworkReplyPrivate(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders);240 UINetworkReplyPrivate(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders); 239 241 /** Destructs reply private data. */ 240 242 ~UINetworkReplyPrivate(); … … 333 335 const QString UINetworkReplyPrivateThread::s_strCertificateFileName = QString("vbox-ssl-cacertificate.crt"); 334 336 335 UINetworkReplyPrivateThread::UINetworkReplyPrivateThread(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders) 337 UINetworkReplyPrivateThread::UINetworkReplyPrivateThread(UINetworkRequestType type, 338 const QUrl &url, 339 const QString &strTarget, 340 const UserDictionary &requestHeaders) 336 341 : m_type(type) 337 342 , m_url(url) 343 , m_strTarget(strTarget) 338 344 , m_requestHeaders(requestHeaders) 339 345 , m_hHttp(NIL_RTHTTP) … … 552 558 case UINetworkRequestType_GET: 553 559 { 554 /* Perform blocking HTTP GET request: */ 555 void *pvResponse = 0; 556 size_t cbResponse = 0; 557 rc = RTHttpGetBinary(m_hHttp, m_url.toString().toUtf8().constData(), &pvResponse, &cbResponse); 558 if (RT_SUCCESS(rc)) 560 /* Perform blocking HTTP GET request. 561 * Keep in mind that if the target parameter is provided, 562 * we are trying to download contents to file directly, 563 * otherwise it will be downloaded to memory and it's 564 * customer responsibility to save it afterwards. */ 565 if (m_strTarget.isEmpty()) 559 566 { 560 m_reply = QByteArray((char*)pvResponse, (int)cbResponse); 561 RTHttpFreeResponse(pvResponse); 567 void *pvResponse = 0; 568 size_t cbResponse = 0; 569 rc = RTHttpGetBinary(m_hHttp, m_url.toString().toUtf8().constData(), &pvResponse, &cbResponse); 570 if (RT_SUCCESS(rc)) 571 { 572 m_reply = QByteArray((char*)pvResponse, (int)cbResponse); 573 RTHttpFreeResponse(pvResponse); 574 } 575 } 576 else 577 { 578 rc = RTHttpGetFile(m_hHttp, m_url.toString().toUtf8().constData(), m_strTarget.toUtf8().constData()); 579 if (RT_SUCCESS(rc)) 580 { 581 QFile file(m_strTarget); 582 if (file.open(QIODevice::ReadOnly)) 583 m_reply = file.readAll(); 584 } 562 585 } 563 586 … … 574 597 void UINetworkReplyPrivateThread::run() 575 598 { 576 /* Init: */577 RTR3InitExeNoArguments(RTR3INIT_FLAGS_SUPLIB); /** @todo r=bird: WTF? */578 579 599 /* Create HTTP client: */ 580 600 m_iError = RTHttpCreate(&m_hHttp); … … 934 954 *********************************************************************************************************************************/ 935 955 936 UINetworkReplyPrivate::UINetworkReplyPrivate(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders)956 UINetworkReplyPrivate::UINetworkReplyPrivate(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders) 937 957 : m_error(UINetworkReply::NoError) 938 958 , m_pThread(0) … … 942 962 943 963 /* Create and run reply thread: */ 944 m_pThread = new UINetworkReplyPrivateThread(type, url, requestHeaders);964 m_pThread = new UINetworkReplyPrivateThread(type, url, strTarget, requestHeaders); 945 965 connect(m_pThread, &UINetworkReplyPrivateThread::sigDownloadProgress, 946 966 this, &UINetworkReplyPrivate::downloadProgress, Qt::QueuedConnection); … … 1010 1030 *********************************************************************************************************************************/ 1011 1031 1012 UINetworkReply::UINetworkReply(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders)1013 : m_pReply(new UINetworkReplyPrivate(type, url, requestHeaders))1032 UINetworkReply::UINetworkReply(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders) 1033 : m_pReply(new UINetworkReplyPrivate(type, url, strTarget, requestHeaders)) 1014 1034 { 1015 1035 /* Prepare network-reply object connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.h
r76581 r78665 82 82 }; 83 83 84 /** Constructs network-reply of the passed @a type for the passed @a url and @a requestHeaders. */85 UINetworkReply(UINetworkRequestType type, const QUrl &url, const UserDictionary &requestHeaders);84 /** Constructs network-reply of the passed @a type for the passed @a url, @a strTarget and @a requestHeaders. */ 85 UINetworkReply(UINetworkRequestType type, const QUrl &url, const QString &strTarget, const UserDictionary &requestHeaders); 86 86 /** Destructs reply. */ 87 87 ~UINetworkReply(); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.cpp
r76606 r78665 28 28 UINetworkRequest::UINetworkRequest(UINetworkRequestType enmType, 29 29 const QList<QUrl> &urls, 30 const QString &strTarget, 30 31 const UserDictionary &requestHeaders, 31 32 UINetworkCustomer *pCustomer, … … 34 35 , m_enmType(enmType) 35 36 , m_urls(urls) 37 , m_strTarget(strTarget) 36 38 , m_requestHeaders(requestHeaders) 37 39 , m_pCustomer(pCustomer) … … 192 194 { 193 195 /* Create network-reply: */ 194 m_pReply = new UINetworkReply(m_enmType, m_url, m_ requestHeaders);196 m_pReply = new UINetworkReply(m_enmType, m_url, m_strTarget, m_requestHeaders); 195 197 AssertPtrReturnVoid(m_pReply.data()); 196 198 { -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkRequest.h
r76581 r78665 72 72 73 73 /** Constructs network-request of the passed @a enmType 74 * on the basis of the passed @a urls and the @a requestHeaders74 * on the basis of the passed @a urls, @a strTarget and the @a requestHeaders 75 75 * for the @a pCustomer and @a pNetworkManager specified. */ 76 76 UINetworkRequest(UINetworkRequestType enmType, 77 77 const QList<QUrl> &urls, 78 const QString &strTarget, 78 79 const UserDictionary &requestHeaders, 79 80 UINetworkCustomer *pCustomer, … … 125 126 /** Holds the request urls. */ 126 127 const QList<QUrl> m_urls; 128 /** Holds the request target. */ 129 const QString m_strTarget; 127 130 /** Holds the request headers. */ 128 131 const UserDictionary m_requestHeaders; -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
r76825 r78665 311 311 QUrl fullUrl(m_url); 312 312 fullUrl.setQuery(url); 313 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << fullUrl, headers);313 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << fullUrl, QString(), headers); 314 314 } 315 315 -
trunk/src/VBox/Frontends/VirtualBox/src/net/tstSSLCertDownloads.cpp
r78066 r78665 37 37 NOREF(hTest); 38 38 QUrl Dummy1; 39 UserDictionary Dummy2; 40 UINetworkReplyPrivateThread TestObj(UINetworkRequestType_GET, Dummy1, Dummy2); 39 QString strDummy2; 40 UserDictionary Dummy3; 41 UINetworkReplyPrivateThread TestObj(UINetworkRequestType_GET, Dummy1, strDummy2, Dummy3); 41 42 42 43 /*
Note:
See TracChangeset
for help on using the changeset viewer.