mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
Adding controls for download throttle.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@426 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -25,14 +25,14 @@ All:
|
||||
|
||||
Ctrl-Q - Quit
|
||||
|
||||
A - Increase Throttle by 1 KiB
|
||||
Z - Decrease Throttle by 1 KiB
|
||||
a/A - Increase upload/download throttle by 1 KiB
|
||||
z/Z - Decrease upload/download throttle by 1 KiB
|
||||
|
||||
S - Increase Throttle by 5 KiB
|
||||
X - Decrease Throttle by 5 KiB
|
||||
s/S - Increase upload/download throttle by 5 KiB
|
||||
x/X - Decrease upload/download throttle by 5 KiB
|
||||
|
||||
D - Increase Throttle by 50 KiB
|
||||
C - Decrease Throttle by 50 KiB
|
||||
d/D - Increase upload/download throttle by 50 KiB
|
||||
c/C - Decrease upload/download throttle by 50 KiB
|
||||
|
||||
|
||||
In main window:
|
||||
|
||||
@@ -43,17 +43,24 @@ WindowStatusbar::redraw() {
|
||||
|
||||
m_canvas->erase();
|
||||
|
||||
int pos = 0;
|
||||
char buf[128];
|
||||
|
||||
if (torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) == 0)
|
||||
m_canvas->print(0, 0, "Throttle: off Listen: %s:%i Handshakes: %i",
|
||||
m_core->get_dns().empty() ? "<default>" : m_core->get_dns().c_str(),
|
||||
(int)torrent::get(torrent::LISTEN_PORT),
|
||||
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
|
||||
pos = snprintf(buf, 128, "off/");
|
||||
else
|
||||
m_canvas->print(0, 0, "Throttle: %i Listen: %s:%i Handshakes: %i",
|
||||
(int)torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) / 1024,
|
||||
m_core->get_dns().empty() ? "<default>" : m_core->get_dns().c_str(),
|
||||
(int)torrent::get(torrent::LISTEN_PORT),
|
||||
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
|
||||
pos = snprintf(buf, 128, "%3i/", (int)torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) / 1024);
|
||||
|
||||
if (torrent::get(torrent::THROTTLE_READ_CONST_RATE) == 0)
|
||||
pos = snprintf(buf + pos, 128 - pos, "off");
|
||||
else
|
||||
pos = snprintf(buf + pos, 128 - pos, "%-3i", (int)torrent::get(torrent::THROTTLE_READ_CONST_RATE) / 1024);
|
||||
|
||||
m_canvas->print(0, 0, "Throttle U/D: %s Listen: %s:%i Handshakes: %i",
|
||||
buf,
|
||||
m_core->get_dns().empty() ? "<default>" : m_core->get_dns().c_str(),
|
||||
(int)torrent::get(torrent::LISTEN_PORT),
|
||||
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -239,7 +239,8 @@ print_help() {
|
||||
std::cout << " ^s Start torrent" << std::endl;
|
||||
std::cout << " ^d Stop torrent or delete a stopped torrent" << std::endl;
|
||||
std::cout << " ^q Initiate shutdown or skip shutdown process" << std::endl;
|
||||
std::cout << " a,s,d,z,x,c Adjust throttle" << std::endl;
|
||||
std::cout << " a,s,d,z,x,c Adjust upload throttle" << std::endl;
|
||||
std::cout << " A,S,D,Z,X,C Adjust download throttle" << std::endl;
|
||||
std::cout << " right View torrent" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Download view keys:" << std::endl;
|
||||
|
||||
+21
-7
@@ -181,7 +181,14 @@ Download::receive_peer_disconnected(torrent::Peer p) {
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_throttle(int t) {
|
||||
Download::receive_read_throttle(int t) {
|
||||
m_windowMainStatus->mark_dirty();
|
||||
|
||||
torrent::set(torrent::THROTTLE_READ_CONST_RATE, torrent::get(torrent::THROTTLE_READ_CONST_RATE) + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_write_throttle(int t) {
|
||||
m_windowMainStatus->mark_dirty();
|
||||
|
||||
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
||||
@@ -229,12 +236,19 @@ Download::receive_snub_peer() {
|
||||
|
||||
void
|
||||
Download::bind_keys() {
|
||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 1);
|
||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -1);
|
||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 5);
|
||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -5);
|
||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 50);
|
||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -50);
|
||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), 1);
|
||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), -1);
|
||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), 5);
|
||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), -5);
|
||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), 50);
|
||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), -50);
|
||||
|
||||
(*m_bindings)['A'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), 1);
|
||||
(*m_bindings)['Z'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), -1);
|
||||
(*m_bindings)['S'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), 5);
|
||||
(*m_bindings)['X'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), -5);
|
||||
(*m_bindings)['D'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), 50);
|
||||
(*m_bindings)['C'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), -50);
|
||||
|
||||
(*m_bindings)['1'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_uploads), -1);
|
||||
(*m_bindings)['2'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_uploads), 1);
|
||||
|
||||
+2
-1
@@ -83,7 +83,8 @@ private:
|
||||
void receive_peer_connected(torrent::Peer p);
|
||||
void receive_peer_disconnected(torrent::Peer p);
|
||||
|
||||
void receive_throttle(int t);
|
||||
void receive_read_throttle(int t);
|
||||
void receive_write_throttle(int t);
|
||||
void receive_max_uploads(int t);
|
||||
void receive_min_peers(int t);
|
||||
void receive_max_peers(int t);
|
||||
|
||||
+21
-7
@@ -169,7 +169,14 @@ DownloadList::receive_prev() {
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_throttle(int t) {
|
||||
DownloadList::receive_read_throttle(int t) {
|
||||
m_windowStatus->mark_dirty();
|
||||
|
||||
torrent::set(torrent::THROTTLE_READ_CONST_RATE, torrent::get(torrent::THROTTLE_READ_CONST_RATE) + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_write_throttle(int t) {
|
||||
m_windowStatus->mark_dirty();
|
||||
|
||||
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
||||
@@ -274,12 +281,19 @@ DownloadList::task_update() {
|
||||
|
||||
void
|
||||
DownloadList::setup_keys() {
|
||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 1);
|
||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -1);
|
||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 5);
|
||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -5);
|
||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 50);
|
||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), -50);
|
||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), 1);
|
||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), -1);
|
||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), 5);
|
||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), -5);
|
||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), 50);
|
||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), -50);
|
||||
|
||||
(*m_bindings)['A'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), 1);
|
||||
(*m_bindings)['Z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), -1);
|
||||
(*m_bindings)['S'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), 5);
|
||||
(*m_bindings)['X'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), -5);
|
||||
(*m_bindings)['D'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), 50);
|
||||
(*m_bindings)['C'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), -50);
|
||||
|
||||
(*m_bindings)['\x13'] = sigc::mem_fun(*this, &DownloadList::receive_start_download);
|
||||
(*m_bindings)['\x04'] = sigc::mem_fun(*this, &DownloadList::receive_stop_download);
|
||||
|
||||
@@ -92,7 +92,8 @@ private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_throttle(int t);
|
||||
void receive_read_throttle(int t);
|
||||
void receive_write_throttle(int t);
|
||||
|
||||
void receive_start_download();
|
||||
void receive_stop_download();
|
||||
|
||||
Reference in New Issue
Block a user