mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
* Put both global and download specific commands in a single
CommandMap. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@914 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+1
-10
@@ -48,7 +48,7 @@
|
||||
#include <torrent/tracker_list.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
|
||||
#include "rpc/command_map.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
@@ -205,15 +205,6 @@ Download::receive_chunk_failed(__UNUSED uint32_t idx) {
|
||||
m_chunksFailed++;
|
||||
}
|
||||
|
||||
int64_t Download::get_value(const char* key) { return control->download_variables()->call_command_d_value(key, this); }
|
||||
const std::string Download::get_string(const char* key) { return control->download_variables()->call_command_d_string(key, this); }
|
||||
int64_t Download::get_std_value(const std::string& key) { return control->download_variables()->call_command_d_value(key.c_str(), this); }
|
||||
const std::string Download::get_std_string(const std::string& key) { return control->download_variables()->call_command_d_string(key.c_str(), this); }
|
||||
|
||||
void Download::set(const char* key, const torrent::Object& value) { control->download_variables()->call_command_d(key, this, value); }
|
||||
void Download::set_value(const char* key, int64_t value) { control->download_variables()->call_command_d_set_value(key, this, value); }
|
||||
void Download::set_string(const char* key, const std::string& value) { control->download_variables()->call_command_d_set_string(key, this, value); }
|
||||
|
||||
// Clean up.
|
||||
void
|
||||
Download::set_root_directory(const std::string& path) {
|
||||
|
||||
@@ -100,17 +100,6 @@ public:
|
||||
uint32_t priority();
|
||||
void set_priority(uint32_t p);
|
||||
|
||||
int64_t get_value(const char* key);
|
||||
const std::string get_string(const char* key);
|
||||
|
||||
int64_t get_std_value(const std::string& key);
|
||||
const std::string get_std_string(const std::string& key);
|
||||
|
||||
void set(const char* key, const torrent::Object& value);
|
||||
|
||||
void set_value(const char* key, int64_t value);
|
||||
void set_string(const char* key, const std::string& value);
|
||||
|
||||
void set_root_directory(const std::string& path);
|
||||
|
||||
bool operator == (const std::string& str) const;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <torrent/resume.h>
|
||||
#include <torrent/data/file_utils.h>
|
||||
|
||||
#include "rpc/command_map.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "curl_get.h"
|
||||
#include "control.h"
|
||||
@@ -75,9 +75,9 @@ DownloadFactory::DownloadFactory(const std::string& uri, Manager* m) :
|
||||
m_taskLoad.set_slot(rak::mem_fn(this, &DownloadFactory::receive_load));
|
||||
m_taskCommit.set_slot(rak::mem_fn(this, &DownloadFactory::receive_commit));
|
||||
|
||||
m_variables["connection_leech"] = control->variable()->call_command_void("get_connection_leech");
|
||||
m_variables["connection_seed"] = control->variable()->call_command_void("get_connection_seed");
|
||||
m_variables["directory"] = control->variable()->call_command_void("get_directory");
|
||||
m_variables["connection_leech"] = rpc::call_command_void("get_connection_leech");
|
||||
m_variables["connection_seed"] = rpc::call_command_void("get_connection_seed");
|
||||
m_variables["directory"] = rpc::call_command_void("get_directory");
|
||||
m_variables["tied_to_file"] = torrent::Object((int64_t)false);
|
||||
}
|
||||
|
||||
@@ -173,44 +173,44 @@ DownloadFactory::receive_success() {
|
||||
initialize_rtorrent(download, rtorrent);
|
||||
|
||||
// Move to 'rtorrent'.
|
||||
download->set("set_connection_leech", m_variables["connection_leech"]);
|
||||
download->set("set_connection_seed", m_variables["connection_seed"]);
|
||||
rpc::call_command_d("set_d_connection_leech", download, m_variables["connection_leech"]);
|
||||
rpc::call_command_d("set_d_connection_seed", download, m_variables["connection_seed"]);
|
||||
|
||||
download->set("set_max_uploads", control->variable()->call_command_void("get_max_uploads"));
|
||||
download->set("set_min_peers", control->variable()->call_command_void("get_min_peers"));
|
||||
download->set("set_max_peers", control->variable()->call_command_void("get_max_peers"));
|
||||
download->set("set_tracker_numwant", control->variable()->call_command_void("get_tracker_numwant"));
|
||||
rpc::call_command_d("set_d_max_uploads", download, rpc::call_command_void("get_max_uploads"));
|
||||
rpc::call_command_d("set_d_min_peers", download, rpc::call_command_void("get_min_peers"));
|
||||
rpc::call_command_d("set_d_max_peers", download, rpc::call_command_void("get_max_peers"));
|
||||
rpc::call_command_d("set_d_tracker_numwant", download, rpc::call_command_void("get_tracker_numwant"));
|
||||
|
||||
if (download->get_value("get_complete") != 0) {
|
||||
if (control->variable()->call_command_value("get_min_peers_seed") >= 0)
|
||||
download->set("set_min_peers", control->variable()->call_command_void("get_min_peers_seed"));
|
||||
if (rpc::call_command_d_value("get_d_complete", download) != 0) {
|
||||
if (rpc::call_command_value("get_min_peers_seed") >= 0)
|
||||
rpc::call_command_d("set_d_min_peers", download, rpc::call_command_void("get_min_peers_seed"));
|
||||
|
||||
if (control->variable()->call_command_value("get_max_peers_seed") >= 0)
|
||||
download->set("set_max_peers", control->variable()->call_command_void("get_max_peers_seed"));
|
||||
if (rpc::call_command_value("get_max_peers_seed") >= 0)
|
||||
rpc::call_command_d("set_d_max_peers", download, rpc::call_command_void("get_max_peers_seed"));
|
||||
}
|
||||
|
||||
if (!control->variable()->call_command_value("get_use_udp_trackers"))
|
||||
if (!rpc::call_command_value("get_use_udp_trackers"))
|
||||
download->enable_udp_trackers(false);
|
||||
|
||||
if (control->variable()->call_command_value("get_max_file_size") > 0)
|
||||
download->set("set_max_file_size", control->variable()->call_command_void("get_max_file_size"));
|
||||
if (rpc::call_command_value("get_max_file_size") > 0)
|
||||
rpc::call_command_d("set_d_max_file_size", download, rpc::call_command_void("get_max_file_size"));
|
||||
|
||||
// Check first if we already have these values set in the session
|
||||
// torrent, so that it is safe to change the values.
|
||||
//
|
||||
// Need to also catch the exceptions.
|
||||
if (control->variable()->call_command_value("get_split_file_size") >= 0)
|
||||
if (rpc::call_command_value("get_split_file_size") >= 0)
|
||||
torrent::file_split_all(download->download()->file_list(),
|
||||
control->variable()->call_command_value("get_split_file_size"),
|
||||
control->variable()->call_command_string("split_suffix"));
|
||||
rpc::call_command_value("get_split_file_size"),
|
||||
rpc::call_command_string("split_suffix"));
|
||||
|
||||
if (!rtorrent->has_key_string("directory"))
|
||||
download->set("set_directory", m_variables["directory"]);
|
||||
rpc::call_command_d("set_d_directory", download, m_variables["directory"]);
|
||||
else
|
||||
download->set("set_directory", rtorrent->get_key("directory"));
|
||||
rpc::call_command_d("set_d_directory", download, rtorrent->get_key("directory"));
|
||||
|
||||
if (!m_session && m_variables["tied_to_file"].as_value())
|
||||
download->set("set_tied_to_file", m_uri);
|
||||
rpc::call_command_d("set_d_tied_to_file", download, m_uri);
|
||||
|
||||
torrent::Object& resumeObject = root->has_key_map("libtorrent_resume")
|
||||
? root->get_key("libtorrent_resume")
|
||||
@@ -235,8 +235,8 @@ DownloadFactory::receive_success() {
|
||||
if (m_session) {
|
||||
// This torrent was queued for hashing or hashing when the session
|
||||
// file was saved. Or it was in a started state.
|
||||
if (download->get_value("get_hashing") != Download::variable_hashing_stopped ||
|
||||
download->get_value("get_state") != 0)
|
||||
if (rpc::call_command_d_value("get_d_hashing", download) != Download::variable_hashing_stopped ||
|
||||
rpc::call_command_d_value("get_d_state", download) != 0)
|
||||
m_manager->download_list()->resume(download);
|
||||
|
||||
} else {
|
||||
@@ -285,9 +285,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
|
||||
rtorrent->insert_key("tied_to_file", std::string());
|
||||
|
||||
if (rtorrent->has_key_value("priority"))
|
||||
download->set("set_priority", rtorrent->get_key_value("priority") % 4);
|
||||
rpc::call_command_d("set_d_priority", download, rtorrent->get_key_value("priority") % 4);
|
||||
else
|
||||
download->set("set_priority", (int64_t)2);
|
||||
rpc::call_command_d("set_d_priority", download, (int64_t)2);
|
||||
|
||||
if (rtorrent->has_key_value("key")) {
|
||||
download->tracker_list()->set_key(rtorrent->get_key_value("key"));
|
||||
|
||||
+34
-34
@@ -46,7 +46,7 @@
|
||||
#include <torrent/resume.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "rpc/command_map.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "globals.h"
|
||||
@@ -242,7 +242,7 @@ DownloadList::close_throw(Download* download) {
|
||||
|
||||
download->download()->close();
|
||||
|
||||
if (!download->is_hash_failed() && download->get_value("get_hashing") != Download::variable_hashing_stopped)
|
||||
if (!download->is_hash_failed() && rpc::call_command_d_value("get_d_hashing", download) != Download::variable_hashing_stopped)
|
||||
throw torrent::internal_error("DownloadList::close_throw(...) called but we're going into a hashing loop.");
|
||||
|
||||
std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));
|
||||
@@ -256,7 +256,7 @@ DownloadList::start_normal(Download* download) {
|
||||
// Clear hash failed as we're doing a manual start and want to try
|
||||
// hashing again.
|
||||
download->set_hash_failed(false);
|
||||
download->set("set_state", (int64_t)1);
|
||||
rpc::call_command_d("set_d_state", download, (int64_t)1);
|
||||
|
||||
resume(download);
|
||||
}
|
||||
@@ -268,12 +268,12 @@ DownloadList::start_try(Download* download) {
|
||||
// Also don't start if the state is one of those that indicate we
|
||||
// were manually stopped?
|
||||
|
||||
if (download->is_hash_failed() || download->get_value("get_ignore_commands") != 0)
|
||||
if (download->is_hash_failed() || rpc::call_command_d_value("get_d_ignore_commands", download) != 0)
|
||||
return false;
|
||||
|
||||
// Don't clear the hash failed as this function is used by scripts,
|
||||
// etc.
|
||||
download->set("set_state", (int64_t)1);
|
||||
rpc::call_command_d("set_d_state", download, (int64_t)1);
|
||||
|
||||
resume(download);
|
||||
return true;
|
||||
@@ -283,7 +283,7 @@ void
|
||||
DownloadList::stop_normal(Download* download) {
|
||||
check_contains(download);
|
||||
|
||||
download->set("set_state", (int64_t)0);
|
||||
rpc::call_command_d("set_d_state", download, (int64_t)0);
|
||||
|
||||
pause(download);
|
||||
}
|
||||
@@ -292,10 +292,10 @@ bool
|
||||
DownloadList::stop_try(Download* download) {
|
||||
check_contains(download);
|
||||
|
||||
if (download->get_value("get_ignore_commands") != 0)
|
||||
if (rpc::call_command_d_value("get_d_ignore_commands", download) != 0)
|
||||
return false;
|
||||
|
||||
download->set("set_state", (int64_t)0);
|
||||
rpc::call_command_d("set_d_state", download, (int64_t)0);
|
||||
|
||||
pause(download);
|
||||
return true;
|
||||
@@ -321,8 +321,8 @@ DownloadList::resume(Download* download) {
|
||||
if (download->is_hash_failed())
|
||||
return;
|
||||
|
||||
if (download->get_value("get_hashing") == Download::variable_hashing_stopped)
|
||||
download->set("set_hashing", Download::variable_hashing_initial);
|
||||
if (rpc::call_command_d_value("get_d_hashing", download) == Download::variable_hashing_stopped)
|
||||
rpc::call_command_d("set_d_hashing", download, Download::variable_hashing_initial);
|
||||
|
||||
std::for_each(slot_map_hash_queued().begin(), slot_map_hash_queued().end(), download_list_call(download));
|
||||
return;
|
||||
@@ -331,12 +331,12 @@ DownloadList::resume(Download* download) {
|
||||
// This will never actually do anything due to the above hash check.
|
||||
// open_throw(download);
|
||||
|
||||
download->set("set_state_changed", cachedTime.seconds());
|
||||
rpc::call_command_d("set_d_state_changed", download, cachedTime.seconds());
|
||||
|
||||
if (download->is_done()) {
|
||||
download->set_connection_type(download->get_string("get_connection_seed"));
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_seed", download));
|
||||
} else {
|
||||
download->set_connection_type(download->get_string("get_connection_leech"));
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_leech", download));
|
||||
|
||||
// For the moment, clear the resume data so we force hash-check
|
||||
// on non-complete downloads after a crash. This shouldn't be
|
||||
@@ -365,9 +365,9 @@ DownloadList::pause(Download* download) {
|
||||
|
||||
// Always clear hashing on pause. When a hashing request is added,
|
||||
// it should have cleared the hash resume data.
|
||||
if (download->get_value("get_hashing") != Download::variable_hashing_stopped) {
|
||||
if (rpc::call_command_d_value("get_d_hashing", download) != Download::variable_hashing_stopped) {
|
||||
download->download()->hash_stop();
|
||||
download->set_value("set_hashing", Download::variable_hashing_stopped);
|
||||
rpc::call_command_d_set_value("set_d_hashing", download, Download::variable_hashing_stopped);
|
||||
|
||||
std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));
|
||||
}
|
||||
@@ -380,7 +380,7 @@ DownloadList::pause(Download* download) {
|
||||
|
||||
std::for_each(slot_map_stop().begin(), slot_map_stop().end(), download_list_call(download));
|
||||
|
||||
download->set("set_state_changed", cachedTime.seconds());
|
||||
rpc::call_command_d("set_d_state_changed", download, cachedTime.seconds());
|
||||
|
||||
// Save the state after all the slots, etc have been called so we
|
||||
// include the modifications they may make.
|
||||
@@ -397,7 +397,7 @@ DownloadList::check_hash(Download* download) {
|
||||
|
||||
try {
|
||||
|
||||
if (download->get_value("get_hashing") != Download::variable_hashing_stopped)
|
||||
if (rpc::call_command_d_value("get_d_hashing", download) != Download::variable_hashing_stopped)
|
||||
return;
|
||||
|
||||
hash_queue(download, Download::variable_hashing_rehash);
|
||||
@@ -430,8 +430,8 @@ DownloadList::hash_done(Download* download) {
|
||||
// confirm all the data, avoiding large BW usage on f.ex. the
|
||||
// ReiserFS bug with >4GB files.
|
||||
|
||||
int64_t hashing = download->get_value("get_hashing");
|
||||
download->set_value("set_hashing", Download::variable_hashing_stopped);
|
||||
int64_t hashing = rpc::call_command_d_value("get_d_hashing", download);
|
||||
rpc::call_command_d_set_value("set_d_hashing", download, Download::variable_hashing_stopped);
|
||||
|
||||
switch (hashing) {
|
||||
case Download::variable_hashing_initial:
|
||||
@@ -440,17 +440,17 @@ DownloadList::hash_done(Download* download) {
|
||||
|
||||
// If the download was previously completed but the files were
|
||||
// f.ex deleted, then we clear the state and complete.
|
||||
if (download->get_value("get_complete") && !download->is_done()) {
|
||||
download->set("set_state", (int64_t)0);
|
||||
if (rpc::call_command_d_value("get_d_complete", download) && !download->is_done()) {
|
||||
rpc::call_command_d("set_d_state", download, (int64_t)0);
|
||||
download->set_message("Download registered as completed, but hash check returned unfinished chunks.");
|
||||
}
|
||||
|
||||
// Save resume data so we update time-stamps and priorities if
|
||||
// they were invalid/changed while loading/hashing.
|
||||
download->set("set_complete", (int64_t)download->is_done());
|
||||
rpc::call_command_d("set_d_complete", download, (int64_t)download->is_done());
|
||||
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||
|
||||
if (download->get_value("get_state") == 1)
|
||||
if (rpc::call_command_d_value("get_d_state", download) == 1)
|
||||
resume(download);
|
||||
|
||||
break;
|
||||
@@ -480,14 +480,14 @@ void
|
||||
DownloadList::hash_queue(Download* download, int type) {
|
||||
check_contains(download);
|
||||
|
||||
if (download->get_value("get_hashing") != Download::variable_hashing_stopped)
|
||||
if (rpc::call_command_d_value("get_d_hashing", download) != Download::variable_hashing_stopped)
|
||||
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
|
||||
|
||||
close_throw(download);
|
||||
torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||
|
||||
download->set_hash_failed(false);
|
||||
download->set_value("set_hashing", type);
|
||||
rpc::call_command_d_set_value("set_d_hashing", download, type);
|
||||
|
||||
if (download->is_open())
|
||||
throw torrent::internal_error("DownloadList::hash_clear(...) download still open.");
|
||||
@@ -501,7 +501,7 @@ void
|
||||
DownloadList::received_finished(Download* download) {
|
||||
check_contains(download);
|
||||
|
||||
if (control->variable()->call_command_value("get_check_hash")) {
|
||||
if (rpc::call_command_value("get_check_hash")) {
|
||||
// Set some 'checking_finished_thingie' variable to make hash_done
|
||||
// trigger correctly, also so it can bork on missing data.
|
||||
hash_queue(download, Download::variable_hashing_last);
|
||||
@@ -516,20 +516,20 @@ void
|
||||
DownloadList::confirm_finished(Download* download) {
|
||||
check_contains(download);
|
||||
|
||||
download->set("set_complete", (int64_t)1);
|
||||
rpc::call_command_d("set_d_complete", download, (int64_t)1);
|
||||
|
||||
download->set_connection_type(download->get_string("get_connection_seed"));
|
||||
download->set_connection_type(rpc::call_command_d_string("get_d_connection_seed", download));
|
||||
download->set_priority(download->priority());
|
||||
|
||||
if (download->get_value("get_min_peers") == control->variable()->call_command_value("get_min_peers") && control->variable()->call_command_value("get_min_peers_seed") >= 0)
|
||||
download->set("set_min_peers", control->variable()->call_command_void("get_min_peers_seed"));
|
||||
if (rpc::call_command_d_value("get_d_min_peers", download) == rpc::call_command_value("get_min_peers") && rpc::call_command_value("get_min_peers_seed") >= 0)
|
||||
rpc::call_command_d("set_d_min_peers", download, rpc::call_command_void("get_min_peers_seed"));
|
||||
|
||||
if (download->get_value("get_max_peers") == control->variable()->call_command_value("get_max_peers") && control->variable()->call_command_value("get_max_peers_seed") >= 0)
|
||||
download->set("set_max_peers", control->variable()->call_command_void("get_max_peers_seed"));
|
||||
if (rpc::call_command_d_value("get_d_max_peers", download) == rpc::call_command_value("get_max_peers") && rpc::call_command_value("get_max_peers_seed") >= 0)
|
||||
rpc::call_command_d("set_d_max_peers", download, rpc::call_command_void("get_max_peers_seed"));
|
||||
|
||||
// Do this before the slots are called in case one of them closes
|
||||
// the download.
|
||||
if (!download->is_active() && control->variable()->call_command_value("get_session_on_completion") != 0) {
|
||||
if (!download->is_active() && rpc::call_command_value("get_session_on_completion") != 0) {
|
||||
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||
control->core()->download_store()->save(download);
|
||||
}
|
||||
@@ -540,7 +540,7 @@ DownloadList::confirm_finished(Download* download) {
|
||||
|
||||
std::for_each(slot_map_finished().begin(), slot_map_finished().end(), download_list_call(download));
|
||||
|
||||
if (!download->is_active() && download->get_value("get_state") == 1)
|
||||
if (!download->is_active() && rpc::call_command_d_value("get_d_state", download) == 1)
|
||||
resume(download);
|
||||
}
|
||||
|
||||
|
||||
+18
-13
@@ -55,7 +55,7 @@
|
||||
#include <torrent/resume.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
|
||||
#include "rpc/command_map.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "curl_get.h"
|
||||
@@ -85,13 +85,13 @@ connect_signal_storage_log(Download* d, torrent::Download::slot_string_type s) {
|
||||
// Need a proper logging class for this.
|
||||
static void
|
||||
connect_signal_tracker_dump(Download* d, torrent::Download::slot_dump_type s) {
|
||||
if (!control->variable()->call_command_string("get_tracker_dump").empty())
|
||||
if (!rpc::call_command_string("get_tracker_dump").empty())
|
||||
d->download()->signal_tracker_dump(s);
|
||||
}
|
||||
|
||||
static void
|
||||
receive_tracker_dump(const std::string& url, const char* data, size_t size) {
|
||||
const std::string& filename = control->variable()->call_command_string("get_tracker_dump");
|
||||
const std::string& filename = rpc::call_command_string("get_tracker_dump");
|
||||
|
||||
if (filename.empty())
|
||||
return;
|
||||
@@ -108,7 +108,7 @@ receive_tracker_dump(const std::string& url, const char* data, size_t size) {
|
||||
|
||||
void
|
||||
Manager::handshake_log(const sockaddr* sa, int msg, int err, const torrent::HashString* hash) {
|
||||
if (!control->variable()->call_command_value("get_handshake_log"))
|
||||
if (!rpc::call_command_value("get_handshake_log"))
|
||||
return;
|
||||
|
||||
std::string peer;
|
||||
@@ -168,7 +168,7 @@ Manager::handshake_log(const sockaddr* sa, int msg, int err, const torrent::Hash
|
||||
// Hmm... find some better place for all this.
|
||||
void
|
||||
Manager::delete_tied(Download* download) {
|
||||
const std::string& tie = download->get_string("get_tied_to_file");
|
||||
const std::string& tie = rpc::call_command_d_string("get_d_tied_to_file", download);
|
||||
|
||||
// This should be configurable, need to wait for the variable
|
||||
// thingie to be implemented.
|
||||
@@ -178,7 +178,7 @@ Manager::delete_tied(Download* download) {
|
||||
if (::unlink(rak::path_expand(tie).c_str()) == -1)
|
||||
push_log("Could not unlink tied file: " + std::string(rak::error_number::current().c_str()));
|
||||
|
||||
download->set("set_tied_to_file", std::string());
|
||||
rpc::call_command_d("set_d_tied_to_file", download, std::string());
|
||||
}
|
||||
|
||||
Manager::Manager() :
|
||||
@@ -276,11 +276,11 @@ void
|
||||
Manager::listen_open() {
|
||||
// This stuff really should be moved outside of manager, make it
|
||||
// part of the init script.
|
||||
if (!control->variable()->call_command_value("get_port_open"))
|
||||
if (!rpc::call_command_value("get_port_open"))
|
||||
return;
|
||||
|
||||
int portFirst, portLast;
|
||||
torrent::Object portRange = control->variable()->call_command_void("get_port_range");
|
||||
torrent::Object portRange = rpc::call_command_void("get_port_range");
|
||||
|
||||
if (portRange.is_string()) {
|
||||
if (std::sscanf(portRange.as_string().c_str(), "%i-%i", &portFirst, &portLast) != 2)
|
||||
@@ -295,7 +295,7 @@ Manager::listen_open() {
|
||||
if (portFirst > portLast || portLast >= (1 << 16))
|
||||
throw torrent::input_error("Invalid port range.");
|
||||
|
||||
if (control->variable()->call_command_value("get_port_random")) {
|
||||
if (rpc::call_command_value("get_port_random")) {
|
||||
int boundary = portFirst + random() % (portLast - portFirst + 1);
|
||||
|
||||
if (torrent::connection_manager()->listen_open(boundary, portLast) ||
|
||||
@@ -473,6 +473,11 @@ path_expand(std::vector<std::string>* paths, const std::string& pattern) {
|
||||
std::transform(currentCache.begin(), currentCache.end(), std::back_inserter(*paths), std::mem_fun_ref(&utils::Directory::get_path));
|
||||
}
|
||||
|
||||
bool
|
||||
manager_equal_tied(const std::string& path, Download* download) {
|
||||
return path == rpc::call_command_d_string("get_d_tied_to_file", download);
|
||||
}
|
||||
|
||||
void
|
||||
Manager::try_create_download_expand(const std::string& uri, bool start, bool printLog, bool tied) {
|
||||
std::vector<std::string> paths;
|
||||
@@ -482,7 +487,7 @@ Manager::try_create_download_expand(const std::string& uri, bool start, bool pri
|
||||
|
||||
if (tied)
|
||||
for (std::vector<std::string>::iterator itr = paths.begin(); itr != paths.end(); )
|
||||
if (std::find_if(m_downloadList->begin(), m_downloadList->end(), rak::equal(*itr, rak::bind2nd(std::mem_fun(&Download::get_string), "get_tied_to_file")))
|
||||
if (std::find_if(m_downloadList->begin(), m_downloadList->end(), rak::bind1st(std::ptr_fun(&manager_equal_tied), *itr))
|
||||
!= m_downloadList->end())
|
||||
itr = paths.erase(itr);
|
||||
else
|
||||
@@ -514,7 +519,7 @@ Manager::receive_hashing_changed() {
|
||||
continue;
|
||||
|
||||
bool tryQuick =
|
||||
(*itr)->get_value("get_hashing") == Download::variable_hashing_initial &&
|
||||
rpc::call_command_d_value("get_d_hashing", *itr) == Download::variable_hashing_initial &&
|
||||
(*itr)->download()->file_list()->bitfield()->empty();
|
||||
|
||||
if (!tryQuick && foundHashing)
|
||||
@@ -537,7 +542,7 @@ Manager::receive_hashing_changed() {
|
||||
(*itr)->download()->hash_stop();
|
||||
|
||||
if (foundHashing) {
|
||||
(*itr)->set_value("set_hashing", Download::variable_hashing_rehash);
|
||||
rpc::call_command_d_set_value("set_d_hashing", *itr, Download::variable_hashing_rehash);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -548,7 +553,7 @@ Manager::receive_hashing_changed() {
|
||||
} catch (torrent::local_error& e) {
|
||||
if (tryQuick) {
|
||||
// Make sure we don't repeat the quick hashing.
|
||||
(*itr)->set_value("set_hashing", Download::variable_hashing_rehash);
|
||||
rpc::call_command_d_set_value("set_d_hashing", *itr, Download::variable_hashing_rehash);
|
||||
|
||||
} else {
|
||||
(*itr)->set_hash_failed(true);
|
||||
|
||||
+18
-16
@@ -42,6 +42,8 @@
|
||||
#include <torrent/object.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "download.h"
|
||||
#include "download_list.h"
|
||||
@@ -71,8 +73,8 @@ public:
|
||||
|
||||
virtual bool operator () (Download* d1, Download* d2) const {
|
||||
return
|
||||
d1->get_string(m_name) == m_value &&
|
||||
d2->get_string(m_name) != m_value;
|
||||
rpc::call_command_d_string(m_name, d1) == m_value &&
|
||||
rpc::call_command_d_string(m_name, d2) != m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -86,9 +88,9 @@ public:
|
||||
|
||||
virtual bool operator () (Download* d1, Download* d2) const {
|
||||
if (m_reverse)
|
||||
return d2->get_value(m_name) < d1->get_value(m_name);
|
||||
return rpc::call_command_d_value(m_name, d2) < rpc::call_command_d_value(m_name, d1);
|
||||
else
|
||||
return d1->get_value(m_name) < d2->get_value(m_name);
|
||||
return rpc::call_command_d_value(m_name, d1) < rpc::call_command_d_value(m_name, d2);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -115,7 +117,7 @@ public:
|
||||
m_name(name), m_value(v), m_inverse(inverse) {}
|
||||
|
||||
virtual bool operator () (Download* d1) const {
|
||||
return (d1->get_value(m_name) == m_value) != m_inverse;
|
||||
return (rpc::call_command_d_value(m_name, d1) == m_value) != m_inverse;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -134,19 +136,19 @@ ViewManager::ViewManager(DownloadList* dl) :
|
||||
m_sort["name"] = new ViewSortName();
|
||||
m_sort["name_reverse"] = new ViewSortReverse(new ViewSortName());
|
||||
|
||||
m_sort["stopped"] = new ViewSortVariableValue("get_state");
|
||||
m_sort["started"] = new ViewSortVariableValue("get_state", true);
|
||||
m_sort["complete"] = new ViewSortVariableValue("get_complete");
|
||||
m_sort["incomplete"] = new ViewSortVariableValue("get_complete", true);
|
||||
m_sort["stopped"] = new ViewSortVariableValue("get_d_state");
|
||||
m_sort["started"] = new ViewSortVariableValue("get_d_state", true);
|
||||
m_sort["complete"] = new ViewSortVariableValue("get_d_complete");
|
||||
m_sort["incomplete"] = new ViewSortVariableValue("get_d_complete", true);
|
||||
|
||||
m_sort["state_changed"] = new ViewSortVariableValue("get_state_changed");
|
||||
m_sort["state_changed_reverse"] = new ViewSortVariableValue("get_state_changed", true);
|
||||
m_sort["state_changed"] = new ViewSortVariableValue("get_d_state_changed");
|
||||
m_sort["state_changed_reverse"] = new ViewSortVariableValue("get_d_state_changed", true);
|
||||
|
||||
m_filter["started"] = new ViewFilterVariableValue("get_state", 1);
|
||||
m_filter["stopped"] = new ViewFilterVariableValue("get_state", 0);
|
||||
m_filter["complete"] = new ViewFilterVariableValue("get_complete", 0, true);
|
||||
m_filter["incomplete"] = new ViewFilterVariableValue("get_complete", 0);
|
||||
m_filter["hashing"] = new ViewFilterVariableValue("get_hashing", 0, true);
|
||||
m_filter["started"] = new ViewFilterVariableValue("get_d_state", 1);
|
||||
m_filter["stopped"] = new ViewFilterVariableValue("get_d_state", 0);
|
||||
m_filter["complete"] = new ViewFilterVariableValue("get_d_complete", 0, true);
|
||||
m_filter["incomplete"] = new ViewFilterVariableValue("get_d_complete", 0);
|
||||
m_filter["hashing"] = new ViewFilterVariableValue("get_d_hashing", 0, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user