mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 03:28:41 -07:00
Fix compilation error with libtorrent v0.14
This commit is contained in:
parent
b7a3ae2b4c
commit
fc8a822dac
1 changed files with 1007 additions and 999 deletions
|
@ -80,9 +80,9 @@ Bittorrent::Bittorrent()
|
||||||
UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false),
|
UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false),
|
||||||
DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
|
DHTEnabled(false), current_dht_port(0), queueingEnabled(false),
|
||||||
torrentExport(false), exiting(false)
|
torrentExport(false), exiting(false)
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
, geoipDBLoaded(false), resolve_countries(false)
|
, geoipDBLoaded(false), resolve_countries(false)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_tracker = 0;
|
m_tracker = 0;
|
||||||
// To avoid some exceptions
|
// To avoid some exceptions
|
||||||
|
@ -882,7 +882,11 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
|
||||||
}
|
}
|
||||||
QString torrent_name = misc::magnetUriToName(magnet_uri);
|
QString torrent_name = misc::magnetUriToName(magnet_uri);
|
||||||
const QString savePath(getSavePath(hash, false, QString::null, torrent_name));
|
const QString savePath(getSavePath(hash, false, QString::null, torrent_name));
|
||||||
if(!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash) && !TorrentTempData::isSeedingMode(hash)) {
|
if(!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)
|
||||||
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
|
&& !TorrentTempData::isSeedingMode(hash)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
qDebug("addMagnetURI: Temp folder is enabled.");
|
qDebug("addMagnetURI: Temp folder is enabled.");
|
||||||
qDebug("addTorrent::Temp folder is enabled.");
|
qDebug("addTorrent::Temp folder is enabled.");
|
||||||
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
||||||
|
@ -1134,7 +1138,11 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
} else {
|
} else {
|
||||||
savePath = getSavePath(hash, fromScanDir, path, root_folder);
|
savePath = getSavePath(hash, fromScanDir, path, root_folder);
|
||||||
}
|
}
|
||||||
if(!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash) && !TorrentTempData::isSeedingMode(hash)) {
|
if(!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)
|
||||||
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
|
&& !TorrentTempData::isSeedingMode(hash)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
qDebug("addTorrent::Temp folder is enabled.");
|
qDebug("addTorrent::Temp folder is enabled.");
|
||||||
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
||||||
if(!root_folder.isEmpty()) {
|
if(!root_folder.isEmpty()) {
|
||||||
|
@ -1634,7 +1642,7 @@ QStringList Bittorrent::getPeerBanMessages() const {
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
void Bittorrent::addConsoleMessage(QString msg, QString) {
|
void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
#else
|
#else
|
||||||
void Bittorrent::addConsoleMessage(QString msg, QColor color) {
|
void Bittorrent::addConsoleMessage(QString msg, QColor color) {
|
||||||
if(consoleMessages.size() > 100) {
|
if(consoleMessages.size() > 100) {
|
||||||
consoleMessages.removeFirst();
|
consoleMessages.removeFirst();
|
||||||
}
|
}
|
||||||
|
@ -1644,9 +1652,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
consoleMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + msg + QString::fromUtf8("</i></font>"));
|
consoleMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + msg + QString::fromUtf8("</i></font>"));
|
||||||
#endif
|
#endif
|
||||||
emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg);
|
emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
|
void Bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
|
||||||
if(peerBanMessages.size() > 100) {
|
if(peerBanMessages.size() > 100) {
|
||||||
peerBanMessages.removeFirst();
|
peerBanMessages.removeFirst();
|
||||||
}
|
}
|
||||||
|
@ -1654,9 +1662,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked due to your IP filter</i>", "x.y.z.w was blocked").arg(ip));
|
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked due to your IP filter</i>", "x.y.z.w was blocked").arg(ip));
|
||||||
else
|
else
|
||||||
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was banned due to corrupt pieces</i>", "x.y.z.w was banned").arg(ip));
|
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was banned due to corrupt pieces</i>", "x.y.z.w was banned").arg(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bittorrent::isFilePreviewPossible(QString hash) const{
|
bool Bittorrent::isFilePreviewPossible(QString hash) const{
|
||||||
// See if there are supported files in the torrent
|
// See if there are supported files in the torrent
|
||||||
const QTorrentHandle h = getTorrentHandle(hash);
|
const QTorrentHandle h = getTorrentHandle(hash);
|
||||||
if(!h.is_valid() || !h.has_metadata()) {
|
if(!h.is_valid() || !h.has_metadata()) {
|
||||||
|
@ -1669,9 +1677,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
|
void Bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
|
||||||
foreach(const QString &file, pathList) {
|
foreach(const QString &file, pathList) {
|
||||||
qDebug("File %s added", qPrintable(file));
|
qDebug("File %s added", qPrintable(file));
|
||||||
try {
|
try {
|
||||||
|
@ -1682,17 +1690,17 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
qDebug("Ignoring incomplete torrent file: %s", qPrintable(file));
|
qDebug("Ignoring incomplete torrent file: %s", qPrintable(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Bittorrent::getDefaultSavePath() const {
|
QString Bittorrent::getDefaultSavePath() const {
|
||||||
return defaultSavePath;
|
return defaultSavePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bittorrent::useTemporaryFolder() const {
|
bool Bittorrent::useTemporaryFolder() const {
|
||||||
return !defaultTempPath.isEmpty();
|
return !defaultTempPath.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::setDefaultTempPath(QString temppath) {
|
void Bittorrent::setDefaultTempPath(QString temppath) {
|
||||||
if(defaultTempPath == temppath)
|
if(defaultTempPath == temppath)
|
||||||
return;
|
return;
|
||||||
if(temppath.isEmpty()) {
|
if(temppath.isEmpty()) {
|
||||||
|
@ -1726,10 +1734,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultTempPath = temppath;
|
defaultTempPath = temppath;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBTORRENT_VERSION_MINOR > 14
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
void Bittorrent::appendqBextensionToTorrent(QTorrentHandle &h, bool append) {
|
void Bittorrent::appendqBextensionToTorrent(QTorrentHandle &h, bool append) {
|
||||||
if(!h.is_valid() || !h.has_metadata()) return;
|
if(!h.is_valid() || !h.has_metadata()) return;
|
||||||
std::vector<size_type> fp;
|
std::vector<size_type> fp;
|
||||||
h.file_progress(fp);
|
h.file_progress(fp);
|
||||||
|
@ -1754,10 +1762,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle &h, QString old_label, QString new_label) {
|
void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle &h, QString old_label, QString new_label) {
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
if(!appendLabelToSavePath) return;
|
if(!appendLabelToSavePath) return;
|
||||||
QString old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
QString old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
||||||
|
@ -1769,9 +1777,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
QDir().mkpath(new_save_path);
|
QDir().mkpath(new_save_path);
|
||||||
h.move_storage(new_save_path);
|
h.move_storage(new_save_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle& h) {
|
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle& h) {
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
const QString label = TorrentPersistentData::getLabel(h.hash());
|
const QString label = TorrentPersistentData::getLabel(h.hash());
|
||||||
if(label.isEmpty()) return;
|
if(label.isEmpty()) return;
|
||||||
|
@ -1783,9 +1791,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
QDir().mkpath(new_save_path);
|
QDir().mkpath(new_save_path);
|
||||||
h.move_storage(new_save_path);
|
h.move_storage(new_save_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::setAppendLabelToSavePath(bool append) {
|
void Bittorrent::setAppendLabelToSavePath(bool append) {
|
||||||
if(appendLabelToSavePath != append) {
|
if(appendLabelToSavePath != append) {
|
||||||
appendLabelToSavePath = !appendLabelToSavePath;
|
appendLabelToSavePath = !appendLabelToSavePath;
|
||||||
if(appendLabelToSavePath) {
|
if(appendLabelToSavePath) {
|
||||||
|
@ -1798,10 +1806,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBTORRENT_VERSION_MINOR > 14
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
void Bittorrent::setAppendqBExtension(bool append) {
|
void Bittorrent::setAppendqBExtension(bool append) {
|
||||||
if(appendqBExtension != append) {
|
if(appendqBExtension != append) {
|
||||||
appendqBExtension = !appendqBExtension;
|
appendqBExtension = !appendqBExtension;
|
||||||
// append or remove .!qB extension for incomplete files
|
// append or remove .!qB extension for incomplete files
|
||||||
|
@ -1812,12 +1820,12 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
appendqBextensionToTorrent(h, appendqBExtension);
|
appendqBextensionToTorrent(h, appendqBExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the ports range in which is chosen the port the Bittorrent
|
// Set the ports range in which is chosen the port the Bittorrent
|
||||||
// session will listen to
|
// session will listen to
|
||||||
void Bittorrent::setListeningPort(int port) {
|
void Bittorrent::setListeningPort(int port) {
|
||||||
std::pair<int,int> ports(port, port);
|
std::pair<int,int> ports(port, port);
|
||||||
const QString& iface_name = Preferences::getNetworkInterface();
|
const QString& iface_name = Preferences::getNetworkInterface();
|
||||||
if(iface_name.isEmpty()) {
|
if(iface_name.isEmpty()) {
|
||||||
|
@ -1835,30 +1843,30 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
qDebug("Listening on interface %s with ip %s", qPrintable(iface_name), qPrintable(ip));
|
qDebug("Listening on interface %s with ip %s", qPrintable(iface_name), qPrintable(ip));
|
||||||
s->listen_on(ports, ip.toLocal8Bit().constData());
|
s->listen_on(ports, ip.toLocal8Bit().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set download rate limit
|
// Set download rate limit
|
||||||
// -1 to disable
|
// -1 to disable
|
||||||
void Bittorrent::setDownloadRateLimit(long rate) {
|
void Bittorrent::setDownloadRateLimit(long rate) {
|
||||||
Q_ASSERT(rate == -1 || rate >= 0);
|
Q_ASSERT(rate == -1 || rate >= 0);
|
||||||
qDebug("Setting a global download rate limit at %ld", rate);
|
qDebug("Setting a global download rate limit at %ld", rate);
|
||||||
s->set_download_rate_limit(rate);
|
s->set_download_rate_limit(rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
session* Bittorrent::getSession() const{
|
session* Bittorrent::getSession() const{
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set upload rate limit
|
// Set upload rate limit
|
||||||
// -1 to disable
|
// -1 to disable
|
||||||
void Bittorrent::setUploadRateLimit(long rate) {
|
void Bittorrent::setUploadRateLimit(long rate) {
|
||||||
Q_ASSERT(rate == -1 || rate >= 0);
|
Q_ASSERT(rate == -1 || rate >= 0);
|
||||||
s->set_upload_rate_limit(rate);
|
s->set_upload_rate_limit(rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Torrents will a ratio superior to the given value will
|
// Torrents will a ratio superior to the given value will
|
||||||
// be automatically deleted
|
// be automatically deleted
|
||||||
void Bittorrent::setMaxRatio(float ratio) {
|
void Bittorrent::setMaxRatio(float ratio) {
|
||||||
if(ratio < 0) ratio = -1.;
|
if(ratio < 0) ratio = -1.;
|
||||||
if(ratio_limit == -1 && ratio != -1) {
|
if(ratio_limit == -1 && ratio != -1) {
|
||||||
Q_ASSERT(!BigRatioTimer);
|
Q_ASSERT(!BigRatioTimer);
|
||||||
|
@ -1875,10 +1883,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
qDebug("* Set deleteRatio to %.1f", ratio_limit);
|
qDebug("* Set deleteRatio to %.1f", ratio_limit);
|
||||||
processBigRatios();
|
processBigRatios();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set DHT port (>= 1 or 0 if same as BT)
|
// Set DHT port (>= 1 or 0 if same as BT)
|
||||||
void Bittorrent::setDHTPort(int dht_port) {
|
void Bittorrent::setDHTPort(int dht_port) {
|
||||||
if(dht_port >= 0) {
|
if(dht_port >= 0) {
|
||||||
if(dht_port == current_dht_port) return;
|
if(dht_port == current_dht_port) return;
|
||||||
struct dht_settings DHTSettings;
|
struct dht_settings DHTSettings;
|
||||||
|
@ -1887,10 +1895,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
current_dht_port = dht_port;
|
current_dht_port = dht_port;
|
||||||
qDebug("Set DHT Port to %d", dht_port);
|
qDebug("Set DHT Port to %d", dht_port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable IP Filtering
|
// Enable IP Filtering
|
||||||
void Bittorrent::enableIPFilter(QString filter) {
|
void Bittorrent::enableIPFilter(QString filter) {
|
||||||
qDebug("Enabling IPFiler");
|
qDebug("Enabling IPFiler");
|
||||||
if(!filterParser) {
|
if(!filterParser) {
|
||||||
filterParser = new FilterParserThread(this, s);
|
filterParser = new FilterParserThread(this, s);
|
||||||
|
@ -1899,32 +1907,32 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
filterPath = filter;
|
filterPath = filter;
|
||||||
filterParser->processFilterFile(filter);
|
filterParser->processFilterFile(filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable IP Filtering
|
// Disable IP Filtering
|
||||||
void Bittorrent::disableIPFilter() {
|
void Bittorrent::disableIPFilter() {
|
||||||
qDebug("Disabling IPFilter");
|
qDebug("Disabling IPFilter");
|
||||||
s->set_ip_filter(ip_filter());
|
s->set_ip_filter(ip_filter());
|
||||||
if(filterParser) {
|
if(filterParser) {
|
||||||
delete filterParser;
|
delete filterParser;
|
||||||
}
|
}
|
||||||
filterPath = "";
|
filterPath = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set BT session settings (user_agent)
|
// Set BT session settings (user_agent)
|
||||||
void Bittorrent::setSessionSettings(const session_settings &sessionSettings) {
|
void Bittorrent::setSessionSettings(const session_settings &sessionSettings) {
|
||||||
qDebug("Set session settings");
|
qDebug("Set session settings");
|
||||||
s->set_settings(sessionSettings);
|
s->set_settings(sessionSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Proxy
|
// Set Proxy
|
||||||
void Bittorrent::setPeerProxySettings(const proxy_settings &proxySettings) {
|
void Bittorrent::setPeerProxySettings(const proxy_settings &proxySettings) {
|
||||||
qDebug("Set Peer Proxy settings");
|
qDebug("Set Peer Proxy settings");
|
||||||
s->set_peer_proxy(proxySettings);
|
s->set_peer_proxy(proxySettings);
|
||||||
s->set_dht_proxy(proxySettings);
|
s->set_dht_proxy(proxySettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::setHTTPProxySettings(const proxy_settings &proxySettings) {
|
void Bittorrent::setHTTPProxySettings(const proxy_settings &proxySettings) {
|
||||||
s->set_tracker_proxy(proxySettings);
|
s->set_tracker_proxy(proxySettings);
|
||||||
s->set_web_seed_proxy(proxySettings);
|
s->set_web_seed_proxy(proxySettings);
|
||||||
QString proxy_str;
|
QString proxy_str;
|
||||||
|
@ -1968,9 +1976,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
else
|
else
|
||||||
setenv("http_proxy", proxy_str.toLocal8Bit().constData(), 1);
|
setenv("http_proxy", proxy_str.toLocal8Bit().constData(), 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::recursiveTorrentDownload(const QTorrentHandle &h) {
|
void Bittorrent::recursiveTorrentDownload(const QTorrentHandle &h) {
|
||||||
torrent_info::file_iterator it;
|
torrent_info::file_iterator it;
|
||||||
for(it = h.get_torrent_info().begin_files(); it != h.get_torrent_info().end_files(); it++) {
|
for(it = h.get_torrent_info().begin_files(); it != h.get_torrent_info().end_files(); it++) {
|
||||||
const QString torrent_relpath = misc::toQStringU(it->path.string());
|
const QString torrent_relpath = misc::toQStringU(it->path.string());
|
||||||
|
@ -1989,13 +1997,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::cleanUpAutoRunProcess(int) {
|
void Bittorrent::cleanUpAutoRunProcess(int) {
|
||||||
sender()->deleteLater();
|
sender()->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::autoRunExternalProgram(QTorrentHandle h, bool async) {
|
void Bittorrent::autoRunExternalProgram(QTorrentHandle h, bool async) {
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
QString program = Preferences::getAutoRunProgram().trimmed();
|
QString program = Preferences::getAutoRunProgram().trimmed();
|
||||||
if(program.isEmpty()) return;
|
if(program.isEmpty()) return;
|
||||||
|
@ -2014,9 +2022,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
process->execute(program);
|
process->execute(program);
|
||||||
delete process;
|
delete process;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::sendNotificationEmail(QTorrentHandle h) {
|
void Bittorrent::sendNotificationEmail(QTorrentHandle h) {
|
||||||
// Prepare mail content
|
// Prepare mail content
|
||||||
QString content = tr("Torrent name: %1").arg(h.name()) + "\n";
|
QString content = tr("Torrent name: %1").arg(h.name()) + "\n";
|
||||||
content += tr("Torrent size: %1").arg(misc::friendlyUnit(h.actual_size())) + "\n";
|
content += tr("Torrent size: %1").arg(misc::friendlyUnit(h.actual_size())) + "\n";
|
||||||
|
@ -2025,10 +2033,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
content += tr("Thank you for using qBittorrent.") + "\n";
|
content += tr("Thank you for using qBittorrent.") + "\n";
|
||||||
// Send the notification email
|
// Send the notification email
|
||||||
new Smtp("notification@qbittorrent.org", Preferences::getMailNotificationEmail(), tr("[qBittorrent] %1 has finished downloading").arg(h.name()), content);
|
new Smtp("notification@qbittorrent.org", Preferences::getMailNotificationEmail(), tr("[qBittorrent] %1 has finished downloading").arg(h.name()), content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read alerts sent by the Bittorrent session
|
// Read alerts sent by the Bittorrent session
|
||||||
void Bittorrent::readAlerts() {
|
void Bittorrent::readAlerts() {
|
||||||
// look at session alerts and display some infos
|
// look at session alerts and display some infos
|
||||||
std::auto_ptr<alert> a = s->pop_alert();
|
std::auto_ptr<alert> a = s->pop_alert();
|
||||||
while (a.get()) {
|
while (a.get()) {
|
||||||
|
@ -2431,9 +2439,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
a = s->pop_alert();
|
a = s->pop_alert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::recheckTorrent(QString hash) {
|
void Bittorrent::recheckTorrent(QString hash) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
if(h.is_valid() && h.has_metadata()) {
|
if(h.is_valid() && h.has_metadata()) {
|
||||||
if(h.is_paused()) {
|
if(h.is_paused()) {
|
||||||
|
@ -2444,22 +2452,22 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
h.force_recheck();
|
h.force_recheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, TrackerInfos> Bittorrent::getTrackersInfo(QString hash) const{
|
QHash<QString, TrackerInfos> Bittorrent::getTrackersInfo(QString hash) const{
|
||||||
return trackersInfos.value(hash, QHash<QString, TrackerInfos>());
|
return trackersInfos.value(hash, QHash<QString, TrackerInfos>());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bittorrent::getListenPort() const{
|
int Bittorrent::getListenPort() const{
|
||||||
qDebug("LISTEN PORT: %d", s->listen_port());
|
qDebug("LISTEN PORT: %d", s->listen_port());
|
||||||
return s->listen_port();
|
return s->listen_port();
|
||||||
}
|
}
|
||||||
|
|
||||||
session_status Bittorrent::getSessionStatus() const{
|
session_status Bittorrent::getSessionStatus() const{
|
||||||
return s->status();
|
return s->status();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Bittorrent::getSavePath(QString hash, bool fromScanDir, QString filePath, QString root_folder) {
|
QString Bittorrent::getSavePath(QString hash, bool fromScanDir, QString filePath, QString root_folder) {
|
||||||
QString savePath;
|
QString savePath;
|
||||||
if(TorrentTempData::hasTempData(hash)) {
|
if(TorrentTempData::hasTempData(hash)) {
|
||||||
savePath = TorrentTempData::getSavePath(hash);
|
savePath = TorrentTempData::getSavePath(hash);
|
||||||
|
@ -2514,33 +2522,33 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
if(!savePath.endsWith("/"))
|
if(!savePath.endsWith("/"))
|
||||||
savePath += "/";
|
savePath += "/";
|
||||||
return savePath;
|
return savePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take an url string to a torrent file,
|
// Take an url string to a torrent file,
|
||||||
// download the torrent file to a tmp location, then
|
// download the torrent file to a tmp location, then
|
||||||
// add it to download list
|
// add it to download list
|
||||||
void Bittorrent::downloadFromUrl(QString url) {
|
void Bittorrent::downloadFromUrl(QString url) {
|
||||||
addConsoleMessage(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url)
|
addConsoleMessage(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url)
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
, QPalette::WindowText
|
, QPalette::WindowText
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
//emit aboutToDownloadFromUrl(url);
|
//emit aboutToDownloadFromUrl(url);
|
||||||
// Launch downloader thread
|
// Launch downloader thread
|
||||||
downloader->downloadTorrentUrl(url);
|
downloader->downloadTorrentUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::downloadFromURLList(const QStringList& urls) {
|
void Bittorrent::downloadFromURLList(const QStringList& urls) {
|
||||||
foreach(const QString &url, urls) {
|
foreach(const QString &url, urls) {
|
||||||
downloadFromUrl(url);
|
downloadFromUrl(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::addMagnetSkipAddDlg(QString uri) {
|
void Bittorrent::addMagnetSkipAddDlg(QString uri) {
|
||||||
addMagnetUri(uri, false);
|
addMagnetUri(uri, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
||||||
//emit aboutToDownloadFromUrl(url);
|
//emit aboutToDownloadFromUrl(url);
|
||||||
const QUrl qurl = QUrl::fromEncoded(url.toLocal8Bit());
|
const QUrl qurl = QUrl::fromEncoded(url.toLocal8Bit());
|
||||||
if(!save_path.isEmpty())
|
if(!save_path.isEmpty())
|
||||||
|
@ -2548,10 +2556,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
url_skippingDlg << qurl;
|
url_skippingDlg << qurl;
|
||||||
// Launch downloader thread
|
// Launch downloader thread
|
||||||
downloader->downloadUrl(url);
|
downloader->downloadUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to Bittorrent session the downloaded torrent file
|
// Add to Bittorrent session the downloaded torrent file
|
||||||
void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
||||||
const int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit()));
|
const int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit()));
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
// Add file to torrent download list
|
// Add file to torrent download list
|
||||||
|
@ -2573,25 +2581,25 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
url_skippingDlg.removeAt(index);
|
url_skippingDlg.removeAt(index);
|
||||||
addTorrent(file_path, false, url, false);
|
addTorrent(file_path, false, url, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return current download rate for the BT
|
// Return current download rate for the BT
|
||||||
// session. Payload means that it only take into
|
// session. Payload means that it only take into
|
||||||
// account "useful" part of the rate
|
// account "useful" part of the rate
|
||||||
float Bittorrent::getPayloadDownloadRate() const{
|
float Bittorrent::getPayloadDownloadRate() const{
|
||||||
return s->status().payload_download_rate;
|
return s->status().payload_download_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return current upload rate for the BT
|
// Return current upload rate for the BT
|
||||||
// session. Payload means that it only take into
|
// session. Payload means that it only take into
|
||||||
// account "useful" part of the rate
|
// account "useful" part of the rate
|
||||||
float Bittorrent::getPayloadUploadRate() const{
|
float Bittorrent::getPayloadUploadRate() const{
|
||||||
return s->status().payload_upload_rate;
|
return s->status().payload_upload_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBTORRENT_VERSION_MINOR < 15
|
#if LIBTORRENT_VERSION_MINOR < 15
|
||||||
// Save DHT entry to hard drive
|
// Save DHT entry to hard drive
|
||||||
void Bittorrent::saveDHTEntry() {
|
void Bittorrent::saveDHTEntry() {
|
||||||
// Save DHT entry
|
// Save DHT entry
|
||||||
if(DHTEnabled) {
|
if(DHTEnabled) {
|
||||||
try{
|
try{
|
||||||
|
@ -2607,17 +2615,17 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Bittorrent::applyEncryptionSettings(pe_settings se) {
|
void Bittorrent::applyEncryptionSettings(pe_settings se) {
|
||||||
qDebug("Applying encryption settings");
|
qDebug("Applying encryption settings");
|
||||||
s->set_pe_settings(se);
|
s->set_pe_settings(se);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will fast resume torrents in
|
// Will fast resume torrents in
|
||||||
// backup directory
|
// backup directory
|
||||||
void Bittorrent::startUpTorrents() {
|
void Bittorrent::startUpTorrents() {
|
||||||
qDebug("Resuming unfinished torrents");
|
qDebug("Resuming unfinished torrents");
|
||||||
const QDir torrentBackup(misc::BTBackupLocation());
|
const QDir torrentBackup(misc::BTBackupLocation());
|
||||||
const QStringList known_torrents = TorrentPersistentData::knownTorrents();
|
const QStringList known_torrents = TorrentPersistentData::knownTorrents();
|
||||||
|
@ -2675,4 +2683,4 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
QIniSettings settings("qBittorrent", "qBittorrent");
|
||||||
settings.setValue("ported_to_new_savepath_system", true);
|
settings.setValue("ported_to_new_savepath_system", true);
|
||||||
qDebug("Unfinished torrents resumed");
|
qDebug("Unfinished torrents resumed");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue