mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 17:23:07 -07:00
Use new DownloadManager interface
This commit is contained in:
parent
8d438e159c
commit
112a9bcfa2
15 changed files with 47 additions and 57 deletions
|
@ -1844,11 +1844,10 @@ void Session::handleRedirectedToMagnet(const QString &url, const QString &magnet
|
|||
}
|
||||
|
||||
// Add to BitTorrent session the downloaded torrent file
|
||||
void Session::handleDownloadFinished(const QString &url, const QString &filePath)
|
||||
void Session::handleDownloadFinished(const QString &url, const QByteArray &data)
|
||||
{
|
||||
emit downloadFromUrlFinished(url);
|
||||
addTorrent_impl(m_downloadedTorrents.take(url), MagnetUri(), TorrentInfo::loadFromFile(filePath));
|
||||
Utils::Fs::forceRemove(filePath); // remove temporary file
|
||||
addTorrent_impl(m_downloadedTorrents.take(url), MagnetUri(), TorrentInfo::load(data));
|
||||
}
|
||||
|
||||
// Return the torrent handle, given its hash
|
||||
|
@ -2077,10 +2076,11 @@ bool Session::addTorrent(QString source, const AddTorrentParams ¶ms)
|
|||
return addTorrent_impl(params, magnetUri);
|
||||
}
|
||||
else if (Utils::Misc::isUrl(source)) {
|
||||
Logger::instance()->addMessage(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source));
|
||||
LogMsg(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source));
|
||||
// Launch downloader
|
||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true);
|
||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
||||
Net::DownloadHandler *handler =
|
||||
Net::DownloadManager::instance()->download(Net::DownloadRequest(source).limit(10485760 /* 10MB */).handleRedirectToMagnet(true));
|
||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
|
||||
, this, &Session::handleDownloadFinished);
|
||||
connect(handler, &Net::DownloadHandler::downloadFailed, this, &Session::handleDownloadFailed);
|
||||
connect(handler, &Net::DownloadHandler::redirectedToMagnet, this, &Session::handleRedirectedToMagnet);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue