* Old file/tracker related xmlrpc commands now work as before.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1163 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2010-04-12 03:37:07 +00:00
parent 74bae32243
commit 575cafc7a8
9 changed files with 97 additions and 63 deletions
+3 -3
View File
@@ -738,7 +738,7 @@ initialize_command_download() {
CMD2_DL ("d.initialize_logs", std::tr1::bind(&cmd_d_initialize_logs, std::tr1::placeholders::_1));
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));
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));
}
+10 -6
View File
@@ -233,12 +233,16 @@ initialize_command_local() {
CMD2_ANY_V ("session_save", std::tr1::bind(&core::DownloadList::session_save, dList));
CMD2_ANY("execute", std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde));
CMD2_ANY("execute_nothrow", std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, rpc::ExecFile::flag_expand_tilde));
CMD2_ANY("execute_raw", std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, rpc::ExecFile::flag_throw));
CMD2_ANY("execute_raw_nothrow", std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, 0));
CMD2_ANY("execute_capture", std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture));
CMD2_ANY("execute_capture_nothrow", std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture));
#define CMD2_EXECUTE(key, flags) \
CMD2_ANY(key, std::tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::tr1::placeholders::_2, flags));
CMD2_EXECUTE ("execute2", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw);
CMD2_EXECUTE ("execute_throw", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw);
CMD2_EXECUTE ("execute_nothrow", rpc::ExecFile::flag_expand_tilde);
CMD2_EXECUTE ("execute_raw", rpc::ExecFile::flag_throw);
CMD2_EXECUTE ("execute_raw_nothrow", 0);
CMD2_EXECUTE ("execute_capture", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
CMD2_EXECUTE ("execute_capture_nothrow", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
CMD2_ANY_STRING ("log.execute", std::tr1::bind(&apply_log, std::tr1::placeholders::_2, 0));
CMD2_ANY_STRING_V("log.xmlrpc", std::tr1::bind(&ThreadWorker::set_xmlrpc_log, worker_thread, std::tr1::placeholders::_2));
+9 -9
View File
@@ -506,13 +506,13 @@ initialize_command_ui() {
CMD2_ANY_LIST("greater", &apply_greater);
CMD2_ANY_LIST("equal", &apply_equal);
CMD2_ANY_VALUE("to_gm_time", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0));
CMD2_ANY_VALUE("to_gm_date", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0x2));
CMD2_ANY_VALUE("to_time", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0x1));
CMD2_ANY_VALUE("to_date", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0x1 | 0x2));
CMD2_ANY_VALUE("to_elapsed_time", std::tr1::bind(&apply_to_elapsed_time, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("to_kb", std::tr1::bind(&apply_to_kb, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("to_mb", std::tr1::bind(&apply_to_mb, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("to_xb", std::tr1::bind(&apply_to_xb, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("to_throttle", std::tr1::bind(&apply_to_throttle, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("convert.gm_time", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0));
CMD2_ANY_VALUE("convert.gm_date", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0x2));
CMD2_ANY_VALUE("convert.time", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0x1));
CMD2_ANY_VALUE("convert.date", std::tr1::bind(&apply_to_time, std::tr1::placeholders::_2, 0x1 | 0x2));
CMD2_ANY_VALUE("convert.elapsed_time", std::tr1::bind(&apply_to_elapsed_time, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("convert.kb", std::tr1::bind(&apply_to_kb, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("convert.mb", std::tr1::bind(&apply_to_mb, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("convert.xb", std::tr1::bind(&apply_to_xb, std::tr1::placeholders::_2));
CMD2_ANY_VALUE("convert.throttle", std::tr1::bind(&apply_to_throttle, std::tr1::placeholders::_2));
}
+49 -26
View File
@@ -326,6 +326,10 @@ main(int argc, char** argv) {
#define CMD2_REDIRECT_GENERIC(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_xmlrpc | rpc::CommandMap::flag_no_target);
#define CMD2_REDIRECT_FILE(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_xmlrpc | rpc::CommandMap::flag_file_target);
#define CMD2_REDIRECT_TRACKER(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_xmlrpc | rpc::CommandMap::flag_tracker_target);
CMD2_REDIRECT_GENERIC("system.method.insert", "method.insert");
CMD2_REDIRECT_GENERIC("system.method.erase", "method.erase");
@@ -548,37 +552,38 @@ main(int argc, char** argv) {
// Tracker:
//
CMD2_REDIRECT ("t.get_group", "t.group");
CMD2_REDIRECT ("t.get_id", "t.id");
CMD2_REDIRECT ("t.get_min_interval", "t.min_interval");
CMD2_REDIRECT ("t.get_normal_interval", "t.normal_interval");
CMD2_REDIRECT ("t.get_scrape_complete", "t.scrape_complete");
CMD2_REDIRECT ("t.get_scrape_downloaded", "t.scrape_downloaded");
CMD2_REDIRECT ("t.get_scrape_incomplete", "t.scrape_incomplete");
CMD2_REDIRECT ("t.get_scrape_time_last", "t.scrape_time_last");
CMD2_REDIRECT ("t.get_type", "t.type");
CMD2_REDIRECT ("t.get_url", "t.url");
CMD2_REDIRECT_TRACKER("t.get_group", "t.group");
CMD2_REDIRECT_TRACKER("t.get_id", "t.id");
CMD2_REDIRECT_TRACKER("t.get_min_interval", "t.min_interval");
CMD2_REDIRECT_TRACKER("t.get_normal_interval", "t.normal_interval");
CMD2_REDIRECT_TRACKER("t.get_scrape_complete", "t.scrape_complete");
CMD2_REDIRECT_TRACKER("t.get_scrape_downloaded", "t.scrape_downloaded");
CMD2_REDIRECT_TRACKER("t.get_scrape_incomplete", "t.scrape_incomplete");
CMD2_REDIRECT_TRACKER("t.get_scrape_time_last", "t.scrape_time_last");
CMD2_REDIRECT_TRACKER("t.get_type", "t.type");
CMD2_REDIRECT_TRACKER("t.get_url", "t.url");
CMD2_REDIRECT_TRACKER("t.set_enabled", "t.is_enabled.set");
//
// File:
//
CMD2_REDIRECT ("f.get_completed_chunks", "f.completed_chunks");
CMD2_REDIRECT ("f.get_frozen_path", "f.frozen_path");
CMD2_REDIRECT ("f.get_last_touched", "f.last_touched");
CMD2_REDIRECT ("f.get_match_depth_next", "f.match_depth_next");
CMD2_REDIRECT ("f.get_match_depth_prev", "f.match_depth_prev");
CMD2_REDIRECT ("f.get_offset", "f.offset");
CMD2_REDIRECT ("f.get_path", "f.path");
CMD2_REDIRECT ("f.get_path_components", "f.path_components");
CMD2_REDIRECT ("f.get_path_depth", "f.path_depth");
CMD2_REDIRECT ("f.get_priority", "f.priority");
CMD2_REDIRECT ("f.get_range_first", "f.range_first");
CMD2_REDIRECT ("f.get_range_second", "f.range_second");
CMD2_REDIRECT ("f.get_size_bytes", "f.size_bytes");
CMD2_REDIRECT ("f.get_size_chunks", "f.size_chunks");
CMD2_REDIRECT ("f.set_priority", "f.priority.set");
CMD2_REDIRECT ("fi.get_filename_last", "fi.filename_last");
CMD2_REDIRECT_FILE ("f.get_completed_chunks", "f.completed_chunks");
CMD2_REDIRECT_FILE ("f.get_frozen_path", "f.frozen_path");
CMD2_REDIRECT_FILE ("f.get_last_touched", "f.last_touched");
CMD2_REDIRECT_FILE ("f.get_match_depth_next", "f.match_depth_next");
CMD2_REDIRECT_FILE ("f.get_match_depth_prev", "f.match_depth_prev");
CMD2_REDIRECT_FILE ("f.get_offset", "f.offset");
CMD2_REDIRECT_FILE ("f.get_path", "f.path");
CMD2_REDIRECT_FILE ("f.get_path_components", "f.path_components");
CMD2_REDIRECT_FILE ("f.get_path_depth", "f.path_depth");
CMD2_REDIRECT_FILE ("f.get_priority", "f.priority");
CMD2_REDIRECT_FILE ("f.get_range_first", "f.range_first");
CMD2_REDIRECT_FILE ("f.get_range_second", "f.range_second");
CMD2_REDIRECT_FILE ("f.get_size_bytes", "f.size_bytes");
CMD2_REDIRECT_FILE ("f.get_size_chunks", "f.size_chunks");
CMD2_REDIRECT_FILE ("f.set_priority", "f.priority.set");
CMD2_REDIRECT_FILE ("fi.get_filename_last", "fi.filename_last");
//
// Peer:
@@ -614,6 +619,24 @@ main(int argc, char** argv) {
// Rename these to avoid conflicts with old style.
CMD2_REDIRECT_GENERIC("d.multicall", "d.multicall2");
CMD2_REDIRECT_GENERIC("to_gm_time", "convert.gm_time");
CMD2_REDIRECT_GENERIC("to_gm_date", "convert.gm_date");
CMD2_REDIRECT_GENERIC("to_time", "convert.time");
CMD2_REDIRECT_GENERIC("to_date", "convert.date");
CMD2_REDIRECT_GENERIC("to_elapsed_time", "convert.elapsed_time");
CMD2_REDIRECT_GENERIC("to_kb", "convert.kb");
CMD2_REDIRECT_GENERIC("to_mb", "convert.mb");
CMD2_REDIRECT_GENERIC("to_xb", "convert.xb");
CMD2_REDIRECT_GENERIC("to_throttle", "convert.throttle");
CMD2_REDIRECT_GENERIC("execute", "execute2");
// CMD2_REDIRECT_GENERIC("execute_throw", "execute.throw");
// CMD2_REDIRECT_GENERIC("execute_nothrow", "execute.nothrow");
// CMD2_REDIRECT_GENERIC("execute_raw", "execute.raw");
// CMD2_REDIRECT_GENERIC("execute_raw_nothrow", "execute.raw_nothrow");
// CMD2_REDIRECT_GENERIC("execute_capture", "execute.capture");
// CMD2_REDIRECT_GENERIC("execute_capture_nothrow", "execute.capture_nothrow");
// Functions that might not get depracted as they are nice for
// configuration files, and thus might do with just some
// cleanup.
+4 -1
View File
@@ -88,11 +88,14 @@ public:
static const int flag_dont_delete = 0x1;
static const int flag_delete_key = 0x2;
static const int flag_public_xmlrpc = 0x4;
static const int flag_no_target = 0x8;
static const int flag_modifiable = 0x10;
static const int flag_is_redirect = 0x20;
static const int flag_has_redirects = 0x40;
static const int flag_no_target = 0x100;
static const int flag_file_target = 0x200;
static const int flag_tracker_target = 0x400;
CommandMap() {}
~CommandMap();
+4
View File
@@ -445,6 +445,10 @@ xmlrpc_call_command(xmlrpc_env* env, xmlrpc_value* args, void* voidServerInfo) {
if (itr->second.m_flags & CommandMap::flag_no_target)
xmlrpc_to_object(env, args, XmlRpc::call_generic, &target).swap(object);
else if (itr->second.m_flags & CommandMap::flag_file_target)
xmlrpc_to_object(env, args, XmlRpc::call_file, &target).swap(object);
else if (itr->second.m_flags & CommandMap::flag_tracker_target)
xmlrpc_to_object(env, args, XmlRpc::call_tracker, &target).swap(object);
else
xmlrpc_to_object(env, args, XmlRpc::call_any, &target).swap(object);
+15 -15
View File
@@ -152,7 +152,7 @@ Download::create_info() {
element->push_column("Name:", te_command("d.name="));
element->push_column("Local id:", te_command("d.local_id_html="));
element->push_column("Info hash:", te_command("d.hash="));
element->push_column("Created:", te_command("cat=$to_date=$d.creation_date=,\" \",$to_time=$d.creation_date="));
element->push_column("Created:", te_command("cat=$convert.date=$d.creation_date=,\" \",$convert.time=$d.creation_date="));
element->push_back("");
element->push_column("Directory:", te_command("d.directory="));
@@ -167,33 +167,33 @@ Download::create_info() {
"$if=$d.is_pex_active=\\,active\\,$d.is_private=\\,private\\,inactive,"
"\\ (,$d.size_pex=,/,$d.max_size_pex=,)"));
element->push_column("State changed:", te_command("to_elapsed_time=$d.state_changed="));
element->push_column("State changed:", te_command("convert.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.free_diskspace=,\" MB\""));
element->push_column("Safe diskspace:", te_command("cat=$to_mb=$pieces.sync.safe_free_diskspace=,\" MB\""));
element->push_column("Memory usage:", te_command("cat=$convert.mb=$pieces.memory.current=,\" MB\""));
element->push_column("Max memory usage:", te_command("cat=$convert.mb=$pieces.memory.max=,\" MB\""));
element->push_column("Free diskspace:", te_command("cat=$convert.mb=$d.free_diskspace=,\" MB\""));
element->push_column("Safe diskspace:", te_command("cat=$convert.mb=$pieces.sync.safe_free_diskspace=,\" MB\""));
element->push_back("");
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\""));
element->push_column("Send buffer:", te_command("cat=$convert.kb=$network.send_buffer.size=,\" KB\""));
element->push_column("Receive buffer:", te_command("cat=$convert.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.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]\\\"\","
"$convert.throttle=$get_throttle_up_max=$d.throttle_name=,\\\"/\\\","
"$convert.throttle=$get_throttle_down_max=$d.throttle_name=,\\\" KB] [Rate \\\","
"$convert.kb=$get_throttle_up_rate=$d.throttle_name=,\\\"/\\\","
"$convert.kb=$get_throttle_down_rate=$d.throttle_name=,\\\" KB]\\\"\","
"cat=\"global\""));
element->push_back("");
element->push_column("Upload:", te_command("cat=$to_kb=$d.up.rate=,\" KB / \",$to_xb=$d.up.total="));
element->push_column("Download:", te_command("cat=$to_kb=$d.down.rate=,\" KB / \",$to_xb=$d.down.total="));
element->push_column("Skipped:", te_command("cat=$to_kb=$d.skip.rate=,\" KB / \",$to_xb=$d.skip.total="));
element->push_column("Upload:", te_command("cat=$convert.kb=$d.up.rate=,\" KB / \",$convert.xb=$d.up.total="));
element->push_column("Download:", te_command("cat=$convert.kb=$d.down.rate=,\" KB / \",$convert.xb=$d.down.total="));
element->push_column("Skipped:", te_command("cat=$convert.kb=$d.skip.rate=,\" KB / \",$convert.xb=$d.skip.total="));
element->push_column("Preload:", te_command("cat=$pieces.preload.type=,\" / \",$pieces.stats_preloaded=,\" / \",$pieces.stats_preloaded="));
element->set_column_width(element->column_width() + 1);
+1 -1
View File
@@ -92,7 +92,7 @@ element_file_list_create_info() {
element->push_column("Filename:", te_command("fi.get_filename_last="));
element->push_back("");
element->push_column("Size:", te_command("if=$fi.is_file=,$to_xb=$f.size_bytes=,---"));
element->push_column("Size:", te_command("if=$fi.is_file=,$convert.xb=$f.size_bytes=,---"));
element->push_column("Chunks:", te_command("cat=$f.completed_chunks=,\" / \",$f.size_chunks="));
element->push_column("Range:", te_command("cat=$f.range_first=,\" - \",$f.range_second="));
element->push_back("");
+2 -2
View File
@@ -113,8 +113,8 @@ ElementPeerList::create_info() {
element->push_back("");
element->push_column("Snubbed:", te_command("if=$p.is_snubbed=,yes,no"));
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->push_column("Rate:", te_command("cat=$convert.kb=$p.up_rate=,\\ KB\\ ,$convert.kb=$p.down_rate=,\\ KB"));
element->push_column("Total:", te_command("cat=$convert.kb=$p.up_total=,\\ KB\\ ,$convert.kb=$p.down_total=,\\ KB"));
element->set_column_width(element->column_width() + 1);
element->set_error_handler(new display::TextElementCString("No peer selected."));