From a0f3e95d20d5aa64a021437376012edb93782aad Mon Sep 17 00:00:00 2001 From: rakshasa Date: Wed, 6 Oct 2010 12:08:44 +0000 Subject: [PATCH] * Fixed group commands. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1179 e378c898-3ddf-0310-93e7-cc216c733640 --- src/command_local.cc | 16 +++++++--------- src/core/view_manager.cc | 5 ++++- src/main.cc | 16 +++++----------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/command_local.cc b/src/command_local.cc index baf90b02..5b5b9537 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -158,11 +158,13 @@ group_insert(const torrent::Object::list_type& args) { 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("method.insert", rpc::create_object_list("group." + name + ".ratio.enable", "simple", + "schedule2=group." + name + ".ratio,5,60,on_ratio=" + name)); + rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.disable", "simple", + "schedule_remove2=group." + name + ".ratio")); + rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple", + "d.try_close= ;d.ignore_commands.set=1")); rpc::commands.call("method.insert", rpc::create_object_list("group2." + name + ".view", "string", view)); - - rpc::commands.call("method.insert", rpc::create_object_list("group2." + name + ".ratio.enable", "simple", "schedule22=group." + name + ".ratio,5,60,on_ratio=" + name)); - rpc::commands.call("method.insert", rpc::create_object_list("group2." + name + ".ratio.disable", "simple", "schedule_remove2=group." + name + ".ratio")); - rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple", "d.try_close= ;d.ignore_commands.set=1")); rpc::commands.call("method.insert", rpc::create_object_list("group2." + name + ".ratio.min", "value", (int64_t)200)); rpc::commands.call("method.insert", rpc::create_object_list("group2." + name + ".ratio.max", "value", (int64_t)300)); rpc::commands.call("method.insert", rpc::create_object_list("group2." + name + ".ratio.upload", "value", (int64_t)20 << 20)); @@ -172,8 +174,6 @@ group_insert(const torrent::Object::list_type& args) { CMD2_REDIRECT_GENERIC_STR("group." + name + ".view", "group2." + name + ".view"); CMD2_REDIRECT_GENERIC_STR("group." + name + ".view.set", "group2." + name + ".view.set"); - CMD2_REDIRECT_GENERIC_STR("group." + name + ".ratio.enable", "group2." + name + ".ratio.enable"); - CMD2_REDIRECT_GENERIC_STR("group." + name + ".ratio.disable", "group2." + name + ".ratio.disable"); CMD2_REDIRECT_GENERIC_STR("group." + name + ".ratio.min", "group2." + name + ".ratio.min"); CMD2_REDIRECT_GENERIC_STR("group." + name + ".ratio.min.set", "group2." + name + ".ratio.min.set"); CMD2_REDIRECT_GENERIC_STR("group." + name + ".ratio.max", "group2." + name + ".ratio.max"); @@ -186,8 +186,6 @@ group_insert(const torrent::Object::list_type& args) { CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".view", "group2." + name + ".view"); CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".view.set", "group2." + name + ".view.set"); - CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".ratio.enable", "group2." + name + ".ratio.enable"); - CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".ratio.disable", "group2." + name + ".ratio.disable"); CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".ratio.min", "group2." + name + ".ratio.min"); CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".ratio.min.set", "group2." + name + ".ratio.min.set"); CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".ratio.max", "group2." + name + ".ratio.max"); @@ -313,5 +311,5 @@ initialize_command_local() { CMD2_ANY_P("argument.2", std::tr1::bind(&rpc::command_base::argument_ref, 2)); CMD2_ANY_P("argument.3", std::tr1::bind(&rpc::command_base::argument_ref, 3)); - CMD2_ANY_LIST ("group2.insert", std::tr1::bind(&group_insert, std::tr1::placeholders::_2)); + CMD2_ANY_LIST ("group.insert", std::tr1::bind(&group_insert, std::tr1::placeholders::_2)); } diff --git a/src/core/view_manager.cc b/src/core/view_manager.cc index 30cb490b..0052cf53 100644 --- a/src/core/view_manager.cc +++ b/src/core/view_manager.cc @@ -62,7 +62,10 @@ ViewManager::clear() { ViewManager::iterator ViewManager::insert(const std::string& name) { - if (find(name) != end() || name.empty()) + if (name.empty()) + throw torrent::input_error("View with empty name not supported."); + + if (find(name) != end()) throw torrent::input_error("View with same name already inserted."); View* view = new View(); diff --git a/src/main.cc b/src/main.cc index 047ba07f..a91b8bae 100644 --- a/src/main.cc +++ b/src/main.cc @@ -238,8 +238,8 @@ main(int argc, char** argv) { "method.set_key = event.download.erased, !_download_list, ui.unfocus_download=\n" "method.set_key = event.download.erased, ~_delete_tied, d.delete_tied=\n" - "method.insert = group2.insert_persistent_view,simple|const," - "view.add=$argument.0=,view.persistent=$argument.0=,\"group2.insert=$argument.0=,$argument.0=\"\n" + "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 'group2.view' as constant, so that we can't // modify the value. And look into the possibility of making @@ -249,7 +249,7 @@ main(int argc, char** argv) { // TODO: Remember to ensure it doesn't get restarted by watch // dir, etc. Set ignore commands, or something. - "group2.insert = seeding,seeding\n" + "group.insert = seeding,seeding\n" "session.name = \"$cat=$system.hostname=,:,$system.pid=\"\n" @@ -317,8 +317,8 @@ main(int argc, char** argv) { CMD2_REDIRECT_GENERIC("upload_rate", "throttle.global_up.max_rate.set_kb"); CMD2_REDIRECT_GENERIC("download_rate", "throttle.global_down.max_rate.set_kb"); - CMD2_REDIRECT_GENERIC("ratio.enable", "group2.seeding.ratio.enable"); - CMD2_REDIRECT_GENERIC("ratio.disable", "group2.seeding.ratio.disable"); + CMD2_REDIRECT_GENERIC("ratio.enable", "group.seeding.ratio.enable"); + CMD2_REDIRECT_GENERIC("ratio.disable", "group.seeding.ratio.disable"); CMD2_REDIRECT_GENERIC("ratio.min", "group2.seeding.ratio.min"); CMD2_REDIRECT_GENERIC("ratio.max", "group2.seeding.ratio.max"); CMD2_REDIRECT_GENERIC("ratio.upload", "group2.seeding.ratio.upload"); @@ -366,9 +366,6 @@ main(int argc, char** argv) { if (rpc::call_command_value("method.use_intermediate") == 1) { CMD2_REDIRECT_GENERIC("execute", "execute2"); - CMD2_REDIRECT_GENERIC("group.insert", "group2.insert"); - CMD2_REDIRECT_GENERIC("group.insert_persistent_view", "group2.insert_persistent_view"); - CMD2_REDIRECT_GENERIC("schedule", "schedule2"); CMD2_REDIRECT_GENERIC("schedule_remove", "schedule_remove2"); @@ -376,9 +373,6 @@ main(int argc, char** argv) { // Allow for use in config files, etc, just don't export it. CMD2_REDIRECT_GENERIC_NO_EXPORT("execute", "execute2"); - CMD2_REDIRECT_GENERIC_NO_EXPORT("group.insert", "group2.insert"); - CMD2_REDIRECT_GENERIC_NO_EXPORT("group.insert_persistent_view", "group2.insert_persistent_view"); - CMD2_REDIRECT_GENERIC_NO_EXPORT("schedule", "schedule2"); CMD2_REDIRECT_GENERIC_NO_EXPORT("schedule_remove", "schedule_remove2"); }