mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
* Modified the fallocate configure check so it will fail if 'fallocate' can't be found.
* Changed more commands to the new format. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1153 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+4
-8
@@ -160,14 +160,10 @@ AC_DEFUN([TORRENT_WITHOUT_VARIABLE_FDSET], [
|
||||
AC_DEFUN([TORRENT_CHECK_FALLOCATE], [
|
||||
AC_MSG_CHECKING(for fallocate)
|
||||
|
||||
AC_COMPILE_IFELSE(
|
||||
[[#include <fcntl.h>
|
||||
#include <linux/falloc.h>
|
||||
int main() {
|
||||
fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
]],
|
||||
AC_TRY_LINK([#include <fcntl.h>
|
||||
#include <linux/falloc.h>
|
||||
],[ fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 0); return 0;
|
||||
],
|
||||
[
|
||||
AC_DEFINE(HAVE_FALLOCATE, 1, Linux's fallocate supported.)
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
@@ -17,7 +17,6 @@ libsub_root_a_SOURCES = \
|
||||
command_helpers.h \
|
||||
command_local.cc \
|
||||
command_network.cc \
|
||||
command_object.cc \
|
||||
command_peer.cc \
|
||||
command_tracker.cc \
|
||||
command_scheduler.cc \
|
||||
|
||||
+17
-25
@@ -82,9 +82,7 @@ create_new_key(const std::string& key, const char postfix[postfix_size]) {
|
||||
// as a command, and which takes advantage of static const char
|
||||
// strings, etc.
|
||||
torrent::Object
|
||||
system_method_insert(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
|
||||
system_method_insert(const torrent::Object::list_type& args) {
|
||||
if (args.empty() || ++args.begin() == args.end())
|
||||
throw torrent::input_error("Invalid argument count.");
|
||||
|
||||
@@ -178,8 +176,8 @@ system_method_insert(__UNUSED rpc::target_type target, const torrent::Object& ra
|
||||
// that aren't modifiable, e.g. defined by rtorrent or set to
|
||||
// read-only by the user, will result in an error.
|
||||
torrent::Object
|
||||
system_method_erase(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
rpc::CommandMap::iterator itr = rpc::commands.find(rawArgs.as_string().c_str());
|
||||
system_method_erase(const torrent::Object::string_type& args) {
|
||||
rpc::CommandMap::iterator itr = rpc::commands.find(args.c_str());
|
||||
|
||||
if (itr == rpc::commands.end())
|
||||
return torrent::Object();
|
||||
@@ -193,9 +191,9 @@ system_method_erase(__UNUSED rpc::target_type target, const torrent::Object& raw
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
system_method_get(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
system_method_get(const torrent::Object::string_type& args) {
|
||||
rpc::CommandFunction* function;
|
||||
rpc::CommandMap::iterator itr = rpc::commands.find(rawArgs.as_string().c_str());
|
||||
rpc::CommandMap::iterator itr = rpc::commands.find(args.c_str());
|
||||
|
||||
if (itr == rpc::commands.end() ||
|
||||
(function = dynamic_cast<rpc::CommandFunction*>(itr->second.m_variable)) == NULL)
|
||||
@@ -205,9 +203,7 @@ system_method_get(__UNUSED rpc::target_type target, const torrent::Object& rawAr
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
system_method_set(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
|
||||
system_method_set(const torrent::Object::list_type& args) {
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Invalid argument count.");
|
||||
|
||||
@@ -223,9 +219,7 @@ system_method_set(__UNUSED rpc::target_type target, const torrent::Object& rawAr
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
system_method_set_key(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
|
||||
system_method_set_key(const torrent::Object::list_type& args) {
|
||||
if (args.empty() || ++args.begin() == args.end())
|
||||
throw torrent::input_error("Invalid argument count.");
|
||||
|
||||
@@ -248,9 +242,7 @@ system_method_set_key(__UNUSED rpc::target_type target, const torrent::Object& r
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
system_method_has_key(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
|
||||
system_method_has_key(const torrent::Object::list_type& args) {
|
||||
if (args.size() != 2)
|
||||
throw torrent::input_error("Invalid argument count.");
|
||||
|
||||
@@ -265,9 +257,9 @@ system_method_has_key(__UNUSED rpc::target_type target, const torrent::Object& r
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
system_method_list_keys(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
system_method_list_keys(const torrent::Object::string_type& args) {
|
||||
rpc::CommandFunctionList* function;
|
||||
rpc::CommandMap::iterator itr = rpc::commands.find(rawArgs.as_string().c_str());
|
||||
rpc::CommandMap::iterator itr = rpc::commands.find(args.c_str());
|
||||
|
||||
if (itr == rpc::commands.end() ||
|
||||
(function = dynamic_cast<rpc::CommandFunctionList*>(itr->second.m_variable)) == NULL)
|
||||
@@ -284,11 +276,11 @@ system_method_list_keys(__UNUSED rpc::target_type target, const torrent::Object&
|
||||
|
||||
void
|
||||
initialize_command_dynamic() {
|
||||
CMD_N ("method.insert", rak::ptr_fn(&system_method_insert));
|
||||
CMD_N_STRING("method.erase", rak::ptr_fn(&system_method_erase));
|
||||
CMD_N_STRING("method.get", rak::ptr_fn(&system_method_get));
|
||||
CMD_N ("method.set", rak::ptr_fn(&system_method_set));
|
||||
CMD_N ("method.set_key", rak::ptr_fn(&system_method_set_key));
|
||||
CMD_N ("method.has_key", rak::ptr_fn(&system_method_has_key));
|
||||
CMD_N_STRING("method.list_keys", rak::ptr_fn(&system_method_list_keys));
|
||||
CMD2_ANY_LIST ("method.insert", std::tr1::bind(&system_method_insert, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.erase", std::tr1::bind(&system_method_erase, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.get", std::tr1::bind(&system_method_get, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.set", std::tr1::bind(&system_method_set, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.set_key", std::tr1::bind(&system_method_set_key, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.has_key", std::tr1::bind(&system_method_has_key, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.list_keys", std::tr1::bind(&system_method_list_keys, std::tr1::placeholders::_2));
|
||||
}
|
||||
|
||||
+29
-25
@@ -216,7 +216,7 @@ apply_load(const torrent::Object::list_type& args, int flags) {
|
||||
void apply_import(const std::string& path) { if (!rpc::parse_command_file(path)) throw torrent::input_error("Could not open option file: " + path); }
|
||||
void apply_try_import(const std::string& path) { if (!rpc::parse_command_file(path)) control->core()->push_log_std("Could not read resource file: " + path); }
|
||||
|
||||
void
|
||||
torrent::Object
|
||||
apply_close_low_diskspace(int64_t arg) {
|
||||
core::DownloadList* downloadList = control->core()->download_list();
|
||||
|
||||
@@ -239,6 +239,8 @@ apply_close_low_diskspace(int64_t arg) {
|
||||
|
||||
if (closed)
|
||||
control->core()->push_log("Closed torrents due to low diskspace.");
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -302,7 +304,7 @@ d_multicall(const torrent::Object::list_type& args) {
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
test_thread_locking(const torrent::Object& rawArgs) {
|
||||
test_thread_locking() {
|
||||
worker_thread->queue_item(&ThreadWorker::start_log_counter);
|
||||
|
||||
return torrent::Object();
|
||||
@@ -310,36 +312,38 @@ test_thread_locking(const torrent::Object& rawArgs) {
|
||||
|
||||
void
|
||||
initialize_command_events() {
|
||||
ADD_COMMAND_NONE("test.thread_locking", rak::ptr_fn(&test_thread_locking));
|
||||
CMD2_ANY("test.thread_locking", std::tr1::bind(&test_thread_locking));
|
||||
|
||||
ADD_VARIABLE_BOOL("check_hash", true); // Rename
|
||||
CMD2_VAR_BOOL ("check_hash", true); // Rename
|
||||
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.session.use_lock", "bool|const", true));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("system.session.on_completion", "bool|const", true));
|
||||
CMD2_VAR_BOOL ("system.session.use_lock", true);
|
||||
CMD2_VAR_BOOL ("system.session.on_completion", true);
|
||||
|
||||
CMD2_ANY_STRING("on_ratio", std::tr1::bind(&apply_on_ratio, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("on_ratio", std::tr1::bind(&apply_on_ratio, std::tr1::placeholders::_2));
|
||||
|
||||
ADD_COMMAND_VOID("start_tied", &apply_start_tied);
|
||||
ADD_COMMAND_VOID("stop_untied", &apply_stop_untied);
|
||||
ADD_COMMAND_VOID("close_untied", &apply_close_untied);
|
||||
ADD_COMMAND_VOID("remove_untied", &apply_remove_untied);
|
||||
CMD2_ANY ("start_tied", std::tr1::bind(&apply_start_tied));
|
||||
CMD2_ANY ("stop_untied", std::tr1::bind(&apply_stop_untied));
|
||||
CMD2_ANY ("close_untied", std::tr1::bind(&apply_close_untied));
|
||||
CMD2_ANY ("remove_untied", std::tr1::bind(&apply_remove_untied));
|
||||
|
||||
CMD2_ANY_LIST("schedule", std::tr1::bind(&apply_schedule, std::tr1::placeholders::_2));
|
||||
ADD_COMMAND_STRING_UN("schedule_remove", rak::make_mem_fun(control->command_scheduler(), &rpc::CommandScheduler::erase_str));
|
||||
CMD2_ANY_LIST ("schedule", std::tr1::bind(&apply_schedule, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("schedule_remove", std::tr1::bind(&rpc::CommandScheduler::erase_str, control->command_scheduler(), std::tr1::placeholders::_2));
|
||||
|
||||
ADD_COMMAND_STRING_UN("import", std::ptr_fun(&apply_import));
|
||||
ADD_COMMAND_STRING_UN("try_import", std::ptr_fun(&apply_try_import));
|
||||
CMD2_ANY_STRING_V("import", std::tr1::bind(&apply_import, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("try_import", std::tr1::bind(&apply_try_import, std::tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("load", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_tied));
|
||||
CMD2_ANY_LIST("load_verbose", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_tied));
|
||||
CMD2_ANY_LIST("load_start", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST("load_start_verbose", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST("load_raw", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST("load_raw_verbose", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST("load_raw_start", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_start | core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_tied));
|
||||
CMD2_ANY_LIST ("load_verbose", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_tied));
|
||||
CMD2_ANY_LIST ("load_start", std::tr1::bind(&apply_load, std::tr1::placeholders::_2,
|
||||
core::Manager::create_quiet | core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST ("load_start_verbose", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST ("load_raw", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load_raw_verbose", std::tr1::bind(&apply_load, std::tr1::placeholders::_2, core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load_raw_start", std::tr1::bind(&apply_load, std::tr1::placeholders::_2,
|
||||
core::Manager::create_quiet | core::Manager::create_start | core::Manager::create_raw_data));
|
||||
|
||||
ADD_COMMAND_VALUE_UN("close_low_diskspace", std::ptr_fun(&apply_close_low_diskspace));
|
||||
CMD2_ANY_VALUE ("close_low_diskspace", std::tr1::bind(&apply_close_low_diskspace, std::tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("download_list", std::tr1::bind(&apply_download_list, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("d.multicall", std::tr1::bind(&d_multicall, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("download_list", std::tr1::bind(&apply_download_list, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("d.multicall", std::tr1::bind(&d_multicall, std::tr1::placeholders::_2));
|
||||
}
|
||||
|
||||
+25
-59
@@ -97,74 +97,40 @@ apply_fi_filename_last(torrent::FileListIterator* itr) {
|
||||
return itr->file()->path()->at(itr->depth());
|
||||
}
|
||||
|
||||
#define ADD_CF_SLOT(key, function, slot, parm, doc) \
|
||||
commandFileSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandFileSlotsItr++, &rpc::CommandSlot<torrent::File*>::function, rpc::CommandMap::flag_dont_delete, parm, doc);
|
||||
|
||||
#define ADD_CF_SLOT_PUBLIC(key, function, slot, parm, doc) \
|
||||
commandFileSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandFileSlotsItr++, &rpc::CommandSlot<torrent::File*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
|
||||
|
||||
#define ADD_CF_VOID(key, slot) \
|
||||
ADD_CF_SLOT_PUBLIC("f." key, call_unknown, rpc::object_fn(slot), "i:", "")
|
||||
|
||||
#define ADD_CF_VALUE(key, get) \
|
||||
ADD_CF_SLOT_PUBLIC("f." key, call_unknown, rpc::object_void_fn<torrent::File*>(get), "i:", "")
|
||||
|
||||
#define ADD_CF_VALUE_UNI(key, get) \
|
||||
ADD_CF_SLOT_PUBLIC("f.get_" key, call_unknown, rpc::object_void_fn<torrent::File*>(get), "i:", "")
|
||||
|
||||
#define ADD_CF_VALUE_BI(key, set, get) \
|
||||
ADD_CF_SLOT_PUBLIC("f.set_" key, call_value, rpc::object_value_fn<torrent::File*>(set), "i:i", "") \
|
||||
ADD_CF_SLOT_PUBLIC("f.get_" key, call_unknown, rpc::object_void_fn<torrent::File*>(get), "i:", "")
|
||||
|
||||
#define ADD_CF_STRING_UNI(key, get) \
|
||||
ADD_CF_SLOT_PUBLIC("f.get_" key, call_unknown, rpc::object_void_fn<torrent::File*>(get), "s:", "")
|
||||
|
||||
#define ADD_CFI_SLOT_PUBLIC(key, function, slot, parm, doc) \
|
||||
commandFileItrSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandFileItrSlotsItr++, &rpc::CommandSlot<torrent::FileListIterator*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
|
||||
|
||||
#define ADD_CFI_VOID(key, slot) \
|
||||
ADD_CFI_SLOT_PUBLIC("fi." key, call_unknown, rpc::object_fn(slot), "i:", "")
|
||||
|
||||
#define ADD_CFI_VALUE(key, get) \
|
||||
ADD_CFI_SLOT_PUBLIC("fi." key, call_unknown, rpc::object_void_fn<torrent::FileListIterator*>(get), "i:", "")
|
||||
|
||||
void
|
||||
initialize_command_file() {
|
||||
ADD_CF_VALUE("is_created", std::mem_fun(&torrent::File::is_created));
|
||||
ADD_CF_VALUE("is_open", std::mem_fun(&torrent::File::is_open));
|
||||
CMD2_FILE("f.is_created", std::tr1::bind(&torrent::File::is_created, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.is_open", std::tr1::bind(&torrent::File::is_open, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CF_VALUE("is_create_queued", std::mem_fun(&torrent::File::is_create_queued));
|
||||
ADD_CF_VALUE("is_resize_queued", std::mem_fun(&torrent::File::is_resize_queued));
|
||||
CMD2_FILE("f.is_create_queued", std::tr1::bind(&torrent::File::is_create_queued, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.is_resize_queued", std::tr1::bind(&torrent::File::is_resize_queued, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CF_VALUE("set_create_queued", std::bind2nd(std::mem_fun(&torrent::File::set_flags), (int)torrent::File::flag_create_queued));
|
||||
ADD_CF_VALUE("set_resize_queued", std::bind2nd(std::mem_fun(&torrent::File::set_flags), (int)torrent::File::flag_resize_queued));
|
||||
ADD_CF_VALUE("unset_create_queued", std::bind2nd(std::mem_fun(&torrent::File::unset_flags), (int)torrent::File::flag_create_queued));
|
||||
ADD_CF_VALUE("unset_resize_queued", std::bind2nd(std::mem_fun(&torrent::File::unset_flags), (int)torrent::File::flag_resize_queued));
|
||||
CMD2_FILE_VALUE_V("f.set_create_queued", std::tr1::bind(&torrent::File::set_flags, std::tr1::placeholders::_1, torrent::File::flag_create_queued));
|
||||
CMD2_FILE_VALUE_V("f.set_resize_queued", std::tr1::bind(&torrent::File::set_flags, std::tr1::placeholders::_1, torrent::File::flag_resize_queued));
|
||||
CMD2_FILE_VALUE_V("f.unset_create_queued", std::tr1::bind(&torrent::File::unset_flags, std::tr1::placeholders::_1, torrent::File::flag_create_queued));
|
||||
CMD2_FILE_VALUE_V("f.unset_resize_queued", std::tr1::bind(&torrent::File::unset_flags, std::tr1::placeholders::_1, torrent::File::flag_resize_queued));
|
||||
|
||||
ADD_CF_VALUE_UNI("size_bytes", std::mem_fun(&torrent::File::size_bytes));
|
||||
ADD_CF_VALUE_UNI("size_chunks", std::mem_fun(&torrent::File::size_chunks));
|
||||
ADD_CF_VALUE_UNI("completed_chunks", std::mem_fun(&torrent::File::completed_chunks));
|
||||
CMD2_FILE("f.size_bytes", std::tr1::bind(&torrent::File::size_bytes, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.size_chunks", std::tr1::bind(&torrent::File::size_chunks, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.completed_chunks", std::tr1::bind(&torrent::File::completed_chunks, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CF_VALUE_UNI("offset", std::mem_fun(&torrent::File::offset));
|
||||
ADD_CF_VALUE_UNI("range_first", std::mem_fun(&torrent::File::range_first));
|
||||
ADD_CF_VALUE_UNI("range_second", std::mem_fun(&torrent::File::range_second));
|
||||
CMD2_FILE("f.offset", std::tr1::bind(&torrent::File::offset, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.range_first", std::tr1::bind(&torrent::File::range_first, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.range_second", std::tr1::bind(&torrent::File::range_second, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CF_VALUE_BI("priority", std::ptr_fun(&apply_f_set_priority), std::mem_fun(&torrent::File::priority));
|
||||
CMD2_FILE("f.priority", std::tr1::bind(&torrent::File::priority, std::tr1::placeholders::_1));
|
||||
CMD2_FILE_VALUE_V("f.priority.set", std::tr1::bind(&apply_f_set_priority, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
|
||||
ADD_CF_STRING_UNI("path", std::ptr_fun(&apply_f_path));
|
||||
ADD_CF_STRING_UNI("path_components", std::ptr_fun(&apply_f_path_components));
|
||||
ADD_CF_STRING_UNI("path_depth", std::ptr_fun(&apply_f_path_depth));
|
||||
ADD_CF_STRING_UNI("frozen_path", std::mem_fun(&torrent::File::frozen_path));
|
||||
CMD2_FILE("f.path", std::tr1::bind(&apply_f_path, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.path_components", std::tr1::bind(&apply_f_path_components, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.path_depth", std::tr1::bind(&apply_f_path_depth, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.frozen_path", std::tr1::bind(&torrent::File::frozen_path, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CF_VALUE_UNI("match_depth_prev", std::mem_fun(&torrent::File::match_depth_prev));
|
||||
ADD_CF_VALUE_UNI("match_depth_next", std::mem_fun(&torrent::File::match_depth_next));
|
||||
CMD2_FILE("f.match_depth_prev", std::tr1::bind(&torrent::File::match_depth_prev, std::tr1::placeholders::_1));
|
||||
CMD2_FILE("f.match_depth_next", std::tr1::bind(&torrent::File::match_depth_next, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CF_VALUE_UNI("last_touched", std::mem_fun(&torrent::File::last_touched));
|
||||
CMD2_FILE("f.last_touched", std::tr1::bind(&torrent::File::last_touched, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CFI_VOID("get_filename_last", &apply_fi_filename_last);
|
||||
|
||||
ADD_CFI_VALUE("is_file", std::mem_fun(&torrent::FileListIterator::is_file));
|
||||
CMD2_FILEITR("fi.filename_last", std::tr1::bind(&apply_fi_filename_last, std::tr1::placeholders::_1));
|
||||
CMD2_FILEITR("fi.is_file", std::tr1::bind(&torrent::FileListIterator::is_file, std::tr1::placeholders::_1));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ rpc::CommandSlot<rpc::target_type>* commandAnySlotsItr = commandAnySlo
|
||||
rpc::command_base commandNewSlots[COMMAND_NEW_SLOTS_SIZE];
|
||||
rpc::command_base* commandNewSlotItr = commandNewSlots;
|
||||
|
||||
void initialize_command_object();
|
||||
void initialize_command_dynamic();
|
||||
void initialize_command_download();
|
||||
void initialize_command_events();
|
||||
@@ -81,7 +80,6 @@ void initialize_command_ui();
|
||||
|
||||
void
|
||||
initialize_commands() {
|
||||
initialize_command_object();
|
||||
initialize_command_dynamic();
|
||||
initialize_command_events();
|
||||
initialize_command_network();
|
||||
|
||||
+24
-10
@@ -233,22 +233,36 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri
|
||||
// New std::function based command_base helper functions:
|
||||
//
|
||||
|
||||
#define CMD2_A_FUNCTION(key, function, func_type, slot, parm, doc) \
|
||||
commandNewSlotItr->set_function<rpc::func_type>(slot); \
|
||||
#define CMD2_A_FUNCTION(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 | rpc::CommandMap::flag_public_xmlrpc, NULL, NULL);
|
||||
|
||||
#define CMD2_ANY(key, slot) CMD2_A_FUNCTION(key, command_base_call_any, any_function, slot, "i:", "")
|
||||
#define CMD2_ANY_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_ANY_L(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, slot, "A:", "")
|
||||
// #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:", "")
|
||||
|
||||
#define CMD2_ANY_VALUE(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_value, any_value_function, slot, "i:i", "")
|
||||
#define CMD2_ANY_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_value, any_value_function, object_convert_void(slot), "i:i", "")
|
||||
#define CMD2_ANY_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<rpc::target_type>, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_ANY_L(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<rpc::target_type>, slot, "A:", "")
|
||||
|
||||
#define CMD2_ANY_STRING(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, slot, "i:s", "")
|
||||
#define CMD2_ANY_STRING_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, object_convert_void(slot), "i:s", "")
|
||||
#define CMD2_ANY_VALUE(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<rpc::target_type>, slot, "i:i", "")
|
||||
#define CMD2_ANY_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<rpc::target_type>, object_convert_void(slot), "i:i", "")
|
||||
|
||||
#define CMD2_ANY_LIST(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, slot, "i:", "")
|
||||
#define CMD2_ANY_STRING(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<rpc::target_type>, slot, "i:s", "")
|
||||
#define CMD2_ANY_STRING_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<rpc::target_type>, object_convert_void(slot), "i:s", "")
|
||||
|
||||
#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_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:", "")
|
||||
#define CMD2_FILE_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<torrent::File*>, object_convert_void(slot), "i:i", "")
|
||||
|
||||
#define CMD2_FILEITR(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::FileListIterator*>, slot, "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) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "bool|const", int64_t(value)));
|
||||
|
||||
+42
-38
@@ -150,9 +150,9 @@ check_name(const std::string& str) {
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
group_insert(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
torrent::Object::list_const_iterator itr = rawArgs.as_list().begin();
|
||||
torrent::Object::list_const_iterator last = rawArgs.as_list().end();
|
||||
group_insert(const torrent::Object::list_type& args) {
|
||||
torrent::Object::list_const_iterator itr = args.begin();
|
||||
torrent::Object::list_const_iterator last = args.end();
|
||||
|
||||
const std::string& name = check_name(post_increment(itr, last)->as_string());
|
||||
const std::string& view = check_name(post_increment(itr, last)->as_string());
|
||||
@@ -176,8 +176,8 @@ initialize_command_local() {
|
||||
core::DownloadList* dList = control->core()->download_list();
|
||||
core::DownloadStore* dStore = control->core()->download_store();
|
||||
|
||||
ADD_COMMAND_VOID("system.hostname", rak::ptr_fun(&system_hostname));
|
||||
ADD_COMMAND_VOID("system.pid", rak::ptr_fun(&getpid));
|
||||
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()));
|
||||
@@ -187,47 +187,50 @@ initialize_command_local() {
|
||||
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", ""));
|
||||
|
||||
ADD_COMMAND_VOID("system.file_status_cache.size", rak::make_mem_fun((utils::FileStatusCache::base_type*)control->core()->file_status_cache(),
|
||||
&utils::FileStatusCache::size));
|
||||
ADD_COMMAND_VOID("system.file_status_cache.prune", rak::make_mem_fun(control->core()->file_status_cache(), &utils::FileStatusCache::prune));
|
||||
CMD2_ANY ("system.file_status_cache.size", std::tr1::bind(&utils::FileStatusCache::size,
|
||||
(utils::FileStatusCache::base_type*)control->core()->file_status_cache()));
|
||||
CMD2_ANY_V ("system.file_status_cache.prune", std::tr1::bind(&utils::FileStatusCache::prune, control->core()->file_status_cache()));
|
||||
|
||||
ADD_COMMAND_VOID("system.files.opened_counter", rak::make_mem_fun(fileManager, &FM_t::files_opened_counter));
|
||||
ADD_COMMAND_VOID("system.files.closed_counter", rak::make_mem_fun(fileManager, &FM_t::files_closed_counter));
|
||||
ADD_COMMAND_VOID("system.files.failed_counter", rak::make_mem_fun(fileManager, &FM_t::files_failed_counter));
|
||||
CMD2_ANY ("system.files.opened_counter", std::tr1::bind(&FM_t::files_opened_counter, fileManager));
|
||||
CMD2_ANY ("system.files.closed_counter", std::tr1::bind(&FM_t::files_closed_counter, fileManager));
|
||||
CMD2_ANY ("system.files.failed_counter", std::tr1::bind(&FM_t::files_failed_counter, fileManager));
|
||||
|
||||
ADD_COMMAND_VOID("system.time", rak::make_mem_fun(&cachedTime, &rak::timer::seconds));
|
||||
ADD_COMMAND_VOID("system.time_seconds", rak::ptr_fun(&rak::timer::current_seconds));
|
||||
ADD_COMMAND_VOID("system.time_usec", rak::ptr_fun(&rak::timer::current_usec));
|
||||
CMD2_ANY ("system.time", std::tr1::bind(&rak::timer::seconds, &cachedTime));
|
||||
CMD2_ANY ("system.time_seconds", std::tr1::bind(&rak::timer::current_seconds));
|
||||
CMD2_ANY ("system.time_usec", std::tr1::bind(&rak::timer::current_usec));
|
||||
|
||||
ADD_COMMAND_VALUE_SET_OCT("system.", "umask", std::ptr_fun(&umask));
|
||||
ADD_COMMAND_STRING_PREFIX("system.", "cwd", std::ptr_fun(system_set_cwd), rak::ptr_fun(&system_get_cwd));
|
||||
// ADD_COMMAND_VALUE_SET_OCT("system.", "umask", std::ptr_fun(&umask));
|
||||
// ADD_COMMAND_STRING_PREFIX("system.", "cwd", std::ptr_fun(system_set_cwd), rak::ptr_fun(&system_get_cwd));
|
||||
|
||||
ADD_COMMAND_VOID("pieces.sync.always_safe", rak::make_mem_fun(chunkManager, &CM_t::safe_sync));
|
||||
ADD_COMMAND_VALUE_UN("pieces.sync.always_safe.set", rak::make_mem_fun(chunkManager, &CM_t::set_safe_sync));
|
||||
ADD_COMMAND_VOID("pieces.sync.safe_free_diskspace", rak::make_mem_fun(chunkManager, &CM_t::safe_free_diskspace));
|
||||
ADD_COMMAND_VOID("pieces.sync.timeout", rak::make_mem_fun(chunkManager, &CM_t::timeout_sync));
|
||||
ADD_COMMAND_VALUE_UN("pieces.sync.timeout.set", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_sync));
|
||||
ADD_COMMAND_VOID("pieces.sync.timeout_safe", rak::make_mem_fun(chunkManager, &CM_t::timeout_safe_sync));
|
||||
ADD_COMMAND_VALUE_UN("pieces.sync.timeout_safe.set", rak::make_mem_fun(chunkManager, &CM_t::set_timeout_safe_sync));
|
||||
CMD2_ANY ("pieces.sync.always_safe", std::tr1::bind(&CM_t::safe_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.always_safe.set", std::tr1::bind(&CM_t::set_safe_sync, chunkManager, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.safe_free_diskspace", std::tr1::bind(&CM_t::safe_free_diskspace, chunkManager));
|
||||
CMD2_ANY ("pieces.sync.timeout", std::tr1::bind(&CM_t::timeout_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.timeout.set", std::tr1::bind(&CM_t::set_timeout_sync, chunkManager, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.timeout_safe", std::tr1::bind(&CM_t::timeout_safe_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.timeout_safe.set", std::tr1::bind(&CM_t::set_timeout_safe_sync, chunkManager, std::tr1::placeholders::_2));
|
||||
|
||||
ADD_COMMAND_VOID("pieces.preload.type", rak::make_mem_fun(chunkManager, &CM_t::preload_type));
|
||||
ADD_COMMAND_VALUE_UN("pieces.preload.type.set", rak::make_mem_fun(chunkManager, &CM_t::set_preload_type));
|
||||
ADD_COMMAND_VOID("pieces.preload.min_size", rak::make_mem_fun(chunkManager, &CM_t::preload_min_size));
|
||||
ADD_COMMAND_VALUE_UN("pieces.preload.min_size.set", rak::make_mem_fun(chunkManager, &CM_t::set_preload_min_size));
|
||||
ADD_COMMAND_VOID("pieces.preload.min_rate", rak::make_mem_fun(chunkManager, &CM_t::preload_required_rate));
|
||||
ADD_COMMAND_VALUE_UN("pieces.preload.min_rate.set", rak::make_mem_fun(chunkManager, &CM_t::set_preload_required_rate));
|
||||
CMD2_ANY ("pieces.preload.type", std::tr1::bind(&CM_t::preload_type, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.type.set", std::tr1::bind(&CM_t::set_preload_type, chunkManager, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.preload.min_size", std::tr1::bind(&CM_t::preload_min_size, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.min_size.set", std::tr1::bind(&CM_t::set_preload_min_size, chunkManager, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.preload.min_rate", std::tr1::bind(&CM_t::preload_required_rate, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.min_rate.set", std::tr1::bind(&CM_t::set_preload_required_rate, chunkManager, std::tr1::placeholders::_2));
|
||||
|
||||
ADD_COMMAND_VOID("pieces.memory.current", rak::make_mem_fun(chunkManager, &CM_t::memory_usage));
|
||||
ADD_COMMAND_VOID("pieces.memory.max", rak::make_mem_fun(chunkManager, &CM_t::max_memory_usage));
|
||||
ADD_COMMAND_VALUE_UN("pieces.memory.max.set", rak::make_mem_fun(chunkManager, &CM_t::set_max_memory_usage));
|
||||
ADD_COMMAND_VOID("pieces.stats_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_preloaded));
|
||||
ADD_COMMAND_VOID("pieces.stats_not_preloaded", rak::make_mem_fun(chunkManager, &CM_t::stats_not_preloaded));
|
||||
CMD2_ANY ("pieces.memory.current", std::tr1::bind(&CM_t::memory_usage, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.max", std::tr1::bind(&CM_t::max_memory_usage, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.memory.max.set", std::tr1::bind(&CM_t::set_max_memory_usage, chunkManager, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.stats_preloaded", std::tr1::bind(&CM_t::stats_preloaded, chunkManager));
|
||||
CMD2_ANY ("pieces.stats_not_preloaded", std::tr1::bind(&CM_t::stats_not_preloaded, chunkManager));
|
||||
|
||||
CMD2_VAR_STRING ("directory.default", "./");
|
||||
|
||||
ADD_VARIABLE_STRING("directory", "./");
|
||||
// TODO: Clean up.
|
||||
CMD2_ANY ("get_session", std::tr1::bind(&core::DownloadStore::path, dStore));
|
||||
CMD2_ANY_STRING_V("set_session", std::tr1::bind(&core::DownloadStore::set_path, dStore, std::tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("session", std::tr1::bind(&core::DownloadStore::set_path, dStore, std::tr1::placeholders::_2));
|
||||
|
||||
ADD_COMMAND_STRING_TRI("session", rak::make_mem_fun(dStore, &core::DownloadStore::set_path), rak::make_mem_fun(dStore, &core::DownloadStore::path));
|
||||
ADD_COMMAND_VOID("session_save", rak::make_mem_fun(dList, &core::DownloadList::session_save));
|
||||
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));
|
||||
@@ -239,6 +242,7 @@ initialize_command_local() {
|
||||
CMD2_ANY_STRING("log.execute", std::tr1::bind(&apply_log, std::tr1::placeholders::_2, 0));
|
||||
CMD2_ANY_STRING("log.xmlrpc", std::tr1::bind(&apply_log, std::tr1::placeholders::_2, 1));
|
||||
|
||||
// TODO: Convert to new command types:
|
||||
*rpc::Command::argument(0) = "placeholder.0";
|
||||
*rpc::Command::argument(1) = "placeholder.1";
|
||||
*rpc::Command::argument(2) = "placeholder.2";
|
||||
@@ -248,5 +252,5 @@ initialize_command_local() {
|
||||
CMD_OBJ_P("argument.2", get_generic, rpc::Command::argument(2));
|
||||
CMD_OBJ_P("argument.3", get_generic, rpc::Command::argument(3));
|
||||
|
||||
CMD_N_LIST("group.insert", rak::ptr_fn(&group_insert));
|
||||
CMD2_ANY_LIST ("group.insert", std::tr1::bind(&group_insert, std::tr1::placeholders::_2));
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2007, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
#include "command_helpers.h"
|
||||
#include "rpc/command_variable.h"
|
||||
|
||||
// torrent::Object
|
||||
// list_push_back(__UNUSED rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
|
||||
|
||||
void
|
||||
initialize_command_object() {
|
||||
// CMD_N ("method.insert", rak::ptr_fn(&system_method_insert));
|
||||
// CMD_N_STRING("method.erase", rak::ptr_fn(&system_method_erase));
|
||||
}
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "command_helpers.h"
|
||||
|
||||
torrent::Object
|
||||
cmd_scheduler_simple_added(core::Download* download, const torrent::Object& rawArgs) {
|
||||
cmd_scheduler_simple_added(core::Download* download) {
|
||||
unsigned int numActive = (*control->view_manager()->find("active"))->size_visible();
|
||||
int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
|
||||
|
||||
@@ -61,7 +61,7 @@ cmd_scheduler_simple_added(core::Download* download, const torrent::Object& rawA
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_scheduler_simple_removed(core::Download* download, const torrent::Object& rawArgs) {
|
||||
cmd_scheduler_simple_removed(core::Download* download) {
|
||||
control->core()->download_list()->pause(download);
|
||||
|
||||
core::View* viewActive = *control->view_manager()->find("active");
|
||||
@@ -84,7 +84,7 @@ cmd_scheduler_simple_removed(core::Download* download, const torrent::Object& ra
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_scheduler_simple_update(core::Download* download, const torrent::Object& rawArgs) {
|
||||
cmd_scheduler_simple_update(core::Download* download) {
|
||||
core::View* viewActive = *control->view_manager()->find("active");
|
||||
core::View* viewStarted = *control->view_manager()->find("started");
|
||||
|
||||
@@ -114,13 +114,9 @@ cmd_scheduler_simple_update(core::Download* download, const torrent::Object& raw
|
||||
|
||||
void
|
||||
initialize_command_scheduler() {
|
||||
// core::DownloadList* dList = control->core()->download_list();
|
||||
CMD2_VAR_VALUE("scheduler.max_active", int64_t(-1));
|
||||
|
||||
// CMD_G("scheduler.active", rak::bind_ptr_fn(&cmd_call, "view.size=active"));
|
||||
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("scheduler.max_active", "value", (int64_t)-1));
|
||||
|
||||
CMD_D_ANY("scheduler.simple.added", rak::ptr_fn(&cmd_scheduler_simple_added));
|
||||
CMD_D_ANY("scheduler.simple.removed", rak::ptr_fn(&cmd_scheduler_simple_removed));
|
||||
CMD_D_ANY("scheduler.simple.update", rak::ptr_fn(&cmd_scheduler_simple_update));
|
||||
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));
|
||||
}
|
||||
|
||||
+15
-49
@@ -45,57 +45,23 @@
|
||||
#include "control.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
void
|
||||
apply_t_set_enabled(torrent::Tracker* tracker, int64_t state) {
|
||||
if (state)
|
||||
tracker->enable();
|
||||
else
|
||||
tracker->disable();
|
||||
}
|
||||
|
||||
#define ADD_CT_SLOT(key, function, slot, parm, doc) \
|
||||
commandTrackerSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandTrackerSlotsItr++, &rpc::CommandSlot<torrent::Tracker*>::function, rpc::CommandMap::flag_dont_delete, parm, doc);
|
||||
|
||||
#define ADD_CT_SLOT_PUBLIC(key, function, slot, parm, doc) \
|
||||
commandTrackerSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_type(key, commandTrackerSlotsItr++, &rpc::CommandSlot<torrent::Tracker*>::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, parm, doc);
|
||||
|
||||
#define ADD_CT_VOID(key, slot) \
|
||||
ADD_CT_SLOT_PUBLIC("t." key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(slot), "i:", "")
|
||||
|
||||
#define ADD_CT_VOID_UNI(key, get) \
|
||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||
|
||||
#define ADD_CT_VALUE_UNI(key, get) \
|
||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||
|
||||
#define ADD_CT_VALUE_BI(key, set, get) \
|
||||
ADD_CT_SLOT_PUBLIC("t.set_" key, call_value, rpc::object_value_fn<torrent::Tracker*>(set), "i:i", "") \
|
||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||
|
||||
#define ADD_CT_BOOL(key, set, get) \
|
||||
ADD_CT_SLOT_PUBLIC("t.set_" key, call_value, rpc::object_value_fn<torrent::Tracker*>(set), "i:i", "") \
|
||||
ADD_CT_SLOT_PUBLIC("t.is_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "i:", "")
|
||||
|
||||
#define ADD_CT_STRING_UNI(key, get) \
|
||||
ADD_CT_SLOT_PUBLIC("t.get_" key, call_unknown, rpc::object_void_fn<torrent::Tracker*>(get), "s:", "")
|
||||
|
||||
void
|
||||
initialize_command_tracker() {
|
||||
ADD_CT_STRING_UNI("url", std::mem_fun(&torrent::Tracker::url));
|
||||
ADD_CT_VOID_UNI("group", std::mem_fun(&torrent::Tracker::group));
|
||||
ADD_CT_VOID_UNI("type", std::mem_fun(&torrent::Tracker::type));
|
||||
ADD_CT_STRING_UNI("id", std::mem_fun(&torrent::Tracker::tracker_id));
|
||||
CMD2_TRACKER ("t.is_open", std::tr1::bind(&torrent::Tracker::is_busy, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_enabled", std::tr1::bind(&torrent::Tracker::is_enabled, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER_VALUE_V("t.is_enabled.set", std::tr1::bind(&torrent::Tracker::set_enabled, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
CMD2_TRACKER_V ("t.enable", std::tr1::bind(&torrent::Tracker::enable, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER_V ("t.disable", std::tr1::bind(&torrent::Tracker::disable, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CT_VOID("is_open", std::mem_fun(&torrent::Tracker::is_busy));
|
||||
ADD_CT_BOOL("enabled", std::ptr_fun(&apply_t_set_enabled), std::mem_fun(&torrent::Tracker::is_enabled));
|
||||
|
||||
ADD_CT_VOID_UNI("normal_interval", std::mem_fun(&torrent::Tracker::normal_interval));
|
||||
ADD_CT_VOID_UNI("min_interval", std::mem_fun(&torrent::Tracker::min_interval));
|
||||
CMD2_TRACKER ("t.url", std::tr1::bind(&torrent::Tracker::url, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.group", std::tr1::bind(&torrent::Tracker::group, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.type", std::tr1::bind(&torrent::Tracker::type, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.id", std::tr1::bind(&torrent::Tracker::tracker_id, std::tr1::placeholders::_1));
|
||||
|
||||
ADD_CT_VOID_UNI("scrape_time_last", std::mem_fun(&torrent::Tracker::scrape_time_last));
|
||||
ADD_CT_VOID_UNI("scrape_complete", std::mem_fun(&torrent::Tracker::scrape_complete));
|
||||
ADD_CT_VOID_UNI("scrape_incomplete", std::mem_fun(&torrent::Tracker::scrape_incomplete));
|
||||
ADD_CT_VOID_UNI("scrape_downloaded", std::mem_fun(&torrent::Tracker::scrape_downloaded));
|
||||
CMD2_TRACKER ("t.normal_interval", std::tr1::bind(&torrent::Tracker::normal_interval, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.min_interval", std::tr1::bind(&torrent::Tracker::min_interval, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_time_last", std::tr1::bind(&torrent::Tracker::scrape_time_last, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_complete", std::tr1::bind(&torrent::Tracker::scrape_complete, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_incomplete", std::tr1::bind(&torrent::Tracker::scrape_incomplete, std::tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_downloaded", std::tr1::bind(&torrent::Tracker::scrape_downloaded, std::tr1::placeholders::_1));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ DownloadFactory::DownloadFactory(Manager* m) :
|
||||
|
||||
m_variables["connection_leech"] = rpc::call_command_void("connection_leech");
|
||||
m_variables["connection_seed"] = rpc::call_command_void("connection_seed");
|
||||
m_variables["directory"] = rpc::call_command_void("get_directory");
|
||||
m_variables["directory"] = rpc::call_command_void("directory.default");
|
||||
m_variables["tied_to_file"] = torrent::Object((int64_t)false);
|
||||
}
|
||||
|
||||
|
||||
+52
-8
@@ -89,7 +89,7 @@ parse_options(Control* c, int argc, char** argv) {
|
||||
optionParser.insert_flag('D', OptionParser::Slot());
|
||||
|
||||
optionParser.insert_option('b', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "network.bind_address.set"));
|
||||
optionParser.insert_option('d', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "directory"));
|
||||
optionParser.insert_option('d', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "directory.default.set"));
|
||||
optionParser.insert_option('i', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "ip"));
|
||||
optionParser.insert_option('p', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "port_range.set"));
|
||||
optionParser.insert_option('s', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "session"));
|
||||
@@ -312,16 +312,16 @@ main(int argc, char** argv) {
|
||||
//
|
||||
// List of cleaned up files:
|
||||
// - command_download.cc
|
||||
// - command_dynamic.cc
|
||||
// - command_events.cc
|
||||
// - command_file.cc
|
||||
// * command_dynamic.cc
|
||||
// * command_events.cc
|
||||
// * command_file.cc
|
||||
// - command_helpers.cc
|
||||
// - command_local.cc
|
||||
// + command_local.cc
|
||||
// * command_network.cc
|
||||
// - command_object.cc
|
||||
// * command_object.cc
|
||||
// - command_peer.cc
|
||||
// - command_scheduler.cc
|
||||
// - command_tracker.cc
|
||||
// * command_scheduler.cc
|
||||
// * command_tracker.cc
|
||||
// - command_ui.cc
|
||||
|
||||
"method.insert = system.method.insert,redirect|const,method.insert\n"
|
||||
@@ -399,6 +399,14 @@ main(int argc, char** argv) {
|
||||
"method.insert = get_dht_throttle,redirect|const,dht.throttle\n"
|
||||
"method.insert = set_dht_throttle,redirect|const,dht.throttle.set\n"
|
||||
|
||||
"method.insert = directory,redirect|const,directory.default.set\n"
|
||||
"method.insert = get_directory,redirect|const,directory.default\n"
|
||||
"method.insert = set_directory,redirect|const,directory.default.set\n"
|
||||
|
||||
//
|
||||
// Download:
|
||||
//
|
||||
|
||||
"method.insert = d.get_hash,redirect|const,d.hash\n"
|
||||
"method.insert = d.get_local_id,redirect|const,d.local_id\n"
|
||||
"method.insert = d.get_local_id_html,redirect|const,d.local_id_html\n"
|
||||
@@ -417,6 +425,42 @@ 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"
|
||||
|
||||
//
|
||||
// Tracker:
|
||||
//
|
||||
|
||||
"method.insert = t.get_group,redirect|const,t.get_group\n"
|
||||
"method.insert = t.get_id,redirect|const,t.get_id\n"
|
||||
"method.insert = t.get_min_interval,redirect|const,t.get_min_interval\n"
|
||||
"method.insert = t.get_normal_interval,redirect|const,t.get_normal_interval\n"
|
||||
"method.insert = t.get_scrape_complete,redirect|const,t.get_scrape_complete\n"
|
||||
"method.insert = t.get_scrape_downloaded,redirect|const,t.get_scrape_downloaded\n"
|
||||
"method.insert = t.get_scrape_incomplete,redirect|const,t.get_scrape_incomplete\n"
|
||||
"method.insert = t.get_scrape_time_last,redirect|const,t.get_scrape_time_last\n"
|
||||
"method.insert = t.get_type,redirect|const,t.get_type\n"
|
||||
"method.insert = t.get_url,redirect|const,t.get_url\n"
|
||||
|
||||
//
|
||||
// Tracker:
|
||||
//
|
||||
|
||||
"method.insert = f.get_completed_chunks,redirect|const,f.completed_chunks\n"
|
||||
"method.insert = f.get_frozen_path,redirect|const,f.frozen_path\n"
|
||||
"method.insert = f.get_last_touched,redirect|const,f.last_touched\n"
|
||||
"method.insert = f.get_match_depth_next,redirect|const,f.match_depth_next\n"
|
||||
"method.insert = f.get_match_depth_prev,redirect|const,f.match_depth_prev\n"
|
||||
"method.insert = f.get_offset,redirect|const,f.offset\n"
|
||||
"method.insert = f.get_path,redirect|const,f.path\n"
|
||||
"method.insert = f.get_path_components,redirect|const,f.path_components\n"
|
||||
"method.insert = f.get_path_depth,redirect|const,f.path_depth\n"
|
||||
"method.insert = f.get_priority,redirect|const,f.priority\n"
|
||||
"method.insert = f.get_range_first,redirect|const,f.range_first\n"
|
||||
"method.insert = f.get_range_second,redirect|const,f.range_second\n"
|
||||
"method.insert = f.get_size_bytes,redirect|const,f.size_bytes\n"
|
||||
"method.insert = f.get_size_chunks,redirect|const,f.size_chunks\n"
|
||||
"method.insert = f.set_priority,redirect|const,f.priority.set\n"
|
||||
"method.insert = fi.get_filename_last,redirect|const,fi.filename_last\n"
|
||||
|
||||
// Functions that might not get depracted as they are nice for
|
||||
// configuration files, and thus might do with just some
|
||||
// cleanup.
|
||||
|
||||
+18
-6
@@ -161,18 +161,30 @@ template <> struct target_type_id<Command::file_itr_slot> { static const in
|
||||
template <> struct target_type_id<Command::download_pair_slot> { static const int value = Command::target_download_pair; };
|
||||
|
||||
template <> struct target_type_id<> { static const int value = Command::target_generic; };
|
||||
template <> struct target_type_id<target_type> { static const int value = Command::target_any; };
|
||||
template <> struct target_type_id<core::Download*> { static const int value = Command::target_download; };
|
||||
template <> struct target_type_id<torrent::Peer*> { static const int value = Command::target_peer; };
|
||||
template <> struct target_type_id<torrent::Tracker*> { static const int value = Command::target_tracker; };
|
||||
template <> struct target_type_id<torrent::File*> { static const int value = Command::target_file; };
|
||||
template <> struct target_type_id<torrent::FileListIterator*> { static const int value = Command::target_file_itr; };
|
||||
template <> struct target_type_id<target_type> { static const int value = Command::target_any; static const int proper_type = 1; };
|
||||
template <> struct target_type_id<core::Download*> { static const int value = Command::target_download; static const int proper_type = 1; };
|
||||
template <> struct target_type_id<torrent::Peer*> { static const int value = Command::target_peer; static const int proper_type = 1; };
|
||||
template <> struct target_type_id<torrent::Tracker*> { static const int value = Command::target_tracker; static const int proper_type = 1; };
|
||||
template <> struct target_type_id<torrent::File*> { static const int value = Command::target_file; static const int proper_type = 1; };
|
||||
template <> struct target_type_id<torrent::FileListIterator*> { static const int value = Command::target_file_itr; static const int proper_type = 1; };
|
||||
|
||||
template <> struct target_type_id<core::Download*, core::Download*> { static const int value = Command::target_download_pair; };
|
||||
|
||||
template <typename T> inline bool
|
||||
is_target_compatible(const target_type& target) { return target.first == target_type_id<T>::value; }
|
||||
|
||||
template <> inline bool
|
||||
is_target_compatible<target_type>(const target_type& target) { return true; }
|
||||
|
||||
// Splitting pairs into separate targets.
|
||||
inline bool is_target_pair(const target_type& target) { return target.first >= Command::target_download_pair; }
|
||||
|
||||
template <typename T> inline T
|
||||
get_target_cast(target_type target, int type = target_type_id<T>::value) { return (T)target.second; }
|
||||
template <> inline target_type
|
||||
get_target_cast<target_type>(target_type target, int type) { return target; }
|
||||
|
||||
|
||||
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); }
|
||||
|
||||
|
||||
+45
-18
@@ -41,15 +41,31 @@
|
||||
|
||||
#include "command_new_slot.h"
|
||||
|
||||
#define COMMAND_BASE_TEMPLATE_DEFINE(func_name) \
|
||||
template const torrent::Object func_name<target_type>(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
template const torrent::Object func_name<core::Download*>(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
template const torrent::Object func_name<torrent::Peer*>(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
template const torrent::Object func_name<torrent::Tracker*>(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
template const torrent::Object func_name<torrent::File*>(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
template const torrent::Object func_name<torrent::FileListIterator*>(Command* rawCommand, target_type target, const torrent::Object& args);
|
||||
|
||||
namespace rpc {
|
||||
|
||||
const torrent::Object
|
||||
command_base_call_any(Command* rawCommand, target_type target, const torrent::Object& args) {
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_function>()(target, args);
|
||||
template <typename T> const torrent::Object
|
||||
command_base_call(Command* rawCommand, target_type target, const torrent::Object& args) {
|
||||
if (!is_target_compatible<T>(target))
|
||||
throw torrent::input_error("Target of wrong type.");
|
||||
|
||||
return command_base::_call<typename command_function<T>::type, T>(rawCommand, target, args);
|
||||
}
|
||||
|
||||
const torrent::Object
|
||||
command_base_call_any_value_base(Command* rawCommand, target_type target, const torrent::Object& rawArgs, int base, int unit) {
|
||||
COMMAND_BASE_TEMPLATE_DEFINE(command_base_call);
|
||||
|
||||
template <typename T> const torrent::Object
|
||||
command_base_call_value_base(Command* rawCommand, target_type target, const torrent::Object& rawArgs, int base, int unit) {
|
||||
if (!is_target_compatible<T>(target))
|
||||
throw torrent::input_error("Target of wrong type.");
|
||||
|
||||
const torrent::Object& arg = convert_to_single_argument(rawArgs);
|
||||
|
||||
if (arg.type() == torrent::Object::TYPE_STRING) {
|
||||
@@ -58,40 +74,51 @@ command_base_call_any_value_base(Command* rawCommand, target_type target, const
|
||||
if (!parse_whole_value_nothrow(arg.as_string().c_str(), &val, base, unit))
|
||||
throw torrent::input_error("Not a value.");
|
||||
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_value_function>()(target, val);
|
||||
return command_base::_call<typename command_value_function<T>::type, T>(rawCommand, target, val);
|
||||
}
|
||||
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_value_function>()(target, arg.as_value());
|
||||
return command_base::_call<typename command_value_function<T>::type, T>(rawCommand, target, arg.as_value());
|
||||
}
|
||||
|
||||
const torrent::Object
|
||||
command_base_call_any_value(Command* rawCommand, target_type target, const torrent::Object& rawArgs) {
|
||||
return command_base_call_any_value_base(rawCommand, target, rawArgs, 0, 1);
|
||||
template <typename T> const torrent::Object
|
||||
command_base_call_value(Command* rawCommand, target_type target, const torrent::Object& rawArgs) {
|
||||
return command_base_call_value_base<T>(rawCommand, target, rawArgs, 0, 1);
|
||||
}
|
||||
|
||||
COMMAND_BASE_TEMPLATE_DEFINE(command_base_call_value);
|
||||
|
||||
template <typename T> const torrent::Object
|
||||
command_base_call_string(Command* rawCommand, target_type target, const torrent::Object& rawArgs) {
|
||||
if (!is_target_compatible<T>(target))
|
||||
throw torrent::input_error("Target of wrong type.");
|
||||
|
||||
const torrent::Object
|
||||
command_base_call_any_string(Command* rawCommand, target_type target, const torrent::Object& rawArgs) {
|
||||
const torrent::Object& arg = convert_to_single_argument(rawArgs);
|
||||
|
||||
if (arg.type() == torrent::Object::TYPE_RAW_STRING)
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_string_function>()(target, arg.as_raw_string().as_string());
|
||||
return command_base::_call<typename command_string_function<T>::type, T>(rawCommand, target, arg.as_raw_string().as_string());
|
||||
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_string_function>()(target, arg.as_string());
|
||||
return command_base::_call<typename command_string_function<T>::type, T>(rawCommand, target, arg.as_string());
|
||||
}
|
||||
|
||||
const torrent::Object
|
||||
command_base_call_any_list(Command* rawCommand, target_type target, const torrent::Object& rawArgs) {
|
||||
COMMAND_BASE_TEMPLATE_DEFINE(command_base_call_string);
|
||||
|
||||
template <typename T> const torrent::Object
|
||||
command_base_call_list(Command* rawCommand, target_type target, const torrent::Object& rawArgs) {
|
||||
if (!is_target_compatible<T>(target))
|
||||
throw torrent::input_error("Target of wrong type.");
|
||||
|
||||
if (rawArgs.type() != torrent::Object::TYPE_LIST) {
|
||||
torrent::Object::list_type arg;
|
||||
|
||||
if (!rawArgs.is_empty())
|
||||
arg.push_back(rawArgs);
|
||||
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_list_function>()(target, arg);
|
||||
return command_base::_call<typename command_list_function<T>::type, T>(rawCommand, target, arg);
|
||||
}
|
||||
|
||||
return static_cast<command_base*>(rawCommand)->_pod<any_list_function>()(target, rawArgs.as_list());
|
||||
return command_base::_call<typename command_list_function<T>::type, T>(rawCommand, target, rawArgs.as_list());
|
||||
}
|
||||
|
||||
COMMAND_BASE_TEMPLATE_DEFINE(command_base_call_list);
|
||||
|
||||
}
|
||||
|
||||
+33
-26
@@ -59,7 +59,7 @@ typedef const torrent::Object (*command_base_call_type)(Command*, target_type, c
|
||||
typedef std::tr1::function<torrent::Object (target_type, const torrent::Object&)> base_function;
|
||||
|
||||
template <typename tmpl> struct command_base_is_valid {};
|
||||
template <typename tmpl_type, command_base_call_type tmpl_func> struct command_base_is_type {};
|
||||
template <command_base_call_type tmpl_func> struct command_base_is_type {};
|
||||
|
||||
class command_base : public Command {
|
||||
public:
|
||||
@@ -76,6 +76,11 @@ public:
|
||||
// have no idea atm.
|
||||
template <typename tmpl> tmpl& _pod() { return reinterpret_cast<tmpl&>(t_pod); }
|
||||
|
||||
template <typename Func, typename T, typename Args>
|
||||
static const torrent::Object _call(Command* cmd, target_type target, Args args) {
|
||||
return static_cast<command_base*>(cmd)->_pod<Func>()(get_target_cast<T>(target), args);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
union {
|
||||
@@ -83,35 +88,37 @@ protected:
|
||||
};
|
||||
};
|
||||
|
||||
#define COMMAND_BASE_TYPE(func_type, func_parm) \
|
||||
typedef std::tr1::function<func_parm> func_type; \
|
||||
template <> struct command_base_is_valid<func_type> { static const int value = 1; };
|
||||
#define COMMAND_BASE_TEMPLATE_TYPE(func_type, func_parm) \
|
||||
template <typename T, int proper = target_type_id<T>::proper_type> struct func_type { typedef std::tr1::function<func_parm> type; }; \
|
||||
\
|
||||
template <> struct command_base_is_valid<func_type<target_type>::type> { static const int value = 1; }; \
|
||||
template <> struct command_base_is_valid<func_type<core::Download*>::type> { static const int value = 1; }; \
|
||||
template <> struct command_base_is_valid<func_type<torrent::Peer*>::type> { static const int value = 1; }; \
|
||||
template <> struct command_base_is_valid<func_type<torrent::Tracker*>::type> { static const int value = 1; }; \
|
||||
template <> struct command_base_is_valid<func_type<torrent::File*>::type> { static const int value = 1; }; \
|
||||
template <> struct command_base_is_valid<func_type<torrent::FileListIterator*>::type> { static const int value = 1; };
|
||||
|
||||
#define COMMAND_BASE_CALL(func_name, func_type) \
|
||||
const torrent::Object func_name(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
template <> struct command_base_is_type<func_type, func_name> { static const int value = 1; };
|
||||
// template <typename Q> struct command_base_is_valid<typename func_type<Q>::type > { static const int value = 1; };
|
||||
|
||||
// template <> struct command_base_is_valid<base_function> { static const int value = 1; };
|
||||
COMMAND_BASE_TEMPLATE_TYPE(command_function, torrent::Object (T, const torrent::Object&));
|
||||
COMMAND_BASE_TEMPLATE_TYPE(command_value_function, torrent::Object (T, const torrent::Object::value_type&));
|
||||
COMMAND_BASE_TEMPLATE_TYPE(command_string_function, torrent::Object (T, const std::string&));
|
||||
COMMAND_BASE_TEMPLATE_TYPE(command_list_function, torrent::Object (T, const torrent::Object::list_type&));
|
||||
|
||||
// const torrent::Object command_base_call_any(Command* rawCommand, target_type target, const torrent::Object& args);
|
||||
// template <> struct command_base_is_type<any_function, command_base_call_any> { static const int value = 1; };
|
||||
#define COMMAND_BASE_TEMPLATE_CALL(func_name, func_type) \
|
||||
template <typename T> const torrent::Object func_name(Command* rawCommand, target_type target, const torrent::Object& args); \
|
||||
\
|
||||
template <> struct command_base_is_type<func_name<target_type> > { static const int value = 1; typedef func_type<target_type>::type type; }; \
|
||||
template <> struct command_base_is_type<func_name<core::Download*> > { static const int value = 1; typedef func_type<core::Download*>::type type; }; \
|
||||
template <> struct command_base_is_type<func_name<torrent::Peer*> > { static const int value = 1; typedef func_type<torrent::Peer*>::type type; }; \
|
||||
template <> struct command_base_is_type<func_name<torrent::Tracker*> > { static const int value = 1; typedef func_type<torrent::Tracker*>::type type; }; \
|
||||
template <> struct command_base_is_type<func_name<torrent::File*> > { static const int value = 1; typedef func_type<torrent::File*>::type type; }; \
|
||||
template <> struct command_base_is_type<func_name<torrent::FileListIterator*> > { static const int value = 1; typedef func_type<torrent::FileListIterator*>::type type; };
|
||||
|
||||
//
|
||||
// Declare valid parameters and functions:
|
||||
//
|
||||
|
||||
// typedef std::tr1::function<torrent::Object (target_type, const torrent::Object&)> any_function;
|
||||
// typedef std::tr1::function<torrent::Object (target_type, const std::string&)> any_string_function;
|
||||
|
||||
COMMAND_BASE_TYPE(any_function, torrent::Object (target_type, const torrent::Object&));
|
||||
COMMAND_BASE_TYPE(any_value_function, torrent::Object (target_type, const torrent::Object::value_type&));
|
||||
COMMAND_BASE_TYPE(any_string_function, torrent::Object (target_type, const std::string&));
|
||||
COMMAND_BASE_TYPE(any_list_function, torrent::Object (target_type, const torrent::Object::list_type&));
|
||||
|
||||
COMMAND_BASE_CALL(command_base_call_any, any_function);
|
||||
COMMAND_BASE_CALL(command_base_call_any_value, any_value_function);
|
||||
COMMAND_BASE_CALL(command_base_call_any_string, any_string_function);
|
||||
COMMAND_BASE_CALL(command_base_call_any_list, any_list_function);
|
||||
COMMAND_BASE_TEMPLATE_CALL(command_base_call, command_function);
|
||||
COMMAND_BASE_TEMPLATE_CALL(command_base_call_value, command_value_function);
|
||||
COMMAND_BASE_TEMPLATE_CALL(command_base_call_string, command_string_function);
|
||||
COMMAND_BASE_TEMPLATE_CALL(command_base_call_list, command_list_function);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ DownloadList::receive_view_input(Input type) {
|
||||
case INPUT_CHANGE_DIRECTORY:
|
||||
title = "change_directory";
|
||||
|
||||
input->str() = rpc::call_command_string("get_directory");
|
||||
input->str() = rpc::call_command_string("directory.default");
|
||||
input->set_pos(input->str().length());
|
||||
|
||||
break;
|
||||
|
||||
@@ -92,9 +92,9 @@ 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.get_size_bytes=,---"));
|
||||
element->push_column("Chunks:", te_command("cat=$f.get_completed_chunks=,\" / \",$f.get_size_chunks="));
|
||||
element->push_column("Range:", te_command("cat=$f.get_range_first=,\" - \",$f.get_range_second="));
|
||||
element->push_column("Size:", te_command("if=$fi.is_file=,$to_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("");
|
||||
|
||||
element->push_column("Queued:", te_command("cat=\"$if=$f.is_create_queued=,create\",\" \",\"$if=$f.is_resize_queued=,resize\""));
|
||||
|
||||
Reference in New Issue
Block a user