mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-18 08:02:29 +00:00
* 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:
+228
-223
@@ -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));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ apply_on_ratio(const torrent::Object& rawArgs) {
|
||||
std::vector<core::Download*> downloads;
|
||||
|
||||
for (core::View::iterator itr = (*viewItr)->begin_visible(), last = (*viewItr)->end_visible(); itr != last; itr++) {
|
||||
if (!(*itr)->is_seeding() || rpc::call_command_value("d.get_ignore_commands", rpc::make_target(*itr)) != 0)
|
||||
if (!(*itr)->is_seeding() || rpc::call_command_value("d.ignore_commands", rpc::make_target(*itr)) != 0)
|
||||
continue;
|
||||
|
||||
// rpc::parse_command_single(rpc::make_target(*itr), "print={Checked ratio of download.}");
|
||||
@@ -116,11 +116,11 @@ apply_on_ratio(const torrent::Object& rawArgs) {
|
||||
torrent::Object
|
||||
apply_start_tied() {
|
||||
for (core::DownloadList::iterator itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ++itr) {
|
||||
if (rpc::call_command_value("d.get_state", rpc::make_target(*itr)) == 1)
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(*itr)) == 1)
|
||||
continue;
|
||||
|
||||
rak::file_stat fs;
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tiedToFile.empty() && fs.update(rak::path_expand(tiedToFile)))
|
||||
rpc::parse_command_single(rpc::make_target(*itr), "d.try_start=");
|
||||
@@ -132,11 +132,11 @@ apply_start_tied() {
|
||||
torrent::Object
|
||||
apply_stop_untied() {
|
||||
for (core::DownloadList::iterator itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ++itr) {
|
||||
if (rpc::call_command_value("d.get_state", rpc::make_target(*itr)) == 0)
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(*itr)) == 0)
|
||||
continue;
|
||||
|
||||
rak::file_stat fs;
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile)))
|
||||
rpc::parse_command_single(rpc::make_target(*itr), "d.try_stop=");
|
||||
@@ -149,9 +149,9 @@ torrent::Object
|
||||
apply_close_untied() {
|
||||
for (core::DownloadList::iterator itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ++itr) {
|
||||
rak::file_stat fs;
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (rpc::call_command_value("d.get_ignore_commands", rpc::make_target(*itr)) == 0 && !tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile)))
|
||||
if (rpc::call_command_value("d.ignore_commands", rpc::make_target(*itr)) == 0 && !tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile)))
|
||||
rpc::parse_command_single(rpc::make_target(*itr), "d.try_close=");
|
||||
}
|
||||
|
||||
@@ -162,11 +162,11 @@ torrent::Object
|
||||
apply_remove_untied() {
|
||||
for (core::DownloadList::iterator itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ) {
|
||||
rak::file_stat fs;
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tiedToFile = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
|
||||
if (!tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile))) {
|
||||
// Need to clear tied_to_file so it doesn't try to delete it.
|
||||
rpc::call_command("d.set_tied_to_file", std::string(), rpc::make_target(*itr));
|
||||
rpc::call_command("d.tied_to_file.set", std::string(), rpc::make_target(*itr));
|
||||
|
||||
itr = control->core()->download_list()->erase(itr);
|
||||
|
||||
|
||||
+29
-5
@@ -59,7 +59,7 @@ namespace rpc {
|
||||
#define COMMAND_TRACKER_SLOTS_SIZE 15
|
||||
#define COMMAND_ANY_SLOTS_SIZE 50
|
||||
|
||||
#define COMMAND_NEW_SLOTS_SIZE 200
|
||||
#define COMMAND_NEW_SLOTS_SIZE 500
|
||||
|
||||
#define ADDING_COMMANDS
|
||||
|
||||
@@ -238,6 +238,11 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri
|
||||
rpc::commands.insert_type(key, commandNewSlotItr++, &rpc::function, \
|
||||
rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, NULL, NULL);
|
||||
|
||||
#define CMD2_A_FUNCTION_PRIVATE(key, function, slot, parm, doc) \
|
||||
commandNewSlotItr->set_function<rpc::command_base_is_type<rpc::function>::type>(slot); \
|
||||
rpc::commands.insert_type(key, commandNewSlotItr++, &rpc::function, \
|
||||
rpc::CommandMap::flag_dont_delete, NULL, NULL);
|
||||
|
||||
// #define CMD2_ANY(key, slot) CMD2_A_FUNCTION(key, command_base_call_any, slot, "i:", "")
|
||||
#define CMD2_ANY(key, slot) CMD2_A_FUNCTION(key, command_base_call<rpc::target_type>, slot, "i:", "")
|
||||
|
||||
@@ -252,7 +257,16 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri
|
||||
|
||||
#define CMD2_ANY_LIST(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<rpc::target_type>, slot, "i:", "")
|
||||
|
||||
#define CMD2_DOWNLOAD(key, slot) CMD2_A_FUNCTION(key, command_base_call<core::Download*>, slot, "i:", "")
|
||||
#define CMD2_DL(key, slot) CMD2_A_FUNCTION(key, command_base_call<core::Download*>, slot, "i:", "")
|
||||
#define CMD2_DL_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<core::Download*>, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_DL_VALUE(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<core::Download*>, slot, "i:", "")
|
||||
#define CMD2_DL_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<core::Download*>, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_DL_STRING(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<core::Download*>, slot, "i:", "")
|
||||
#define CMD2_DL_STRING_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<core::Download*>, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_DL_LIST(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<core::Download*>, slot, "i:", "")
|
||||
|
||||
#define CMD2_DL_VALUE_P(key, slot) CMD2_A_FUNCTION_PRIVATE(key, command_base_call_value<core::Download*>, slot, "i:", "")
|
||||
#define CMD2_DL_STRING_P(key, slot) CMD2_A_FUNCTION_PRIVATE(key, command_base_call_string<core::Download*>, slot, "i:", "")
|
||||
|
||||
#define CMD2_FILE(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::File*>, slot, "i:", "")
|
||||
#define CMD2_FILE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::File*>, object_convert_void(slot), "i:", "")
|
||||
@@ -260,16 +274,26 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri
|
||||
|
||||
#define CMD2_FILEITR(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::FileListIterator*>, slot, "i:", "")
|
||||
|
||||
#define CMD2_PEER(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::Peer*>, slot, "i:", "")
|
||||
#define CMD2_PEER_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::Peer*>, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_PEER_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<torrent::Peer*>, object_convert_void(slot), "i:i", "")
|
||||
|
||||
#define CMD2_TRACKER(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::Tracker*>, slot, "i:", "")
|
||||
#define CMD2_TRACKER_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::Tracker*>, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_TRACKER_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<torrent::Tracker*>, object_convert_void(slot), "i:i", "")
|
||||
|
||||
#define CMD2_VAR_BOOL(key, value) \
|
||||
#define CMD2_VAR_BOOL(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "bool|const", int64_t(value)));
|
||||
#define CMD2_VAR_VALUE(key, value) \
|
||||
#define CMD2_VAR_VALUE(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "value|const", int64_t(value)));
|
||||
#define CMD2_VAR_STRING(key, value) \
|
||||
#define CMD2_VAR_STRING(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "string|const", std::string(value)));
|
||||
#define CMD2_VAR_C_STRING(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "string|static|const", std::string(value)));
|
||||
|
||||
#define CMD2_FUNC_SINGLE(key, cmds) \
|
||||
CMD2_ANY(key, std::tr1::bind(&rpc::command_function_call, torrent::raw_string::from_c_str(cmds), \
|
||||
std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
|
||||
//
|
||||
// Conversion of return types:
|
||||
|
||||
@@ -161,7 +161,7 @@ group_insert(const torrent::Object::list_type& args) {
|
||||
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.enable", "simple", "schedule=group." + name + ".ratio,5,60,on_ratio=" + name));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.disable", "simple", "schedule_remove=group." + name + ".ratio"));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple", "d.try_close= ;d.set_ignore_commands=1"));
|
||||
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("group." + name + ".ratio.min", "value", (int64_t)200));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.max", "value", (int64_t)300));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.upload", "value", (int64_t)20 << 20));
|
||||
@@ -179,13 +179,13 @@ initialize_command_local() {
|
||||
CMD2_ANY ("system.hostname", std::tr1::bind(&system_hostname));
|
||||
CMD2_ANY ("system.pid", std::tr1::bind(&getpid));
|
||||
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.client_version", "string|static|const", PACKAGE_VERSION));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.library_version", "string|static|const", torrent::version()));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.file.allocate", "value|const", (int64_t)0));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.file.max_size", "value|const", -1));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.file.split_size", "value|const", -1));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.file.split_suffix", "string|const", ".part"));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.session_name", "string|const", ""));
|
||||
CMD2_VAR_C_STRING("system.client_version", PACKAGE_VERSION);
|
||||
CMD2_VAR_C_STRING("system.library_version", torrent::version());
|
||||
CMD2_VAR_VALUE ("system.file.allocate", (int64_t)0);
|
||||
CMD2_VAR_VALUE ("system.file.max_size", -1);
|
||||
CMD2_VAR_VALUE ("system.file.split_size", -1);
|
||||
CMD2_VAR_STRING ("system.file.split_suffix", ".part");
|
||||
CMD2_VAR_STRING ("system.session_name", "");
|
||||
|
||||
CMD2_ANY ("system.file_status_cache.size", std::tr1::bind(&utils::FileStatusCache::size,
|
||||
(utils::FileStatusCache::base_type*)control->core()->file_status_cache()));
|
||||
|
||||
@@ -501,7 +501,7 @@ initialize_command_network() {
|
||||
|
||||
// CMD2_ANY_V ("dht.enable", std::tr1::bind(&core::DhtManager::set_start, control->dht_manager()));
|
||||
// CMD2_ANY_V ("dht.disable", std::tr1::bind(&core::DhtManager::set_stop, control->dht_manager()));
|
||||
CMD2_ANY_STRING_V("dht.mode", std::tr1::bind(&core::DhtManager::set_start, control->dht_manager(), std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("dht.mode.set", std::tr1::bind(&core::DhtManager::set_mode, control->dht_manager(), std::tr1::placeholders::_2));
|
||||
CMD2_VAR_VALUE ("dht.port", int64_t(6881));
|
||||
CMD2_ANY_STRING ("dht.add_node", std::tr1::bind(&apply_dht_add_node, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("dht.statistics", std::tr1::bind(&core::DhtManager::dht_statistics, control->dht_manager()));
|
||||
|
||||
+17
-44
@@ -94,55 +94,28 @@ retrieve_p_completed_percent(torrent::Peer* peer) {
|
||||
return (100 * peer->bitfield()->size_set()) / peer->bitfield()->size_bits();
|
||||
}
|
||||
|
||||
#define ADD_CP_SLOT(key, function, slot, parm, doc) \
|
||||
commandPeerSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandPeerSlotsItr++, &rpc::CommandSlot<torrent::Peer*>::function, rpc::CommandMap::flag_dont_delete, parm, doc);
|
||||
|
||||
#define ADD_CP_SLOT_PUBLIC(key, function, slot, parm, doc) \
|
||||
commandPeerSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandPeerSlotsItr++, &rpc::CommandSlot<torrent::Peer*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
|
||||
|
||||
#define ADD_CP_VOID(key, slot) \
|
||||
ADD_CP_SLOT_PUBLIC("p.get_" key, call_unknown, rpc::object_fn(slot), "i:", "")
|
||||
|
||||
#define ADD_CP_VALUE(key, get) \
|
||||
ADD_CP_SLOT_PUBLIC("p." key, call_unknown, rpc::object_void_fn<torrent::Peer*>(get), "i:", "")
|
||||
|
||||
#define ADD_CP_VALUE_UNI(key, get) \
|
||||
ADD_CP_SLOT_PUBLIC("p.get_" key, call_unknown, rpc::object_void_fn<torrent::Peer*>(get), "i:", "")
|
||||
|
||||
#define ADD_CP_VALUE_BI(key, set, get) \
|
||||
ADD_CP_SLOT_PUBLIC("p.set_" key, call_value, rpc::object_value_fn<torrent::Peer*>(set), "i:i", "") \
|
||||
ADD_CP_SLOT_PUBLIC("p.get_" key, call_unknown, rpc::object_void_fn<torrent::Peer*>(get), "i:", "")
|
||||
|
||||
#define ADD_CP_VALUE_MEM_UNI(key, target, get) \
|
||||
ADD_CP_SLOT_PUBLIC("p.get_" key, call_unknown, rpc::object_void_fn<torrent::Peer*>(rak::on(std::mem_fun(target), std::mem_fun(get))), "i:", "");
|
||||
|
||||
#define ADD_CP_STRING_UNI(key, get) \
|
||||
ADD_CP_SLOT_PUBLIC("p.get_" key, call_unknown, rpc::object_void_fn<torrent::Peer*>(get), "s:", "")
|
||||
|
||||
void
|
||||
initialize_command_peer() {
|
||||
ADD_CP_STRING_UNI("id", std::ptr_fun(&retrieve_p_id));
|
||||
ADD_CP_STRING_UNI("id_html", std::ptr_fun(&retrieve_p_id_html));
|
||||
ADD_CP_STRING_UNI("client_version", std::ptr_fun(&retrieve_p_client_version));
|
||||
CMD2_PEER("p.id", std::tr1::bind(&retrieve_p_id, std::tr1::placeholders::_1));
|
||||
CMD2_PEER("p.id_html", std::tr1::bind(&retrieve_p_id_html, std::tr1::placeholders::_1));
|
||||
CMD2_PEER("p.client_version", std::tr1::bind(&retrieve_p_client_version, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CP_STRING_UNI("options_str", std::ptr_fun(&retrieve_p_options_str));
|
||||
CMD2_PEER("p.options_str", std::tr1::bind(&retrieve_p_options_str, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CP_VALUE("is_encrypted", std::mem_fun(&torrent::Peer::is_encrypted));
|
||||
ADD_CP_VALUE("is_incoming", std::mem_fun(&torrent::Peer::is_incoming));
|
||||
ADD_CP_VALUE("is_obfuscated", std::mem_fun(&torrent::Peer::is_obfuscated));
|
||||
ADD_CP_VALUE("is_snubbed", std::mem_fun(&torrent::Peer::is_snubbed));
|
||||
CMD2_PEER("p.is_encrypted", std::tr1::bind(&torrent::Peer::is_encrypted, std::tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_incoming", std::tr1::bind(&torrent::Peer::is_incoming, std::tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_obfuscated", std::tr1::bind(&torrent::Peer::is_obfuscated, std::tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_snubbed", std::tr1::bind(&torrent::Peer::is_snubbed, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CP_STRING_UNI("address", std::ptr_fun(&retrieve_p_address));
|
||||
ADD_CP_VALUE_UNI("port", std::ptr_fun(&retrieve_p_port));
|
||||
CMD2_PEER("p.address", std::tr1::bind(&retrieve_p_address, std::tr1::placeholders::_1));
|
||||
CMD2_PEER("p.port", std::tr1::bind(&retrieve_p_port, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CP_VALUE_UNI("completed_percent", std::ptr_fun(&retrieve_p_completed_percent));
|
||||
CMD2_PEER("p.completed_percent", std::tr1::bind(&retrieve_p_completed_percent, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CP_VALUE_MEM_UNI("up_rate", &torrent::Peer::up_rate, &torrent::Rate::rate);
|
||||
ADD_CP_VALUE_MEM_UNI("up_total", &torrent::Peer::up_rate, &torrent::Rate::total);
|
||||
ADD_CP_VALUE_MEM_UNI("down_rate", &torrent::Peer::down_rate, &torrent::Rate::rate);
|
||||
ADD_CP_VALUE_MEM_UNI("down_total", &torrent::Peer::down_rate, &torrent::Rate::total);
|
||||
ADD_CP_VALUE_MEM_UNI("peer_rate", &torrent::Peer::peer_rate, &torrent::Rate::rate);
|
||||
ADD_CP_VALUE_MEM_UNI("peer_total", &torrent::Peer::peer_rate, &torrent::Rate::total);
|
||||
CMD2_PEER("p.up_rate", std::tr1::bind(&torrent::Rate::rate, std::tr1::bind(&torrent::Peer::up_rate, std::tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.up_total", std::tr1::bind(&torrent::Rate::total, std::tr1::bind(&torrent::Peer::up_rate, std::tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.down_rate", std::tr1::bind(&torrent::Rate::rate, std::tr1::bind(&torrent::Peer::down_rate, std::tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.down_total", std::tr1::bind(&torrent::Rate::total, std::tr1::bind(&torrent::Peer::down_rate, std::tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_rate", std::tr1::bind(&torrent::Rate::rate, std::tr1::bind(&torrent::Peer::peer_rate, std::tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_total", std::tr1::bind(&torrent::Rate::total, std::tr1::bind(&torrent::Peer::peer_rate, std::tr1::placeholders::_1)));
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ void
|
||||
initialize_command_scheduler() {
|
||||
CMD2_VAR_VALUE("scheduler.max_active", int64_t(-1));
|
||||
|
||||
CMD2_DOWNLOAD("scheduler.simple.added", std::tr1::bind(&cmd_scheduler_simple_added, std::tr1::placeholders::_1));
|
||||
CMD2_DOWNLOAD("scheduler.simple.removed", std::tr1::bind(&cmd_scheduler_simple_removed, std::tr1::placeholders::_1));
|
||||
CMD2_DOWNLOAD("scheduler.simple.update", std::tr1::bind(&cmd_scheduler_simple_update, std::tr1::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.added", std::tr1::bind(&cmd_scheduler_simple_added, std::tr1::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.removed", std::tr1::bind(&cmd_scheduler_simple_removed, std::tr1::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.update", std::tr1::bind(&cmd_scheduler_simple_update, std::tr1::placeholders::_1));
|
||||
}
|
||||
|
||||
+21
-20
@@ -422,6 +422,7 @@ cmd_view_persistent(const torrent::Object::string_type& args) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
// TODO: These don't need wrapper functions anymore...
|
||||
torrent::Object
|
||||
cmd_ui_set_view(const torrent::Object::string_type& args) {
|
||||
control->ui()->download_list()->set_current_view(args);
|
||||
@@ -429,48 +430,48 @@ cmd_ui_set_view(const torrent::Object::string_type& args) {
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_ui_unfocus_download(core::Download* download, const torrent::Object& rawArgs) {
|
||||
cmd_ui_unfocus_download(core::Download* download) {
|
||||
control->ui()->download_list()->unfocus_download(download);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_view_filter_download(core::Download* download, const torrent::Object& rawArgs) {
|
||||
(*control->view_manager()->find_throw(rawArgs.as_string()))->filter_download(download);
|
||||
cmd_view_filter_download(core::Download* download, const torrent::Object::string_type& args) {
|
||||
(*control->view_manager()->find_throw(args))->filter_download(download);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_view_set_visible(core::Download* download, const torrent::Object& rawArgs) {
|
||||
(*control->view_manager()->find_throw(rawArgs.as_string()))->set_visible(download);
|
||||
cmd_view_set_visible(core::Download* download, const torrent::Object::string_type& args) {
|
||||
(*control->view_manager()->find_throw(args))->set_visible(download);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_view_set_not_visible(core::Download* download, const torrent::Object& rawArgs) {
|
||||
(*control->view_manager()->find_throw(rawArgs.as_string()))->set_not_visible(download);
|
||||
cmd_view_set_not_visible(core::Download* download, const torrent::Object::string_type& args) {
|
||||
(*control->view_manager()->find_throw(args))->set_not_visible(download);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_ui() {
|
||||
ADD_VARIABLE_STRING("key_layout", "qwerty");
|
||||
CMD2_VAR_STRING("key_layout", "qwerty");
|
||||
|
||||
CMD2_ANY_STRING("view_add", object_convert_void(std::tr1::bind(&core::ViewManager::insert_throw, control->view_manager(), std::tr1::placeholders::_2)));
|
||||
CMD2_ANY_STRING("view.add", object_convert_void(std::tr1::bind(&core::ViewManager::insert_throw, control->view_manager(), std::tr1::placeholders::_2)));
|
||||
|
||||
CMD2_ANY_L("view_list", std::tr1::bind(&apply_view_list));
|
||||
CMD2_ANY_LIST("view_set", std::tr1::bind(&apply_view_set, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_L ("view.list", std::tr1::bind(&apply_view_list));
|
||||
CMD2_ANY_LIST("view.set", std::tr1::bind(&apply_view_set, std::tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("view_filter", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_filter, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view_filter_on", std::tr1::bind(&apply_view_filter_on, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.filter", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_filter, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.filter_on", std::tr1::bind(&apply_view_filter_on, std::tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("view_sort", std::tr1::bind(&apply_view_sort, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view_sort_new", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_sort_new, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view_sort_current", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_sort_current, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort", std::tr1::bind(&apply_view_sort, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort_new", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_sort_new, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort_current", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_sort_current, std::tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("view.event_added", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_event_added, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.event_removed", std::tr1::bind(&apply_view_cfilter, &core::ViewManager::set_event_removed, std::tr1::placeholders::_2));
|
||||
@@ -481,12 +482,12 @@ initialize_command_ui() {
|
||||
CMD2_ANY_STRING("view.size_not_visible", std::tr1::bind(&cmd_view_size_not_visible, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING("view.persistent", std::tr1::bind(&cmd_view_persistent, std::tr1::placeholders::_2));
|
||||
|
||||
CMD_D_STRING("view.filter_download", rak::ptr_fn(&cmd_view_filter_download));
|
||||
CMD_D_STRING("view.set_visible", rak::ptr_fn(&cmd_view_set_visible));
|
||||
CMD_D_STRING("view.set_not_visible", rak::ptr_fn(&cmd_view_set_not_visible));
|
||||
CMD2_DL_STRING ("view.filter_download", std::tr1::bind(&cmd_view_filter_download, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.set_visible", std::tr1::bind(&cmd_view_set_visible, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.set_not_visible", std::tr1::bind(&cmd_view_set_not_visible, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
|
||||
// Commands that affect the default rtorrent UI.
|
||||
CMD_D_ANY("ui.unfocus_download", rak::ptr_fn(&cmd_ui_unfocus_download));
|
||||
CMD2_DL ("ui.unfocus_download", std::tr1::bind(&cmd_ui_unfocus_download, std::tr1::placeholders::_1));
|
||||
CMD2_ANY_STRING("ui.current_view.set", std::tr1::bind(&cmd_ui_set_view, std::tr1::placeholders::_2));
|
||||
|
||||
// Move.
|
||||
|
||||
@@ -103,7 +103,7 @@ DhtManager::start_dht() {
|
||||
torrent::dht_manager()->set_upload_throttle(throttles.first);
|
||||
torrent::dht_manager()->set_download_throttle(throttles.second);
|
||||
|
||||
int port = rpc::call_command_value("get_dht_port");
|
||||
int port = rpc::call_command_value("dht.port");
|
||||
if (port <= 0)
|
||||
return;
|
||||
|
||||
@@ -167,7 +167,7 @@ DhtManager::save_dht_cache() {
|
||||
}
|
||||
|
||||
void
|
||||
DhtManager::set_start(const std::string& arg) {
|
||||
DhtManager::set_mode(const std::string& arg) {
|
||||
int i;
|
||||
for (i = 0; i < dht_settings_num; i++) {
|
||||
if (arg == dht_settings[i]) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
void stop_dht();
|
||||
void auto_start() { if (m_start == dht_auto) start_dht(); }
|
||||
|
||||
void set_start(const std::string& arg);
|
||||
void set_mode(const std::string& arg);
|
||||
|
||||
void set_throttle_name(const std::string& throttleName);
|
||||
const std::string& throttle_name() const { return m_throttleName; }
|
||||
|
||||
@@ -251,24 +251,24 @@ DownloadFactory::receive_success() {
|
||||
if (!rtorrent->has_key_string("custom4")) rtorrent->insert_key("custom4", std::string());
|
||||
if (!rtorrent->has_key_string("custom5")) rtorrent->insert_key("custom5", std::string());
|
||||
|
||||
rpc::call_command("d.set_uploads_max", rpc::call_command_void("max_uploads"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("min_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("max_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_tracker_numwant", rpc::call_command_void("trackers.numwant"), rpc::make_target(download));
|
||||
rpc::call_command("d.uploads_max.set", rpc::call_command_void("max_uploads"), rpc::make_target(download));
|
||||
rpc::call_command("d.peers_min.set", rpc::call_command_void("min_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.peers_max.set", rpc::call_command_void("max_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.tracker_numwant.set", rpc::call_command_void("trackers.numwant"), rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("d.get_complete", rpc::make_target(download)) != 0) {
|
||||
if (rpc::call_command_value("d.complete", rpc::make_target(download)) != 0) {
|
||||
if (rpc::call_command_value("min_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("min_peers_seed"), rpc::make_target(download));
|
||||
rpc::call_command("d.peers_min.set", rpc::call_command_void("min_peers_seed"), rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("max_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("max_peers_seed"), rpc::make_target(download));
|
||||
rpc::call_command("d.peers_max.set", rpc::call_command_void("max_peers_seed"), rpc::make_target(download));
|
||||
}
|
||||
|
||||
if (!rpc::call_command_value("trackers.use_udp"))
|
||||
download->enable_udp_trackers(false);
|
||||
|
||||
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));
|
||||
rpc::call_command("d.max_file_size.set", 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.
|
||||
@@ -280,12 +280,12 @@ DownloadFactory::receive_success() {
|
||||
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));
|
||||
rpc::call_command("d.directory.set", m_variables["directory"], rpc::make_target(download));
|
||||
else
|
||||
rpc::call_command("d.set_directory_base", rtorrent->get_key("directory"), rpc::make_target(download));
|
||||
rpc::call_command("d.directory_base.set", rtorrent->get_key("directory"), rpc::make_target(download));
|
||||
|
||||
if (!m_session && m_variables["tied_to_file"].as_value())
|
||||
rpc::call_command("d.set_tied_to_file", m_uri.empty() ? m_variables["tied_file"] : m_uri, rpc::make_target(download));
|
||||
rpc::call_command("d.tied_to_file.set", m_uri.empty() ? m_variables["tied_file"] : m_uri, rpc::make_target(download));
|
||||
|
||||
rpc::call_command("d.peer_exchange.set", rpc::call_command_value("protocol.pex"), rpc::make_target(download));
|
||||
|
||||
@@ -313,7 +313,7 @@ DownloadFactory::receive_success() {
|
||||
throw torrent::input_error("The newly created download was removed.");
|
||||
|
||||
if (!m_session)
|
||||
rpc::call_command("d.set_state", (int64_t)m_start, rpc::make_target(download));
|
||||
rpc::call_command("d.state.set", (int64_t)m_start, rpc::make_target(download));
|
||||
|
||||
rpc::commands.call_catch(m_session ? "event.download.inserted_session" : "event.download.inserted_new",
|
||||
rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
@@ -369,9 +369,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
|
||||
rtorrent->insert_key("loaded_file", m_isFile ? m_uri : std::string());
|
||||
|
||||
if (rtorrent->has_key_value("priority"))
|
||||
rpc::call_command("d.set_priority", rtorrent->get_key_value("priority") % 4, rpc::make_target(download));
|
||||
rpc::call_command("d.priority.set", rtorrent->get_key_value("priority") % 4, rpc::make_target(download));
|
||||
else
|
||||
rpc::call_command("d.set_priority", (int64_t)2, rpc::make_target(download));
|
||||
rpc::call_command("d.priority.set", (int64_t)2, rpc::make_target(download));
|
||||
|
||||
if (rtorrent->has_key_value("key")) {
|
||||
download->tracker_list()->set_key(rtorrent->get_key_value("key"));
|
||||
|
||||
+30
-30
@@ -309,7 +309,7 @@ DownloadList::close_throw(Download* download) {
|
||||
|
||||
download->download()->close();
|
||||
|
||||
if (!download->is_hash_failed() && rpc::call_command_value("d.get_hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||
if (!download->is_hash_failed() && rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||
throw torrent::internal_error("DownloadList::close_throw(...) called but we're going into a hashing loop.");
|
||||
|
||||
rpc::commands.call_catch("event.download.hash_removed", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
@@ -343,8 +343,8 @@ DownloadList::resume(Download* download, int flags) {
|
||||
if (download->is_hash_failed())
|
||||
return;
|
||||
|
||||
if (rpc::call_command_value("d.get_hashing", rpc::make_target(download)) == Download::variable_hashing_stopped)
|
||||
rpc::call_command("d.set_hashing", Download::variable_hashing_initial, rpc::make_target(download));
|
||||
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) == Download::variable_hashing_stopped)
|
||||
rpc::call_command("d.hashing.set", Download::variable_hashing_initial, rpc::make_target(download));
|
||||
|
||||
rpc::commands.call_catch("event.download.hash_queued", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
return;
|
||||
@@ -353,13 +353,13 @@ DownloadList::resume(Download* download, int flags) {
|
||||
// This will never actually do anything due to the above hash check.
|
||||
// open_throw(download);
|
||||
|
||||
rpc::call_command("d.set_state_changed", cachedTime.seconds(), rpc::make_target(download));
|
||||
rpc::call_command("d.set_state_counter", rpc::call_command_value("d.get_state_counter", rpc::make_target(download)) + 1, rpc::make_target(download));
|
||||
rpc::call_command("d.state_changed.set", cachedTime.seconds(), rpc::make_target(download));
|
||||
rpc::call_command("d.state_counter.set", rpc::call_command_value("d.state_counter", rpc::make_target(download)) + 1, rpc::make_target(download));
|
||||
|
||||
if (download->is_done()) {
|
||||
rpc::call_command("d.set_connection_current", rpc::call_command_void("d.get_connection_seed", rpc::make_target(download)), rpc::make_target(download));
|
||||
rpc::call_command("d.connection_current.set", rpc::call_command_void("d.connection_seed", rpc::make_target(download)), rpc::make_target(download));
|
||||
} else {
|
||||
rpc::call_command("d.set_connection_current", rpc::call_command_void("d.get_connection_leech", rpc::make_target(download)), rpc::make_target(download));
|
||||
rpc::call_command("d.connection_current.set", rpc::call_command_void("d.connection_leech", rpc::make_target(download)), rpc::make_target(download));
|
||||
|
||||
// For the moment, clear the resume data so we force hash-check
|
||||
// on non-complete downloads after a crash. This shouldn't be
|
||||
@@ -400,9 +400,9 @@ DownloadList::pause(Download* download, int flags) {
|
||||
|
||||
// Always clear hashing on pause. When a hashing request is added,
|
||||
// it should have cleared the hash resume data.
|
||||
if (rpc::call_command_value("d.get_hashing", rpc::make_target(download)) != Download::variable_hashing_stopped) {
|
||||
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped) {
|
||||
download->download()->hash_stop();
|
||||
rpc::call_command_set_value("d.set_hashing", Download::variable_hashing_stopped, rpc::make_target(download));
|
||||
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_stopped, rpc::make_target(download));
|
||||
|
||||
rpc::commands.call_catch("event.download.hash_removed", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
}
|
||||
@@ -418,13 +418,13 @@ DownloadList::pause(Download* download, int flags) {
|
||||
// view.
|
||||
rpc::commands.call_catch("event.download.paused", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
|
||||
rpc::call_command("d.set_state_changed", cachedTime.seconds(), rpc::make_target(download));
|
||||
rpc::call_command("d.set_state_counter", rpc::call_command_value("d.get_state_counter", rpc::make_target(download)), rpc::make_target(download));
|
||||
rpc::call_command("d.state_changed.set", cachedTime.seconds(), rpc::make_target(download));
|
||||
rpc::call_command("d.state_counter.set", rpc::call_command_value("d.state_counter", rpc::make_target(download)), rpc::make_target(download));
|
||||
|
||||
// If initial seeding is complete, don't try it again when restarting.
|
||||
if (download->is_done() &&
|
||||
rpc::call_command_void("d.get_connection_current", rpc::make_target(download)).as_string() == "initial_seed")
|
||||
rpc::call_command("d.set_connection_seed", rpc::call_command_void("d.get_connection_current", rpc::make_target(download)), rpc::make_target(download));
|
||||
rpc::call_command_void("d.connection_current", rpc::make_target(download)).as_string() == "initial_seed")
|
||||
rpc::call_command("d.connection_seed.set", rpc::call_command_void("d.connection_current", rpc::make_target(download)), rpc::make_target(download));
|
||||
|
||||
// Save the state after all the slots, etc have been called so we
|
||||
// include the modifications they may make.
|
||||
@@ -441,7 +441,7 @@ DownloadList::check_hash(Download* download) {
|
||||
|
||||
try {
|
||||
|
||||
if (rpc::call_command_value("d.get_hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||
return;
|
||||
|
||||
hash_queue(download, Download::variable_hashing_rehash);
|
||||
@@ -474,8 +474,8 @@ DownloadList::hash_done(Download* download) {
|
||||
// confirm all the data, avoiding large BW usage on f.ex. the
|
||||
// ReiserFS bug with >4GB files.
|
||||
|
||||
int64_t hashing = rpc::call_command_value("d.get_hashing", rpc::make_target(download));
|
||||
rpc::call_command_set_value("d.set_hashing", Download::variable_hashing_stopped, rpc::make_target(download));
|
||||
int64_t hashing = rpc::call_command_value("d.hashing", rpc::make_target(download));
|
||||
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_stopped, rpc::make_target(download));
|
||||
|
||||
if (download->is_done() && download->download()->info()->is_meta_download())
|
||||
return process_meta_download(download);
|
||||
@@ -487,17 +487,17 @@ DownloadList::hash_done(Download* download) {
|
||||
|
||||
// If the download was previously completed but the files were
|
||||
// f.ex deleted, then we clear the state and complete.
|
||||
if (rpc::call_command_value("d.get_complete", rpc::make_target(download)) && !download->is_done()) {
|
||||
rpc::call_command("d.set_state", (int64_t)0, rpc::make_target(download));
|
||||
if (rpc::call_command_value("d.complete", rpc::make_target(download)) && !download->is_done()) {
|
||||
rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(download));
|
||||
download->set_message("Download registered as completed, but hash check returned unfinished chunks.");
|
||||
}
|
||||
|
||||
// Save resume data so we update time-stamps and priorities if
|
||||
// they were invalid/changed while loading/hashing.
|
||||
rpc::call_command("d.set_complete", (int64_t)download->is_done(), rpc::make_target(download));
|
||||
rpc::call_command("d.complete.set", (int64_t)download->is_done(), rpc::make_target(download));
|
||||
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||
|
||||
if (rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(download)) == 1)
|
||||
resume(download, download->resume_flags());
|
||||
//rpc::commands.call_catch("scheduler.simple.resume", rpc::make_target(download), torrent::Object(), "Download event action failed: ");
|
||||
|
||||
@@ -529,7 +529,7 @@ void
|
||||
DownloadList::hash_queue(Download* download, int type) {
|
||||
check_contains(download);
|
||||
|
||||
if (rpc::call_command_value("d.get_hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
|
||||
|
||||
// HACK
|
||||
@@ -544,7 +544,7 @@ DownloadList::hash_queue(Download* download, int type) {
|
||||
torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||
|
||||
download->set_hash_failed(false);
|
||||
rpc::call_command_set_value("d.set_hashing", type, rpc::make_target(download));
|
||||
rpc::call_command_set_value("d.hashing.set", type, rpc::make_target(download));
|
||||
|
||||
if (download->is_open())
|
||||
throw torrent::internal_error("DownloadList::hash_clear(...) download still open.");
|
||||
@@ -558,7 +558,7 @@ void
|
||||
DownloadList::received_finished(Download* download) {
|
||||
check_contains(download);
|
||||
|
||||
if (rpc::call_command_value("get_check_hash"))
|
||||
if (rpc::call_command_value("check_hash"))
|
||||
// Set some 'checking_finished_thingie' variable to make hash_done
|
||||
// trigger correctly, also so it can bork on missing data.
|
||||
hash_queue(download, Download::variable_hashing_last);
|
||||
@@ -574,16 +574,16 @@ DownloadList::confirm_finished(Download* download) {
|
||||
if (download->download()->info()->is_meta_download())
|
||||
return process_meta_download(download);
|
||||
|
||||
rpc::call_command("d.set_complete", (int64_t)1, rpc::make_target(download));
|
||||
rpc::call_command("d.complete.set", (int64_t)1, rpc::make_target(download));
|
||||
|
||||
rpc::call_command("d.set_connection_current", rpc::call_command_void("d.get_connection_seed", rpc::make_target(download)), rpc::make_target(download));
|
||||
rpc::call_command("d.connection_current.set", rpc::call_command_void("d.connection_seed", rpc::make_target(download)), rpc::make_target(download));
|
||||
download->set_priority(download->priority());
|
||||
|
||||
if (rpc::call_command_value("d.get_peers_min", rpc::make_target(download)) == rpc::call_command_value("min_peers") && rpc::call_command_value("min_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("min_peers_seed"), rpc::make_target(download));
|
||||
if (rpc::call_command_value("d.peers_min", rpc::make_target(download)) == rpc::call_command_value("min_peers") && rpc::call_command_value("min_peers_seed") >= 0)
|
||||
rpc::call_command("d.peers_min.set", rpc::call_command_void("min_peers_seed"), rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("d.get_peers_max", rpc::make_target(download)) == rpc::call_command_value("max_peers") && rpc::call_command_value("max_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("max_peers_seed"), rpc::make_target(download));
|
||||
if (rpc::call_command_value("d.peers_max", rpc::make_target(download)) == rpc::call_command_value("max_peers") && rpc::call_command_value("max_peers_seed") >= 0)
|
||||
rpc::call_command("d.peers_max.set", rpc::call_command_void("max_peers_seed"), rpc::make_target(download));
|
||||
|
||||
// Do this before the slots are called in case one of them closes
|
||||
// the download.
|
||||
@@ -603,7 +603,7 @@ DownloadList::confirm_finished(Download* download) {
|
||||
if (download->resume_flags() != ~uint32_t())
|
||||
throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t().");
|
||||
|
||||
if (!download->is_active() && rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
|
||||
if (!download->is_active() && rpc::call_command_value("d.state", rpc::make_target(download)) == 1)
|
||||
resume(download, torrent::Download::start_no_create | torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -500,7 +500,7 @@ path_expand(std::vector<std::string>* paths, const std::string& pattern) {
|
||||
|
||||
bool
|
||||
manager_equal_tied(const std::string& path, Download* download) {
|
||||
return path == rpc::call_command_string("d.get_tied_to_file", rpc::make_target(download));
|
||||
return path == rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -541,7 +541,7 @@ Manager::receive_hashing_changed() {
|
||||
continue;
|
||||
|
||||
bool tryQuick =
|
||||
rpc::call_command_value("d.get_hashing", rpc::make_target(*itr)) == Download::variable_hashing_initial &&
|
||||
rpc::call_command_value("d.hashing", rpc::make_target(*itr)) == Download::variable_hashing_initial &&
|
||||
(*itr)->download()->file_list()->bitfield()->empty();
|
||||
|
||||
if (!tryQuick && foundHashing)
|
||||
@@ -564,7 +564,7 @@ Manager::receive_hashing_changed() {
|
||||
(*itr)->download()->hash_stop();
|
||||
|
||||
if (foundHashing) {
|
||||
rpc::call_command_set_value("d.set_hashing", Download::variable_hashing_rehash, rpc::make_target(*itr));
|
||||
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_rehash, rpc::make_target(*itr));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -575,7 +575,7 @@ Manager::receive_hashing_changed() {
|
||||
} catch (torrent::local_error& e) {
|
||||
if (tryQuick) {
|
||||
// Make sure we don't repeat the quick hashing.
|
||||
rpc::call_command_set_value("d.set_hashing", Download::variable_hashing_rehash, rpc::make_target(*itr));
|
||||
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_rehash, rpc::make_target(*itr));
|
||||
|
||||
} else {
|
||||
(*itr)->set_hash_failed(true);
|
||||
|
||||
+2
-2
@@ -294,7 +294,7 @@ View::set_filter_on_event(const std::string& event) {
|
||||
if (std::find(m_events.begin(), m_events.end(), event) != m_events.end())
|
||||
return;
|
||||
|
||||
rpc::commands.call_catch("method.set_key", rpc::make_target(), rpc::create_object_list(event, "!view_" + m_name, "view.filter_download=" + m_name));
|
||||
rpc::commands.call_catch("method.set_key", rpc::make_target(), rpc::create_object_list(event, "!view." + m_name, "view.filter_download=" + m_name));
|
||||
m_events.push_back(event);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ View::clear_filter_on() {
|
||||
// Don't clear insert and erase as these are required to keep the
|
||||
// View up-to-date with the available downloads.
|
||||
for (event_list_type::const_iterator itr = m_events.begin(); itr != m_events.end(); itr++)
|
||||
rpc::commands.call_catch("method.set_key", rpc::make_target(), rpc::create_object_list(*itr, "!view_" + m_name));
|
||||
rpc::commands.call_catch("method.set_key", rpc::make_target(), rpc::create_object_list(*itr, "!view." + m_name));
|
||||
}
|
||||
|
||||
inline void
|
||||
|
||||
@@ -163,15 +163,15 @@ print_download_info(char* first, char* last, core::Download* d) {
|
||||
}
|
||||
|
||||
first = print_buffer(first, last, " [%c%c R: %4.2f",
|
||||
rpc::call_command_string("d.get_tied_to_file", rpc::make_target(d)).empty() ? ' ' : 'T',
|
||||
rpc::call_command_value("d.get_ignore_commands", rpc::make_target(d)) == 0 ? ' ' : 'I',
|
||||
(double)rpc::call_command_value("d.get_ratio", rpc::make_target(d)) / 1000.0);
|
||||
rpc::call_command_string("d.tied_to_file", rpc::make_target(d)).empty() ? ' ' : 'T',
|
||||
rpc::call_command_value("d.ignore_commands", rpc::make_target(d)) == 0 ? ' ' : 'I',
|
||||
(double)rpc::call_command_value("d.ratio", rpc::make_target(d)) / 1000.0);
|
||||
|
||||
if (d->priority() != 2)
|
||||
first = print_buffer(first, last, " %s", rpc::call_command_string("d.get_priority_str", rpc::make_target(d)).c_str());
|
||||
first = print_buffer(first, last, " %s", rpc::call_command_string("d.priority_str", rpc::make_target(d)).c_str());
|
||||
|
||||
if (!d->bencode()->get_key("rtorrent").get_key_string("throttle_name").empty())
|
||||
first = print_buffer(first, last , " %s", rpc::call_command_string("d.get_throttle_name", rpc::make_target(d)).c_str());
|
||||
first = print_buffer(first, last , " %s", rpc::call_command_string("d.throttle_name", rpc::make_target(d)).c_str());
|
||||
|
||||
first = print_buffer(first, last , "]");
|
||||
|
||||
@@ -185,7 +185,7 @@ char*
|
||||
print_download_status(char* first, char* last, core::Download* d) {
|
||||
if (d->is_active())
|
||||
;
|
||||
else if (rpc::call_command_value("d.get_hashing", rpc::make_target(d)) != 0)
|
||||
else if (rpc::call_command_value("d.hashing", rpc::make_target(d)) != 0)
|
||||
first = print_buffer(first, last, "Hashing: ");
|
||||
else if (!d->is_active())
|
||||
first = print_buffer(first, last, "Inactive: ");
|
||||
|
||||
+148
-41
@@ -214,8 +214,8 @@ main(int argc, char** argv) {
|
||||
"method.insert = event.download.hash_queued,multi\n"
|
||||
|
||||
"method.set_key = event.download.inserted, 1_connect_logs, d.initialize_logs=\n"
|
||||
"method.set_key = event.download.inserted_new, 1_prepare, \"branch=d.get_state=,view.set_visible=started,view.set_visible=stopped ;d.save_full_session=\"\n"
|
||||
"method.set_key = event.download.inserted_session, 1_prepare, \"branch=d.get_state=,view.set_visible=started,view.set_visible=stopped\"\n"
|
||||
"method.set_key = event.download.inserted_new, 1_prepare, \"branch=d.state=,view.set_visible=started,view.set_visible=stopped ;d.save_full_session=\"\n"
|
||||
"method.set_key = event.download.inserted_session, 1_prepare, \"branch=d.state=,view.set_visible=started,view.set_visible=stopped\"\n"
|
||||
|
||||
"method.set_key = event.download.erased, !_download_list, ui.unfocus_download=\n"
|
||||
"method.set_key = event.download.erased, ~_delete_tied, d.delete_tied=\n"
|
||||
@@ -230,7 +230,7 @@ main(int argc, char** argv) {
|
||||
"method.insert = ratio.upload.set,simple|const,group.seeding.ratio.upload.set=$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"
|
||||
"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
|
||||
// modify the value. And look into the possibility of making
|
||||
@@ -245,55 +245,55 @@ main(int argc, char** argv) {
|
||||
"system.session_name = \"$cat=$system.hostname=,:,$system.pid=\"\n"
|
||||
|
||||
// Currently not doing any sorting on main.
|
||||
"view_add = main\n"
|
||||
"view_add = default\n"
|
||||
"view.add = main\n"
|
||||
"view.add = default\n"
|
||||
|
||||
"view_add = name\n"
|
||||
"view_sort_new = name,less=d.name=\n"
|
||||
"view_sort_current = name,less=d.name=\n"
|
||||
"view.add = name\n"
|
||||
"view.sort_new = name,less=d.name=\n"
|
||||
"view.sort_current = name,less=d.name=\n"
|
||||
|
||||
"view_add = active\n"
|
||||
"view_filter = active,false=\n"
|
||||
"view.add = active\n"
|
||||
"view.filter = active,false=\n"
|
||||
|
||||
"view_add = started\n"
|
||||
"view_filter = started,false=\n"
|
||||
"view.event_added = started,\"view.set_not_visible=stopped ;d.set_state=1 ;scheduler.simple.added=\"\n"
|
||||
"view.add = started\n"
|
||||
"view.filter = started,false=\n"
|
||||
"view.event_added = started,\"view.set_not_visible=stopped ;d.state.set=1 ;scheduler.simple.added=\"\n"
|
||||
"view.event_removed = started,\"view.set_visible=stopped ;scheduler.simple.removed=\"\n"
|
||||
|
||||
"view_add = stopped\n"
|
||||
"view_filter = stopped,false=\n"
|
||||
"view.event_added = stopped,\"view.set_not_visible=started ;d.set_state=0\"\n"
|
||||
"view.add = stopped\n"
|
||||
"view.filter = stopped,false=\n"
|
||||
"view.event_added = stopped,\"view.set_not_visible=started ;d.state.set=0\"\n"
|
||||
"view.event_removed = stopped,view.set_visible=started\n"
|
||||
|
||||
"view_add = complete\n"
|
||||
"view_filter = complete,d.get_complete=\n"
|
||||
"view_filter_on = complete,event.download.hash_done,event.download.hash_failed,event.download.hash_final_failed,event.download.finished\n"
|
||||
"view_sort_new = complete,less=d.get_state_changed=\n"
|
||||
"view_sort_current = complete,less=d.get_state_changed=\n"
|
||||
"view.add = complete\n"
|
||||
"view.filter = complete,d.complete=\n"
|
||||
"view.filter_on = complete,event.download.hash_done,event.download.hash_failed,event.download.hash_final_failed,event.download.finished\n"
|
||||
"view.sort_new = complete,less=d.state_changed=\n"
|
||||
"view.sort_current = complete,less=d.state_changed=\n"
|
||||
|
||||
"view_add = incomplete\n"
|
||||
"view_filter = incomplete,not=$d.get_complete=\n"
|
||||
"view_filter_on = incomplete,event.download.hash_done,event.download.hash_failed,"
|
||||
"view.add = incomplete\n"
|
||||
"view.filter = incomplete,not=$d.complete=\n"
|
||||
"view.filter_on = incomplete,event.download.hash_done,event.download.hash_failed,"
|
||||
"event.download.hash_final_failed,event.download.finished\n"
|
||||
"view_sort_new = incomplete,less=d.get_state_changed=\n"
|
||||
"view_sort_current = incomplete,less=d.get_state_changed=\n"
|
||||
"view.sort_new = incomplete,less=d.state_changed=\n"
|
||||
"view.sort_current = incomplete,less=d.state_changed=\n"
|
||||
|
||||
// The hashing view does not include stopped torrents.
|
||||
"view_add = hashing\n"
|
||||
"view_filter = hashing,d.get_hashing=\n"
|
||||
"view_filter_on = hashing,event.download.hash_queued,event.download.hash_removed,"
|
||||
"view.add = hashing\n"
|
||||
"view.filter = hashing,d.hashing=\n"
|
||||
"view.filter_on = hashing,event.download.hash_queued,event.download.hash_removed,"
|
||||
"event.download.hash_done,event.download.hash_failed,event.download.hash_final_failed\n"
|
||||
// "view_sort_new = hashing,less=d.get_state_changed=\n"
|
||||
// "view_sort_current = hashing,less=d.get_state_changed=\n"
|
||||
// "view.sort_new = hashing,less=d.state_changed=\n"
|
||||
// "view.sort_current = hashing,less=d.state_changed=\n"
|
||||
|
||||
"view_add = seeding\n"
|
||||
"view_filter = seeding,\"and=d.get_state=,d.get_complete=\"\n"
|
||||
"view_filter_on = seeding,event.download.resumed,event.download.paused,event.download.finished\n"
|
||||
"view_sort_new = seeding,less=d.get_state_changed=\n"
|
||||
"view_sort_current = seeding,less=d.get_state_changed=\n"
|
||||
"view.add = seeding\n"
|
||||
"view.filter = seeding,\"and=d.state=,d.complete=\"\n"
|
||||
"view.filter_on = seeding,event.download.resumed,event.download.paused,event.download.finished\n"
|
||||
"view.sort_new = seeding,less=d.state_changed=\n"
|
||||
"view.sort_current = seeding,less=d.state_changed=\n"
|
||||
|
||||
"schedule = view_main,10,10,\"view_sort=main,20\"\n"
|
||||
"schedule = view_name,10,10,\"view_sort=name,20\"\n"
|
||||
"schedule = view.main,10,10,\"view.sort=main,20\"\n"
|
||||
"schedule = view.name,10,10,\"view.sort=name,20\"\n"
|
||||
|
||||
"schedule = session_save,1200,1200,session_save=\n"
|
||||
"schedule = low_diskspace,5,60,close_low_diskspace=500M\n"
|
||||
@@ -319,15 +319,18 @@ main(int argc, char** argv) {
|
||||
// + command_local.cc
|
||||
// * command_network.cc
|
||||
// * command_object.cc
|
||||
// - command_peer.cc
|
||||
// * command_peer.cc
|
||||
// * command_scheduler.cc
|
||||
// * command_tracker.cc
|
||||
// - command_ui.cc
|
||||
// * command_ui.cc
|
||||
|
||||
"method.insert = system.method.insert,redirect|const,method.insert\n"
|
||||
"method.insert = system.method.set,redirect|const,method.set\n"
|
||||
"method.insert = system.method.set_key,redirect|const,method.set_key\n"
|
||||
|
||||
"method.insert = get_key_layout,redirect|const,key_layout\n"
|
||||
"method.insert = set_key_layout,redirect|const,key_layout.set\n"
|
||||
|
||||
"method.insert = get_handshake_log,redirect|const,log.handshake\n"
|
||||
"method.insert = set_handshake_log,redirect|const,log.handshake.set\n"
|
||||
"method.insert = get_log.tracker,redirect|const,log.tracker\n"
|
||||
@@ -391,7 +394,7 @@ main(int argc, char** argv) {
|
||||
"method.insert = get_connection_seed,redirect|const,connection_seed\n"
|
||||
"method.insert = set_connection_seed,redirect|const,connection_seed.set\n"
|
||||
|
||||
"method.insert = dht,redirect|const,dht.mode\n"
|
||||
"method.insert = dht,redirect|const,dht.mode.set\n"
|
||||
"method.insert = dht_add_node, redirect|const,dht.add_node\n"
|
||||
"method.insert = dht_statistics, redirect|const,dht.statistics\n"
|
||||
"method.insert = get_dht_port, redirect|const,dht.port\n"
|
||||
@@ -425,6 +428,79 @@ main(int argc, char** argv) {
|
||||
"method.insert = d.get_skip_rate,redirect|const,d.skip.rate\n"
|
||||
"method.insert = d.get_skip_total,redirect|const,d.skip.total\n"
|
||||
|
||||
//
|
||||
"method.insert = d.get_bytes_done,redirect|const,d.bytes_done\n"
|
||||
"method.insert = d.get_chunk_size,redirect|const,d.chunk_size\n"
|
||||
"method.insert = d.get_chunks_hashed,redirect|const,d.chunks_hashed\n"
|
||||
"method.insert = d.get_complete,redirect|const,d.complete\n"
|
||||
"method.insert = d.get_completed_bytes,redirect|const,d.completed_bytes\n"
|
||||
"method.insert = d.get_completed_chunks,redirect|const,d.completed_chunks\n"
|
||||
"method.insert = d.get_connection_current,redirect|const,d.connection_current\n"
|
||||
"method.insert = d.get_connection_leech,redirect|const,d.connection_leech\n"
|
||||
"method.insert = d.get_connection_seed,redirect|const,d.connection_seed\n"
|
||||
"method.insert = d.get_custom,redirect|const,d.custom\n"
|
||||
"method.insert = d.get_custom1,redirect|const,d.custom1\n"
|
||||
"method.insert = d.get_custom2,redirect|const,d.custom2\n"
|
||||
"method.insert = d.get_custom3,redirect|const,d.custom3\n"
|
||||
"method.insert = d.get_custom4,redirect|const,d.custom4\n"
|
||||
"method.insert = d.get_custom5,redirect|const,d.custom5\n"
|
||||
"method.insert = d.get_custom_throw,redirect|const,d.custom_throw\n"
|
||||
"method.insert = d.get_directory,redirect|const,d.directory\n"
|
||||
"method.insert = d.get_directory_base,redirect|const,d.directory_base\n"
|
||||
"method.insert = d.get_free_diskspace,redirect|const,d.free_diskspace\n"
|
||||
"method.insert = d.get_hashing,redirect|const,d.hashing\n"
|
||||
"method.insert = d.get_hashing_failed,redirect|const,d.hashing_failed\n"
|
||||
"method.insert = d.get_ignore_commands,redirect|const,d.ignore_commands\n"
|
||||
"method.insert = d.get_left_bytes,redirect|const,d.left_bytes\n"
|
||||
"method.insert = d.get_loaded_file,redirect|const,d.loaded_file\n"
|
||||
"method.insert = d.get_max_file_size,redirect|const,d.max_file_size\n"
|
||||
"method.insert = d.get_max_size_pex,redirect|const,d.max_size_pex\n"
|
||||
"method.insert = d.get_message,redirect|const,d.message\n"
|
||||
"method.insert = d.get_mode,redirect|const,d.mode\n"
|
||||
"method.insert = d.get_peers_accounted,redirect|const,d.peers_accounted\n"
|
||||
"method.insert = d.get_peers_complete,redirect|const,d.peers_complete\n"
|
||||
"method.insert = d.get_peers_connected,redirect|const,d.peers_connected\n"
|
||||
"method.insert = d.get_peers_max,redirect|const,d.peers_max\n"
|
||||
"method.insert = d.get_peers_min,redirect|const,d.peers_min\n"
|
||||
"method.insert = d.get_peers_not_connected,redirect|const,d.peers_not_connected\n"
|
||||
"method.insert = d.get_priority,redirect|const,d.priority\n"
|
||||
"method.insert = d.get_priority_str,redirect|const,d.priority_str\n"
|
||||
"method.insert = d.get_ratio,redirect|const,d.ratio\n"
|
||||
"method.insert = d.get_size_bytes,redirect|const,d.size_bytes\n"
|
||||
"method.insert = d.get_size_chunks,redirect|const,d.size_chunks\n"
|
||||
"method.insert = d.get_size_files,redirect|const,d.size_files\n"
|
||||
"method.insert = d.get_size_pex,redirect|const,d.size_pex\n"
|
||||
"method.insert = d.get_state,redirect|const,d.state\n"
|
||||
"method.insert = d.get_state_changed,redirect|const,d.state_changed\n"
|
||||
"method.insert = d.get_state_counter,redirect|const,d.state_counter\n"
|
||||
"method.insert = d.get_throttle_name,redirect|const,d.throttle_name\n"
|
||||
"method.insert = d.get_tied_to_file,redirect|const,d.tied_to_file\n"
|
||||
"method.insert = d.get_tracker_focus,redirect|const,d.tracker_focus\n"
|
||||
"method.insert = d.get_tracker_numwant,redirect|const,d.tracker_numwant\n"
|
||||
"method.insert = d.get_tracker_size,redirect|const,d.tracker_size\n"
|
||||
"method.insert = d.get_uploads_max,redirect|const,d.uploads_max\n"
|
||||
|
||||
"method.insert = d.get_connection_current,redirect|const,d.connection_current.set\n"
|
||||
"method.insert = d.get_custom,redirect|const,d.custom.set\n"
|
||||
"method.insert = d.get_custom1,redirect|const,d.custom1.set\n"
|
||||
"method.insert = d.get_custom2,redirect|const,d.custom2.set\n"
|
||||
"method.insert = d.get_custom3,redirect|const,d.custom3.set\n"
|
||||
"method.insert = d.get_custom4,redirect|const,d.custom4.set\n"
|
||||
"method.insert = d.get_custom5,redirect|const,d.custom5.set\n"
|
||||
"method.insert = d.get_directory,redirect|const,d.directory.set\n"
|
||||
"method.insert = d.get_directory_base,redirect|const,d.directory_base.set\n"
|
||||
"method.insert = d.get_hashing_failed,redirect|const,d.hashing_failed.set\n"
|
||||
"method.insert = d.get_ignore_commands,redirect|const,d.ignore_commands.set\n"
|
||||
"method.insert = d.get_max_file_size,redirect|const,d.max_file_size.set\n"
|
||||
"method.insert = d.get_message,redirect|const,d.message.set\n"
|
||||
"method.insert = d.get_peers_max,redirect|const,d.peers_max.set\n"
|
||||
"method.insert = d.get_peers_min,redirect|const,d.peers_min.set\n"
|
||||
"method.insert = d.get_priority,redirect|const,d.priority.set\n"
|
||||
"method.insert = d.get_throttle_name,redirect|const,d.throttle_name.set\n"
|
||||
"method.insert = d.get_tied_to_file,redirect|const,d.tied_to_file.set\n"
|
||||
"method.insert = d.get_tracker_numwant,redirect|const,d.tracker_numwant.set\n"
|
||||
"method.insert = d.get_uploads_max,redirect|const,d.uploads_max.set\n"
|
||||
|
||||
//
|
||||
// Tracker:
|
||||
//
|
||||
@@ -461,6 +537,37 @@ main(int argc, char** argv) {
|
||||
"method.insert = f.set_priority,redirect|const,f.priority.set\n"
|
||||
"method.insert = fi.get_filename_last,redirect|const,fi.filename_last\n"
|
||||
|
||||
//
|
||||
// Peer:
|
||||
//
|
||||
|
||||
"method.insert = p.get_address,redirect|const,p.address\n"
|
||||
"method.insert = p.get_client_version,redirect|const,p.client_version\n"
|
||||
"method.insert = p.get_completed_percent,redirect|const,p.completed_percent\n"
|
||||
"method.insert = p.get_down_rate,redirect|const,p.down_rate\n"
|
||||
"method.insert = p.get_down_total,redirect|const,p.down_total\n"
|
||||
"method.insert = p.get_id,redirect|const,p.id\n"
|
||||
"method.insert = p.get_id_html,redirect|const,p.id_html\n"
|
||||
"method.insert = p.get_options_str,redirect|const,p.options_str\n"
|
||||
"method.insert = p.get_peer_rate,redirect|const,p.peer_rate\n"
|
||||
"method.insert = p.get_peer_total,redirect|const,p.peer_total\n"
|
||||
"method.insert = p.get_port,redirect|const,p.port\n"
|
||||
"method.insert = p.get_up_rate,redirect|const,p.up_rate\n"
|
||||
"method.insert = p.get_up_total,redirect|const,p.up_total\n"
|
||||
|
||||
//
|
||||
// View:
|
||||
//
|
||||
|
||||
"method.insert = view_add,redirect|const,view.add\n"
|
||||
"method.insert = view_filter,redirect|const,view.filter\n"
|
||||
"method.insert = view_filter_on,redirect|const,view.filter_on\n"
|
||||
"method.insert = view_list,redirect|const,view.list\n"
|
||||
"method.insert = view_set,redirect|const,view.set\n"
|
||||
"method.insert = view_sort,redirect|const,view.sort\n"
|
||||
"method.insert = view_sort_current,redirect|const,view.sort_current\n"
|
||||
"method.insert = view_sort_new,redirect|const,view.sort_new\n"
|
||||
|
||||
// Functions that might not get depracted as they are nice for
|
||||
// configuration files, and thus might do with just some
|
||||
// cleanup.
|
||||
|
||||
+13
-3
@@ -38,6 +38,7 @@
|
||||
#define RTORRENT_RPC_VARIABLE_H
|
||||
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
|
||||
namespace core {
|
||||
class Download;
|
||||
@@ -132,6 +133,9 @@ public:
|
||||
|
||||
static torrent::Object* argument(unsigned int index) { return m_arguments + index; }
|
||||
|
||||
static const unsigned int max_arguments = 10;
|
||||
static torrent::Object m_arguments[max_arguments];
|
||||
|
||||
protected:
|
||||
Command(const Command&);
|
||||
void operator = (const Command&);
|
||||
@@ -139,9 +143,6 @@ protected:
|
||||
// For use by functions that need to use placeholders to arguments
|
||||
// within commands. E.d. callable command strings where one of the
|
||||
// arguments within the command needs to be supplied by the caller.
|
||||
static const unsigned int max_arguments = 10;
|
||||
|
||||
static torrent::Object m_arguments[max_arguments];
|
||||
};
|
||||
|
||||
template <typename T1 = void, typename T2 = void>
|
||||
@@ -175,6 +176,8 @@ is_target_compatible(const target_type& target) { return target.first == target_
|
||||
|
||||
template <> inline bool
|
||||
is_target_compatible<target_type>(const target_type& target) { return true; }
|
||||
template <> inline bool
|
||||
is_target_compatible<torrent::File*>(const target_type& target) { return target.first == Command::target_file || Command::target_file_itr; }
|
||||
|
||||
// Splitting pairs into separate targets.
|
||||
inline bool is_target_pair(const target_type& target) { return target.first >= Command::target_download_pair; }
|
||||
@@ -184,6 +187,13 @@ get_target_cast(target_type target, int type = target_type_id<T>::value) { retur
|
||||
template <> inline target_type
|
||||
get_target_cast<target_type>(target_type target, int type) { return target; }
|
||||
|
||||
template <> inline torrent::File*
|
||||
get_target_cast<torrent::File*>(target_type target, int type) {
|
||||
if (target.first == Command::target_file_itr)
|
||||
return static_cast<torrent::FileListIterator*>(target.second)->file();
|
||||
else
|
||||
return static_cast<torrent::File*>(target.second);
|
||||
}
|
||||
|
||||
inline target_type get_target_left(const target_type& target) { return target_type(target.first - 5, target.second); }
|
||||
inline target_type get_target_right(const target_type& target) { return target_type(target.first - 5, target.third); }
|
||||
|
||||
@@ -46,6 +46,47 @@
|
||||
|
||||
namespace rpc {
|
||||
|
||||
// Temp until it can be moved somewhere better...
|
||||
const torrent::Object
|
||||
command_function_call(const torrent::raw_string& cmd, target_type target, const torrent::Object& args) {
|
||||
char* buffer[sizeof(torrent::Object) * Command::max_arguments];
|
||||
torrent::Object* stack = (torrent::Object*)buffer;
|
||||
torrent::Object* first = (torrent::Object*)buffer;
|
||||
|
||||
if (args.is_list()) {
|
||||
// Do nothing for now.
|
||||
for (torrent::Object::list_const_iterator itr = args.as_list().begin(), last = args.as_list().end();
|
||||
itr != last && first != stack + Command::max_arguments;
|
||||
itr++, first++) {
|
||||
new (first) torrent::Object(*itr);
|
||||
first->swap(*Command::argument(std::distance(stack, first)));
|
||||
}
|
||||
|
||||
} else if (args.type() != torrent::Object::TYPE_NONE) {
|
||||
new (first) torrent::Object(args);
|
||||
(first++)->swap(*Command::argument(0));
|
||||
}
|
||||
|
||||
try {
|
||||
torrent::Object result = parse_command_multiple(target, cmd.begin(), cmd.end());
|
||||
|
||||
while (first-- != stack) {
|
||||
first->swap(*Command::argument(std::distance(stack, first)));
|
||||
first->~Object();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (torrent::bencode_error& e) {
|
||||
while (first-- != stack) {
|
||||
first->swap(*Command::argument(std::distance(stack, first)));
|
||||
first->~Object();
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
const torrent::Object
|
||||
CommandFunction::call(Command* rawCommand, target_type target, const torrent::Object& args) {
|
||||
char* buffer[sizeof(torrent::Object) * Command::max_arguments];
|
||||
@@ -68,14 +109,24 @@ CommandFunction::call(Command* rawCommand, target_type target, const torrent::Ob
|
||||
|
||||
CommandFunction* command = reinterpret_cast<CommandFunction*>(rawCommand);
|
||||
|
||||
torrent::Object result = parse_command_multiple(target, command->m_command.c_str(), command->m_command.c_str() + command->m_command.size());
|
||||
try {
|
||||
torrent::Object result = parse_command_multiple(target, command->m_command.c_str(), command->m_command.c_str() + command->m_command.size());
|
||||
|
||||
while (first-- != stack) {
|
||||
first->swap(*argument(std::distance(stack, first)));
|
||||
first->~Object();
|
||||
while (first-- != stack) {
|
||||
first->swap(*argument(std::distance(stack, first)));
|
||||
first->~Object();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (torrent::bencode_error& e) {
|
||||
while (first-- != stack) {
|
||||
first->swap(*Command::argument(std::distance(stack, first)));
|
||||
first->~Object();
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const torrent::Object
|
||||
@@ -107,8 +158,18 @@ CommandFunctionList::call(Command* rawCommand, target_type target, const torrent
|
||||
|
||||
CommandFunctionList* command = reinterpret_cast<CommandFunctionList*>(rawCommand);
|
||||
|
||||
for (base_type::const_iterator itr = command->begin(), last = command->end(); itr != last; itr++)
|
||||
parse_command_multiple(target, itr->second.c_str(), itr->second.c_str() + itr->second.size());
|
||||
try {
|
||||
for (base_type::const_iterator itr = command->begin(), last = command->end(); itr != last; itr++)
|
||||
parse_command_multiple(target, itr->second.c_str(), itr->second.c_str() + itr->second.size());
|
||||
|
||||
} catch (torrent::bencode_error& e) {
|
||||
while (first-- != stack) {
|
||||
first->swap(*Command::argument(std::distance(stack, first)));
|
||||
first->~Object();
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
while (first-- != stack) {
|
||||
first->swap(*argument(std::distance(stack, first)));
|
||||
|
||||
@@ -83,6 +83,10 @@ public:
|
||||
static const torrent::Object call(Command* rawCommand, target_type target, const torrent::Object& args);
|
||||
};
|
||||
|
||||
// Temp until it can be moved somewhere better...
|
||||
const torrent::Object
|
||||
command_function_call(const torrent::raw_string& cmd, target_type target, const torrent::Object& args);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+15
-15
@@ -155,39 +155,39 @@ Download::create_info() {
|
||||
element->push_column("Created:", te_command("cat=$to_date=$d.creation_date=,\" \",$to_time=$d.creation_date="));
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Directory:", te_command("d.get_directory="));
|
||||
element->push_column("Directory:", te_command("d.directory="));
|
||||
element->push_column("Base Path:", te_command("d.base_path="));
|
||||
element->push_column("Tied to file:", te_command("d.get_tied_to_file="));
|
||||
element->push_column("File stats:", te_command("cat=$if=$d.is_multi_file=\\,multi\\,single,\" \",$d.get_size_files=,\" files\""));
|
||||
element->push_column("Tied to file:", te_command("d.tied_to_file="));
|
||||
element->push_column("File stats:", te_command("cat=$if=$d.is_multi_file=\\,multi\\,single,\" \",$d.size_files=,\" files\""));
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Chunks:", te_command("cat=$d.get_completed_chunks=,\" / \",$d.get_size_chunks=,\" * \",$d.get_chunk_size="));
|
||||
element->push_column("Priority:", te_command("d.get_priority="));
|
||||
element->push_column("Chunks:", te_command("cat=$d.completed_chunks=,\" / \",$d.size_chunks=,\" * \",$d.chunk_size="));
|
||||
element->push_column("Priority:", te_command("d.priority="));
|
||||
element->push_column("Peer exchange:", te_command("cat=$if=$d.peer_exchange=\\,enabled\\,disabled,\\ ,"
|
||||
"$if=$d.is_pex_active=\\,active\\,$d.is_private=\\,private\\,inactive,"
|
||||
"\\ (,$d.get_size_pex=,/,$d.get_max_size_pex=,)"));
|
||||
"\\ (,$d.size_pex=,/,$d.max_size_pex=,)"));
|
||||
|
||||
element->push_column("State changed:", te_command("to_elapsed_time=$d.get_state_changed="));
|
||||
element->push_column("State changed:", te_command("to_elapsed_time=$d.state_changed="));
|
||||
|
||||
element->push_back("");
|
||||
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("Free diskspace:", te_command("cat=$to_mb=$d.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("Connection type:", te_command("d.connection_current="));
|
||||
element->push_column("Safe sync:", te_command("if=$pieces.sync.always_safe=,yes,no"));
|
||||
element->push_column("Send buffer:", te_command("cat=$to_kb=$network.send_buffer.size=,\" KB\""));
|
||||
element->push_column("Receive buffer:", te_command("cat=$to_kb=$network.receive_buffer.size=,\" KB\""));
|
||||
|
||||
// TODO: Define a custom command for this and use $argument.0 instead of looking up the name multiple times?
|
||||
element->push_column("Throttle:", te_command("branch=d.get_throttle_name=,\""
|
||||
"cat=$d.get_throttle_name=,\\\" [Max \\\","
|
||||
"$to_throttle=$get_throttle_up_max=$d.get_throttle_name=,\\\"/\\\","
|
||||
"$to_throttle=$get_throttle_down_max=$d.get_throttle_name=,\\\" KB] [Rate \\\","
|
||||
"$to_kb=$get_throttle_up_rate=$d.get_throttle_name=,\\\"/\\\","
|
||||
"$to_kb=$get_throttle_down_rate=$d.get_throttle_name=,\\\" KB]\\\"\","
|
||||
element->push_column("Throttle:", te_command("branch=d.throttle_name=,\""
|
||||
"cat=$d.throttle_name=,\\\" [Max \\\","
|
||||
"$to_throttle=$get_throttle_up_max=$d.throttle_name=,\\\"/\\\","
|
||||
"$to_throttle=$get_throttle_down_max=$d.throttle_name=,\\\" KB] [Rate \\\","
|
||||
"$to_kb=$get_throttle_up_rate=$d.throttle_name=,\\\"/\\\","
|
||||
"$to_kb=$get_throttle_down_rate=$d.throttle_name=,\\\" KB]\\\"\","
|
||||
"cat=\"global\""));
|
||||
|
||||
element->push_back("");
|
||||
|
||||
@@ -313,8 +313,8 @@ DownloadList::receive_exit_input(Input type) {
|
||||
if ((*current_view()->focus())->is_open())
|
||||
throw torrent::input_error("Cannot change root directory on an open download.");
|
||||
|
||||
rpc::call_command("d.set_directory", rak::trim(input->str()), rpc::make_target(*current_view()->focus()));
|
||||
control->core()->push_log_std("New root directory \"" + rpc::call_command_string("d.get_directory", rpc::make_target(*current_view()->focus())) + "\" for torrent.");
|
||||
rpc::call_command("d.directory.set", rak::trim(input->str()), rpc::make_target(*current_view()->focus()));
|
||||
control->core()->push_log_std("New root directory \"" + rpc::call_command_string("d.directory", rpc::make_target(*current_view()->focus())) + "\" for torrent.");
|
||||
break;
|
||||
|
||||
case INPUT_COMMAND:
|
||||
|
||||
@@ -64,8 +64,8 @@ ElementDownloadList::ElementDownloadList() :
|
||||
throw torrent::internal_error("View \"main\" must be present to initialize the main display.");
|
||||
|
||||
m_bindings['\x13'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "d.start=");
|
||||
m_bindings['\x04'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "branch=d.get_state=,d.stop=,d.erase=");
|
||||
m_bindings['\x0B'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "d.set_ignore_commands=1; d.stop=; d.close=");
|
||||
m_bindings['\x04'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "branch=d.state=,d.stop=,d.erase=");
|
||||
m_bindings['\x0B'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "d.ignore_commands.set=1; d.stop=; d.close=");
|
||||
m_bindings['\x12'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "d.check_hash=");
|
||||
m_bindings['\x05'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command),
|
||||
"f.multicall=,f.set_create_queued=,f.set_resize_queued=; print=\"Queued create/resize of files in torrent.\"");
|
||||
@@ -74,13 +74,13 @@ ElementDownloadList::ElementDownloadList() :
|
||||
m_bindings['-'] = sigc::mem_fun(*this, &ElementDownloadList::receive_prev_priority);
|
||||
m_bindings['T'-'@']= sigc::mem_fun(*this, &ElementDownloadList::receive_cycle_throttle);
|
||||
m_bindings['I'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command),
|
||||
"branch=d.get_ignore_commands=,"
|
||||
"{d.set_ignore_commands=0, print=\"Torrent set to heed commands.\"},"
|
||||
"{d.set_ignore_commands=1, print=\"Torrent set to ignore commands.\"}");
|
||||
"branch=d.ignore_commands=,"
|
||||
"{d.ignore_commands.set=0, print=\"Torrent set to heed commands.\"},"
|
||||
"{d.ignore_commands.set=1, print=\"Torrent set to ignore commands.\"}");
|
||||
m_bindings['B'-'@']= sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command),
|
||||
"branch=d.is_active=,"
|
||||
"{print=\"Cannot enable initial seeding on an active download.\"},"
|
||||
"{d.set_connection_seed=initial_seed, print=\"Enabled initial seeding for the selected download.\"}");
|
||||
"{d.connection_seed.set=initial_seed, print=\"Enabled initial seeding for the selected download.\"}");
|
||||
|
||||
m_bindings['U'] = sigc::bind(sigc::mem_fun(*this, &ElementDownloadList::receive_command), "d.delete_tied=; print=\"Cleared tied to file association for the selected download.\"");
|
||||
|
||||
|
||||
@@ -103,18 +103,18 @@ ElementPeerList::create_info() {
|
||||
element->push_back("Peer info:");
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Address:", te_command("cat=$p.get_address=,:,$p.get_port="));
|
||||
element->push_column("Id:", te_command("p.get_id_html="));
|
||||
element->push_column("Client:", te_command("p.get_client_version="));
|
||||
element->push_column("Options:", te_command("p.get_options_str="));
|
||||
element->push_column("Address:", te_command("cat=$p.address=,:,$p.port="));
|
||||
element->push_column("Id:", te_command("p.id_html="));
|
||||
element->push_column("Client:", te_command("p.client_version="));
|
||||
element->push_column("Options:", te_command("p.options_str="));
|
||||
element->push_column("Connected:", te_command("if=$p.is_incoming=,incoming,outgoing"));
|
||||
element->push_column("Encrypted:", te_command("if=$p.is_encrypted=,yes,$p.is_obfuscated=,handshake,no"));
|
||||
|
||||
element->push_back("");
|
||||
element->push_column("Snubbed:", te_command("if=$p.is_snubbed=,yes,no"));
|
||||
element->push_column("Done:", te_command("p.get_completed_percent="));
|
||||
element->push_column("Rate:", te_command("cat=$to_kb=$p.get_up_rate=,\\ KB\\ ,$to_kb=$p.get_down_rate=,\\ KB"));
|
||||
element->push_column("Total:", te_command("cat=$to_kb=$p.get_up_total=,\\ KB\\ ,$to_kb=$p.get_down_total=,\\ KB"));
|
||||
element->push_column("Done:", te_command("p.completed_percent="));
|
||||
element->push_column("Rate:", te_command("cat=$to_kb=$p.up_rate=,\\ KB\\ ,$to_kb=$p.down_rate=,\\ KB"));
|
||||
element->push_column("Total:", te_command("cat=$to_kb=$p.up_total=,\\ KB\\ ,$to_kb=$p.down_total=,\\ KB"));
|
||||
|
||||
element->set_column_width(element->column_width() + 1);
|
||||
element->set_error_handler(new display::TextElementCString("No peer selected."));
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ Root::cleanup() {
|
||||
|
||||
const char*
|
||||
Root::get_throttle_keys() {
|
||||
const std::string& keyLayout = rpc::call_command_string("get_key_layout");
|
||||
const std::string& keyLayout = rpc::call_command_string("key_layout");
|
||||
|
||||
if (strcasecmp(keyLayout.c_str(), "azerty") == 0)
|
||||
return "qwQWsxSXdcDC";
|
||||
|
||||
Reference in New Issue
Block a user