mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 21:38:51 +03:00
commit
47e7b3fac2
7 changed files with 60 additions and 47 deletions
|
@ -63,12 +63,10 @@ static QPair<int, int> 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#endif
|
||||
|
||||
#include <libtorrent/session_status.hpp>
|
||||
#include <libtorrent/session.hpp>
|
||||
|
||||
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<qlonglong>(sessionStatus.total_payload_download);
|
||||
info[KEY_TRANSFER_UPSPEED] = sessionStatus.payload_upload_rate;
|
||||
info[KEY_TRANSFER_UPDATA] = static_cast<qlonglong>(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);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>_(Torrent Download Speed Limiting)</title>
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="css/mocha.css" type="text/css" />
|
||||
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="scripts/mocha-yc.js" charset="utf-8"></script>
|
||||
|
@ -13,7 +12,7 @@
|
|||
<body>
|
||||
<div style="width: 100%; text-align: center; margin: 0 auto;">
|
||||
<div id="dllimitSlider" class="slider">
|
||||
<div id="dllimitUpdate" class="update">_(Download limit:) <span id="dllimitUpdatevalue" class="updatevalue">0</span> <span id="dlLimitUnit">_(KiB/s)</span></div>
|
||||
<div id="dllimitUpdate" class="update">_(Download limit:) <input id="dllimitUpdatevalue" size="6" placeholder="∞" style="text-align: center;"> <span id="dlLimitUnit">_(KiB/s)</span></div>
|
||||
<div class="sliderWrapper">
|
||||
<div id="dllimitSliderknob" class="sliderknob"></div>
|
||||
<div id="dllimitSliderarea" class="sliderarea"></div>
|
||||
|
@ -23,7 +22,7 @@
|
|||
<script type="text/javascript">
|
||||
var hash = new URI().getData('hash');
|
||||
setDlLimit = function() {
|
||||
var limit = $("dllimitUpdatevalue").get('html').toInt() * 1024;
|
||||
var limit = $("dllimitUpdatevalue").value.toInt() * 1024;
|
||||
if(hash == "global") {
|
||||
new Request({url: 'command/setGlobalDlLimit',
|
||||
method: 'post',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -46,23 +46,23 @@ MochaUI.extend({
|
|||
initialStep: up_limit.round(),
|
||||
onChange: function(pos) {
|
||||
if (pos > 0) {
|
||||
$('uplimitUpdatevalue').set('html', pos);
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
$('uplimitUpdatevalue').value = pos;
|
||||
$('upLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
else {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
$('uplimitUpdatevalue').value = '∞';
|
||||
$('upLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if (up_limit == 0) {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
$('uplimitUpdatevalue').value = '∞';
|
||||
$('upLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
else {
|
||||
$('uplimitUpdatevalue').set('html', up_limit.round());
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
$('uplimitUpdatevalue').value = up_limit.round();
|
||||
$('upLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -82,23 +82,23 @@ MochaUI.extend({
|
|||
initialStep: (up_limit / 1024.).round(),
|
||||
onChange: function(pos) {
|
||||
if (pos > 0) {
|
||||
$('uplimitUpdatevalue').set('html', pos);
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
$('uplimitUpdatevalue').value = pos;
|
||||
$('upLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
else {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
$('uplimitUpdatevalue').value = '∞';
|
||||
$('upLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if (up_limit == 0) {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
$('uplimitUpdatevalue').value = '∞';
|
||||
$('upLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
else {
|
||||
$('uplimitUpdatevalue').set('html', (up_limit / 1024.).round());
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
$('uplimitUpdatevalue').value = (up_limit / 1024.).round();
|
||||
$('upLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,10 @@ MochaUI.extend({
|
|||
maximum = tmp / 1024.
|
||||
}
|
||||
else {
|
||||
maximum = 1000
|
||||
if (hash == "global")
|
||||
maximum = 10000;
|
||||
else
|
||||
maximum = 1000;
|
||||
}
|
||||
}
|
||||
// Get torrent download limit
|
||||
|
@ -141,23 +144,23 @@ MochaUI.extend({
|
|||
initialStep: dl_limit.round(),
|
||||
onChange: function(pos) {
|
||||
if (pos > 0) {
|
||||
$('dllimitUpdatevalue').set('html', pos);
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
$('dllimitUpdatevalue').value = pos;
|
||||
$('dlLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
else {
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
$('dllimitUpdatevalue').value = '∞';
|
||||
$('dlLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if (dl_limit == 0) {
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
$('dllimitUpdatevalue').value = '∞';
|
||||
$('dlLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
else {
|
||||
$('dllimitUpdatevalue').set('html', dl_limit.round());
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
$('dllimitUpdatevalue').value = dl_limit.round();
|
||||
$('dlLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -177,23 +180,23 @@ MochaUI.extend({
|
|||
initialStep: (dl_limit / 1024.).round(),
|
||||
onChange: function(pos) {
|
||||
if (pos > 0) {
|
||||
$('dllimitUpdatevalue').set('html', pos);
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
$('dllimitUpdatevalue').value = pos;
|
||||
$('dlLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
else {
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
$('dllimitUpdatevalue').value = '∞';
|
||||
$('dlLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if (dl_limit == 0) {
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
$('dllimitUpdatevalue').value = '∞';
|
||||
$('dlLimitUnit').style.visibility = "hidden";
|
||||
}
|
||||
else {
|
||||
$('dllimitUpdatevalue').set('html', (dl_limit / 1024.).round());
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
$('dllimitUpdatevalue').value = (dl_limit / 1024.).round();
|
||||
$('dlLimitUnit').style.visibility = "visible";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>_(Torrent Upload Speed Limiting)</title>
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="css/mocha.css" type="text/css" />
|
||||
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="scripts/mocha-yc.js" charset="utf-8"></script>
|
||||
|
@ -13,7 +12,7 @@
|
|||
<body>
|
||||
<div style="width: 100%; text-align: center; margin: 0 auto;">
|
||||
<div id="uplimitSlider" class="slider">
|
||||
<div id="uplimitUpdate" class="update">_(Upload limit:) <span id="uplimitUpdatevalue" class="updatevalue">0</span> <span id="upLimitUnit">_(KiB/s)</span></div>
|
||||
<div id="uplimitUpdate" class="update">_(Upload limit:) <input id="uplimitUpdatevalue" size="6" placeholder="∞" style="text-align: center;"> <span id="upLimitUnit">_(KiB/s)</span></div>
|
||||
<div class="sliderWrapper">
|
||||
<div id="uplimitSliderknob" class="sliderknob"></div>
|
||||
<div id="uplimitSliderarea" class="sliderarea"></div>
|
||||
|
@ -23,7 +22,7 @@
|
|||
<script type="text/javascript">
|
||||
var hash = new URI().getData('hash');
|
||||
setUpLimit = function() {
|
||||
var limit = $("uplimitUpdatevalue").get('html').toInt() * 1024;
|
||||
var limit = $("uplimitUpdatevalue").value.toInt() * 1024;
|
||||
if(hash == "global") {
|
||||
new Request({url: 'command/setGlobalUpLimit',
|
||||
method: 'post',
|
||||
|
|
Loading…
Reference in a new issue