Use new DownloadManager interface

This commit is contained in:
Vladimir Golovnev (Glassez)
2018-06-25 20:31:32 +03:00
parent 8d438e159c
commit 112a9bcfa2
15 changed files with 47 additions and 57 deletions

View File

@@ -75,9 +75,8 @@ void DNSUpdater::checkPublicIP()
{
Q_ASSERT(m_state == OK);
DownloadHandler *handler = DownloadManager::instance()->downloadUrl(
"http://checkip.dyndns.org", false, 0, false,
"qBittorrent/" QBT_VERSION_2);
DownloadHandler *handler = DownloadManager::instance()->download(
DownloadRequest("http://checkip.dyndns.org").userAgent("qBittorrent/" QBT_VERSION_2));
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
, this, &DNSUpdater::ipRequestFinished);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &DNSUpdater::ipRequestFailed);
@@ -123,9 +122,8 @@ void DNSUpdater::updateDNSService()
qDebug() << Q_FUNC_INFO;
m_lastIPCheckTime = QDateTime::currentDateTime();
DownloadHandler *handler = DownloadManager::instance()->downloadUrl(
getUpdateUrl(), false, 0, false,
"qBittorrent/" QBT_VERSION_2);
DownloadHandler *handler = DownloadManager::instance()->download(
DownloadRequest(getUpdateUrl()).userAgent("qBittorrent/" QBT_VERSION_2));
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
, this, &DNSUpdater::ipUpdateFinished);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &DNSUpdater::ipUpdateFailed);

View File

@@ -155,11 +155,6 @@ Net::DownloadManager *Net::DownloadManager::instance()
return m_instance;
}
Net::DownloadHandler *Net::DownloadManager::downloadUrl(const QString &url, bool saveToFile, qint64 limit, bool handleRedirectToMagnet, const QString &userAgent)
{
return download(DownloadRequest(url).saveToFile(saveToFile).limit(limit).handleRedirectToMagnet(handleRedirectToMagnet).userAgent(userAgent));
}
Net::DownloadHandler *Net::DownloadManager::download(const DownloadRequest &downloadRequest)
{
// Process download request

View File

@@ -93,7 +93,6 @@ namespace Net
static void freeInstance();
static DownloadManager *instance();
DownloadHandler *downloadUrl(const QString &url, bool saveToFile = false, qint64 limit = 0, bool handleRedirectToMagnet = false, const QString &userAgent = "");
DownloadHandler *download(const DownloadRequest &downloadRequest);
void registerSequentialService(const ServiceID &serviceID);

View File

@@ -118,7 +118,7 @@ void GeoIPManager::manageDatabaseUpdate()
void GeoIPManager::downloadDatabaseFile()
{
DownloadHandler *handler = DownloadManager::instance()->downloadUrl(DATABASE_URL);
DownloadHandler *handler = DownloadManager::instance()->download({DATABASE_URL});
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
, this, &GeoIPManager::downloadFinished);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &GeoIPManager::downloadFailed);