* Put both global and download specific commands in a single

CommandMap.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@914 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-06-17 03:14:38 +00:00
parent 297b4b5f1d
commit e9db89e6d6
36 changed files with 330 additions and 345 deletions
+6 -6
View File
@@ -154,13 +154,13 @@ Download::create_info() {
element->push_back("");
element->push_column("Directory:", te_string(&torrent::FileList::root_dir));
element->push_column("Tied to file:", te_variable_string("get_tied_to_file"));
element->push_column("Tied to file:", te_variable_string("get_d_tied_to_file"));
element->push_back("");
element->push_column("Chunks:", te_value(&torrent::FileList::completed_chunks), " / ", te_value(&torrent::FileList::size_chunks), " * ", te_value(&torrent::FileList::chunk_size));
element->push_column("Priority:", te_variable_value("get_priority"));
element->push_column("Priority:", te_variable_value("get_d_priority"));
element->push_column("State changed:", te_variable_value("get_state_changed", value_base::flag_timer | value_base::flag_elapsed));
element->push_column("State changed:", te_variable_value("get_d_state_changed", value_base::flag_timer | value_base::flag_elapsed));
element->push_back("");
element->push_column("Memory usage:", te_value(&torrent::ChunkManager::memory_usage, value_base::flag_mb), " MB");
@@ -174,9 +174,9 @@ Download::create_info() {
element->push_column("Receive buffer:", te_value(&torrent::ConnectionManager::receive_buffer_size, value_base::flag_kb), " KB");
element->push_back("");
element->push_column("Upload:", te_variable_value("get_up_rate", value_base::flag_kb), " KB / ", te_variable_value("get_up_total", value_base::flag_xb));
element->push_column("Download:", te_variable_value("get_down_rate", value_base::flag_kb), " KB / ", te_variable_value("get_down_total", value_base::flag_xb));
element->push_column("Skipped:", te_variable_value("get_skip_rate", value_base::flag_kb), " KB / ", te_variable_value("get_skip_total", value_base::flag_xb));
element->push_column("Upload:", te_variable_value("get_d_up_rate", value_base::flag_kb), " KB / ", te_variable_value("get_d_up_total", value_base::flag_xb));
element->push_column("Download:", te_variable_value("get_d_down_rate", value_base::flag_kb), " KB / ", te_variable_value("get_d_down_total", value_base::flag_xb));
element->push_column("Skipped:", te_variable_value("get_d_skip_rate", value_base::flag_kb), " KB / ", te_variable_value("get_d_skip_total", value_base::flag_xb));
element->push_column("Preload:", te_value(&torrent::ChunkManager::preload_type), " / ", te_value(&torrent::ChunkManager::stats_preloaded), " / ", te_value(&torrent::ChunkManager::stats_not_preloaded));
element->set_column_width(element->column_width() + 1);
+4 -5
View File
@@ -56,7 +56,6 @@
#include "display/window_log.h"
#include "display/window_title.h"
#include "rpc/command_map.h"
#include "rpc/parse_commands.h"
#include "control.h"
@@ -233,7 +232,7 @@ DownloadList::receive_view_input(Input type) {
case INPUT_CHANGE_DIRECTORY:
title = "change_directory";
input->str() = control->variable()->call_command_string("get_directory");
input->str() = rpc::call_command_string("get_directory");
input->set_pos(input->str().length());
break;
@@ -286,12 +285,12 @@ DownloadList::receive_exit_input(Input type) {
if (current_view()->focus() == current_view()->end_visible())
throw torrent::input_error("No download in focus to change root directory.");
control->download_variables()->call_command_d("set_directory", *current_view()->focus(), rak::trim(input->str()));
control->core()->push_log("New root directory \"" + (*current_view()->focus())->get_string("get_directory") + "\" for torrent.");
rpc::call_command_d("set_d_directory", *current_view()->focus(), rak::trim(input->str()));
control->core()->push_log("New root directory \"" + rpc::call_command_d_string("get_d_directory", *current_view()->focus()) + "\" for torrent.");
break;
case INPUT_COMMAND:
utils::parse_command_single_std(control->variable(), input->str());
rpc::parse_command_single_std(input->str());
break;
default:
+7 -6
View File
@@ -47,6 +47,7 @@
#include "display/frame.h"
#include "display/manager.h"
#include "input/manager.h"
#include "rpc/parse_commands.h"
#include "control.h"
#include "element_download_list.h"
@@ -151,7 +152,7 @@ ElementDownloadList::receive_stop_download() {
if (m_view->focus() == m_view->end_visible())
return;
if ((*m_view->focus())->get_value("get_state") == 1)
if (rpc::call_command_d_value("get_d_state", *m_view->focus()) == 1)
control->core()->download_list()->stop_normal(*m_view->focus());
else
control->core()->download_list()->erase(*m_view->focus());
@@ -166,7 +167,7 @@ ElementDownloadList::receive_close_download() {
core::Download* download = *m_view->focus();
download->set("set_ignore_commands", (int64_t)1);
rpc::call_command_d("set_d_ignore_commands", download, (int64_t)1);
control->core()->download_list()->stop_normal(download);
control->core()->download_list()->close(download);
@@ -205,11 +206,11 @@ ElementDownloadList::receive_ignore_ratio() {
if (m_view->focus() == m_view->end_visible())
return;
if ((*m_view->focus())->get_value("get_ignore_commands") != 0) {
(*m_view->focus())->set("set_ignore_commands", (int64_t)0);
if (rpc::call_command_d_value("get_d_ignore_commands", *m_view->focus()) != 0) {
rpc::call_command_d_set_value("set_d_ignore_commands", *m_view->focus(), (int64_t)0);
control->core()->push_log("Torrent set to heed commands.");
} else {
(*m_view->focus())->set("set_ignore_commands", (int64_t)1);
rpc::call_command_d_set_value("set_d_ignore_commands", *m_view->focus(), (int64_t)1);
control->core()->push_log("Torrent set to ignore commands.");
}
}
@@ -219,7 +220,7 @@ ElementDownloadList::receive_clear_tied() {
if (m_view->focus() == m_view->end_visible())
return;
const std::string& tiedFile = (*m_view->focus())->get_string("get_tied_to_file");
const std::string& tiedFile = rpc::call_command_d_string("get_d_tied_to_file", *m_view->focus());
if (!tiedFile.empty()) {
// Move this into core?
+6 -6
View File
@@ -49,7 +49,7 @@
#include "display/window_statusbar.h"
#include "input/manager.h"
#include "input/text_input.h"
#include "rpc/command_map.h"
#include "rpc/parse_commands.h"
#include "control.h"
#include "download_list.h"
@@ -126,7 +126,7 @@ void
Root::setup_keys() {
m_control->input()->push_back(&m_bindings);
const std::string& keyLayout = control->variable()->call_command_string("get_key_layout");
const std::string& keyLayout = rpc::call_command_string("get_key_layout");
if (strcasecmp(keyLayout.c_str(), "azerty") == 0) {
m_bindings['q'] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 1);
@@ -187,14 +187,14 @@ Root::set_down_throttle(unsigned int throttle) {
torrent::set_down_throttle(throttle * 1024);
int64_t div = control->variable()->call_command_value("get_max_downloads_div");
int64_t div = rpc::call_command_value("get_max_downloads_div");
if (throttle == 0 || div <= 0) {
torrent::set_max_download_unchoked(m_maxDownloadsGlobal);
return;
}
throttle /= control->variable()->call_command_value("get_max_downloads_div");
throttle /= rpc::call_command_value("get_max_downloads_div");
unsigned int maxUnchoked;
@@ -216,14 +216,14 @@ Root::set_up_throttle(unsigned int throttle) {
torrent::set_up_throttle(throttle * 1024);
int64_t div = control->variable()->call_command_value("get_max_uploads_div");
int64_t div = rpc::call_command_value("get_max_uploads_div");
if (throttle == 0 || div <= 0) {
torrent::set_max_unchoked(m_maxUploadsGlobal);
return;
}
throttle /= control->variable()->call_command_value("get_max_uploads_div");
throttle /= rpc::call_command_value("get_max_uploads_div");
unsigned int maxUnchoked;