mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Stop using internal libtorrent API. Closes 2202.
This commit is contained in:
parent
99a596ab8d
commit
79f3c6439c
2 changed files with 15 additions and 12 deletions
12
src/misc.cpp
12
src/misc.cpp
|
@ -70,6 +70,8 @@ const int UNLEN = 256;
|
||||||
#endif
|
#endif
|
||||||
#endif // DISABLE_GUI
|
#endif // DISABLE_GUI
|
||||||
|
|
||||||
|
#include <libtorrent/magnet_uri.hpp>
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
static struct { const char *source; const char *comment; } units[] = {
|
static struct { const char *source; const char *comment; } units[] = {
|
||||||
|
@ -372,6 +374,7 @@ QList<QUrl> misc::magnetUriToTrackers(const QString& magnet_uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString misc::magnetUriToHash(const QString& magnet_uri) {
|
QString misc::magnetUriToHash(const QString& magnet_uri) {
|
||||||
|
#if LIBTORRENT_VERSION_NUM < 1600
|
||||||
QString hash = "";
|
QString hash = "";
|
||||||
QRegExp regHex("urn:btih:([0-9A-Za-z]+)");
|
QRegExp regHex("urn:btih:([0-9A-Za-z]+)");
|
||||||
// Hex
|
// Hex
|
||||||
|
@ -397,6 +400,15 @@ QString misc::magnetUriToHash(const QString& magnet_uri) {
|
||||||
}
|
}
|
||||||
qDebug("magnetUriToHash (base32): hash: %s", qPrintable(hash));
|
qDebug("magnetUriToHash (base32): hash: %s", qPrintable(hash));
|
||||||
return hash;
|
return hash;
|
||||||
|
#else
|
||||||
|
add_torrent_params p;
|
||||||
|
error_code ec;
|
||||||
|
parse_magnet_uri(magnet_uri.toUtf8().constData(), p, ec);
|
||||||
|
|
||||||
|
if (ec)
|
||||||
|
return QString::null;
|
||||||
|
return toQString(p.info_hash);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take a number of seconds and return an user-friendly
|
// Take a number of seconds and return an user-friendly
|
||||||
|
|
|
@ -77,22 +77,13 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||||
{
|
{
|
||||||
QIniSettings settings;
|
QIniSettings settings;
|
||||||
const QString default_dir = settings.value(QString::fromUtf8("TorrentImport/LastContentDir"), QDir::homePath()).toString();
|
const QString default_dir = settings.value(QString::fromUtf8("TorrentImport/LastContentDir"), QDir::homePath()).toString();
|
||||||
// Test for multi-file taken from libtorrent/create_torrent.hpp -> create_torrent::create_torrent
|
|
||||||
bool multifile = t->num_files() > 1;
|
bool multifile = t->num_files() > 1;
|
||||||
#if LIBTORRENT_VERSION_NUM >= 1600
|
if (!multifile && (QDir::fromNativeSeparators(misc::toQStringU(t->file_at(0).path)).indexOf('/') != -1))
|
||||||
if (!multifile && has_parent_path(t->files().file_path(*(t->files().begin()))))
|
|
||||||
multifile = true;
|
multifile = true;
|
||||||
#else
|
|
||||||
if (!multifile && t->file_at(0).path.has_parent_path())
|
|
||||||
multifile = true;
|
|
||||||
#endif
|
|
||||||
if (!multifile) {
|
if (!multifile) {
|
||||||
// Single file torrent
|
// Single file torrent
|
||||||
#if LIBTORRENT_VERSION_NUM >= 1600
|
|
||||||
const QString file_name = fsutils::fileName(misc::toQStringU(t->file_at(0).path));
|
const QString file_name = fsutils::fileName(misc::toQStringU(t->file_at(0).path));
|
||||||
#else
|
|
||||||
const QString file_name = misc::toQStringU(t->file_at(0).path.filename());
|
|
||||||
#endif
|
|
||||||
qDebug("Torrent has only one file: %s", qPrintable(file_name));
|
qDebug("Torrent has only one file: %s", qPrintable(file_name));
|
||||||
QString extension = fsutils::fileExtension(file_name);
|
QString extension = fsutils::fileExtension(file_name);
|
||||||
qDebug("File extension is : %s", qPrintable(extension));
|
qDebug("File extension is : %s", qPrintable(extension));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue