mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- FEATURE: Added an option to set the max number of connections per torrent
- FEATURE: Added an option to set the max number of uploads per torrent
This commit is contained in:
parent
6ba4588e62
commit
078c80c81d
@ -35,6 +35,8 @@
|
|||||||
- FEATURE: Added BTJunkie search engine plugin
|
- FEATURE: Added BTJunkie search engine plugin
|
||||||
- FEATURE: Added an option to force full disk allocation for all torrents
|
- FEATURE: Added an option to force full disk allocation for all torrents
|
||||||
- FEATURE: Added an option to add torrents in paused state
|
- FEATURE: Added an option to add torrents in paused state
|
||||||
|
- FEATURE: Added an option to set the max number of connections per torrent
|
||||||
|
- FEATURE: Added an option to set the max number of uploads per torrent
|
||||||
- I18N: Added Hungarian translation
|
- I18N: Added Hungarian translation
|
||||||
- I18N: Added Brazilian translation
|
- I18N: Added Brazilian translation
|
||||||
- BUGFIX: Progress of paused torrents is now correct on restart
|
- BUGFIX: Progress of paused torrents is now correct on restart
|
||||||
|
6
TODO
6
TODO
@ -71,7 +71,7 @@
|
|||||||
LANGUAGES UPDATED:
|
LANGUAGES UPDATED:
|
||||||
- French *BETA6*
|
- French *BETA6*
|
||||||
- English *BETA6*
|
- English *BETA6*
|
||||||
- Japanese *BETA3*
|
- Japanese *BETA6*
|
||||||
- Swedish *BETA6*
|
- Swedish *BETA6*
|
||||||
- Slovak *BETA6*
|
- Slovak *BETA6*
|
||||||
- Ukrainian *BETA6*
|
- Ukrainian *BETA6*
|
||||||
@ -81,7 +81,7 @@ LANGUAGES UPDATED:
|
|||||||
- Polish *BETA6*
|
- Polish *BETA6*
|
||||||
- Portuguese *BETA5*
|
- Portuguese *BETA5*
|
||||||
- Brazilian *BETA5*
|
- Brazilian *BETA5*
|
||||||
- Spanish *BETA5*
|
- Spanish *BETA6*
|
||||||
- German *BETA6*
|
- German *BETA6*
|
||||||
- Russian *BETA6*
|
- Russian *BETA6*
|
||||||
- Korean *BETA6*
|
- Korean *BETA6*
|
||||||
@ -100,6 +100,8 @@ beta6->beta7 changelog:
|
|||||||
- FEATURE: Added an option to force full disk allocation for all torrents
|
- FEATURE: Added an option to force full disk allocation for all torrents
|
||||||
- FEATURE: Added an option to add torrents in paused state
|
- FEATURE: Added an option to add torrents in paused state
|
||||||
- FEATURE: Allow to disable UPnP/NAT-PMP/LSD
|
- FEATURE: Allow to disable UPnP/NAT-PMP/LSD
|
||||||
|
- FEATURE: Added an option to set the max number of connections per torrent
|
||||||
|
- FEATURE: Added an option to set the max number of uploads per torrent
|
||||||
- BUGFIX: In torrent content, it is now easier to filter all torrents using right click menu
|
- BUGFIX: In torrent content, it is now easier to filter all torrents using right click menu
|
||||||
- BUGFIX: Updated man page / README / INSTALL
|
- BUGFIX: Updated man page / README / INSTALL
|
||||||
- BUGFIX: Paused torrents could be displayed as connected for a sec after checking
|
- BUGFIX: Paused torrents could be displayed as connected for a sec after checking
|
||||||
|
183
src/GUI.cpp
183
src/GUI.cpp
@ -777,21 +777,35 @@ void GUI::processDownloadedFiles(QString path, QString url) {
|
|||||||
// Set BT session configuration
|
// Set BT session configuration
|
||||||
void GUI::configureSession(bool deleteOptions) {
|
void GUI::configureSession(bool deleteOptions) {
|
||||||
qDebug("Configuring session");
|
qDebug("Configuring session");
|
||||||
QPair<int, int> limits;
|
|
||||||
unsigned short old_listenPort, new_listenPort;
|
|
||||||
proxy_settings proxySettings;
|
|
||||||
session_settings sessionSettings;
|
|
||||||
pe_settings encryptionSettings;
|
|
||||||
// Downloads
|
// Downloads
|
||||||
BTSession->preAllocateAllFiles(options->preAllocateAllFiles());
|
BTSession->preAllocateAllFiles(options->preAllocateAllFiles());
|
||||||
BTSession->startTorrentsInPause(options->addTorrentsInPause());
|
BTSession->startTorrentsInPause(options->addTorrentsInPause());
|
||||||
// Connection
|
// Connection
|
||||||
old_listenPort = BTSession->getListenPort();
|
// * Ports binding
|
||||||
|
unsigned short old_listenPort = BTSession->getListenPort();
|
||||||
BTSession->setListeningPortsRange(options->getPorts());
|
BTSession->setListeningPortsRange(options->getPorts());
|
||||||
new_listenPort = BTSession->getListenPort();
|
unsigned short new_listenPort = BTSession->getListenPort();
|
||||||
if(new_listenPort != old_listenPort) {
|
if(new_listenPort != old_listenPort) {
|
||||||
downloadingTorrentTab->setInfoBar(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort)));
|
downloadingTorrentTab->setInfoBar(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort)));
|
||||||
}
|
}
|
||||||
|
// * Global download limit
|
||||||
|
QPair<int, int> limits = options->getGlobalBandwidthLimits();
|
||||||
|
if(limits.first <= 0) {
|
||||||
|
// Download limit disabled
|
||||||
|
BTSession->setDownloadRateLimit(-1);
|
||||||
|
} else {
|
||||||
|
// Enabled
|
||||||
|
BTSession->setDownloadRateLimit(limits.first*1024);
|
||||||
|
}
|
||||||
|
// * Global Upload limit
|
||||||
|
if(limits.second <= 0) {
|
||||||
|
// Upload limit disabled
|
||||||
|
BTSession->setUploadRateLimit(-1);
|
||||||
|
} else {
|
||||||
|
// Enabled
|
||||||
|
BTSession->setUploadRateLimit(limits.second*1024);
|
||||||
|
}
|
||||||
|
// * UPnP
|
||||||
if(options->isUPnPEnabled()) {
|
if(options->isUPnPEnabled()) {
|
||||||
BTSession->enableUPnP(true);
|
BTSession->enableUPnP(true);
|
||||||
downloadingTorrentTab->setInfoBar(tr("UPnP support [ON]"), QString::fromUtf8("blue"));
|
downloadingTorrentTab->setInfoBar(tr("UPnP support [ON]"), QString::fromUtf8("blue"));
|
||||||
@ -799,6 +813,7 @@ void GUI::configureSession(bool deleteOptions) {
|
|||||||
BTSession->enableUPnP(false);
|
BTSession->enableUPnP(false);
|
||||||
downloadingTorrentTab->setInfoBar(tr("UPnP support [OFF]"), QString::fromUtf8("blue"));
|
downloadingTorrentTab->setInfoBar(tr("UPnP support [OFF]"), QString::fromUtf8("blue"));
|
||||||
}
|
}
|
||||||
|
// * NAT-PMP
|
||||||
if(options->isNATPMPEnabled()) {
|
if(options->isNATPMPEnabled()) {
|
||||||
BTSession->enableNATPMP(true);
|
BTSession->enableNATPMP(true);
|
||||||
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [ON]"), QString::fromUtf8("blue"));
|
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [ON]"), QString::fromUtf8("blue"));
|
||||||
@ -806,87 +821,8 @@ void GUI::configureSession(bool deleteOptions) {
|
|||||||
BTSession->enableNATPMP(false);
|
BTSession->enableNATPMP(false);
|
||||||
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [OFF]"), QString::fromUtf8("blue"));
|
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [OFF]"), QString::fromUtf8("blue"));
|
||||||
}
|
}
|
||||||
// Bittorrent
|
// * Proxy settings
|
||||||
if(options->isLSDEnabled()) {
|
proxy_settings proxySettings;
|
||||||
BTSession->enableLSD(true);
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery [ON]"), QString::fromUtf8("blue"));
|
|
||||||
} else {
|
|
||||||
BTSession->enableLSD(false);
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery support [OFF]"), QString::fromUtf8("blue"));
|
|
||||||
}
|
|
||||||
if(options->isDHTEnabled()) {
|
|
||||||
BTSession->enableDHT(true);
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue"));
|
|
||||||
// Set DHT Port
|
|
||||||
BTSession->setDHTPort(new_listenPort);
|
|
||||||
}else{
|
|
||||||
BTSession->enableDHT(false);
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
|
|
||||||
}
|
|
||||||
// IP Filter
|
|
||||||
// Configure session regarding options
|
|
||||||
BTSession->setDefaultSavePath(options->getSavePath());
|
|
||||||
// Apply max connec limit (-1 if disabled)
|
|
||||||
BTSession->setMaxConnections(options->getMaxConnecs());
|
|
||||||
limits = options->getGlobalBandwidthLimits();
|
|
||||||
switch(limits.first) {
|
|
||||||
case -1: // Download limit disabled
|
|
||||||
case 0:
|
|
||||||
BTSession->setDownloadRateLimit(-1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BTSession->setDownloadRateLimit(limits.first*1024);
|
|
||||||
}
|
|
||||||
switch(limits.second) {
|
|
||||||
case -1: // Upload limit disabled
|
|
||||||
case 0:
|
|
||||||
BTSession->setUploadRateLimit(-1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BTSession->setUploadRateLimit(limits.second*1024);
|
|
||||||
}
|
|
||||||
// Apply ratio (0 if disabled)
|
|
||||||
BTSession->setGlobalRatio(options->getDesiredRatio());
|
|
||||||
// Encryption settings
|
|
||||||
int encryptionState = options->getEncryptionSetting();
|
|
||||||
// The most secure, rc4 only so that all streams and encrypted
|
|
||||||
encryptionSettings.allowed_enc_level = pe_settings::rc4;
|
|
||||||
encryptionSettings.prefer_rc4 = true;
|
|
||||||
switch(encryptionState) {
|
|
||||||
case 0: //Enabled
|
|
||||||
encryptionSettings.out_enc_policy = pe_settings::enabled;
|
|
||||||
encryptionSettings.in_enc_policy = pe_settings::enabled;
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("Encryption support [ON]"), QString::fromUtf8("blue"));
|
|
||||||
break;
|
|
||||||
case 1: // Forced
|
|
||||||
encryptionSettings.out_enc_policy = pe_settings::forced;
|
|
||||||
encryptionSettings.in_enc_policy = pe_settings::forced;
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("Encryption support [FORCED]"), QString::fromUtf8("blue"));
|
|
||||||
break;
|
|
||||||
default: // Disabled
|
|
||||||
encryptionSettings.out_enc_policy = pe_settings::disabled;
|
|
||||||
encryptionSettings.in_enc_policy = pe_settings::disabled;
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("Encryption support [OFF]"), QString::fromUtf8("blue"));
|
|
||||||
}
|
|
||||||
BTSession->applyEncryptionSettings(encryptionSettings);
|
|
||||||
// PeX
|
|
||||||
if(options->isPeXEnabled()) {
|
|
||||||
qDebug("Enabling Peer eXchange (PeX)");
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("PeX support [ON]"), QString::fromUtf8("blue"));
|
|
||||||
BTSession->enablePeerExchange();
|
|
||||||
}else{
|
|
||||||
downloadingTorrentTab->setInfoBar(tr("PeX support [OFF]"), QString::fromUtf8("blue"));
|
|
||||||
qDebug("Peer eXchange (PeX) disabled");
|
|
||||||
}
|
|
||||||
// Apply filtering settings
|
|
||||||
if(options->isFilteringEnabled()) {
|
|
||||||
BTSession->enableIPFilter(options->getFilter());
|
|
||||||
downloadingTorrentTab->setBottomTabEnabled(1, true);
|
|
||||||
}else{
|
|
||||||
BTSession->disableIPFilter();
|
|
||||||
downloadingTorrentTab->setBottomTabEnabled(1, false);
|
|
||||||
}
|
|
||||||
// Apply Proxy settings
|
|
||||||
if(options->isProxyEnabled()) {
|
if(options->isProxyEnabled()) {
|
||||||
switch(options->getProxyType()) {
|
switch(options->getProxyType()) {
|
||||||
case HTTP:
|
case HTTP:
|
||||||
@ -910,8 +846,79 @@ void GUI::configureSession(bool deleteOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BTSession->setProxySettings(proxySettings, options->useProxyForTrackers(), options->useProxyForPeers(), options->useProxyForWebseeds(), options->useProxyForDHT());
|
BTSession->setProxySettings(proxySettings, options->useProxyForTrackers(), options->useProxyForPeers(), options->useProxyForWebseeds(), options->useProxyForDHT());
|
||||||
|
// * Session settings
|
||||||
|
session_settings sessionSettings;
|
||||||
sessionSettings.user_agent = "qBittorrent "VERSION;
|
sessionSettings.user_agent = "qBittorrent "VERSION;
|
||||||
BTSession->setSessionSettings(sessionSettings);
|
BTSession->setSessionSettings(sessionSettings);
|
||||||
|
// Bittorrent
|
||||||
|
// * Max connections limit
|
||||||
|
BTSession->setMaxConnections(options->getMaxConnecs());
|
||||||
|
// * Max connections per torrent limit
|
||||||
|
BTSession->setMaxConnectionsPerTorrent(options->getMaxConnecsPerTorrent());
|
||||||
|
// * Max uploads per torrent limit
|
||||||
|
BTSession->setMaxUploadsPerTorrent(options->getMaxUploadsPerTorrent());
|
||||||
|
// * DHT
|
||||||
|
if(options->isDHTEnabled()) {
|
||||||
|
BTSession->enableDHT(true);
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue"));
|
||||||
|
// Set DHT Port
|
||||||
|
BTSession->setDHTPort(new_listenPort);
|
||||||
|
}else{
|
||||||
|
BTSession->enableDHT(false);
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
|
||||||
|
}
|
||||||
|
// * PeX
|
||||||
|
if(options->isPeXEnabled()) {
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("PeX support [ON]"), QString::fromUtf8("blue"));
|
||||||
|
BTSession->enablePeerExchange();
|
||||||
|
}else{
|
||||||
|
// TODO: How can we remove the extension?
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("PeX support [OFF]"), QString::fromUtf8("blue"));
|
||||||
|
}
|
||||||
|
// * LSD
|
||||||
|
if(options->isLSDEnabled()) {
|
||||||
|
BTSession->enableLSD(true);
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery [ON]"), QString::fromUtf8("blue"));
|
||||||
|
} else {
|
||||||
|
BTSession->enableLSD(false);
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery support [OFF]"), QString::fromUtf8("blue"));
|
||||||
|
}
|
||||||
|
// * Encryption
|
||||||
|
int encryptionState = options->getEncryptionSetting();
|
||||||
|
// The most secure, rc4 only so that all streams and encrypted
|
||||||
|
pe_settings encryptionSettings;
|
||||||
|
encryptionSettings.allowed_enc_level = pe_settings::rc4;
|
||||||
|
encryptionSettings.prefer_rc4 = true;
|
||||||
|
switch(encryptionState) {
|
||||||
|
case 0: //Enabled
|
||||||
|
encryptionSettings.out_enc_policy = pe_settings::enabled;
|
||||||
|
encryptionSettings.in_enc_policy = pe_settings::enabled;
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("Encryption support [ON]"), QString::fromUtf8("blue"));
|
||||||
|
break;
|
||||||
|
case 1: // Forced
|
||||||
|
encryptionSettings.out_enc_policy = pe_settings::forced;
|
||||||
|
encryptionSettings.in_enc_policy = pe_settings::forced;
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("Encryption support [FORCED]"), QString::fromUtf8("blue"));
|
||||||
|
break;
|
||||||
|
default: // Disabled
|
||||||
|
encryptionSettings.out_enc_policy = pe_settings::disabled;
|
||||||
|
encryptionSettings.in_enc_policy = pe_settings::disabled;
|
||||||
|
downloadingTorrentTab->setInfoBar(tr("Encryption support [OFF]"), QString::fromUtf8("blue"));
|
||||||
|
}
|
||||||
|
BTSession->applyEncryptionSettings(encryptionSettings);
|
||||||
|
// IP Filter
|
||||||
|
// Configure session regarding options
|
||||||
|
BTSession->setDefaultSavePath(options->getSavePath());
|
||||||
|
// Apply ratio (0 if disabled)
|
||||||
|
BTSession->setGlobalRatio(options->getDesiredRatio());
|
||||||
|
// Apply filtering settings
|
||||||
|
if(options->isFilteringEnabled()) {
|
||||||
|
BTSession->enableIPFilter(options->getFilter());
|
||||||
|
downloadingTorrentTab->setBottomTabEnabled(1, true);
|
||||||
|
}else{
|
||||||
|
BTSession->disableIPFilter();
|
||||||
|
downloadingTorrentTab->setBottomTabEnabled(1, false);
|
||||||
|
}
|
||||||
// Scan dir stuff
|
// Scan dir stuff
|
||||||
if(options->getScanDir().isNull()) {
|
if(options->getScanDir().isNull()) {
|
||||||
BTSession->disableDirectoryScanning();
|
BTSession->disableDirectoryScanning();
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#define MAX_TRACKER_ERRORS 2
|
#define MAX_TRACKER_ERRORS 2
|
||||||
|
|
||||||
// Main constructor
|
// Main constructor
|
||||||
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false){
|
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4) {
|
||||||
// To avoid some exceptions
|
// To avoid some exceptions
|
||||||
fs::path::default_name_check(fs::no_check);
|
fs::path::default_name_check(fs::no_check);
|
||||||
// Creating bittorrent session
|
// Creating bittorrent session
|
||||||
@ -369,7 +369,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
if(file.isEmpty()) {
|
if(file.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_ASSERT(!file.startsWith("http://") && !file.startsWith("https://") && !file.startsWith("ftp://"));
|
Q_ASSERT(!file.startsWith("http://", Qt::CaseInsensitive) && !file.startsWith("https://", Qt::CaseInsensitive) && !file.startsWith("ftp://", Qt::CaseInsensitive));
|
||||||
qDebug("Adding %s to download list", file.toUtf8().data());
|
qDebug("Adding %s to download list", file.toUtf8().data());
|
||||||
std::ifstream in(file.toUtf8().data(), std::ios_base::binary);
|
std::ifstream in(file.toUtf8().data(), std::ios_base::binary);
|
||||||
in.unsetf(std::ios_base::skipws);
|
in.unsetf(std::ios_base::skipws);
|
||||||
@ -386,15 +386,6 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
QString old_hash = fi.baseName();
|
QString old_hash = fi.baseName();
|
||||||
if(old_hash != hash){
|
if(old_hash != hash){
|
||||||
qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
|
qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
|
||||||
// QStringList filters;
|
|
||||||
// filters << old_hash+".*";
|
|
||||||
// QStringList files = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
|
||||||
// QString my_f;
|
|
||||||
// foreach(my_f, files) {
|
|
||||||
// qDebug("* deleting %s", my_f.toUtf8().data());
|
|
||||||
// torrentBackup.remove(my_f);
|
|
||||||
// }
|
|
||||||
// return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(s->find_torrent(t->info_hash()).is_valid()) {
|
if(s->find_torrent(t->info_hash()).is_valid()) {
|
||||||
@ -442,9 +433,10 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
if(!from_url.isNull()) QFile::remove(file);
|
if(!from_url.isNull()) QFile::remove(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Is this really useful and appropriate ?
|
// Connections limit per torrent
|
||||||
//h.set_max_connections(60);
|
h.set_max_connections(maxConnecsPerTorrent);
|
||||||
h.set_max_uploads(-1);
|
// Uploads limit per torrent
|
||||||
|
h.set_max_uploads(maxUploadsPerTorrent);
|
||||||
// Load filtered files
|
// Load filtered files
|
||||||
loadFilesPriorities(h);
|
loadFilesPriorities(h);
|
||||||
// Load custom url seeds
|
// Load custom url seeds
|
||||||
@ -557,6 +549,36 @@ void bittorrent::setMaxConnections(int maxConnec) {
|
|||||||
s->set_max_connections(maxConnec);
|
s->set_max_connections(maxConnec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bittorrent::setMaxConnectionsPerTorrent(int max) {
|
||||||
|
maxConnecsPerTorrent = max;
|
||||||
|
// Apply this to all session torrents
|
||||||
|
std::vector<torrent_handle> handles = s->get_torrents();
|
||||||
|
unsigned int nbHandles = handles.size();
|
||||||
|
for(unsigned int i=0; i<nbHandles; ++i) {
|
||||||
|
QTorrentHandle h = handles[i];
|
||||||
|
if(!h.is_valid()) {
|
||||||
|
qDebug("/!\\ Error: Invalid handle");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
h.set_max_connections(max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bittorrent::setMaxUploadsPerTorrent(int max) {
|
||||||
|
maxUploadsPerTorrent = max;
|
||||||
|
// Apply this to all session torrents
|
||||||
|
std::vector<torrent_handle> handles = s->get_torrents();
|
||||||
|
unsigned int nbHandles = handles.size();
|
||||||
|
for(unsigned int i=0; i<nbHandles; ++i) {
|
||||||
|
QTorrentHandle h = handles[i];
|
||||||
|
if(!h.is_valid()) {
|
||||||
|
qDebug("/!\\ Error: Invalid handle");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
h.set_max_uploads(max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return DHT state
|
// Return DHT state
|
||||||
bool bittorrent::isDHTEnabled() const{
|
bool bittorrent::isDHTEnabled() const{
|
||||||
return DHTEnabled;
|
return DHTEnabled;
|
||||||
@ -1151,8 +1173,10 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h) {
|
|||||||
}
|
}
|
||||||
QTorrentHandle new_h = s->add_torrent(t, saveDir, resumeData, false);
|
QTorrentHandle new_h = s->add_torrent(t, saveDir, resumeData, false);
|
||||||
qDebug("Using full allocation mode");
|
qDebug("Using full allocation mode");
|
||||||
|
// Connections limit per torrent
|
||||||
new_h.set_max_uploads(-1);
|
new_h.set_max_connections(maxConnecsPerTorrent);
|
||||||
|
// Uploads limit per torrent
|
||||||
|
new_h.set_max_uploads(maxUploadsPerTorrent);
|
||||||
// Load filtered Files
|
// Load filtered Files
|
||||||
loadFilesPriorities(new_h);
|
loadFilesPriorities(new_h);
|
||||||
// Load speed limit from hard drive
|
// Load speed limit from hard drive
|
||||||
|
@ -59,6 +59,8 @@ class bittorrent : public QObject{
|
|||||||
QStringList unfinishedTorrents;
|
QStringList unfinishedTorrents;
|
||||||
bool preAllocateAll;
|
bool preAllocateAll;
|
||||||
bool addInPause;
|
bool addInPause;
|
||||||
|
int maxConnecsPerTorrent;
|
||||||
|
int maxUploadsPerTorrent;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getSavePath(QString hash);
|
QString getSavePath(QString hash);
|
||||||
@ -112,6 +114,8 @@ class bittorrent : public QObject{
|
|||||||
// Session configuration - Setters
|
// Session configuration - Setters
|
||||||
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
||||||
void setMaxConnections(int maxConnec);
|
void setMaxConnections(int maxConnec);
|
||||||
|
void setMaxConnectionsPerTorrent(int max);
|
||||||
|
void setMaxUploadsPerTorrent(int max);
|
||||||
void setDownloadRateLimit(long rate);
|
void setDownloadRateLimit(long rate);
|
||||||
void setUploadRateLimit(long rate);
|
void setUploadRateLimit(long rate);
|
||||||
void setGlobalRatio(float ratio);
|
void setGlobalRatio(float ratio);
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -120,7 +120,7 @@ QStringList QTorrentHandle::url_seeds() const {
|
|||||||
std::vector<std::string> existing_seeds = h.get_torrent_info().url_seeds();
|
std::vector<std::string> existing_seeds = h.get_torrent_info().url_seeds();
|
||||||
unsigned int nbSeeds = existing_seeds.size();
|
unsigned int nbSeeds = existing_seeds.size();
|
||||||
QString existing_seed;
|
QString existing_seed;
|
||||||
for(unsigned int i=0; i<nbSeeds; ++i){
|
for(unsigned int i=0; i<nbSeeds; ++i) {
|
||||||
res << misc::toQString(existing_seeds[i]);
|
res << misc::toQString(existing_seeds[i]);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@ -278,11 +278,16 @@ void QTorrentHandle::add_url_seed(QString seed) {
|
|||||||
h.add_url_seed(misc::toString((const char*)seed.toUtf8()));
|
h.add_url_seed(misc::toString((const char*)seed.toUtf8()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_max_uploads(int val){
|
void QTorrentHandle::set_max_uploads(int val) {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_max_uploads(val);
|
h.set_max_uploads(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QTorrentHandle::set_max_connections(int val) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
|
h.set_max_connections(val);
|
||||||
|
}
|
||||||
|
|
||||||
void QTorrentHandle::prioritize_files(std::vector<int> v) {
|
void QTorrentHandle::prioritize_files(std::vector<int> v) {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
h.prioritize_files(v);
|
h.prioritize_files(v);
|
||||||
@ -308,7 +313,7 @@ void QTorrentHandle::set_sequenced_download_threshold(int val) {
|
|||||||
h.set_sequenced_download_threshold(val);
|
h.set_sequenced_download_threshold(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_tracker_login(QString username, QString password){
|
void QTorrentHandle::set_tracker_login(QString username, QString password) {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_tracker_login(std::string(username.toUtf8().data()), std::string(password.toUtf8().data()));
|
h.set_tracker_login(std::string(username.toUtf8().data()), std::string(password.toUtf8().data()));
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ class QTorrentHandle {
|
|||||||
void remove_url_seed(QString seed);
|
void remove_url_seed(QString seed);
|
||||||
void add_url_seed(QString seed);
|
void add_url_seed(QString seed);
|
||||||
void set_max_uploads(int val);
|
void set_max_uploads(int val);
|
||||||
|
void set_max_connections(int val);
|
||||||
void prioritize_files(std::vector<int> v);
|
void prioritize_files(std::vector<int> v);
|
||||||
void set_ratio(float ratio) const;
|
void set_ratio(float ratio) const;
|
||||||
void replace_trackers(std::vector<announce_entry> const&) const;
|
void replace_trackers(std::vector<announce_entry> const&) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user