Reduce number of DownloadManager signals

This commit is contained in:
Vladimir Golovnev (Glassez) 2019-03-01 10:38:16 +03:00
parent 0f1fc7be9d
commit 6cb15706f5
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
26 changed files with 317 additions and 337 deletions

View file

@ -58,14 +58,18 @@ void ProgramUpdater::checkForUpdates()
// the filehost can identify it and contact us.
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
Net::DownloadRequest(RSS_URL).userAgent("qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)"));
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
, this, &ProgramUpdater::rssDownloadFinished);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &ProgramUpdater::rssDownloadFailed);
connect(handler, &Net::DownloadHandler::finished, this, &ProgramUpdater::rssDownloadFinished);
}
void ProgramUpdater::rssDownloadFinished(const QString &url, const QByteArray &data)
void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
{
Q_UNUSED(url);
if (result.status != Net::DownloadStatus::Success) {
qDebug() << "Downloading the new qBittorrent updates RSS failed:" << result.errorString;
emit updateCheckFinished(false, QString(), m_invokedByUser);
return;
}
qDebug("Finished downloading the new qBittorrent updates RSS");
#ifdef Q_OS_MAC
@ -77,7 +81,7 @@ void ProgramUpdater::rssDownloadFinished(const QString &url, const QByteArray &d
#endif
QString version;
QXmlStreamReader xml(data);
QXmlStreamReader xml(result.data);
bool inItem = false;
QString updateLink;
QString type;
@ -118,14 +122,6 @@ void ProgramUpdater::rssDownloadFinished(const QString &url, const QByteArray &d
emit updateCheckFinished(!m_updateUrl.isEmpty(), version, m_invokedByUser);
}
void ProgramUpdater::rssDownloadFailed(const QString &url, const QString &error)
{
Q_UNUSED(url);
qDebug() << "Downloading the new qBittorrent updates RSS failed:" << error;
emit updateCheckFinished(false, QString(), m_invokedByUser);
}
void ProgramUpdater::updateProgram()
{
Q_ASSERT(!m_updateUrl.isEmpty());