From 805689c3af059aefb1d9c2943e482ca695cb2da2 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Mon, 28 Jan 2008 16:56:01 +0000 Subject: [PATCH] * Preliminary API changes for the throttle groups. Patch by Josef Drexler with some changes. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1034 e378c898-3ddf-0310-93e7-cc216c733640 --- src/command_network.cc | 5 +++-- src/display/utils.cc | 9 +++++---- src/ui/root.cc | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/command_network.cc b/src/command_network.cc index 8e2f2041..10112f66 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -317,8 +318,8 @@ initialize_command_network() { // ADD_COMMAND_VALUE_TRI("max_uploads_global", rak::make_mem_fun(control->ui(), &ui::Root::set_max_uploads_global), rak::make_mem_fun(control->ui(), &ui::Root::max_uploads_global)); // ADD_COMMAND_VALUE_TRI("max_downloads_global", rak::make_mem_fun(control->ui(), &ui::Root::set_max_downloads_global), rak::make_mem_fun(control->ui(), &ui::Root::max_downloads_global)); - ADD_COMMAND_VALUE_TRI_KB("download_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_down_throttle_i64), rak::ptr_fun(&torrent::down_throttle)); - ADD_COMMAND_VALUE_TRI_KB("upload_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_up_throttle_i64), rak::ptr_fun(&torrent::up_throttle)); + ADD_COMMAND_VALUE_TRI_KB("download_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_down_throttle_i64), rak::make_mem_fun(torrent::down_throttle_global(), &torrent::Throttle::max_rate)); + ADD_COMMAND_VALUE_TRI_KB("upload_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_up_throttle_i64), rak::make_mem_fun(torrent::up_throttle_global(), &torrent::Throttle::max_rate)); ADD_COMMAND_VOID("get_up_rate", rak::make_mem_fun(torrent::up_rate(), &torrent::Rate::rate)); ADD_COMMAND_VOID("get_up_total", rak::make_mem_fun(torrent::up_rate(), &torrent::Rate::total)); diff --git a/src/display/utils.cc b/src/display/utils.cc index 054fa555..0cd17890 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -250,15 +251,15 @@ print_client_version(char* first, char* last, const torrent::ClientInfo& clientI char* print_status_info(char* first, char* last) { - if (torrent::up_throttle() == 0) + if (torrent::up_throttle_global()->max_rate() == 0) first = print_buffer(first, last, "[Throttle off"); else - first = print_buffer(first, last, "[Throttle %3i", torrent::up_throttle() / 1024); + first = print_buffer(first, last, "[Throttle %3i", torrent::up_throttle_global()->max_rate() / 1024); - if (torrent::down_throttle() == 0) + if (torrent::down_throttle_global()->max_rate() == 0) first = print_buffer(first, last, "/off KB]"); else - first = print_buffer(first, last, "/%3i KB]", torrent::down_throttle() / 1024); + first = print_buffer(first, last, "/%3i KB]", torrent::down_throttle_global()->max_rate() / 1024); first = print_buffer(first, last, " [Rate %5.1f/%5.1f KB]", (double)torrent::up_rate()->rate() / 1024.0, diff --git a/src/ui/root.cc b/src/ui/root.cc index 8397edb5..94c1d750 100644 --- a/src/ui/root.cc +++ b/src/ui/root.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "core/manager.h" @@ -182,7 +183,7 @@ Root::set_down_throttle(unsigned int throttle) { if (m_windowStatusbar != NULL) m_windowStatusbar->mark_dirty(); - torrent::set_down_throttle(throttle * 1024); + torrent::down_throttle_global()->set_max_rate(throttle * 1024); unsigned int div = std::max(rpc::call_command_value("get_max_downloads_div"), 0); unsigned int global = std::max(rpc::call_command_value("get_max_downloads_global"), 0); @@ -212,7 +213,7 @@ Root::set_up_throttle(unsigned int throttle) { if (m_windowStatusbar != NULL) m_windowStatusbar->mark_dirty(); - torrent::set_up_throttle(throttle * 1024); + torrent::up_throttle_global()->set_max_rate(throttle * 1024); unsigned int div = std::max(rpc::call_command_value("get_max_uploads_div"), 0); unsigned int global = std::max(rpc::call_command_value("get_max_uploads_global"), 0); @@ -239,12 +240,12 @@ Root::set_up_throttle(unsigned int throttle) { void Root::adjust_down_throttle(int throttle) { - set_down_throttle(std::max(torrent::down_throttle() / 1024 + throttle, 0)); + set_down_throttle(std::max(torrent::down_throttle_global()->max_rate() / 1024 + throttle, 0)); } void Root::adjust_up_throttle(int throttle) { - set_up_throttle(std::max(torrent::up_throttle() / 1024 + throttle, 0)); + set_up_throttle(std::max(torrent::up_throttle_global()->max_rate() / 1024 + throttle, 0)); } void