mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-06 22:29:23 +00:00
* Cycle the order in which downloads are handled during ticks to
ensure resource usage gets spread out over time. * Changed element_file_list.cc to use te_command. * File commands on file list iterators will be called on the File pointed to. * Fixed some sigc++ 2.1 compile errors. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@992 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include <rak/file_stat.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/hash_string.h>
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <rak/path.h>
|
||||
#include <torrent/data/file.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
|
||||
#include "core/manager.h"
|
||||
|
||||
@@ -85,6 +86,17 @@ apply_f_path_depth(torrent::File* file) {
|
||||
return (int64_t)file->path()->size();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_fi_filename_last(torrent::FileListIterator* itr) {
|
||||
if (itr->file()->path()->empty())
|
||||
return "EMPTY";
|
||||
|
||||
if (itr->depth() >= itr->file()->path()->size())
|
||||
return "ERROR";
|
||||
|
||||
return itr->file()->path()->at(itr->depth());
|
||||
}
|
||||
|
||||
#define ADD_CF_SLOT(key, function, slot, parm, doc) \
|
||||
commandFileSlotsItr->set_slot(slot); \
|
||||
rpc::commands.insert_file(key, commandFileSlotsItr++, &rpc::CommandSlot<torrent::File*>::function, rpc::CommandMap::flag_dont_delete, parm, doc);
|
||||
@@ -106,6 +118,16 @@ apply_f_path_depth(torrent::File* file) {
|
||||
#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_file_itr(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.get_" 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_UNI("is_created", std::mem_fun(&torrent::File::is_created));
|
||||
@@ -130,4 +152,8 @@ initialize_command_file() {
|
||||
ADD_CF_VALUE_UNI("match_depth_next", std::mem_fun(&torrent::File::match_depth_next));
|
||||
|
||||
ADD_CF_VALUE_UNI("last_touched", std::mem_fun(&torrent::File::last_touched));
|
||||
|
||||
ADD_CFI_VOID("filename_last", &apply_fi_filename_last);
|
||||
|
||||
ADD_CFI_VALUE("is_file", std::mem_fun(&torrent::FileListIterator::is_file));
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <rak/functional.h>
|
||||
#include <rak/functional_fun.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
|
||||
#include "core/manager.h"
|
||||
#include "core/view_manager.h"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <curl/multi.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "rak/functional.h"
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
#include <sigc++/signal.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/functional.h>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <rak/functional.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
#include <torrent/http.h>
|
||||
|
||||
#include "rak/functional.h"
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@
|
||||
#include <rak/regex.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/error.h>
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <rak/functional.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/download.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/http.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
#include <getopt.h>
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
|
||||
#include "option_parser.h"
|
||||
|
||||
|
||||
+14
-2
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
|
||||
#include "command.h"
|
||||
#include "command_map.h"
|
||||
@@ -134,6 +135,7 @@ CommandMap::insert(key_type key, const command_map_data_type src) {
|
||||
case target_any: itr->second.m_anySlot = src.m_anySlot; break;
|
||||
case target_download: itr->second.m_downloadSlot = src.m_downloadSlot; break;
|
||||
case target_file: itr->second.m_fileSlot = src.m_fileSlot; break;
|
||||
case target_file_itr: itr->second.m_fileItrSlot = src.m_fileItrSlot; break;
|
||||
case target_peer: itr->second.m_peerSlot = src.m_peerSlot; break;
|
||||
case target_tracker: itr->second.m_trackerSlot = src.m_trackerSlot; break;
|
||||
default: throw torrent::internal_error("CommandMap::insert(...) Invalid target.");
|
||||
@@ -147,10 +149,20 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe
|
||||
if (itr == base_type::end())
|
||||
throw torrent::input_error("Command \"" + std::string(key) + "\" does not exist.");
|
||||
|
||||
if ((itr->second.m_target != target.first && itr->second.m_target > target_any) ||
|
||||
(target.second == NULL && itr->second.m_target != target_generic && !(itr->second.m_target == target_any && target.first == target_generic)))
|
||||
if (target.second == NULL &&
|
||||
itr->second.m_target != target_generic &&
|
||||
!(itr->second.m_target == target_any && target.first == target_generic))
|
||||
throw torrent::input_error("Command type mis-match.");
|
||||
|
||||
if (itr->second.m_target != target.first && itr->second.m_target > target_any) {
|
||||
// Mismatch between the target and command type. If it is not
|
||||
// possible to convert, then throw an input error.
|
||||
if (target.first == target_file_itr && itr->second.m_target == target_file)
|
||||
target = target_type((int)target_file, static_cast<torrent::FileListIterator*>(target.second)->file());
|
||||
else
|
||||
throw torrent::input_error("Command type mis-match.");
|
||||
}
|
||||
|
||||
// This _should_ be optimized int just two calls.
|
||||
switch (itr->second.m_target) {
|
||||
case target_generic: return itr->second.m_genericSlot (itr->second.m_variable, arg);
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <rak/functional.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
|
||||
#include <rak/functional.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/object.h>
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <rak/algorithm.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/data/file.h>
|
||||
@@ -78,17 +78,6 @@ ElementFileList::ElementFileList(core::Download* d) :
|
||||
m_bindings[KEY_UP] = m_bindings['P' - '@'] = sigc::mem_fun(*this, &ElementFileList::receive_prev);
|
||||
}
|
||||
|
||||
const char*
|
||||
element_file_list_filename(const torrent::FileListIterator* itr) {
|
||||
if ((**itr)->path()->empty())
|
||||
return "EMPTY";
|
||||
|
||||
if (itr->depth() >= (**itr)->path()->size())
|
||||
return "ERROR";
|
||||
|
||||
return (**itr)->path()->at(itr->depth()).c_str();
|
||||
}
|
||||
|
||||
inline ElementText*
|
||||
element_file_list_create_info() {
|
||||
using namespace display::helpers;
|
||||
@@ -101,12 +90,13 @@ element_file_list_create_info() {
|
||||
element->push_back("File info:");
|
||||
element->push_back("");
|
||||
|
||||
element->push_column("Filename:", te_string(&element_file_list_filename));
|
||||
element->push_column("Filename:", te_command("fi.get_filename_last="));
|
||||
element->push_back("");
|
||||
|
||||
element->push_column("Size:", te_branch(&torrent::FileListIterator::is_file, te_value(&torrent::File::size_bytes, value_base::flag_xb), te_string("---")));
|
||||
element->push_column("Chunks:", te_value(&torrent::File::completed_chunks), " / ", te_value(&torrent::File::size_chunks));
|
||||
element->push_column("Range:", te_value(&torrent::File::range_first), " - ", te_value(&torrent::File::range_second));
|
||||
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->set_column_width(element->column_width() + 1);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/hash_string.h>
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "core/manager.h"
|
||||
|
||||
Reference in New Issue
Block a user