summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r--rbutil/rbutilqt/base/httpget.cpp44
-rw-r--r--rbutil/rbutilqt/base/httpget.h2
2 files changed, 25 insertions, 21 deletions
diff --git a/rbutil/rbutilqt/base/httpget.cpp b/rbutil/rbutilqt/base/httpget.cpp
index 12429e5d17..2df9501fd6 100644
--- a/rbutil/rbutilqt/base/httpget.cpp
+++ b/rbutil/rbutilqt/base/httpget.cpp
@@ -29,18 +29,18 @@ QDir HttpGet::m_globalCache; //< global cach path value for new objects
29QNetworkProxy HttpGet::m_globalProxy; 29QNetworkProxy HttpGet::m_globalProxy;
30 30
31HttpGet::HttpGet(QObject *parent) 31HttpGet::HttpGet(QObject *parent)
32 : QObject(parent) 32 : QObject(parent),
33 m_mgr(this),
34 m_reply(nullptr),
35 m_cache(nullptr),
36 m_cachedir(m_globalCache),
37 m_outputFile(nullptr),
38 m_proxy(QNetworkProxy::NoProxy)
33{ 39{
34 m_mgr = new QNetworkAccessManager(this);
35 m_cache = NULL;
36 m_cachedir = m_globalCache;
37 setCache(true); 40 setCache(true);
38 connect(m_mgr, SIGNAL(finished(QNetworkReply*)), 41 connect(&m_mgr, &QNetworkAccessManager::finished, this,
39 this, SLOT(requestFinished(QNetworkReply*))); 42 static_cast<void (HttpGet::*)(QNetworkReply*)>(&HttpGet::requestFinished));
40 m_outputFile = NULL;
41 m_lastServerTimestamp = QDateTime(); 43 m_lastServerTimestamp = QDateTime();
42 m_proxy = QNetworkProxy::NoProxy;
43 m_reply = NULL;
44} 44}
45 45
46 46
@@ -67,7 +67,7 @@ void HttpGet::setCache(bool c)
67 // don't delete the old cache directly, it might still be in use. Just 67 // don't delete the old cache directly, it might still be in use. Just
68 // instruct it to delete itself later. 68 // instruct it to delete itself later.
69 if(m_cache) m_cache->deleteLater(); 69 if(m_cache) m_cache->deleteLater();
70 m_cache = NULL; 70 m_cache = nullptr;
71 71
72 QString path = m_cachedir.absolutePath(); 72 QString path = m_cachedir.absolutePath();
73 73
@@ -83,7 +83,7 @@ void HttpGet::setCache(bool c)
83 m_cache = new QNetworkDiskCache(this); 83 m_cache = new QNetworkDiskCache(this);
84 m_cache->setCacheDirectory(path); 84 m_cache->setCacheDirectory(path);
85 } 85 }
86 m_mgr->setCache(m_cache); 86 m_mgr.setCache(m_cache);
87} 87}
88 88
89 89
@@ -107,7 +107,7 @@ void HttpGet::setProxy(const QUrl &proxy)
107 m_proxy.setPort(proxy.port()); 107 m_proxy.setPort(proxy.port());
108 m_proxy.setUser(proxy.userName()); 108 m_proxy.setUser(proxy.userName());
109 m_proxy.setPassword(proxy.password()); 109 m_proxy.setPassword(proxy.password());
110 m_mgr->setProxy(m_proxy); 110 m_mgr.setProxy(m_proxy);
111} 111}
112 112
113 113
@@ -116,8 +116,8 @@ void HttpGet::setProxy(const QUrl &proxy)
116 */ 116 */
117void HttpGet::setProxy(bool enable) 117void HttpGet::setProxy(bool enable)
118{ 118{
119 if(enable) m_mgr->setProxy(m_proxy); 119 if(enable) m_mgr.setProxy(m_proxy);
120 else m_mgr->setProxy(QNetworkProxy::NoProxy); 120 else m_mgr.setProxy(QNetworkProxy::NoProxy);
121} 121}
122 122
123 123
@@ -185,7 +185,7 @@ void HttpGet::requestFinished(QNetworkReply* reply)
185 emit done(true); 185 emit done(true);
186 } 186 }
187 reply->deleteLater(); 187 reply->deleteLater();
188 m_reply = NULL; 188 m_reply = nullptr;
189} 189}
190 190
191 191
@@ -202,11 +202,15 @@ void HttpGet::startRequest(QUrl url)
202 if(!m_globalUserAgent.isEmpty()) 202 if(!m_globalUserAgent.isEmpty())
203 req.setRawHeader("User-Agent", m_globalUserAgent.toLatin1()); 203 req.setRawHeader("User-Agent", m_globalUserAgent.toLatin1());
204 204
205 m_reply = m_mgr->get(req); 205 m_reply = m_mgr.get(req);
206 connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), 206#if QT_VERSION < 0x050f00
207 this, SLOT(networkError(QNetworkReply::NetworkError))); 207 connect(m_reply,
208 connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), 208 static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
209 this, SLOT(downloadProgress(qint64, qint64))); 209 this, &HttpGet::networkError);
210#else
211 connect(m_reply, &QNetworkReply::errorOccurred, this, &HttpGet::networkError);
212#endif
213 connect(m_reply, &QNetworkReply::downloadProgress, this, &HttpGet::downloadProgress);
210} 214}
211 215
212 216
diff --git a/rbutil/rbutilqt/base/httpget.h b/rbutil/rbutilqt/base/httpget.h
index 0bd3d284ac..7cdddedfbf 100644
--- a/rbutil/rbutilqt/base/httpget.h
+++ b/rbutil/rbutilqt/base/httpget.h
@@ -92,7 +92,7 @@ class HttpGet : public QObject
92 private: 92 private:
93 static QString m_globalUserAgent; 93 static QString m_globalUserAgent;
94 static QNetworkProxy m_globalProxy; 94 static QNetworkProxy m_globalProxy;
95 QNetworkAccessManager *m_mgr; 95 QNetworkAccessManager m_mgr;
96 QNetworkReply *m_reply; 96 QNetworkReply *m_reply;
97 QNetworkDiskCache *m_cache; 97 QNetworkDiskCache *m_cache;
98 QDir m_cachedir; 98 QDir m_cachedir;