Browse Source

- Remove useless code since it is handled on libtorrent side

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
31374d8d30
  1. 25
      src/bittorrent.cpp
  2. 1
      src/bittorrent.h
  3. 28
      src/torrentPersistentData.h

25
src/bittorrent.cpp

@ -156,7 +156,6 @@ void bittorrent::setDownloadLimit(QString hash, long val) { @@ -156,7 +156,6 @@ void bittorrent::setDownloadLimit(QString hash, long val) {
QTorrentHandle h = getTorrentHandle(hash);
if(h.is_valid()) {
h.set_download_limit(val);
TorrentPersistentData::saveSpeedLimits(h);
}
}
@ -169,7 +168,6 @@ void bittorrent::setUploadLimit(QString hash, long val) { @@ -169,7 +168,6 @@ void bittorrent::setUploadLimit(QString hash, long val) {
QTorrentHandle h = getTorrentHandle(hash);
if(h.is_valid()) {
h.set_upload_limit(val);
TorrentPersistentData::saveSpeedLimits(h);
}
}
@ -701,19 +699,12 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { @@ -701,19 +699,12 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
h.set_max_connections(Preferences::getMaxConnecsPerTorrent());
// Uploads limit per torrent
h.set_max_uploads(Preferences::getMaxUploadsPerTorrent());
// Speed limits
if(TorrentPersistentData::isKnownTorrent(h.hash())) {
h.set_download_limit(TorrentPersistentData::getDownloadLimit(h.hash()));
h.set_upload_limit(TorrentPersistentData::getUploadLimit(h.hash()));
}
// Resolve countries
h.resolve_countries(resolve_countries);
// Load filtered files
if(resumed) {
// Load custom url seeds
loadWebSeeds(hash);
// Load speed limit from hard drive
loadTorrentSpeedLimits(hash);
// Load trackers
loadTrackerFile(hash);
// XXX: only when resuming because torrentAddition dialog is not supported yet
@ -880,11 +871,6 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr @@ -880,11 +871,6 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
h.set_max_connections(Preferences::getMaxConnecsPerTorrent());
// Uploads limit per torrent
h.set_max_uploads(Preferences::getMaxUploadsPerTorrent());
// Speed limits
if(TorrentPersistentData::isKnownTorrent(h.hash())) {
h.set_download_limit(TorrentPersistentData::getDownloadLimit(h.hash()));
h.set_upload_limit(TorrentPersistentData::getUploadLimit(h.hash()));
}
// Resolve countries
qDebug("AddTorrent: Resolve_countries: %d", (int)resolve_countries);
h.resolve_countries(resolve_countries);
@ -893,8 +879,6 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr @@ -893,8 +879,6 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
if(resumed) {
// Load custom url seeds
loadWebSeeds(hash);
// Load speed limit from hard drive
loadTorrentSpeedLimits(hash);
// Load trackers
loadTrackerFile(hash);
} else {
@ -977,7 +961,6 @@ void bittorrent::setMaxConnectionsPerTorrent(int max) { @@ -977,7 +961,6 @@ void bittorrent::setMaxConnectionsPerTorrent(int max) {
continue;
}
h.set_max_connections(max);
TorrentPersistentData::saveSpeedLimits(h);
}
}
@ -992,7 +975,6 @@ void bittorrent::setMaxUploadsPerTorrent(int max) { @@ -992,7 +975,6 @@ void bittorrent::setMaxUploadsPerTorrent(int max) {
continue;
}
h.set_max_uploads(max);
TorrentPersistentData::saveSpeedLimits(h);
}
}
@ -1102,13 +1084,6 @@ bool bittorrent::enableDHT(bool b) { @@ -1102,13 +1084,6 @@ bool bittorrent::enableDHT(bool b) {
return true;
}
void bittorrent::loadTorrentSpeedLimits(QString hash) {
QTorrentHandle h = getTorrentHandle(hash);
qDebug("Loading speedLimits file for %s", hash.toLocal8Bit().data());
h.set_download_limit(TorrentPersistentData::getDownloadLimit(hash));
h.set_upload_limit(TorrentPersistentData::getUploadLimit(hash));
}
// Read pieces priorities from hard disk
// and ask QTorrentHandle to consider them
void bittorrent::loadFilesPriorities(QTorrentHandle &h) {

1
src/bittorrent.h

@ -135,7 +135,6 @@ class bittorrent : public QObject { @@ -135,7 +135,6 @@ class bittorrent : public QObject {
void enableIPFilter(QString filter);
void disableIPFilter();
void setQueueingEnabled(bool enable);
void loadTorrentSpeedLimits(QString hash);
void handleDownloadFailure(QString url, QString reason);
void loadWebSeeds(QString fileHash);
void downloadUrlAndSkipDialog(QString url, QString save_path=QString::null);

28
src/torrentPersistentData.h

@ -204,9 +204,6 @@ public: @@ -204,9 +204,6 @@ public:
}
// Sequential download
data["sequential"] = h.is_sequential_download();
// Speed limits
data["up_speed"] = h.upload_limit();
data["dl_speed"] = h.download_limit();
// Save data
all_data[h.hash()] = data;
settings.setValue("torrents", all_data);
@ -259,17 +256,6 @@ public: @@ -259,17 +256,6 @@ public:
qDebug("TorrentPersistentData: Saving save_path: %s, hash: %s", save_path.toLocal8Bit().data(), hash.toLocal8Bit().data());
}
static void saveSpeedLimits(QTorrentHandle h) {
Q_ASSERT(!h.hash().isEmpty());
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
data["up_speed"] = h.upload_limit();
data["dl_speed"] = h.download_limit();
all_data[h.hash()] = data;
settings.setValue("torrents", all_data);
}
static void saveUrlSeeds(QTorrentHandle h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
@ -325,20 +311,6 @@ public: @@ -325,20 +311,6 @@ public:
return data["files_priority"].toList();
}
static int getUploadLimit(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data.value("up_speed", -1).toInt();
}
static int getDownloadLimit(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data.value("dl_speed", -1).toInt();
}
static QString getSavePath(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();

Loading…
Cancel
Save