* Last of the commands converted, cleanup remaining.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1154 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2010-03-27 16:35:15 +00:00
parent bc96dbfa2d
commit 10f665e9c6
24 changed files with 640 additions and 455 deletions
+228 -223
View File
@@ -88,9 +88,7 @@ retrieve_d_base_filename(core::Download* download) {
}
torrent::Object
apply_d_change_link(int changeType, core::Download* download, const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
apply_d_change_link(core::Download* download, const torrent::Object::list_type& args, int changeType) {
if (args.size() != 3)
throw torrent::input_error("Wrong argument count.");
@@ -112,14 +110,14 @@ apply_d_change_link(int changeType, core::Download* download, const torrent::Obj
} else if (type == "base_filename") {
target = rpc::call_command_string("d.base_path", rpc::make_target(download));
link = rak::path_expand(prefix + rpc::call_command_string("d.get_base_filename", rpc::make_target(download)) + postfix);
link = rak::path_expand(prefix + rpc::call_command_string("d.base_filename", rpc::make_target(download)) + postfix);
// } else if (type == "directory_path") {
// target = rpc::call_command_string("d.get_directory", rpc::make_target(download));
// target = rpc::call_command_string("d.directory", rpc::make_target(download));
// link = rak::path_expand(prefix + rpc::call_command_string("d.base_path", rpc::make_target(download)) + postfix);
} else if (type == "tied") {
link = rak::path_expand(rpc::call_command_string("d.get_tied_to_file", rpc::make_target(download)));
link = rak::path_expand(rpc::call_command_string("d.tied_to_file", rpc::make_target(download)));
if (link.empty())
return torrent::Object();
@@ -157,25 +155,21 @@ apply_d_change_link(int changeType, core::Download* download, const torrent::Obj
return torrent::Object();
}
template <int type> torrent::Object
cmd_d_change_link(core::Download* download, const torrent::Object& rawArgs) {
return apply_d_change_link(type, download, rawArgs);
}
void
torrent::Object
apply_d_delete_tied(core::Download* download) {
const std::string& tie = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(download));
const std::string& tie = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
if (tie.empty())
return;
return torrent::Object();
if (::unlink(rak::path_expand(tie).c_str()) == -1)
control->core()->push_log_std("Could not unlink tied file: " + std::string(rak::error_number::current().c_str()));
rpc::call_command("d.set_tied_to_file", std::string(), rpc::make_target(download));
rpc::call_command("d.tied_to_file.set", std::string(), rpc::make_target(download));
return torrent::Object();
}
void
torrent::Object
apply_d_connection_type(core::Download* download, const std::string& name) {
torrent::Download::ConnectionType connType;
@@ -189,6 +183,7 @@ apply_d_connection_type(core::Download* download, const std::string& name) {
throw torrent::input_error("Unknown peer connection type selected.");
download->download()->set_connection_type(connType);
return torrent::Object();
}
void
@@ -264,13 +259,15 @@ retrieve_d_local_id_html(core::Download* download) {
}
torrent::Object
apply_d_custom(core::Download* download, const torrent::Object& rawArgs) {
torrent::Object::list_const_iterator itr = rawArgs.as_list().begin();
if (itr == rawArgs.as_list().end())
apply_d_custom(core::Download* download, const torrent::Object::list_type& args) {
torrent::Object::list_const_iterator itr = args.begin();
if (itr == args.end())
throw torrent::bencode_error("Missing key argument.");
const std::string& key = itr->as_string();
if (++itr == rawArgs.as_list().end())
if (++itr == args.end())
throw torrent::bencode_error("Missing value argument.");
download->bencode()->get_key("rtorrent").
@@ -358,9 +355,7 @@ apply_d_add_peer(core::Download* download, const std::string& arg) {
}
torrent::Object
f_multicall(core::Download* download, const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
f_multicall(core::Download* download, const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("Too few arguments.");
@@ -385,9 +380,7 @@ f_multicall(core::Download* download, const torrent::Object& rawArgs) {
}
torrent::Object
t_multicall(core::Download* download, const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
t_multicall(core::Download* download, const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("Too few arguments.");
@@ -414,9 +407,7 @@ t_multicall(core::Download* download, const torrent::Object& rawArgs) {
}
torrent::Object
p_multicall(core::Download* download, const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
p_multicall(core::Download* download, const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("Too few arguments.");
@@ -441,30 +432,59 @@ p_multicall(core::Download* download, const torrent::Object& rawArgs) {
return resultRaw;
}
inline torrent::Object&
d_object_wrapper(const std::pair<const char*, const char*> keyPair, core::Download* download) {
if (keyPair.first == NULL)
return download->bencode()->get_key(keyPair.second);
else
return download->bencode()->get_key(keyPair.first).get_key(keyPair.second);
//
// New download commands and macros:
//
torrent::Object
download_get_variable(core::Download* download, const char* first_key, const char* second_key = NULL) {
if (second_key == NULL)
return download->bencode()->get_key(first_key);
return download->bencode()->get_key(first_key).get_key(second_key);
}
torrent::Object
d_object_get(const std::pair<const char*, const char*> keyPair, core::Download* download, __UNUSED const torrent::Object& rawArgs) {
return d_object_wrapper(keyPair, download);
download_set_variable(core::Download* download, const torrent::Object& rawArgs, const char* first_key, const char* second_key = NULL) {
if (second_key == NULL)
return download->bencode()->get_key(first_key) = torrent::object_create_normal(rawArgs);
return download->bencode()->get_key(first_key).get_key(second_key) = torrent::object_create_normal(rawArgs);
}
torrent::Object
d_list_push_back(const std::pair<const char*, const char*> keyPair, core::Download* download, const torrent::Object& rawArgs) {
d_object_wrapper(keyPair, download).as_list().push_back(rawArgs);
download_set_variable_value(core::Download* download, const torrent::Object::value_type& args,
const char* first_key, const char* second_key = NULL) {
if (second_key == NULL)
return download->bencode()->get_key(first_key) = args;
return download->bencode()->get_key(first_key).get_key(second_key) = args;
}
torrent::Object
download_set_variable_string(core::Download* download, const torrent::Object::string_type& args,
const char* first_key, const char* second_key = NULL) {
if (second_key == NULL)
return download->bencode()->get_key(first_key) = args;
return download->bencode()->get_key(first_key).get_key(second_key) = args;
}
//
//
//
torrent::Object
d_list_push_back(core::Download* download, const torrent::Object& rawArgs, const char* first_key, const char* second_key) {
download_get_variable(download, first_key, second_key).as_list().push_back(rawArgs);
return torrent::Object();
}
torrent::Object
d_list_push_back_unique(const std::pair<const char*, const char*> keyPair, core::Download* download, const torrent::Object& rawArgs) {
d_list_push_back_unique(core::Download* download, const torrent::Object& rawArgs, const char* first_key, const char* second_key) {
const torrent::Object& args = (rawArgs.is_list() && !rawArgs.as_list().empty()) ? rawArgs.as_list().front() : rawArgs;
torrent::Object::list_type& list = d_object_wrapper(keyPair, download).as_list();
torrent::Object::list_type& list = download_get_variable(download, first_key, second_key).as_list();
if (std::find_if(list.begin(), list.end(),
rak::bind1st(std::ptr_fun(&torrent::object_equal), args)) == list.end())
@@ -474,89 +494,24 @@ d_list_push_back_unique(const std::pair<const char*, const char*> keyPair, core:
}
torrent::Object
d_list_has(const std::pair<const char*, const char*> keyPair, core::Download* download, const torrent::Object& rawArgs) {
d_list_has(core::Download* download, const torrent::Object& rawArgs, const char* first_key, const char* second_key) {
const torrent::Object& args = (rawArgs.is_list() && !rawArgs.as_list().empty()) ? rawArgs.as_list().front() : rawArgs;
torrent::Object::list_type& list = d_object_wrapper(keyPair, download).as_list();
torrent::Object::list_type& list = download_get_variable(download, first_key, second_key).as_list();
return (int64_t)(std::find_if(list.begin(), list.end(),
rak::bind1st(std::ptr_fun(&torrent::object_equal), args)) != list.end());
}
torrent::Object
d_list_remove(const std::pair<const char*, const char*> keyPair, core::Download* download, const torrent::Object& rawArgs) {
d_list_remove(core::Download* download, const torrent::Object& rawArgs, const char* first_key, const char* second_key) {
const torrent::Object& args = (rawArgs.is_list() && !rawArgs.as_list().empty()) ? rawArgs.as_list().front() : rawArgs;
torrent::Object::list_type& list = d_object_wrapper(keyPair, download).as_list();
torrent::Object::list_type& list = download_get_variable(download, first_key, second_key).as_list();
list.erase(std::remove_if(list.begin(), list.end(), rak::bind1st(std::ptr_fun(&torrent::object_equal), args)), list.end());
return torrent::Object();
}
#define ADD_CD_SLOT(key, function, slot, parm, doc) \
commandDownloadSlotsItr->set_slot(slot); \
rpc::commands.insert_type(key, commandDownloadSlotsItr++, &rpc::CommandSlot<core::Download*>::function, rpc::CommandMap::flag_dont_delete, parm, doc);
#define ADD_CD_SLOT_PUBLIC(key, function, slot, parm, doc) \
commandDownloadSlotsItr->set_slot(slot); \
rpc::commands.insert_type(key, commandDownloadSlotsItr++, &rpc::CommandSlot<core::Download*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
#define ADD_CD_VOID(key, slot) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::object_fn(slot), "i:", "")
#define ADD_CD_V_VOID(key, slot) \
ADD_CD_SLOT_PUBLIC("d." key, call_unknown, rpc::object_fn(slot), "i:", "")
#define ADD_CD_F_VOID(key, slot) \
ADD_CD_SLOT_PUBLIC("d." key, call_unknown, rpc::object_void_fn<core::Download*>(slot), "i:", "")
#define ADD_CD_LIST_OBSOLETE(key, slot) \
ADD_CD_SLOT_PUBLIC(key, call_list, slot, "i:", "")
#define ADD_CD_LIST(key, slot) \
ADD_CD_SLOT_PUBLIC("d." key, call_list, slot, "i:", "")
#define ADD_CD_STRING(key, slot) \
ADD_CD_SLOT_PUBLIC("d." key, call_string, rpc::object_string_fn<core::Download*>(slot), "i:s", "")
#define ADD_CD_VARIABLE_VALUE(key, firstKey, secondKey) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::get_variable_d_fn(firstKey, secondKey), "i:", ""); \
ADD_CD_SLOT ("d.set_" key, call_value, rpc::set_variable_d_fn(firstKey, secondKey), "i:i", "");
#define ADD_CD_VARIABLE_VALUE_PUBLIC(key, firstKey, secondKey) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::get_variable_d_fn(firstKey, secondKey), "i:", ""); \
ADD_CD_SLOT_PUBLIC("d.set_" key, call_value, rpc::set_variable_d_fn(firstKey, secondKey), "i:i", "");
#define ADD_CD_VARIABLE_STRING(key, firstKey, secondKey) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::get_variable_d_fn(firstKey, secondKey), "i:", ""); \
ADD_CD_SLOT ("d.set_" key, call_string, rpc::set_variable_d_fn(firstKey, secondKey), "i:s", "");
#define ADD_CD_VARIABLE_STRING_PUBLIC(key, firstKey, secondKey) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::get_variable_d_fn(firstKey, secondKey), "i:", ""); \
ADD_CD_SLOT_PUBLIC("d.set_" key, call_string, rpc::set_variable_d_fn(firstKey, secondKey), "i:s", "");
#define ADD_CD_VALUE(key, get) \
ADD_CD_SLOT_PUBLIC("d." key, call_unknown, rpc::object_void_fn<core::Download*>(get), "i:", "")
#define ADD_CD_VALUE_UNI(key, get) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::object_void_fn<core::Download*>(get), "i:", "")
#define ADD_CD_VALUE_BI(key, set, get) \
ADD_CD_SLOT_PUBLIC("d.set_" key, call_value, rpc::object_value_fn<core::Download*>(set), "i:i", "") \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::object_void_fn<core::Download*>(get), "i:", "")
#define ADD_CD_VALUE_MEM_BI(key, target, set, get) \
ADD_CD_VALUE_BI(key, rak::on2(std::mem_fun(target), std::mem_fun(set)), rak::on(std::mem_fun(target), std::mem_fun(get)));
#define ADD_CD_VALUE_MEM_UNI(key, target, get) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::object_void_fn<core::Download*>(rak::on(rak::on(std::mem_fun(&core::Download::download), std::mem_fun(target)), std::mem_fun(get))), "i:", "");
#define ADD_CD_STRING_UNI(key, get) \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::object_void_fn<core::Download*>(get), "s:", "")
#define ADD_CD_STRING_BI(key, set, get) \
ADD_CD_SLOT_PUBLIC("d.set_" key, call_string, rpc::object_string_fn<core::Download*>(set), "i:s", "") \
ADD_CD_SLOT_PUBLIC("d.get_" key, call_unknown, rpc::object_void_fn<core::Download*>(get), "s:", "")
void
add_copy_to_download(const char* src, const char* dest) {
rpc::CommandMap::iterator itr = rpc::commands.find(src);
@@ -567,173 +522,223 @@ add_copy_to_download(const char* src, const char* dest) {
rpc::commands.insert(dest, itr->second);
}
#define CMD_ON_INFO(func) \
rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::func))
#define CMD_ON_INFO(func) rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::func))
#define CMD2_ON_INFO(func) std::tr1::bind(&torrent::DownloadInfo::func, std::tr1::bind(&core::Download::info, std::tr1::placeholders::_1))
#define CMD2_ON_DL(func) std::tr1::bind(&torrent::Download::func, std::tr1::bind(&core::Download::download, std::tr1::placeholders::_1))
#define CMD2_ON_FL(func) std::tr1::bind(&torrent::FileList::func, std::tr1::bind(&core::Download::file_list, std::tr1::placeholders::_1))
#define CMD2_BIND_DL std::tr1::bind(&core::Download::download, std::tr1::placeholders::_1)
#define CMD2_BIND_CL std::tr1::bind(&core::Download::connection_list, std::tr1::placeholders::_1)
#define CMD2_BIND_FL std::tr1::bind(&core::Download::file_list, std::tr1::placeholders::_1)
#define CMD2_BIND_PL std::tr1::bind(&core::Download::c_peer_list, std::tr1::placeholders::_1)
#define CMD2_BIND_TL std::tr1::bind(&core::Download::tracker_list, std::tr1::placeholders::_1)
#define CMD2_DL_VAR_VALUE(key, first_key, second_key) \
CMD2_DL(key, std::tr1::bind(&download_get_variable, std::tr1::placeholders::_1, first_key, second_key)); \
CMD2_DL_VALUE_P(key ".set", std::tr1::bind(&download_set_variable_value, \
std::tr1::placeholders::_1, std::tr1::placeholders::_2, \
first_key, second_key));
#define CMD2_DL_VAR_VALUE_PUBLIC(key, first_key, second_key) \
CMD2_DL(key, std::tr1::bind(&download_get_variable, std::tr1::placeholders::_1, first_key, second_key)); \
CMD2_DL_VALUE(key ".set", std::tr1::bind(&download_set_variable_value, \
std::tr1::placeholders::_1, std::tr1::placeholders::_2, \
first_key, second_key));
#define CMD2_DL_VAR_STRING(key, first_key, second_key) \
CMD2_DL(key, std::tr1::bind(&download_get_variable, std::tr1::placeholders::_1, first_key, second_key)); \
CMD2_DL_STRING_P(key ".set", std::tr1::bind(&download_set_variable_string, \
std::tr1::placeholders::_1, std::tr1::placeholders::_2, \
first_key, second_key));
#define CMD2_DL_VAR_STRING_PUBLIC(key, first_key, second_key) \
CMD2_DL(key, std::tr1::bind(&download_get_variable, std::tr1::placeholders::_1, first_key, second_key)); \
CMD2_DL_STRING(key ".set", std::tr1::bind(&download_set_variable_string, \
std::tr1::placeholders::_1, std::tr1::placeholders::_2, \
first_key, second_key));
void
initialize_command_download() {
CMD_D_VOID("d.hash", &retrieve_d_hash);
CMD_D_VOID("d.local_id", &retrieve_d_local_id);
CMD_D_VOID("d.local_id_html", &retrieve_d_local_id_html);
CMD_D_VOID("d.bitfield", &retrieve_d_bitfield);
CMD_D_VOID("d.base_path", &retrieve_d_base_path);
CMD_D_VOID("d.base_filename", &retrieve_d_base_filename);
CMD2_DL("d.hash", std::tr1::bind(&retrieve_d_hash, std::tr1::placeholders::_1));
CMD2_DL("d.local_id", std::tr1::bind(&retrieve_d_local_id, std::tr1::placeholders::_1));
CMD2_DL("d.local_id_html", std::tr1::bind(&retrieve_d_local_id_html, std::tr1::placeholders::_1));
CMD2_DL("d.bitfield", std::tr1::bind(&retrieve_d_bitfield, std::tr1::placeholders::_1));
CMD2_DL("d.base_path", std::tr1::bind(&retrieve_d_base_path, std::tr1::placeholders::_1));
CMD2_DL("d.base_filename", std::tr1::bind(&retrieve_d_base_filename, std::tr1::placeholders::_1));
CMD_D_VOID_SLOT("d.name", CMD_ON_INFO(name));
CMD2_DL("d.name", CMD2_ON_INFO(name));
CMD_D_VOID_SLOT("d.creation_date", CMD_ON_INFO(creation_date));
CMD_D_VOID_SLOT("d.load_date", CMD_ON_INFO(load_date));
CMD2_DL("d.creation_date", CMD2_ON_INFO(creation_date));
CMD2_DL("d.load_date", CMD2_ON_INFO(load_date));
// ?????
ADD_CD_LIST_OBSOLETE("create_link", rak::bind_ptr_fn(&apply_d_change_link, 0));
ADD_CD_LIST_OBSOLETE("delete_link", rak::bind_ptr_fn(&apply_d_change_link, 1));
//
// Network related:
//
ADD_CD_LIST("create_link", rak::bind_ptr_fn(&apply_d_change_link, 0));
ADD_CD_LIST("delete_link", rak::bind_ptr_fn(&apply_d_change_link, 1));
ADD_CD_V_VOID("delete_tied", &apply_d_delete_tied);
CMD2_DL ("d.up.rate", std::tr1::bind(&torrent::Rate::rate, CMD2_ON_INFO(up_rate)));
CMD2_DL ("d.up.total", std::tr1::bind(&torrent::Rate::total, CMD2_ON_INFO(up_rate)));
CMD2_DL ("d.down.rate", std::tr1::bind(&torrent::Rate::rate, CMD2_ON_INFO(down_rate)));
CMD2_DL ("d.down.total", std::tr1::bind(&torrent::Rate::total, CMD2_ON_INFO(down_rate)));
CMD2_DL ("d.skip.rate", std::tr1::bind(&torrent::Rate::rate, CMD2_ON_INFO(skip_rate)));
CMD2_DL ("d.skip.total", std::tr1::bind(&torrent::Rate::total, CMD2_ON_INFO(skip_rate)));
CMD_FUNC_SINGLE("d.start", "d.set_hashing_failed=0 ;view.set_visible=started");
CMD_FUNC_SINGLE("d.stop", "view.set_visible=stopped");
CMD_FUNC_SINGLE("d.try_start", "branch=\"or={d.get_hashing_failed=,d.get_ignore_commands=}\",{},{view.set_visible=started}");
CMD_FUNC_SINGLE("d.try_stop", "branch=d.get_ignore_commands=, {}, {view.set_visible=stopped}");
CMD_FUNC_SINGLE("d.try_close", "branch=d.get_ignore_commands=, {}, {view.set_visible=stopped, d.close=}");
CMD2_DL ("d.peer_exchange", CMD2_ON_INFO(is_pex_enabled));
CMD2_DL_VALUE_V ("d.peer_exchange.set", std::tr1::bind(&torrent::Download::set_pex_enabled, CMD2_BIND_DL, std::tr1::placeholders::_2));
ADD_CD_F_VOID("resume", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::resume_default));
ADD_CD_F_VOID("pause", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::pause_default));
ADD_CD_F_VOID("open", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::open_throw));
ADD_CD_F_VOID("close", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::close_throw));
ADD_CD_F_VOID("erase", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::erase_ptr));
ADD_CD_F_VOID("check_hash", rak::make_mem_fun(control->core()->download_list(), &core::DownloadList::check_hash));
CMD2_DL_LIST ("d.create_link", std::tr1::bind(&apply_d_change_link, std::tr1::placeholders::_1, std::tr1::placeholders::_2, 0));
CMD2_DL_LIST ("d.delete_link", std::tr1::bind(&apply_d_change_link, std::tr1::placeholders::_1, std::tr1::placeholders::_2, 1));
CMD2_DL ("d.delete_tied", std::tr1::bind(&apply_d_delete_tied, std::tr1::placeholders::_1));
ADD_CD_F_VOID("save_resume", rak::make_mem_fun(control->core()->download_store(), &core::DownloadStore::save_resume));
ADD_CD_F_VOID("save_full_session", rak::make_mem_fun(control->core()->download_store(), &core::DownloadStore::save_full));
CMD2_FUNC_SINGLE("d.start", "d.hashing_failed.set=0 ;view.set_visible=started");
CMD2_FUNC_SINGLE("d.stop", "view.set_visible=stopped");
CMD2_FUNC_SINGLE("d.try_start", "branch=\"or={d.hashing_failed=,d.ignore_commands=}\",{},{view.set_visible=started}");
CMD2_FUNC_SINGLE("d.try_stop", "branch=d.ignore_commands=, {}, {view.set_visible=stopped}");
CMD2_FUNC_SINGLE("d.try_close", "branch=d.ignore_commands=, {}, {view.set_visible=stopped, d.close=}");
ADD_CD_F_VOID("update_priorities", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::update_priorities)));
//
// Control functinos:
//
ADD_CD_STRING("add_peer", std::ptr_fun(&apply_d_add_peer));
CMD2_DL ("d.is_open", CMD2_ON_INFO(is_open));
CMD2_DL ("d.is_active", CMD2_ON_INFO(is_active));
CMD2_DL ("d.is_hash_checked", std::tr1::bind(&torrent::Download::is_hash_checked, CMD2_BIND_DL));
CMD2_DL ("d.is_hash_checking", std::tr1::bind(&torrent::Download::is_hash_checking, CMD2_BIND_DL));
CMD2_DL ("d.is_multi_file", std::tr1::bind(&torrent::FileList::is_multi_file, CMD2_BIND_FL));
CMD2_DL ("d.is_private", CMD2_ON_INFO(is_private));
CMD2_DL ("d.is_pex_active", CMD2_ON_INFO(is_pex_active));
ADD_CD_VALUE("is_open", rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::is_open)));
ADD_CD_VALUE("is_active", rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::is_active)));
ADD_CD_VALUE("is_hash_checked", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_hash_checked)));
ADD_CD_VALUE("is_hash_checking", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_hash_checking)));
ADD_CD_VALUE("is_multi_file", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::is_multi_file)));
ADD_CD_VALUE("is_private", rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::is_private)));
ADD_CD_VALUE("is_pex_active", rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::is_pex_active)));
CMD2_DL_V("d.resume", std::tr1::bind(&core::DownloadList::resume_default, control->core()->download_list(), std::tr1::placeholders::_1));
CMD2_DL_V("d.pause", std::tr1::bind(&core::DownloadList::pause_default, control->core()->download_list(), std::tr1::placeholders::_1));
CMD2_DL_V("d.open", std::tr1::bind(&core::DownloadList::open_throw, control->core()->download_list(), std::tr1::placeholders::_1));
CMD2_DL_V("d.close", std::tr1::bind(&core::DownloadList::close_throw, control->core()->download_list(), std::tr1::placeholders::_1));
CMD2_DL_V("d.erase", std::tr1::bind(&core::DownloadList::erase_ptr, control->core()->download_list(), std::tr1::placeholders::_1));
CMD2_DL_V("d.check_hash", std::tr1::bind(&core::DownloadList::check_hash, control->core()->download_list(), std::tr1::placeholders::_1));
ADD_CD_VARIABLE_STRING_PUBLIC("custom1", "rtorrent", "custom1");
ADD_CD_VARIABLE_STRING_PUBLIC("custom2", "rtorrent", "custom2");
ADD_CD_VARIABLE_STRING_PUBLIC("custom3", "rtorrent", "custom3");
ADD_CD_VARIABLE_STRING_PUBLIC("custom4", "rtorrent", "custom4");
ADD_CD_VARIABLE_STRING_PUBLIC("custom5", "rtorrent", "custom5");
CMD2_DL ("d.save_resume", std::tr1::bind(&core::DownloadStore::save_resume, control->core()->download_store(), std::tr1::placeholders::_1));
CMD2_DL ("d.save_full_session", std::tr1::bind(&core::DownloadStore::save_full, control->core()->download_store(), std::tr1::placeholders::_1));
ADD_CD_SLOT_PUBLIC("d.set_custom", call_list, rak::ptr_fn(&apply_d_custom), "i:", "");
ADD_CD_SLOT_PUBLIC("d.get_custom", call_string, rpc::object_string_fn<core::Download*>(std::ptr_fun(&retrieve_d_custom)), "s:s", "");
ADD_CD_SLOT_PUBLIC("d.get_custom_throw", call_string, rpc::object_string_fn<core::Download*>(std::ptr_fun(&retrieve_d_custom_throw)), "s:s", "");
CMD2_DL_V("d.update_priorities", CMD2_ON_DL(update_priorities));
CMD2_DL_STRING_V("add_peer", std::tr1::bind(&apply_d_add_peer, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
//
// Custom settings:
//
CMD2_DL_STRING("d.custom", std::tr1::bind(&retrieve_d_custom, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL_STRING("d.custom_throw", std::tr1::bind(&retrieve_d_custom_throw, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL_LIST ("d.custom.set", std::tr1::bind(&apply_d_custom, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL_VAR_STRING_PUBLIC("d.custom1", "rtorrent", "custom1");
CMD2_DL_VAR_STRING_PUBLIC("d.custom2", "rtorrent", "custom2");
CMD2_DL_VAR_STRING_PUBLIC("d.custom3", "rtorrent", "custom3");
CMD2_DL_VAR_STRING_PUBLIC("d.custom4", "rtorrent", "custom4");
CMD2_DL_VAR_STRING_PUBLIC("d.custom5", "rtorrent", "custom5");
// 0 - stopped
// 1 - started
ADD_CD_VARIABLE_VALUE("state", "rtorrent", "state");
ADD_CD_VARIABLE_VALUE("complete", "rtorrent", "complete");
CMD2_DL_VAR_VALUE("d.state", "rtorrent", "state");
CMD2_DL_VAR_VALUE("d.complete", "rtorrent", "complete");
// 0 off
// 1 scheduled, being controlled by a download scheduler. Includes a priority.
// 3 forced off
// 2 forced on
ADD_CD_VARIABLE_VALUE("mode", "rtorrent", "mode");
CMD2_DL_VAR_VALUE("d.mode", "rtorrent", "mode");
// 0 - Not hashing
// 1 - Normal hashing
// 2 - Download finished, hashing
// 3 - Rehashing
ADD_CD_VARIABLE_VALUE("hashing", "rtorrent", "hashing");
CMD2_DL_VAR_VALUE("d.hashing", "rtorrent", "hashing");
// 'tied_to_file' is the file the download is associated with, and
// can be changed by the user.
//
// 'loaded_file' is the file this instance of the torrent was loaded
// from, and should not be changed.
ADD_CD_VARIABLE_STRING_PUBLIC("tied_to_file", "rtorrent", "tied_to_file");
ADD_CD_VARIABLE_STRING ("loaded_file", "rtorrent", "loaded_file");
CMD2_DL_VAR_STRING_PUBLIC("d.tied_to_file", "rtorrent", "tied_to_file");
CMD2_DL_VAR_STRING("d.loaded_file", "rtorrent", "loaded_file");
// The "state_changed" variable is required to be a valid unix time
// value, it indicates the last time the torrent changed its state,
// resume/pause.
ADD_CD_VARIABLE_VALUE("state_changed", "rtorrent", "state_changed");
ADD_CD_VARIABLE_VALUE("state_counter", "rtorrent", "state_counter");
ADD_CD_VARIABLE_VALUE_PUBLIC("ignore_commands", "rtorrent", "ignore_commands");
CMD2_DL_VAR_VALUE("d.state_changed", "rtorrent", "state_changed");
CMD2_DL_VAR_VALUE("d.state_counter", "rtorrent", "state_counter");
CMD2_DL_VAR_VALUE_PUBLIC("d.ignore_commands", "rtorrent", "ignore_commands");
ADD_CD_STRING_BI("connection_current", std::ptr_fun(&apply_d_connection_type), std::ptr_fun(&retrieve_d_connection_type));
ADD_CD_VARIABLE_STRING("connection_leech", "rtorrent", "connection_leech");
ADD_CD_VARIABLE_STRING("connection_seed", "rtorrent", "connection_seed");
CMD2_DL ("d.connection_current", std::tr1::bind(&retrieve_d_connection_type, std::tr1::placeholders::_1));
CMD2_DL_STRING("d.connection_current.set", std::tr1::bind(&apply_d_connection_type, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
ADD_CD_VALUE_BI("hashing_failed", std::mem_fun(&core::Download::set_hash_failed), std::mem_fun(&core::Download::is_hash_failed));
CMD2_DL_VAR_STRING("d.connection_leech", "rtorrent", "connection_leech");
CMD2_DL_VAR_STRING("d.connection_seed", "rtorrent", "connection_seed");
CMD_D("d.views", rak::bind_ptr_fn(&d_object_get, std::make_pair("rtorrent", "views")));
CMD_D("d.views.has", rak::bind_ptr_fn(&d_list_has, std::make_pair("rtorrent", "views")));
CMD_D("d.views.remove", rak::bind_ptr_fn(&d_list_remove, std::make_pair("rtorrent", "views")));
CMD_D("d.views.push_back", rak::bind_ptr_fn(&d_list_push_back, std::make_pair("rtorrent", "views")));
CMD_D("d.views.push_back_unique", rak::bind_ptr_fn(&d_list_push_back_unique, std::make_pair("rtorrent", "views")));
CMD2_DL ("d.hashing_failed", std::tr1::bind(&core::Download::is_hash_failed, std::tr1::placeholders::_1));
CMD2_DL_VALUE_V("d.hashing_failed.set", std::tr1::bind(&core::Download::set_hash_failed, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL ("d.views", std::tr1::bind(&download_get_variable, std::tr1::placeholders::_1, "rtorrent", "views"));
CMD2_DL ("d.views.has", std::tr1::bind(&d_list_has, std::tr1::placeholders::_1, std::tr1::placeholders::_2, "rtorrent", "views"));
CMD2_DL ("d.views.remove", std::tr1::bind(&d_list_remove, std::tr1::placeholders::_1, std::tr1::placeholders::_2, "rtorrent", "views"));
CMD2_DL ("d.views.push_back", std::tr1::bind(&d_list_push_back, std::tr1::placeholders::_1, std::tr1::placeholders::_2, "rtorrent", "views"));
CMD2_DL ("d.views.push_back_unique", std::tr1::bind(&d_list_push_back_unique, std::tr1::placeholders::_1, std::tr1::placeholders::_2, "rtorrent", "views"));
// This command really needs to be improved, so we have proper
// logging support.
ADD_CD_STRING_BI("message", std::mem_fun(&core::Download::set_message), std::mem_fun(&core::Download::message));
CMD2_DL ("d.message", std::tr1::bind(&core::Download::message, std::tr1::placeholders::_1));
CMD2_DL_STRING_V("d.message.set", std::tr1::bind(&core::Download::set_message, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
ADD_CD_VALUE_MEM_BI("max_file_size", &core::Download::file_list, &torrent::FileList::set_max_file_size, &torrent::FileList::max_file_size);
CMD2_DL ("d.max_file_size", CMD2_ON_FL(max_file_size));
CMD2_DL_VALUE_V ("d.max_file_size.set", std::tr1::bind(&torrent::FileList::set_max_file_size, CMD2_BIND_FL, std::tr1::placeholders::_2));
ADD_CD_VALUE_MEM_BI("peers_min", &core::Download::connection_list, &torrent::ConnectionList::set_min_size, &torrent::ConnectionList::min_size);
ADD_CD_VALUE_MEM_BI("peers_max", &core::Download::connection_list, &torrent::ConnectionList::set_max_size, &torrent::ConnectionList::max_size);
ADD_CD_VALUE_MEM_BI("uploads_max", &core::Download::download, &torrent::Download::set_uploads_max, &torrent::Download::uploads_max);
ADD_CD_VALUE_UNI("peers_connected", std::mem_fun(&core::Download::connection_list_size));
ADD_CD_VALUE_UNI("peers_not_connected", rak::on(std::mem_fun(&core::Download::c_peer_list), std::mem_fun(&torrent::PeerList::available_list_size)));
ADD_CD_VALUE_UNI("peers_complete", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_complete)));
ADD_CD_VALUE_UNI("peers_accounted", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_accounted)));
CMD2_DL ("d.peers_min", std::tr1::bind(&torrent::ConnectionList::min_size, CMD2_BIND_CL));
CMD2_DL_VALUE_V ("d.peers_min.set", std::tr1::bind(&torrent::ConnectionList::set_min_size, CMD2_BIND_CL, std::tr1::placeholders::_2));
CMD2_DL ("d.peers_max", std::tr1::bind(&torrent::ConnectionList::max_size, CMD2_BIND_CL));
CMD2_DL_VALUE_V ("d.peers_max.set", std::tr1::bind(&torrent::ConnectionList::set_max_size, CMD2_BIND_CL, std::tr1::placeholders::_2));
CMD2_DL ("d.uploads_max", std::tr1::bind(&torrent::ConnectionList::max_size, CMD2_BIND_CL));
CMD2_DL_VALUE_V ("d.uploads_max.set", std::tr1::bind(&torrent::ConnectionList::set_max_size, CMD2_BIND_CL, std::tr1::placeholders::_2));
CMD2_DL ("d.peers_connected", std::tr1::bind(&torrent::ConnectionList::size, CMD2_BIND_CL));
CMD2_DL ("d.peers_note_connected", std::tr1::bind(&torrent::PeerList::available_list_size, CMD2_BIND_PL));
//
CMD_D_VOID_SLOT("d.up.rate", rak::on(CMD_ON_INFO(up_rate), std::mem_fun(&torrent::Rate::rate)));
CMD_D_VOID_SLOT("d.up.total", rak::on(CMD_ON_INFO(up_rate), std::mem_fun(&torrent::Rate::total)));
CMD_D_VOID_SLOT("d.down.rate", rak::on(CMD_ON_INFO(down_rate), std::mem_fun(&torrent::Rate::rate)));
CMD_D_VOID_SLOT("d.down.total", rak::on(CMD_ON_INFO(down_rate), std::mem_fun(&torrent::Rate::total)));
CMD_D_VOID_SLOT("d.skip.rate", rak::on(CMD_ON_INFO(skip_rate), std::mem_fun(&torrent::Rate::rate)));
CMD_D_VOID_SLOT("d.skip.total", rak::on(CMD_ON_INFO(skip_rate), std::mem_fun(&torrent::Rate::total)));
//
CMD2_DL ("d.peers_complete", CMD2_ON_DL(peers_complete));
CMD2_DL ("d.peers_accounted", CMD2_ON_DL(peers_accounted));
ADD_CD_STRING("set_throttle_name", std::mem_fun(&core::Download::set_throttle_name));
ADD_CD_SLOT_PUBLIC("d.get_throttle_name", call_unknown, rpc::get_variable_d_fn("rtorrent", "throttle_name"), "i:", "");
CMD2_DL ("d.throttle_name", std::tr1::bind(&download_get_variable, std::tr1::placeholders::_1, "rtorrent", "throttle_name"));
CMD2_DL_STRING_V("d.throttle_name.set", std::tr1::bind(&core::Download::set_throttle_name, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
ADD_CD_VALUE_UNI("bytes_done", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::bytes_done)));
ADD_CD_VALUE_UNI("ratio", std::ptr_fun(&retrieve_d_ratio));
ADD_CD_VALUE_UNI("chunks_hashed", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::chunks_hashed)));
ADD_CD_VALUE_UNI("free_diskspace", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::free_diskspace)));
CMD2_DL ("d.bytes_done", CMD2_ON_DL(bytes_done));
CMD2_DL ("d.ratio", std::tr1::bind(&retrieve_d_ratio, std::tr1::placeholders::_1));
CMD2_DL ("d.chunks_hashed", CMD2_ON_DL(chunks_hashed));
CMD2_DL ("d.free_diskspace", CMD2_ON_FL(free_diskspace));
ADD_CD_VALUE_UNI("size_files", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_files)));
ADD_CD_VALUE_UNI("size_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_bytes)));
ADD_CD_VALUE_UNI("size_chunks", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::size_chunks)));
ADD_CD_VALUE_UNI("size_pex", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::size_pex)));
ADD_CD_VALUE_UNI("max_size_pex", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::max_size_pex)));
CMD2_DL ("d.size_files", CMD2_ON_FL(size_files));
CMD2_DL ("d.size_bytes", CMD2_ON_FL(size_bytes));
CMD2_DL ("d.size_chunks", CMD2_ON_FL(size_chunks));
CMD2_DL ("d.chunk_size", CMD2_ON_FL(chunk_size));
CMD2_DL ("d.size_pex", CMD2_ON_DL(size_pex));
CMD2_DL ("d.max_size_pex", CMD2_ON_DL(max_size_pex));
ADD_CD_VALUE_UNI("completed_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::completed_bytes)));
ADD_CD_VALUE_UNI("completed_chunks", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::completed_chunks)));
ADD_CD_VALUE_UNI("left_bytes", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::left_bytes)));
CMD2_DL ("d.completed_bytes", CMD2_ON_FL(completed_bytes));
CMD2_DL ("d.completed_chunks", CMD2_ON_FL(completed_chunks));
CMD2_DL ("d.left_bytes", CMD2_ON_FL(left_bytes));
ADD_CD_VALUE_UNI("chunk_size", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::chunk_size)));
CMD2_DL ("d.tracker_numwant", std::tr1::bind(&torrent::TrackerList::numwant, CMD2_BIND_TL));
CMD2_DL_VALUE_V ("d.tracker_numwant.set", std::tr1::bind(&torrent::TrackerList::set_numwant, CMD2_BIND_TL, std::tr1::placeholders::_2));
CMD2_DL ("d.tracker_focus", std::tr1::bind(&torrent::TrackerList::focus_index, CMD2_BIND_TL));
CMD2_DL ("d.tracker_size", std::tr1::bind(&core::Download::tracker_list_size, std::tr1::placeholders::_1));
ADD_CD_VALUE_MEM_BI("tracker_numwant", &core::Download::tracker_list, &torrent::TrackerList::set_numwant, &torrent::TrackerList::numwant);
ADD_CD_VALUE_UNI("tracker_focus", rak::on(std::mem_fun(&core::Download::tracker_list), std::mem_fun(&torrent::TrackerList::focus_index)));
ADD_CD_VALUE_UNI("tracker_size", std::mem_fun(&core::Download::tracker_list_size));
CMD2_DL ("d.directory", CMD2_ON_FL(root_dir));
CMD2_DL_STRING_V("d.directory.set", std::tr1::bind(&apply_d_directory, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL ("d.directory_base", CMD2_ON_FL(root_dir));
CMD2_DL_STRING_V("d.directory_base.set", std::tr1::bind(&core::Download::set_root_directory, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
ADD_CD_STRING_BI("directory", std::ptr_fun(&apply_d_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir)));
ADD_CD_STRING_BI("directory_base", std::mem_fun(&core::Download::set_root_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir)));
CMD2_DL ("d.priority", std::tr1::bind(&core::Download::priority, std::tr1::placeholders::_1));
CMD2_DL ("d.priority_str", std::tr1::bind(&retrieve_d_priority_str, std::tr1::placeholders::_1));
CMD2_DL_VALUE_V ("d.priority.set", std::tr1::bind(&core::Download::set_priority, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
ADD_CD_VALUE_BI("priority", std::mem_fun(&core::Download::set_priority), std::mem_fun(&core::Download::priority));
ADD_CD_STRING_UNI("priority_str", std::ptr_fun(&retrieve_d_priority_str));
CMD2_DL ("d.initialize_logs", std::tr1::bind(&cmd_d_initialize_logs, std::tr1::placeholders::_1));
ADD_CD_SLOT_PUBLIC("f.multicall", call_list, rak::ptr_fn(&f_multicall), "i:", "");
ADD_CD_SLOT_PUBLIC("p.multicall", call_list, rak::ptr_fn(&p_multicall), "i:", "");
ADD_CD_SLOT_PUBLIC("t.multicall", call_list, rak::ptr_fn(&t_multicall), "i:", "");
// NEWISH:
CMD_D_VOID("d.initialize_logs", &cmd_d_initialize_logs);
CMD_D_VOID_SLOT("d.peer_exchange", rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::is_pex_enabled)));
CMD_D_VALUE_SLOT("d.peer_exchange.set", rak::on2(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::set_pex_enabled)));
CMD2_DL_LIST("f.multicall", std::tr1::bind(&f_multicall, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL_LIST("p.multicall", std::tr1::bind(&p_multicall, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
CMD2_DL_LIST("t.multicall", std::tr1::bind(&t_multicall, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
}