mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 16:58:06 -06:00
Merge pull request #9125 from glassez/downloader
Implement "Sequential downloading" feature. Closes #6835
This commit is contained in:
@@ -230,7 +230,9 @@ void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParam
|
||||
|
||||
if (Utils::Misc::isUrl(source)) {
|
||||
// Launch downloader
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true);
|
||||
// TODO: Don't save loaded torrent to file, just use downloaded data!
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(source).limit(10485760 /* 10MB */).handleRedirectToMagnet(true).saveToFile(true));
|
||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
||||
, dlg, &AddNewTorrentDialog::handleDownloadFinished);
|
||||
connect(handler, &Net::DownloadHandler::downloadFailed, dlg, &AddNewTorrentDialog::handleDownloadFailed);
|
||||
|
||||
@@ -2041,11 +2041,11 @@ void MainWindow::installPython()
|
||||
{
|
||||
setCursor(QCursor(Qt::WaitCursor));
|
||||
// Download python
|
||||
Net::DownloadHandler *handler = nullptr;
|
||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
|
||||
handler = Net::DownloadManager::instance()->downloadUrl("https://www.python.org/ftp/python/3.5.2/python-3.5.2.exe", true);
|
||||
else
|
||||
handler = Net::DownloadManager::instance()->downloadUrl("https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi", true);
|
||||
const QString installerURL = ((QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
|
||||
? "https://www.python.org/ftp/python/3.5.2/python-3.5.2.exe"
|
||||
: "https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi");
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(installerURL).saveToFile(true));
|
||||
|
||||
using Func = void (Net::DownloadHandler::*)(const QString &, const QString &);
|
||||
connect(handler, static_cast<Func>(&Net::DownloadHandler::downloadFinished), this, &MainWindow::pythonDownloadSuccess);
|
||||
|
||||
@@ -61,11 +61,10 @@ ProgramUpdater::ProgramUpdater(QObject *parent, bool invokedByUser)
|
||||
|
||||
void ProgramUpdater::checkForUpdates()
|
||||
{
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(
|
||||
RSS_URL, false, 0, false,
|
||||
// Don't change this User-Agent. In case our updater goes haywire,
|
||||
// the filehost can identify it and contact us.
|
||||
"qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)");
|
||||
// Don't change this User-Agent. In case our updater goes haywire,
|
||||
// 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);
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "trackersadditiondialog.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QBuffer>
|
||||
#include <QMessageBox>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
@@ -70,25 +71,16 @@ QStringList TrackersAdditionDialog::newTrackers() const
|
||||
void TrackersAdditionDialog::on_uTorrentListButton_clicked()
|
||||
{
|
||||
m_ui->uTorrentListButton->setEnabled(false);
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_ui->list_url->text(), true);
|
||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download({m_ui->list_url->text()});
|
||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
|
||||
, this, &TrackersAdditionDialog::parseUTorrentList);
|
||||
connect(handler, &Net::DownloadHandler::downloadFailed, this, &TrackersAdditionDialog::getTrackerError);
|
||||
// Just to show that it takes times
|
||||
setCursor(Qt::WaitCursor);
|
||||
}
|
||||
|
||||
void TrackersAdditionDialog::parseUTorrentList(const QString &, const QString &path)
|
||||
void TrackersAdditionDialog::parseUTorrentList(const QString &, const QByteArray &data)
|
||||
{
|
||||
QFile listFile(path);
|
||||
if (!listFile.open(QFile::ReadOnly)) {
|
||||
QMessageBox::warning(this, tr("I/O Error"), tr("Error while trying to open the downloaded file."), QMessageBox::Ok);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
m_ui->uTorrentListButton->setEnabled(true);
|
||||
Utils::Fs::forceRemove(path);
|
||||
return;
|
||||
}
|
||||
|
||||
// Load from torrent handle
|
||||
QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
|
||||
// Load from current user list
|
||||
@@ -103,19 +95,21 @@ void TrackersAdditionDialog::parseUTorrentList(const QString &, const QString &p
|
||||
if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith('\n'))
|
||||
m_ui->trackers_list->insertPlainText("\n");
|
||||
int nb = 0;
|
||||
while (!listFile.atEnd()) {
|
||||
const QString line = listFile.readLine().trimmed();
|
||||
QBuffer buffer;
|
||||
buffer.setData(data);
|
||||
buffer.open(QBuffer::ReadOnly);
|
||||
while (!buffer.atEnd()) {
|
||||
const QString line = buffer.readLine().trimmed();
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
BitTorrent::TrackerEntry newTracker(line);
|
||||
if (!existingTrackers.contains(newTracker)) {
|
||||
m_ui->trackers_list->insertPlainText(line + '\n');
|
||||
++nb;
|
||||
}
|
||||
}
|
||||
// Clean up
|
||||
listFile.close();
|
||||
Utils::Fs::forceRemove(path);
|
||||
//To restore the cursor ...
|
||||
|
||||
// To restore the cursor ...
|
||||
setCursor(Qt::ArrowCursor);
|
||||
m_ui->uTorrentListButton->setEnabled(true);
|
||||
// Display information message if necessary
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void on_uTorrentListButton_clicked();
|
||||
void parseUTorrentList(const QString &, const QString &path);
|
||||
void parseUTorrentList(const QString &, const QByteArray &data);
|
||||
void getTrackerError(const QString &, const QString &error);
|
||||
|
||||
private:
|
||||
|
||||
@@ -292,7 +292,8 @@ void PluginSelectDialog::addNewPlugin(QString pluginName)
|
||||
else {
|
||||
// Icon is missing, we must download it
|
||||
using namespace Net;
|
||||
DownloadHandler *handler = DownloadManager::instance()->downloadUrl(plugin->url + "/favicon.ico", true);
|
||||
DownloadHandler *handler = DownloadManager::instance()->download(
|
||||
DownloadRequest(plugin->url + "/favicon.ico").saveToFile(true));
|
||||
connect(handler, static_cast<void (DownloadHandler::*)(const QString &, const QString &)>(&DownloadHandler::downloadFinished)
|
||||
, this, &PluginSelectDialog::iconDownloaded);
|
||||
connect(handler, &DownloadHandler::downloadFailed, this, &PluginSelectDialog::iconDownloadFailed);
|
||||
|
||||
@@ -404,7 +404,8 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac
|
||||
void TrackerFiltersList::downloadFavicon(const QString& url)
|
||||
{
|
||||
if (!m_downloadTrackerFavicon) return;
|
||||
Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(url, true);
|
||||
Net::DownloadHandler *h = Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(url).saveToFile(true));
|
||||
using Func = void (Net::DownloadHandler::*)(const QString &, const QString &);
|
||||
connect(h, static_cast<Func>(&Net::DownloadHandler::downloadFinished), this
|
||||
, &TrackerFiltersList::handleFavicoDownload);
|
||||
|
||||
Reference in New Issue
Block a user