* Added 'system.method.get', 'ui.current_view.set' and 'group.insert'

commands.

* Enabled different ratio settings for different groups of
downloads.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1079 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2008-11-10 18:52:36 +00:00
parent 66a2af991a
commit de8a11c4fd
10 changed files with 138 additions and 10 deletions
+39
View File
@@ -48,6 +48,7 @@
#include "core/download_list.h"
#include "core/download_store.h"
#include "core/manager.h"
#include "rak/string_manip.h"
#include "rpc/command_slot.h"
#include "rpc/command_variable.h"
#include "rpc/parse_commands.h"
@@ -116,6 +117,42 @@ system_set_cwd(const torrent::Object& rawArgs) {
return torrent::Object();
}
inline torrent::Object::list_const_iterator
post_increment(torrent::Object::list_const_iterator& itr, const torrent::Object::list_const_iterator& last) {
if (itr == last)
throw torrent::input_error("Invalid number of arguments.");
return itr++;
}
inline const std::string&
check_name(const std::string& str) {
if (!rak::is_all_name(str))
throw torrent::input_error("Non-alphanumeric characters found.");
return str;
}
torrent::Object
group_insert(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
torrent::Object::list_const_iterator itr = rawArgs.as_list().begin();
torrent::Object::list_const_iterator last = rawArgs.as_list().end();
const std::string& name = check_name(post_increment(itr, last)->as_string());
const std::string& view = check_name(post_increment(itr, last)->as_string());
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".view", "string", view));
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".ratio.enable", "simple", "schedule=group." + name + ".ratio,5,60,on_ratio=" + name));
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".ratio.disable", "simple", "schedule_remove=group." + name + ".ratio"));
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple", "d.try_close= ;d.set_ignore_commands=1"));
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".ratio.min", "value", (int64_t)200));
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".ratio.max", "value", (int64_t)300));
rpc::commands.call("system.method.insert", rpc::create_object_list("group." + name + ".ratio.upload", "value", (int64_t)20 << 20));
return name;
}
void
initialize_command_local() {
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
@@ -178,4 +215,6 @@ initialize_command_local() {
CMD_OBJ_P("argument.1", get_generic, rpc::Command::argument(1));
CMD_OBJ_P("argument.2", get_generic, rpc::Command::argument(2));
CMD_OBJ_P("argument.3", get_generic, rpc::Command::argument(3));
CMD_N_LIST("group.insert", rak::ptr_fn(&group_insert));
}