diff --git a/src/command_download.cc b/src/command_download.cc index c933f3b9..1c01039c 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -599,8 +599,9 @@ d_list_remove(core::Download* download, const torrent::Object& rawArgs, const ch std::placeholders::_1, std::placeholders::_2, \ first_key, second_key)); -int64_t cg_d_group(core::Download* download); -void cg_d_group_set(core::Download* download, const torrent::Object& arg); +int64_t cg_d_group(core::Download* download); +const std::string& cg_d_group_name(core::Download* download); +void cg_d_group_set(core::Download* download, const torrent::Object& arg); void initialize_command_download() { @@ -816,8 +817,9 @@ initialize_command_download() { // std::bind(&core::Download::main, std::placeholders::_1)), // CG_GROUP_INDEX())); - CMD2_DL ("d.group", std::bind(&cg_d_group, std::placeholders::_1));; - CMD2_DL_V ("d.group.set", std::bind(&cg_d_group_set, std::placeholders::_1, std::placeholders::_2)); + CMD2_DL ("d.group", std::bind(&cg_d_group, std::placeholders::_1));; + CMD2_DL ("d.group.name", std::bind(&cg_d_group, std::placeholders::_1));; + CMD2_DL_V ("d.group.set", std::bind(&cg_d_group_set, std::placeholders::_1, std::placeholders::_2)); CMD2_DL ("d.initialize_logs", std::bind(&cmd_d_initialize_logs, std::placeholders::_1)); diff --git a/src/command_groups.cc b/src/command_groups.cc index d8a80dee..2bb41aba 100644 --- a/src/command_groups.cc +++ b/src/command_groups.cc @@ -88,6 +88,11 @@ cg_d_group(core::Download* download) { return torrent::resource_manager()->entry_at(download->main()).group(); } +const std::string& +cg_d_group_name(core::Download* download) { + return torrent::resource_manager()->group_at(torrent::resource_manager()->entry_at(download->main()).group()).name(); +} + void cg_d_group_set(core::Download* download, const torrent::Object& arg) { torrent::resource_manager()->set_group(torrent::resource_manager()->find_throw(download->main()), cg_get_index(arg)); @@ -192,6 +197,9 @@ apply_cg_insert(const std::string& arg) { cg_list_hack.push_back(new torrent::choke_group()); cg_list_hack.back()->set_name(arg); + cg_list_hack.back()->up_queue()->set_heuristics(torrent::choke_queue::HEURISTICS_UPLOAD_LEECH); + cg_list_hack.back()->down_queue()->set_heuristics(torrent::choke_queue::HEURISTICS_DOWNLOAD_LEECH); + return torrent::Object(); } @@ -233,7 +241,8 @@ apply_cg_heuristics_set(const torrent::Object::list_type& args, bool is_up) { if (args.size() != 2) throw torrent::input_error("Incorrect number of arguments."); - int t = torrent::option_find_string(torrent::OPTION_CHOKE_HEURISTICS, args.back().as_string().c_str()); + int t = torrent::option_find_string(is_up ? torrent::OPTION_CHOKE_HEURISTICS_UPLOAD : torrent::OPTION_CHOKE_HEURISTICS_DOWNLOAD, + args.back().as_string().c_str()); if (is_up) cg_get_group(args.front())->up_queue()->set_heuristics((torrent::choke_queue::heuristics_enum)t); @@ -293,8 +302,10 @@ Upload / download rate for the aggregate of all torrents in this particular group. (choke_group.up.max,) -> +(choke_group.up.max.unlimited,) -> (choke_group.up.max.set,, ) (choke_group.down.max,) -> +(choke_group.down.max.unlimited,) -> (choke_group.down.max.set,, ) -> "heuristics" (choke_group.down.heuristics.set,,"heuristics") -Heuristics used for deciding what peers to choke and unchoke, see +Heuristics are used for deciding what peers to choke and unchoke, see 'strings.choke_heuristics{,_download,_upload}' for a list of available options. +(d.group) -> +(d.group.name) -> "choke_group_name" +(d.group.set,) + */ @@ -333,8 +348,7 @@ initialize_command_groups() { CMD2_ANY ("choke_group.size", std::bind(&torrent::ResourceManager::group_size, torrent::resource_manager())); CMD2_ANY_STRING ("choke_group.index_of", std::bind(&torrent::ResourceManager::group_index_of, torrent::resource_manager(), std::placeholders::_2)); #else - cg_list_hack.push_back(new torrent::choke_group()); - cg_list_hack.back()->set_name("default"); + apply_cg_insert("default"); CMD2_ANY ("choke_group.size", std::bind(&std::vector::size, cg_list_hack)); CMD2_ANY_STRING ("choke_group.index_of", std::bind(&apply_cg_index_of, std::placeholders::_2)); @@ -351,7 +365,8 @@ initialize_command_groups() { CMD2_ANY ("choke_group.up.rate", std::bind(&torrent::choke_group::up_rate, CG_GROUP_AT())); CMD2_ANY ("choke_group.down.rate", std::bind(&torrent::choke_group::down_rate, CG_GROUP_AT())); - CMD2_ANY ("choke_group.up.max", std::bind(&torrent::choke_queue::max_unchoked, CHOKE_GROUP(&torrent::choke_group::up_queue))); + CMD2_ANY ("choke_group.up.max.unlimited", std::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::up_queue))); + CMD2_ANY ("choke_group.up.max", std::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::up_queue))); CMD2_ANY_LIST ("choke_group.up.max.set", std::bind(&apply_cg_max_set, std::placeholders::_2, true)); CMD2_ANY ("choke_group.up.total", std::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::up_queue))); @@ -361,8 +376,10 @@ initialize_command_groups() { std::bind(&torrent::choke_queue::heuristics, CHOKE_GROUP(&torrent::choke_group::up_queue)))); CMD2_ANY_LIST ("choke_group.up.heuristics.set", std::bind(&apply_cg_heuristics_set, std::placeholders::_2, true)); - CMD2_ANY ("choke_group.down.max", std::bind(&torrent::choke_queue::max_unchoked, CHOKE_GROUP(&torrent::choke_group::down_queue))); + CMD2_ANY ("choke_group.down.max.unlimited", std::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::down_queue))); + CMD2_ANY ("choke_group.down.max", std::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::down_queue))); CMD2_ANY_LIST ("choke_group.down.max.set", std::bind(&apply_cg_max_set, std::placeholders::_2, false)); + CMD2_ANY ("choke_group.down.total", std::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::down_queue))); CMD2_ANY ("choke_group.down.queued", std::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::down_queue))); CMD2_ANY ("choke_group.down.unchoked", std::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::down_queue)));