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; } }