From 3cae3d37be0b86ef5dea7db13ea945e04d5ff450 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 16 Feb 2010 17:29:53 +0000 Subject: [PATCH] * Cleaning up command names. The deprecated commands will be redirected. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1131 e378c898-3ddf-0310-93e7-cc216c733640 --- src/command_download.cc | 2 +- src/command_dynamic.cc | 14 +++++++- src/command_events.cc | 51 ++-------------------------- src/command_helpers.h | 13 +++----- src/command_local.cc | 49 ++++++++++++++------------- src/command_network.cc | 3 +- src/control.cc | 2 +- src/core/download_factory.cc | 10 +++--- src/core/download_list.cc | 4 +-- src/core/manager.cc | 4 +-- src/main.cc | 64 ++++++++++++++++++++++++++++++------ src/rpc/command_function.cc | 7 ++++ src/rpc/command_function.h | 1 + src/ui/download.cc | 10 +++--- src/ui/download_list.cc | 4 ++- 15 files changed, 130 insertions(+), 108 deletions(-) diff --git a/src/command_download.cc b/src/command_download.cc index 9eff993d..de221c63 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -310,7 +310,7 @@ cmd_d_initialize_logs(core::Download* download) { download->download()->signal_network_log(sigc::mem_fun(control->core(), &core::Manager::push_log_complete)); download->download()->signal_storage_error(sigc::mem_fun(control->core(), &core::Manager::push_log_complete)); - if (!rpc::call_command_string("get_log.tracker").empty()) + if (!rpc::call_command_string("log.tracker").empty()) download->download()->signal_tracker_dump(sigc::ptr_fun(&core::receive_tracker_dump)); return torrent::Object(); diff --git a/src/command_dynamic.cc b/src/command_dynamic.cc index bb3db03c..68348320 100644 --- a/src/command_dynamic.cc +++ b/src/command_dynamic.cc @@ -77,6 +77,10 @@ create_new_key(const std::string& key, const char postfix[postfix_size]) { // // Add a new user-defined method called 'name' and any number of // lines. +// +// TODO: Make a static version of this that doesn't need to be called +// as a command, and which takes advantage of static const char +// strings, etc. torrent::Object system_method_insert(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) { const torrent::Object::list_type& args = rawArgs.as_list(); @@ -96,7 +100,6 @@ system_method_insert(__UNUSED rpc::target_type target, const torrent::Object& ra if (options.find("private") != std::string::npos) flags &= ~rpc::CommandMap::flag_public_xmlrpc; - if (options.find("const") != std::string::npos) flags &= ~rpc::CommandMap::flag_modifiable; @@ -113,6 +116,15 @@ system_method_insert(__UNUSED rpc::target_type target, const torrent::Object& ra rpc::commands.insert_type(create_new_key<0>(rawKey, ""), command, slot, flags, NULL, NULL); + } else if (options.find("redirect") != std::string::npos) { + if (++itrArgs == args.end()) + throw torrent::input_error("Invalid argument count."); + + rpc::Command::any_slot slot = &rpc::CommandFunction::call_redirect; + rpc::Command* command = new rpc::CommandFunction(itrArgs->as_string()); + + rpc::commands.insert_type(create_new_key<0>(rawKey, ""), command, slot, flags, NULL, NULL); + } else if (options.find("value") != std::string::npos || options.find("bool") != std::string::npos || options.find("string") != std::string::npos || diff --git a/src/command_events.cc b/src/command_events.cc index c5bcb84e..233a77a0 100644 --- a/src/command_events.cc +++ b/src/command_events.cc @@ -61,40 +61,6 @@ #include "thread_worker.h" -torrent::Object -apply_on_state_change(const char* name, const torrent::Object& rawArgs) { - const torrent::Object::list_type& args = rawArgs.as_list(); - - if (args.size() == 0 || args.size() > 2) - throw torrent::input_error("Wrong number of arguments."); - - const std::string& rawKey = args.front().as_string(); - - if (rawKey.empty()) - throw torrent::input_error("Empty key."); - - // If the key starts with '_' then it's supposed to be literal, with - // the initial '_' removed. This allows us to get proper ordering - // for internal rtorrent tasks. - std::string key = rawKey[0] != '_' ? ("1_state_" + rawKey) : rawKey.substr(1); - - if (args.size() == 1) - rpc::commands.call("system.method.set_key", rpc::make_target(), rpc::create_object_list(name, key)); - else - rpc::commands.call("system.method.set_key", rpc::make_target(), rpc::create_object_list(name, key, args.back())); - - // Deprecated notice, remove this function in the next minor - // version. - static bool notify = true; - - if (notify) { - control->core()->push_log("Deprecated on_* commands, use 'system.method.set_key = event.download.{inserted, erased, ...}, , ' instead."); - notify = false; - } - - return torrent::Object(); -} - torrent::Object apply_on_ratio(const torrent::Object& rawArgs) { const std::string& groupName = rawArgs.as_string(); @@ -363,21 +329,10 @@ void initialize_command_events() { ADD_COMMAND_NONE("test.thread_locking", rak::ptr_fn(&test_thread_locking)); - ADD_VARIABLE_BOOL("check_hash", true); + ADD_VARIABLE_BOOL("check_hash", true); // Rename - ADD_VARIABLE_BOOL("session_lock", true); - ADD_VARIABLE_BOOL("session_on_completion", true); - - // Deprecated. - ADD_COMMAND_LIST("on_insert", rak::bind_ptr_fn(&apply_on_state_change, "event.download.inserted")); - ADD_COMMAND_LIST("on_erase" , rak::bind_ptr_fn(&apply_on_state_change, "event.download.erased")); - ADD_COMMAND_LIST("on_open", rak::bind_ptr_fn(&apply_on_state_change, "event.download.opened")); - ADD_COMMAND_LIST("on_close", rak::bind_ptr_fn(&apply_on_state_change, "event.download.closed")); - ADD_COMMAND_LIST("on_start", rak::bind_ptr_fn(&apply_on_state_change, "event.download.resumed")); - ADD_COMMAND_LIST("on_stop", rak::bind_ptr_fn(&apply_on_state_change, "event.download.paused")); - ADD_COMMAND_LIST("on_hash_queued", rak::bind_ptr_fn(&apply_on_state_change, "event.download.hash_queued")); - ADD_COMMAND_LIST("on_hash_removed", rak::bind_ptr_fn(&apply_on_state_change, "event.download.hash_removed")); - ADD_COMMAND_LIST("on_finished", rak::bind_ptr_fn(&apply_on_state_change, "event.download.finished")); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.session.use_lock", "bool|const", true)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.session.on_completion", "bool|const", true)); ADD_COMMAND_STRING("on_ratio", rak::ptr_fn(&apply_on_ratio)); diff --git a/src/command_helpers.h b/src/command_helpers.h index a807b5f7..bc0ae14b 100644 --- a/src/command_helpers.h +++ b/src/command_helpers.h @@ -202,14 +202,11 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri rpc::commands.insert_type(key, commandAnySlotsItr++, &rpc::CommandSlot::function, \ rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_no_target | rpc::CommandMap::flag_public_xmlrpc, parm, doc); -#define CMD_N(key, slot) \ - CMD_N_SLOT(key, call_unknown, slot, "i:", "") - -#define CMD_N_STRING(key, slot) \ - CMD_N_SLOT(key, call_string, slot, "i:", "") - -#define CMD_N_LIST(key, slot) \ - CMD_N_SLOT(key, call_list, slot, "i:", "") +#define CMD_N(key, slot) CMD_N_SLOT(key, call_unknown, slot, "i:", "") +#define CMD_N_VOID(key, slot) CMD_N_SLOT(key, call_unknown, slot, "i:", "") +#define CMD_N_VALUE(key, slot) CMD_N_SLOT(key, call_value, slot, "i:", "") +#define CMD_N_STRING(key, slot) CMD_N_SLOT(key, call_string, slot, "i:", "") +#define CMD_N_LIST(key, slot) CMD_N_SLOT(key, call_list, slot, "i:", "") #define CMD_D_SLOT(key, function, slot, parm, doc) \ commandDownloadSlotsItr->set_slot(slot); \ diff --git a/src/command_local.cc b/src/command_local.cc index 4d14870a..a07bc8a3 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -173,17 +173,20 @@ initialize_command_local() { core::DownloadList* dList = control->core()->download_list(); core::DownloadStore* dStore = control->core()->download_store(); - ADD_C_STRING("system.client_version", PACKAGE_VERSION); - ADD_C_STRING("system.library_version", torrent::version()); - ADD_COMMAND_VOID("system.hostname", rak::ptr_fun(&system_hostname)); ADD_COMMAND_VOID("system.pid", rak::ptr_fun(&getpid)); - rpc::commands.call("system.method.insert", rpc::create_object_list("system.file_allocate", "value", (int64_t)0)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.client_version", "string|static|const", PACKAGE_VERSION)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.library_version", "string|static|const", torrent::version())); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.file.allocate", "value|const", (int64_t)0)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.file.max_size", "value|const", -1)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.file.split_size", "value|const", -1)); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.file.split_suffix", "string|const", ".part")); + rpc::commands.call("system.method.insert", rpc::create_object_list("system.session_name", "string|const", "")); - ADD_COMMAND_VOID("system.file_status_cache.size", rak::make_mem_fun((utils::FileStatusCache::base_type*)control->core()->file_status_cache(), &utils::FileStatusCache::size)); + ADD_COMMAND_VOID("system.file_status_cache.size", rak::make_mem_fun((utils::FileStatusCache::base_type*)control->core()->file_status_cache(), + &utils::FileStatusCache::size)); ADD_COMMAND_VOID("system.file_status_cache.prune", rak::make_mem_fun(control->core()->file_status_cache(), &utils::FileStatusCache::prune)); - ADD_COMMAND_VOID("system.time", rak::make_mem_fun(&cachedTime, &rak::timer::seconds)); ADD_COMMAND_VOID("system.time_seconds", rak::ptr_fun(&rak::timer::current_seconds)); ADD_COMMAND_VOID("system.time_usec", rak::ptr_fun(&rak::timer::current_usec)); @@ -191,25 +194,27 @@ initialize_command_local() { ADD_COMMAND_VALUE_SET_OCT("system.", "umask", std::ptr_fun(&umask)); ADD_COMMAND_STRING_PREFIX("system.", "cwd", std::ptr_fun(system_set_cwd), rak::ptr_fun(&system_get_cwd)); - ADD_VARIABLE_STRING("name", ""); + ADD_COMMAND_VOID("pieces.sync.always_safe", rak::make_mem_fun(chunkManager, &CM_t::safe_sync)); + ADD_COMMAND_VALUE_UN("pieces.sync.always_safe.set", rak::make_mem_fun(chunkManager, &CM_t::set_safe_sync)); + ADD_COMMAND_VOID("pieces.sync.safe_free_diskspace", rak::make_mem_fun(chunkManager, &CM_t::safe_free_diskspace)); + ADD_COMMAND_VOID("pieces.sync.timeout", rak::make_mem_fun(chunkManager, &CM_t::timeout_sync)); + ADD_COMMAND_VALUE_UN("pieces.sync.timeout.set", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_sync)); + ADD_COMMAND_VOID("pieces.sync.timeout_safe", rak::make_mem_fun(chunkManager, &CM_t::timeout_safe_sync)); + ADD_COMMAND_VALUE_UN("pieces.sync.timeout_safe.set", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_safe_sync)); - ADD_VARIABLE_VALUE("max_file_size", -1); - ADD_VARIABLE_VALUE("split_file_size", -1); - ADD_VARIABLE_STRING("split_suffix", ".part"); + ADD_COMMAND_VOID("pieces.preload.type", rak::make_mem_fun(chunkManager, &CM_t::preload_type)); + ADD_COMMAND_VALUE_UN("pieces.preload.type.set", rak::make_mem_fun(chunkManager, &CM_t::set_preload_type)); + ADD_COMMAND_VOID("pieces.preload.min_size", rak::make_mem_fun(chunkManager, &CM_t::preload_min_size)); + ADD_COMMAND_VALUE_UN("pieces.preload.min_size.set", rak::make_mem_fun(chunkManager, &CM_t::set_preload_min_size)); + ADD_COMMAND_VOID("pieces.preload.min_rate", rak::make_mem_fun(chunkManager, &CM_t::preload_required_rate)); + ADD_COMMAND_VALUE_UN("pieces.preload.min_rate.set", rak::make_mem_fun(chunkManager, &CM_t::set_preload_required_rate)); - ADD_COMMAND_VOID("get_memory_usage", rak::make_mem_fun(chunkManager, &CM_t::memory_usage)); - ADD_COMMAND_VALUE_TRI("max_memory_usage", rak::make_mem_fun(chunkManager, &CM_t::set_max_memory_usage), rak::make_mem_fun(chunkManager, &CM_t::max_memory_usage)); - ADD_COMMAND_VALUE_TRI("safe_sync", rak::make_mem_fun(chunkManager, &CM_t::set_safe_sync), rak::make_mem_fun(chunkManager, &CM_t::safe_sync)); - ADD_COMMAND_VOID("get_safe_free_diskspace", rak::make_mem_fun(chunkManager, &CM_t::safe_free_diskspace)); - ADD_COMMAND_VALUE_TRI("timeout_sync", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_sync), rak::make_mem_fun(chunkManager, &CM_t::timeout_sync)); - ADD_COMMAND_VALUE_TRI("timeout_safe_sync", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_safe_sync), rak::make_mem_fun(chunkManager, &CM_t::timeout_safe_sync)); + ADD_COMMAND_VOID("pieces.memory.current", rak::make_mem_fun(chunkManager, &CM_t::memory_usage)); + ADD_COMMAND_VOID("pieces.memory.max", rak::make_mem_fun(chunkManager, &CM_t::max_memory_usage)); + ADD_COMMAND_VALUE_UN("pieces.memory.max.set", rak::make_mem_fun(chunkManager, &CM_t::set_max_memory_usage)); + ADD_COMMAND_VOID("pieces.stats_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_preloaded)); + ADD_COMMAND_VOID("pieces.stats_not_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_not_preloaded)); - ADD_COMMAND_VALUE_TRI("preload_type", rak::make_mem_fun(chunkManager, &CM_t::set_preload_type), rak::make_mem_fun(chunkManager, &CM_t::preload_type)); - ADD_COMMAND_VALUE_TRI("preload_min_size", rak::make_mem_fun(chunkManager, &CM_t::set_preload_min_size), rak::make_mem_fun(chunkManager, &CM_t::preload_min_size)); - ADD_COMMAND_VALUE_TRI_KB("preload_required_rate", rak::make_mem_fun(chunkManager, &CM_t::set_preload_required_rate), rak::make_mem_fun(chunkManager, &CM_t::preload_required_rate)); - - ADD_COMMAND_VOID("get_stats_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_preloaded)); - ADD_COMMAND_VOID("get_stats_not_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_not_preloaded)); ADD_VARIABLE_STRING("directory", "./"); diff --git a/src/command_network.cc b/src/command_network.cc index a41d50fa..4a9226fe 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -491,7 +491,6 @@ initialize_command_network() { ADD_VARIABLE_BOOL("peer_exchange", true); - // Not really network stuff: - ADD_VARIABLE_BOOL ("handshake_log", false); + rpc::commands.call("system.method.insert", rpc::create_object_list("log.handshake", "bool|const", int64_t())); rpc::commands.call("system.method.insert", rpc::create_object_list("log.tracker", "string|const", "")); } diff --git a/src/control.cc b/src/control.cc index dd06aecd..f674a725 100644 --- a/src/control.cc +++ b/src/control.cc @@ -105,7 +105,7 @@ Control::initialize() { m_core->initialize_second(); m_core->listen_open(); - m_core->download_store()->enable(rpc::call_command_value("get_session_lock")); + m_core->download_store()->enable(rpc::call_command_value("system.session.use_lock")); m_core->set_hashing_view(*m_viewManager->find_throw("hashing")); diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index 6e13a2ca..e0f29735 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -233,17 +233,17 @@ DownloadFactory::receive_success() { if (!rpc::call_command_value("get_use_udp_trackers")) download->enable_udp_trackers(false); - if (rpc::call_command_value("get_max_file_size") > 0) - rpc::call_command("d.set_max_file_size", rpc::call_command_void("get_max_file_size"), rpc::make_target(download)); + if (rpc::call_command_value("system.file.max_size") > 0) + rpc::call_command("d.set_max_file_size", rpc::call_command_void("system.file.max_size"), rpc::make_target(download)); // Check first if we already have these values set in the session // torrent, so that it is safe to change the values. // // Need to also catch the exceptions. - if (rpc::call_command_value("get_split_file_size") >= 0) + if (rpc::call_command_value("system.file.split_size") >= 0) torrent::file_split_all(download->download()->file_list(), - rpc::call_command_value("get_split_file_size"), - rpc::call_command_string("split_suffix")); + rpc::call_command_value("system.file.split_size"), + rpc::call_command_string("system.file.split_suffix")); if (!rtorrent->has_key_string("directory")) rpc::call_command("d.set_directory", m_variables["directory"], rpc::make_target(download)); diff --git a/src/core/download_list.cc b/src/core/download_list.cc index d8f0b2e9..bba7ff48 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -220,7 +220,7 @@ DownloadList::open_throw(Download* download) { int openFlags = download->resume_flags(); - if (rpc::call_command_value("system.file_allocate")) + if (rpc::call_command_value("system.file.allocate")) openFlags |= torrent::Download::open_enable_fallocate; download->download()->open(openFlags); @@ -560,7 +560,7 @@ DownloadList::confirm_finished(Download* download) { // the download. // // Obsolete. - if (!download->is_active() && rpc::call_command_value("get_session_on_completion") != 0) { + if (!download->is_active() && rpc::call_command_value("system.session.on_completion") != 0) { // torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")); control->core()->download_store()->save_resume(download); } diff --git a/src/core/manager.cc b/src/core/manager.cc index 62738cab..e5eecb2a 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -77,7 +77,7 @@ namespace core { void receive_tracker_dump(const std::string& url, const char* data, size_t size) { - const std::string& filename = rpc::call_command_string("get_log.tracker"); + const std::string& filename = rpc::call_command_string("log.tracker"); if (filename.empty()) return; @@ -94,7 +94,7 @@ receive_tracker_dump(const std::string& url, const char* data, size_t size) { void Manager::handshake_log(const sockaddr* sa, int msg, int err, const torrent::HashString* hash) { - if (!rpc::call_command_value("get_handshake_log")) + if (!rpc::call_command_value("log.handshake")) return; std::string peer; diff --git a/src/main.cc b/src/main.cc index 91c9c68c..6d63b7b1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -219,16 +219,16 @@ main(int argc, char** argv) { "system.method.set_key = event.download.erased, !_download_list, ui.unfocus_download=\n" "system.method.set_key = event.download.erased, ~_delete_tied, d.delete_tied=\n" - "system.method.insert = ratio.enable, simple|static|const,group.seeding.ratio.enable=\n" - "system.method.insert = ratio.disable,simple|static|const,group.seeding.ratio.disable=\n" - "system.method.insert = ratio.min, simple|static|const,group.seeding.ratio.min=\n" - "system.method.insert = ratio.max, simple|static|const,group.seeding.ratio.max=\n" - "system.method.insert = ratio.upload, simple|static|const,group.seeding.ratio.upload=\n" - "system.method.insert = ratio.min.set, simple|static|const,group.seeding.ratio.min.set=$argument.0=\n" - "system.method.insert = ratio.max.set, simple|static|const,group.seeding.ratio.max.set=$argument.0=\n" - "system.method.insert = ratio.upload.set,simple|static|const,group.seeding.ratio.upload.set=$argument.0=\n" + "system.method.insert = ratio.enable, simple|const,group.seeding.ratio.enable=\n" + "system.method.insert = ratio.disable,simple|const,group.seeding.ratio.disable=\n" + "system.method.insert = ratio.min, simple|const,group.seeding.ratio.min=\n" + "system.method.insert = ratio.max, simple|const,group.seeding.ratio.max=\n" + "system.method.insert = ratio.upload, simple|const,group.seeding.ratio.upload=\n" + "system.method.insert = ratio.min.set, simple|const,group.seeding.ratio.min.set=$argument.0=\n" + "system.method.insert = ratio.max.set, simple|const,group.seeding.ratio.max.set=$argument.0=\n" + "system.method.insert = ratio.upload.set,simple|const,group.seeding.ratio.upload.set=$argument.0=\n" - "system.method.insert = group.insert_persistent_view,simple|static|const," + "system.method.insert = group.insert_persistent_view,simple|const," "view_add=$argument.0=,view.persistent=$argument.0=,\"group.insert=$argument.0=,$argument.0=\"\n" // Allow setting 'group.view' as constant, so that we can't @@ -241,7 +241,7 @@ main(int argc, char** argv) { "group.insert = seeding,seeding\n" - "set_name = \"$cat=$system.hostname=,:,$system.pid=\"\n" + "system.session_name = \"$cat=$system.hostname=,:,$system.pid=\"\n" // Currently not doing any sorting on main. "view_add = main\n" @@ -301,6 +301,50 @@ main(int argc, char** argv) { "encryption=allow_incoming,prefer_plaintext,enable_retry\n" ); + // Deprecated commands. Don't use these anymore. + + rpc::parse_command_multiple + (rpc::make_target(), + // Deprecated in 0.7.0: + // + // List of cleaned up files: + // - command_download.cc + // * command_dynamic.cc + // / command_events.cc + // - command_file.cc + // - command_helpers.cc + // * command_local.cc + // - command_network.cc + // - command_object.cc + // - command_peer.cc + // - command_scheduler.cc + // - command_tracker.cc + // - command_ui.cc + + "system.method.insert = get_handshake_log,redirect|const,log.handshake\n" + "system.method.insert = set_handshake_log,redirect|const,log.handshake.set\n" + "system.method.insert = get_log.tracker,redirect|const,log.tracker\n" + "system.method.insert = set_log.tracker,redirect|const,log.tracker.set\n" + + "system.method.insert = get_name,redirect|const,system.session_name\n" + "system.method.insert = set_name,redirect|const,system.session_name.set\n" + "system.method.insert = system.file_allocate,redirect|const,system.file.allocate\n" + "system.method.insert = system.file_allocate.set,redirect|const,system.file.allocate.set\n" + + "system.method.insert = get_preload_type,redirect|const,pieces.preload.type\n" + "system.method.insert = get_preload_min_size,redirect|const,pieces.preload.min_size\n" + "system.method.insert = get_preload_required_rate,redirect|const,pieces.preload.min_rate\n" + "system.method.insert = set_preload_type,redirect|const,pieces.preload.type.set\n" + "system.method.insert = set_preload_min_size,redirect|const,pieces.preload.min_size.set\n" + "system.method.insert = set_preload_required_rate,redirect|const,pieces.preload.min_rate.set\n" + "system.method.insert = get_stats_preloaded,redirect|const,pieces.stats_preloaded\n" + "system.method.insert = get_stats_not_preloaded,redirect|const,pieces.stats_not_preloaded\n" + + "system.method.insert = get_memory_usage,redirect|const,pieces.memory.current\n" + "system.method.insert = get_max_memory_usage,redirect|const,pieces.memory.max\n" + "system.method.insert = set_max_memory_usage,redirect|const,pieces.memory.max.set\n" + ); + if (OptionParser::has_flag('n', argc, argv)) control->core()->push_log("Ignoring ~/.rtorrent.rc."); else diff --git a/src/rpc/command_function.cc b/src/rpc/command_function.cc index 195b291b..ab698a8a 100644 --- a/src/rpc/command_function.cc +++ b/src/rpc/command_function.cc @@ -78,6 +78,13 @@ CommandFunction::call(Command* rawCommand, target_type target, const torrent::Ob return result; } +const torrent::Object +CommandFunction::call_redirect(Command* rawCommand, target_type target, const torrent::Object& args) { + CommandFunction* command = reinterpret_cast(rawCommand); + + return commands.call_command(command->m_command.c_str(), args, target); +} + const torrent::Object CommandFunctionList::call(Command* rawCommand, target_type target, const torrent::Object& args) { char* buffer[sizeof(torrent::Object) * Command::max_arguments]; diff --git a/src/rpc/command_function.h b/src/rpc/command_function.h index bbf37387..502d4c7e 100644 --- a/src/rpc/command_function.h +++ b/src/rpc/command_function.h @@ -55,6 +55,7 @@ public: void set_command(const std::string& cmd) { m_command = cmd; } static const torrent::Object call(Command* rawCommand, target_type target, const torrent::Object& args); + static const torrent::Object call_redirect(Command* rawCommand, target_type target, const torrent::Object& args); private: // TODO: Replace with a delete-me flag and const char*. diff --git a/src/ui/download.cc b/src/ui/download.cc index 9bf9f18a..78f74001 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -170,14 +170,14 @@ Download::create_info() { element->push_column("State changed:", te_command("to_elapsed_time=$d.get_state_changed=")); element->push_back(""); - element->push_column("Memory usage:", te_command("cat=$to_mb=$get_memory_usage=,\" MB\"")); - element->push_column("Max memory usage:", te_command("cat=$to_mb=$get_max_memory_usage=,\" MB\"")); + element->push_column("Memory usage:", te_command("cat=$to_mb=$pieces.memory.current=,\" MB\"")); + element->push_column("Max memory usage:", te_command("cat=$to_mb=$pieces.memory.max=,\" MB\"")); element->push_column("Free diskspace:", te_command("cat=$to_mb=$d.get_free_diskspace=,\" MB\"")); - element->push_column("Safe diskspace:", te_command("cat=$to_mb=$get_safe_free_diskspace=,\" MB\"")); + element->push_column("Safe diskspace:", te_command("cat=$to_mb=$pieces.sync.safe_free_diskspace=,\" MB\"")); element->push_back(""); element->push_column("Connection type:", te_command("d.get_connection_current=")); - element->push_column("Safe sync:", te_command("if=$get_safe_sync=,yes,no")); + element->push_column("Safe sync:", te_command("if=$pieces.sync.always_safe=,yes,no")); element->push_column("Send buffer:", te_command("cat=$to_kb=$get_send_buffer_size=,\" KB\"")); element->push_column("Receive buffer:", te_command("cat=$to_kb=$get_receive_buffer_size=,\" KB\"")); @@ -194,7 +194,7 @@ Download::create_info() { element->push_column("Upload:", te_command("cat=$to_kb=$d.get_up_rate=,\" KB / \",$to_xb=$d.get_up_total=")); element->push_column("Download:", te_command("cat=$to_kb=$d.get_down_rate=,\" KB / \",$to_xb=$d.get_down_total=")); element->push_column("Skipped:", te_command("cat=$to_kb=$d.get_skip_rate=,\" KB / \",$to_xb=$d.get_skip_total=")); - element->push_column("Preload:", te_command("cat=$get_preload_type=,\" / \",$get_stats_preloaded=,\" / \",$get_stats_not_preloaded=")); + element->push_column("Preload:", te_command("cat=$pieces.preload.type=,\" / \",$pieces.stats_preloaded=,\" / \",$pieces.stats_preloaded=")); element->set_column_width(element->column_width() + 1); diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index b7d69834..1cf9296e 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -220,7 +220,9 @@ DownloadList::activate_display(Display displayType) { // Set title. switch (displayType) { case DISPLAY_DOWNLOAD_LIST: - control->ui()->window_title()->set_title("rTorrent " VERSION "/" + std::string(torrent::version()) + " - " + rpc::call_command_string("get_name")); + control->ui()->window_title()->set_title("rTorrent " VERSION "/" + + std::string(torrent::version()) + " - " + + rpc::call_command_string("system.session_name")); break; case DISPLAY_LOG: control->ui()->window_title()->set_title("Log");