void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent) { AddNewTorrentDialog *dlg = new AddNewTorrentDialog(inParams, parent); if (Utils::Misc::isUrl(source)) { // Launch downloader // 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); connect(handler, &Net::DownloadHandler::redirectedToMagnet, dlg, &AddNewTorrentDialog::handleRedirectedToMagnet); } else { bool ok = false; BitTorrent::MagnetUri magnetUri(source); if (magnetUri.isValid()) ok = dlg->loadMagnet(magnetUri); else ok = dlg->loadTorrent(source); if (ok) #ifdef Q_OS_MAC dlg->exec(); #else dlg->open(); #endif else delete dlg; }
void AddNewTorrentDialog::show(QString source, QWidget *parent) { AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent); if (Utils::Misc::isUrl(source)) { // Launch downloader Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true); connect(handler, SIGNAL(downloadFinished(QString, QString)), dlg, SLOT(handleDownloadFinished(QString, QString))); connect(handler, SIGNAL(downloadFailed(QString, QString)), dlg, SLOT(handleDownloadFailed(QString, QString))); connect(handler, SIGNAL(redirectedToMagnet(QString, QString)), dlg, SLOT(handleRedirectedToMagnet(QString, QString))); } else { bool ok = false; BitTorrent::MagnetUri magnetUri(source); if (magnetUri.isValid()) ok = dlg->loadMagnet(magnetUri); else ok = dlg->loadTorrent(source); if (ok) dlg->open(); else delete dlg; } }
void AddNewTorrentDialog::show(QString source, QWidget *parent) { if (source.startsWith("bc://bt/", Qt::CaseInsensitive)) { qDebug("Converting bc link to magnet link"); source = Utils::Misc::bcLinkToMagnet(source); } AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent); if (Utils::Misc::isUrl(source)) { // Launch downloader Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(source, true, 10485760 /* 10MB */, true); connect(handler, SIGNAL(downloadFinished(QString, QString)), dlg, SLOT(handleDownloadFinished(QString, QString))); connect(handler, SIGNAL(downloadFailed(QString, QString)), dlg, SLOT(handleDownloadFailed(QString, QString))); connect(handler, SIGNAL(redirectedToMagnet(QString, QString)), dlg, SLOT(handleRedirectedToMagnet(QString, QString))); } else { bool ok = false; if (source.startsWith("magnet:", Qt::CaseInsensitive)) ok = dlg->loadMagnet(source); else ok = dlg->loadTorrent(source); if (ok) dlg->open(); else delete dlg; } }
void AddNewTorrentDialog::showMagnet(const QString& link, QWidget *parent) { AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent); if (dlg->loadMagnet(link)) dlg->open(); else delete dlg; }
void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url, QWidget *parent) { AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent); if (dlg->loadTorrent(torrent_path, from_url)) dlg->open(); else delete dlg; }