From 09c7c50ad3f28dc1de26310123fd393efb8f7a15 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 1 Jan 2010 20:29:03 +0000 Subject: [PATCH] - qBittorrent can now identify itself as KTorrent too --- Changelog | 2 +- src/bittorrent.cpp | 16 ++++++++++++---- src/options_imp.cpp | 28 +++++++++++++++++++++++++--- src/preferences.h | 17 ++++++++++------- src/src.pro | 2 ++ src/ui/options.ui | 5 +++++ src/webui/preferences_content.html | 19 ++++++++++++++----- 7 files changed, 69 insertions(+), 20 deletions(-) diff --git a/Changelog b/Changelog index d2468e1e5..c0964bebd 100644 --- a/Changelog +++ b/Changelog @@ -7,7 +7,7 @@ - FEATURE: Torrent files/folders can be renamed (torrent addition dialog or files properties) - FEATURE: uTorrent compatible tracker list support (use torrentz.com url as a default) - FEATURE: Better proxy support and preferences remodeling - - FEATURE: qBittorrent can identify itself as uTorrent or Vuze (Any version) + - FEATURE: qBittorrent can identify itself as uTorrent, Vuze or KTorrent (Any stable version) - FEATURE: Torrents can be renamed in transfer list - COSMETIC: Use checkboxes to filter torrent content instead of comboboxes - COSMETIC: Use alternating row colors in transfer list (set in program preferences) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 8adc582f7..d483f86a1 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -62,6 +62,8 @@ #define MAX_RATIO 100. enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5}; +enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL }; + // Main constructor Bittorrent::Bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), DHTEnabled(false), current_dht_port(0), queueingEnabled(false), geoipDBLoaded(false), exiting(false) { resolve_countries = false; @@ -73,17 +75,19 @@ Bittorrent::Bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit version << VERSION_MAJOR; version << VERSION_MINOR; version << VERSION_BUGFIX; - version << 0; + version << VERSION_TYPE; QString peer_id = Preferences::getPeerID(); if(peer_id.size() != 2) peer_id = "qB"; if(peer_id != "qB") { QStringList peer_ver = Preferences::getClientVersion().split('.'); - while(peer_ver.size() < 3) { + while(peer_ver.size() < 4) { peer_ver << "0"; } for(int i=0; icurrentIndex()) { + case 3: // KTorrent + Preferences::setPeerID("KT"); + Preferences::setClientVersion(client_version->text()); + break; case 2: // uTorrent Preferences::setPeerID("UT"); Preferences::setClientVersion(client_version->text()); @@ -725,9 +729,15 @@ void options_imp::loadOptions(){ enableSpoofingSettings(1); client_version->setText(Preferences::getClientVersion()); } else { - // qBittorrent - comboPeerID->setCurrentIndex(0); - enableSpoofingSettings(0); + if(peer_id == "KT") { + comboPeerID->setCurrentIndex(3); + enableSpoofingSettings(3); + client_version->setText(Preferences::getClientVersion()); + } else { + // qBittorrent + comboPeerID->setCurrentIndex(0); + enableSpoofingSettings(0); + } } } comboEncryption->setCurrentIndex(Preferences::getEncryptionSetting()); @@ -819,6 +829,15 @@ void options_imp::enableSpoofingSettings(int index) { client_build->setEnabled(true); client_build->setText(Preferences::getDefaultClientBuild("UT")); break; + case 3: // KTorrent + resetPeerVersion_button->setEnabled(true); + version_label->setEnabled(true); + client_version->setEnabled(true); + client_version->setText(Preferences::getDefaultClientVersion("KT")); + build_label->setEnabled(false); + client_build->setEnabled(false); + client_build->clear(); + break; } } @@ -827,6 +846,9 @@ void options_imp::on_resetPeerVersion_button_clicked() { case 1: // Vuze client_version->setText(Preferences::getDefaultClientVersion("AZ")); break; + case 3: // KTorrent + client_version->setText(Preferences::getDefaultClientVersion("KT")); + break; case 2: // uTorrent client_version->setText(Preferences::getDefaultClientVersion("UT")); client_build->setText(Preferences::getDefaultClientBuild("UT")); diff --git a/src/preferences.h b/src/preferences.h index 4655a8003..39534f2ef 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -462,14 +462,17 @@ public: if(peer_id == "UT") { // uTorrent return "1.8.5"; - } else { - // Azureus - if(peer_id == "AZ") { - return "4.3.0.4"; - } else { - return QString(VERSION); - } } + // Azureus + if(peer_id == "AZ") { + return "4.3.0.4"; + } + // KTorrent + if(peer_id == "KT") { + return "3.3.2"; + } + // qBittorrent + return QString(VERSION); } static QString getDefaultClientBuild(QString peer_id) { diff --git a/src/src.pro b/src/src.pro index 426b094ed..803ddebfa 100644 --- a/src/src.pro +++ b/src/src.pro @@ -16,6 +16,8 @@ DEFINES += VERSION=\\\"v2.1.0beta4\\\" DEFINES += VERSION_MAJOR=2 DEFINES += VERSION_MINOR=1 DEFINES += VERSION_BUGFIX=0 +# NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL +DEFINES += VERSION_TYPE=DEVEL # !mac:QMAKE_LFLAGS += -Wl,--as-needed contains(DEBUG_MODE, 1) { diff --git a/src/ui/options.ui b/src/ui/options.ui index 967e60696..31ae82566 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -1722,6 +1722,11 @@ QGroupBox { µTorrent + + + KTorrent + + diff --git a/src/webui/preferences_content.html b/src/webui/preferences_content.html index 469933cbc..13f930bc8 100644 --- a/src/webui/preferences_content.html +++ b/src/webui/preferences_content.html @@ -76,6 +76,7 @@ +    _(Version:) @@ -514,11 +515,19 @@ updateSpoofingSettings = function() { $('peer_build_text').set('disabled', 'true'); $('peer_build_text').set('value', ''); } else { - // qBittorrent - $('peer_version_text').set('disabled', 'true'); - $('peer_version_text').set('value', ''); - $('peer_build_text').set('disabled', 'true'); - $('peer_build_text').set('value', ''); + if(peer_id == "KT") { + // KTorrent + $('peer_version_text').removeProperty('disabled'); + $('peer_version_text').set('value', '3.3.2'); + $('peer_build_text').set('disabled', 'true'); + $('peer_build_text').set('value', ''); + } else { + // qBittorrent + $('peer_version_text').set('disabled', 'true'); + $('peer_version_text').set('value', ''); + $('peer_build_text').set('disabled', 'true'); + $('peer_build_text').set('value', ''); + } } } }