* Removed old non-download set/get functions from VariableMap.

* Added forgotten command_download.cc file.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@900 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-05-11 22:47:15 +00:00
parent 0182bfbfba
commit 032bae7030
15 changed files with 113 additions and 98 deletions
+24 -23
View File
@@ -48,6 +48,7 @@
#include <torrent/data/file_utils.h>
#include "utils/variable_generic.h"
#include "utils/variable_map.h"
#include "curl_get.h"
#include "control.h"
@@ -75,10 +76,10 @@ 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.insert("connection_leech", new utils::VariableAny(control->variable()->get("get_connection_leech")));
m_variables.insert("connection_seed", new utils::VariableAny(control->variable()->get("get_connection_seed")));
m_variables.insert("directory", new utils::VariableAny(control->variable()->get("get_directory")));
m_variables.insert("tied_to_file", new utils::VariableBool(false));
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("directory");
m_variables["tied_to_file"] = torrent::Object((int64_t)false);
}
DownloadFactory::~DownloadFactory() {
@@ -112,7 +113,7 @@ DownloadFactory::receive_load() {
(*itr)->signal_done().slots().push_front(sigc::mem_fun(*this, &DownloadFactory::receive_loaded));
(*itr)->signal_failed().slots().push_front(sigc::mem_fun(*this, &DownloadFactory::receive_failed));
m_variables.set("tied_to_file", (int64_t)false);
m_variables["tied_to_file"] = (int64_t)false;
} else {
std::fstream* stream = new std::fstream(rak::path_expand(m_uri).c_str(), std::ios::in | std::ios::binary);
@@ -173,43 +174,43 @@ DownloadFactory::receive_success() {
initialize_rtorrent(download, rtorrent);
// Move to 'rtorrent'.
download->set("connection_leech", m_variables.get("connection_leech"));
download->set("connection_seed", m_variables.get("connection_seed"));
download->set("connection_leech", m_variables["connection_leech"]);
download->set("connection_seed", m_variables["get_connection_seed"]);
download->set("max_uploads", control->variable()->get("get_max_uploads"));
download->set("min_peers", control->variable()->get("get_min_peers"));
download->set("max_peers", control->variable()->get("get_max_peers"));
download->set("tracker_numwant", control->variable()->get("get_tracker_numwant"));
download->set("max_uploads", control->variable()->call_command_void("get_max_uploads"));
download->set("min_peers", control->variable()->call_command_void("get_min_peers"));
download->set("max_peers", control->variable()->call_command_void("get_max_peers"));
download->set("tracker_numwant", control->variable()->call_command_void("get_tracker_numwant"));
if (download->get_value("complete") != 0) {
if (control->variable()->get_value("get_min_peers_seed") >= 0)
download->set("min_peers", control->variable()->get("get_min_peers_seed"));
if (control->variable()->call_command_value("get_min_peers_seed") >= 0)
download->set("min_peers", control->variable()->call_command_void("get_min_peers_seed"));
if (control->variable()->get_value("get_max_peers_seed") >= 0)
download->set("max_peers", control->variable()->get("get_max_peers_seed"));
if (control->variable()->call_command_value("get_max_peers_seed") >= 0)
download->set("max_peers", control->variable()->call_command_void("get_max_peers_seed"));
}
if (!control->variable()->get_value("get_use_udp_trackers"))
if (!control->variable()->call_command_value("get_use_udp_trackers"))
download->enable_udp_trackers(false);
if (control->variable()->get_value("get_max_file_size") > 0)
download->set("max_file_size", control->variable()->get("get_max_file_size"));
if (control->variable()->call_command_value("get_max_file_size") > 0)
download->set("max_file_size", control->variable()->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()->get_value("get_split_file_size") >= 0)
if (control->variable()->call_command_value("get_split_file_size") >= 0)
torrent::file_split_all(download->download()->file_list(),
control->variable()->get_value("get_split_file_size"),
control->variable()->get_string("split_suffix"));
control->variable()->call_command_value("get_split_file_size"),
control->variable()->call_command_string("split_suffix"));
if (!rtorrent->has_key_string("directory"))
download->set("directory", m_variables.get("directory"));
download->set("directory", m_variables["get_directory"]);
else
download->set("directory", rtorrent->get_key("directory"));
if (!m_session && m_variables.get("tied_to_file").as_value())
if (!m_session && m_variables["tied_to_file"].as_value())
download->set("tied_to_file", m_uri);
torrent::Object& resumeObject = root->has_key_map("libtorrent_resume")
+3 -4
View File
@@ -44,8 +44,7 @@
#include <iosfwd>
#include <sigc++/slot.h>
#include <rak/priority_queue_default.h>
#include "utils/variable_map.h"
#include <torrent/object.h>
#include "http_queue.h"
@@ -67,7 +66,7 @@ public:
void load();
void commit();
utils::VariableMap* variable() { return &m_variables; }
torrent::Object::map_type& variables() { return m_variables; }
bool get_session() const { return m_session; }
void set_session(bool v) { m_session = v; }
@@ -100,7 +99,7 @@ private:
bool m_start;
bool m_printLog;
utils::VariableMap m_variables;
torrent::Object::map_type m_variables;
Slot m_slotFinished;
rak::priority_item m_taskLoad;
+6 -6
View File
@@ -501,7 +501,7 @@ void
DownloadList::received_finished(Download* download) {
check_contains(download);
if (control->variable()->get_value("get_check_hash")) {
if (control->variable()->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);
@@ -521,15 +521,15 @@ DownloadList::confirm_finished(Download* download) {
download->set_connection_type(download->get_string("connection_seed"));
download->set_priority(download->priority());
if (download->get_value("min_peers") == control->variable()->get_value("get_min_peers") && control->variable()->get_value("get_min_peers_seed") >= 0)
download->set("min_peers", control->variable()->get("get_min_peers_seed"));
if (download->get_value("min_peers") == control->variable()->call_command_value("get_min_peers") && control->variable()->call_command_value("get_min_peers_seed") >= 0)
download->set("min_peers", control->variable()->call_command_void("get_min_peers_seed"));
if (download->get_value("max_peers") == control->variable()->get_value("get_max_peers") && control->variable()->get_value("get_max_peers_seed") >= 0)
download->set("max_peers", control->variable()->get("get_max_peers_seed"));
if (download->get_value("max_peers") == control->variable()->call_command_value("get_max_peers") && control->variable()->call_command_value("get_max_peers_seed") >= 0)
download->set("max_peers", control->variable()->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()->get_value("get_session_on_completion") != 0) {
if (!download->is_active() && control->variable()->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);
}
+7 -7
View File
@@ -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()->get_string("get_tracker_dump").empty())
if (!control->variable()->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()->get_string("get_tracker_dump");
const std::string& filename = control->variable()->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()->get_value("get_handshake_log"))
if (!control->variable()->call_command_value("get_handshake_log"))
return;
std::string peer;
@@ -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()->get_value("get_port_open"))
if (!control->variable()->call_command_value("get_port_open"))
return;
int portFirst, portLast;
torrent::Object portRange = control->variable()->get("get_port_range");
torrent::Object portRange = control->variable()->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()->get_value("get_port_random")) {
if (control->variable()->call_command_value("get_port_random")) {
int boundary = portFirst + random() % (portLast - portFirst + 1);
if (torrent::connection_manager()->listen_open(boundary, portLast) ||
@@ -415,7 +415,7 @@ Manager::try_create_download(const std::string& uri, bool start, bool printLog,
// Adding download.
DownloadFactory* f = new DownloadFactory(uri, this);
f->variable()->set("tied_to_file", tied ? "yes" : "no");
f->variables()["tied_to_file"] = (int64_t)tied;
f->set_start(start);
f->set_print_log(printLog);