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

1
src/bittorrent.h

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

28
src/torrentPersistentData.h

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

Loading…
Cancel
Save