* Cleaned up torrent/download.h.

* Removed raw_value as it is redundant.

* Fixed 'greater' command and added 'equal'. Patch by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1146 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2010-03-15 23:31:58 +00:00
parent c5e839287d
commit 589c8c147b
4 changed files with 27 additions and 17 deletions
+3 -3
View File
@@ -307,11 +307,11 @@ retrieve_d_bitfield(core::Download* download) {
// Just a helper function atm.
torrent::Object
cmd_d_initialize_logs(core::Download* download) {
download->download()->signal_network_log(sigc::mem_fun(control->core(), &core::Manager::push_log_complete));
download->download()->signal_storage_error(sigc::mem_fun(control->core(), &core::Manager::push_log_complete));
download->info()->signal_network_log().connect(sigc::mem_fun(control->core(), &core::Manager::push_log_complete));
download->info()->signal_storage_error().connect(sigc::mem_fun(control->core(), &core::Manager::push_log_complete));
if (!rpc::call_command_string("log.tracker").empty())
download->download()->signal_tracker_dump(sigc::ptr_fun(&core::receive_tracker_dump));
download->info()->signal_tracker_dump().connect(sigc::ptr_fun(&core::receive_tracker_dump));
return torrent::Object();
}
+18 -8
View File
@@ -212,7 +212,7 @@ apply_or(rpc::target_type target, const torrent::Object& rawArgs) {
}
torrent::Object
apply_less(rpc::target_type target, const torrent::Object& rawArgs) {
apply_cmp(rpc::target_type target, const torrent::Object& rawArgs) {
const torrent::Object::list_type& args = rawArgs.as_list();
// We only need to check if empty() since if size() == 1 it calls
@@ -239,16 +239,25 @@ apply_less(rpc::target_type target, const torrent::Object& rawArgs) {
throw torrent::input_error("Type mismatch.");
switch (result1.type()) {
case torrent::Object::TYPE_VALUE: return result1.as_value() < result2.as_value();
case torrent::Object::TYPE_STRING: return result1.as_string() < result2.as_string();
default: return (int64_t)false;
case torrent::Object::TYPE_VALUE: return result1.as_value() - result2.as_value();
case torrent::Object::TYPE_STRING: return result1.as_string().compare(result2.as_string());
default: return torrent::Object();
}
}
// Fixme.
torrent::Object
apply_greater(rpc::target_type target, const torrent::Object& rawArgs) {
return (int64_t)!apply_less(target, rawArgs).as_value();
torrent::Object apply_less(rpc::target_type target, const torrent::Object& rawArgs) {
torrent::Object result = apply_cmp(target, rawArgs);
return result.is_value() ? result.as_value() < 0 : (int64_t)false;
}
torrent::Object apply_greater(rpc::target_type target, const torrent::Object& rawArgs) {
torrent::Object result = apply_cmp(target, rawArgs);
return result.is_value() ? result.as_value() > 0 : (int64_t)false;
}
torrent::Object apply_equal(rpc::target_type target, const torrent::Object& rawArgs) {
torrent::Object result = apply_cmp(target, rawArgs);
return result.is_value() ? result.as_value() == 0 : (int64_t)false;
}
torrent::Object
@@ -505,6 +514,7 @@ initialize_command_ui() {
ADD_ANY_LIST("less", rak::ptr_fn(&apply_less));
ADD_ANY_LIST("greater", rak::ptr_fn(&apply_greater));
ADD_ANY_LIST("equal", rak::ptr_fn(&apply_equal));
// A temporary command for handling stuff until we get proper
// support for seperation of commands and literals.
+4 -4
View File
@@ -63,11 +63,11 @@ Download::Download(download_type d) :
m_chunksFailed(0),
m_resumeFlags(~uint32_t()) {
m_connTrackerSucceeded = m_download.signal_tracker_succeeded(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
m_connTrackerFailed = m_download.signal_tracker_failed(sigc::mem_fun(*this, &Download::receive_tracker_msg));
m_connStorageError = m_download.signal_storage_error(sigc::mem_fun(*this, &Download::receive_storage_error));
m_connTrackerSucceeded = m_download.info()->signal_tracker_success().connect(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
m_connTrackerFailed = m_download.info()->signal_tracker_failed().connect(sigc::mem_fun(*this, &Download::receive_tracker_msg));
m_connStorageError = m_download.info()->signal_storage_error().connect(sigc::mem_fun(*this, &Download::receive_storage_error));
m_download.signal_chunk_failed(sigc::mem_fun(*this, &Download::receive_chunk_failed));
m_download.info()->signal_chunk_failed().connect(sigc::mem_fun(*this, &Download::receive_chunk_failed));
}
Download::~Download() {
+2 -2
View File
@@ -175,8 +175,8 @@ DownloadList::insert(Download* download) {
iterator itr = base_type::insert(end(), download);
try {
(*itr)->download()->signal_download_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::received_finished), download));
(*itr)->download()->signal_hash_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::hash_done), download));
(*itr)->info()->signal_download_done().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::received_finished), download));
(*itr)->info()->signal_initial_hash().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::hash_done), download));
// This needs to be separated into two different calls to ensure
// the download remains in the view.