mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-16 23:22:31 +00:00
* Dynamically sized SCGI read buffer.
* Added 'call_command' that takes a view as the first parameter and then a list of commands. It will return a list of lists containing the results from those commands. * Fixed the xmlrpc-c-config usage. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@954 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+32
-18
@@ -270,33 +270,47 @@ apply_download_list(const torrent::Object& rawArgs) {
|
||||
torrent::Object
|
||||
apply_call_download(const torrent::Object& rawArgs) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
torrent::Object::list_type::const_iterator argsItr = args.begin();
|
||||
|
||||
if (argsItr == args.end() || ++argsItr == args.end())
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
const torrent::Object::string_type& infoHash = args.begin()->as_string();
|
||||
// const torrent::Object::string_type& infoHash = args.begin()->as_string();
|
||||
|
||||
core::DownloadList* dList = control->core()->download_list();
|
||||
core::DownloadList::iterator dItr = dList->end();
|
||||
// core::DownloadList* dList = control->core()->download_list();
|
||||
// core::DownloadList::iterator dItr = dList->end();
|
||||
|
||||
if (infoHash.size() == 40)
|
||||
dItr = dList->find_hex(infoHash.c_str());
|
||||
// if (infoHash.size() == 40)
|
||||
// dItr = dList->find_hex(infoHash.c_str());
|
||||
|
||||
if (dItr == dList->end())
|
||||
throw torrent::input_error("Not a valid info-hash.");
|
||||
// if (dItr == dList->end())
|
||||
// throw torrent::input_error("Not a valid info-hash.");
|
||||
|
||||
torrent::Object result;
|
||||
const char* command = (argsItr++)->as_string().c_str();
|
||||
core::ViewManager* viewManager = control->view_manager();
|
||||
core::ViewManager::iterator viewItr;
|
||||
|
||||
if (argsItr == args.end())
|
||||
result = rpc::call_command_d(command, *dItr, torrent::Object());
|
||||
else if (argsItr == --args.end())
|
||||
result = rpc::call_command_d(command, *dItr, *argsItr);
|
||||
if (!args.front().as_string().empty())
|
||||
viewItr = viewManager->find(args.front().as_string());
|
||||
else
|
||||
result = rpc::call_command_d_range(command, *dItr, argsItr, args.end());
|
||||
viewItr = viewManager->find("default");
|
||||
|
||||
return result;
|
||||
if (viewItr == viewManager->end())
|
||||
throw torrent::input_error("Could not find view.");
|
||||
|
||||
// Add some pre-parsing of the commands, so we don't spend time
|
||||
// parsing and searching command map for every single call.
|
||||
torrent::Object resultRaw(torrent::Object::TYPE_LIST);
|
||||
torrent::Object::list_type& result = resultRaw.as_list();
|
||||
|
||||
for (core::View::const_iterator vItr = (*viewItr)->begin_visible(), vLast = (*viewItr)->end_visible(); vItr != vLast; vItr++) {
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
|
||||
|
||||
for (torrent::Object::list_type::const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
|
||||
const std::string& cmd = cItr->as_string();
|
||||
row.push_back(rpc::parse_command_d_single(*vItr, cmd.c_str(), cmd.c_str() + cmd.size()));
|
||||
}
|
||||
}
|
||||
|
||||
return resultRaw;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -340,5 +354,5 @@ initialize_command_events() {
|
||||
ADD_COMMAND_VALUE_UN("close_low_diskspace", std::ptr_fun(&apply_close_low_diskspace));
|
||||
|
||||
ADD_COMMAND_LIST("download_list", rak::ptr_fn(&apply_download_list));
|
||||
// ADD_COMMAND_LIST("call_download", rak::ptr_fn(&apply_call_download));
|
||||
ADD_COMMAND_LIST("call_download", rak::ptr_fn(&apply_call_download));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user