From 1b4dad214ae1fe52ce407d2b89a0187ac466722a Mon Sep 17 00:00:00 2001 From: buinsky Date: Sat, 13 Dec 2014 01:25:37 +0300 Subject: [PATCH 1/4] Fix setting session id --- src/webui/abstractrequesthandler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/webui/abstractrequesthandler.cpp b/src/webui/abstractrequesthandler.cpp index 6d6fa1c8b..8753e9409 100644 --- a/src/webui/abstractrequesthandler.cpp +++ b/src/webui/abstractrequesthandler.cpp @@ -45,8 +45,6 @@ AbstractRequestHandler::AbstractRequestHandler(const HttpRequest &request, const HttpResponse AbstractRequestHandler::run() { - response_ = HttpResponse(); - if (isBanned()) { status(403, "Forbidden"); print(QObject::tr("Your IP address has been banned after too many failed authentication attempts."), CONTENT_TYPE_TXT); From 364e4277ecca1bd18bc83a0669d96a2dfe3a7573 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sat, 13 Dec 2014 02:48:30 +0300 Subject: [PATCH 2/4] Show upload and download limits in status bar --- src/webui/btjson.cpp | 8 ++++++++ src/webui/www/public/scripts/client.js | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 0f422b4ad..1c8190fd2 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -45,6 +45,7 @@ #endif #include +#include using namespace libtorrent; @@ -135,8 +136,10 @@ static const char KEY_FILE_IS_SEED[] = "is_seed"; // TransferInfo keys static const char KEY_TRANSFER_DLSPEED[] = "dl_info_speed"; static const char KEY_TRANSFER_DLDATA[] = "dl_info_data"; +static const char KEY_TRANSFER_DLRATELIMIT[] = "dl_rate_limit"; static const char KEY_TRANSFER_UPSPEED[] = "up_info_speed"; static const char KEY_TRANSFER_UPDATA[] = "up_info_data"; +static const char KEY_TRANSFER_UPRATELIMIT[] = "up_rate_limit"; class QTorrentCompare { @@ -448,9 +451,14 @@ QByteArray btjson::getTransferInfo() { CACHED_VARIABLE(QVariantMap, info, CACHE_DURATION_MS); session_status sessionStatus = QBtSession::instance()->getSessionStatus(); + session_settings sessionSettings = QBtSession::instance()->getSession()->settings(); info[KEY_TRANSFER_DLSPEED] = sessionStatus.payload_download_rate; info[KEY_TRANSFER_DLDATA] = static_cast(sessionStatus.total_payload_download); info[KEY_TRANSFER_UPSPEED] = sessionStatus.payload_upload_rate; info[KEY_TRANSFER_UPDATA] = static_cast(sessionStatus.total_payload_upload); + if (sessionSettings.download_rate_limit) + info[KEY_TRANSFER_DLRATELIMIT] = sessionSettings.download_rate_limit; + if (sessionSettings.upload_rate_limit) + info[KEY_TRANSFER_UPRATELIMIT] = sessionSettings.upload_rate_limit; return json::toJson(info); } diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index e7bd8b652..8602f72a3 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -240,12 +240,20 @@ window.addEvent('load', function () { }, onSuccess : function (info) { if (info) { - $("DlInfos").set('html', "_(D: %1 - T: %2)" + dl_limit = ""; + if (info.dl_rate_limit != undefined) + dl_limit = "[%1] ".replace("%1", friendlyUnit(info.dl_rate_limit, true)); + $("DlInfos").set('html', "%3_(D: %1 - T: %2)" .replace("%1", friendlyUnit(info.dl_info_speed, true)) - .replace("%2", friendlyUnit(info.dl_info_data, false))); - $("UpInfos").set('html', "_(U: %1 - T: %2)" + .replace("%2", friendlyUnit(info.dl_info_data, false)) + .replace("%3", dl_limit)); + up_limit = ""; + if (info.up_rate_limit != undefined) + up_limit = "[%1] ".replace("%1", friendlyUnit(info.up_rate_limit, true)); + $("UpInfos").set('html', "%3_(U: %1 - T: %2)" .replace("%1", friendlyUnit(info.up_info_speed, true)) - .replace("%2", friendlyUnit(info.up_info_data, false))); + .replace("%2", friendlyUnit(info.up_info_data, false)) + .replace("%3", up_limit)); if (speedInTitle) document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true)); else From c95e1813781ae3797e1bf1acc7f7b9f3d226ede8 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sat, 13 Dec 2014 03:01:03 +0300 Subject: [PATCH 3/4] Disable flooding debug messages --- src/qtlibtorrent/qtorrenthandle.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index d30d0cacc..4c06b68f7 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -63,12 +63,10 @@ static QPair get_file_extremity_pieces(const torrent_info& t, int file // Determine the first and last piece of the file int first_piece = floor((file.offset + 1) / (float) piece_size); Q_ASSERT(first_piece >= 0 && first_piece < num_pieces); - qDebug("First piece of the file is %d/%d", first_piece, num_pieces - 1); int num_pieces_in_file = ceil(file.size / (float) piece_size); int last_piece = first_piece + num_pieces_in_file - 1; Q_ASSERT(last_piece >= 0 && last_piece < num_pieces); - qDebug("last piece of the file is %d/%d", last_piece, num_pieces - 1); return qMakePair(first_piece, last_piece); } From 98deac97a0fd21300415d4863ed53c08c7cbaf20 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sat, 13 Dec 2014 03:54:24 +0300 Subject: [PATCH 4/4] Precise setting of upload/download limits --- src/webui/www/public/downloadlimit.html | 5 +- src/webui/www/public/scripts/parametrics.js | 69 +++++++++++---------- src/webui/www/public/uploadlimit.html | 5 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/webui/www/public/downloadlimit.html b/src/webui/www/public/downloadlimit.html index 1cf3ae6e5..74f7c8a8f 100644 --- a/src/webui/www/public/downloadlimit.html +++ b/src/webui/www/public/downloadlimit.html @@ -4,7 +4,6 @@ _(Torrent Download Speed Limiting) - @@ -13,7 +12,7 @@
-
_(Download limit:) 0 _(KiB/s)
+
_(Download limit:) _(KiB/s)
@@ -23,7 +22,7 @@ @@ -13,7 +12,7 @@
-
_(Upload limit:) 0 _(KiB/s)
+
_(Upload limit:) _(KiB/s)
@@ -23,7 +22,7 @@