* Fixed an overflow in rak::partial_queue, and added some exceptions.

* Changed to configure script so --disable-mincore must be called
explicitly to disable it.

* API and core::Download cleanup.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@660 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-31 23:02:39 +00:00
parent 59a23ea9ed
commit d9d27139d1
26 changed files with 266 additions and 254 deletions
+16 -1
View File
@@ -94,13 +94,28 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [
AC_MSG_RESULT(signed)
],
[
AC_MSG_RESULT(none)
AC_MSG_ERROR([failed, do *not* attempt to use --disable-mincore unless you are running Win32.])
])
])
AC_LANG_POP(C++)
])
AC_DEFUN([TORRENT_MINCORE], [
AC_ARG_ENABLE(mincore,
[ --disable-mincore disable mincore check [[default=enable]]],
[
if test "$enableval" = "yes"; then
TORRENT_MINCORE_SIGNEDNESS()
else
AC_MSG_CHECKING(for mincore)
AC_MSG_RESULT(disabled)
fi
],[
TORRENT_MINCORE_SIGNEDNESS()
])
])
AC_DEFUN([TORRENT_CHECK_MADVISE], [
AC_MSG_CHECKING(for madvise)
+1 -1
View File
@@ -89,7 +89,7 @@ public:
input::InputEvent* input_stdin() { return m_inputStdin; }
CommandScheduler* command_scheduler() { return m_commandScheduler; }
utils::VariableMap* variables() { return m_variables; }
utils::VariableMap* variable() { return m_variables; }
display::ClientInfo* client_info() { return m_clientInfo; }
+22 -21
View File
@@ -52,9 +52,10 @@
namespace core {
Download::Download(torrent::Download d) :
Download::Download(download_type d) :
m_download(d),
m_fileList(d.file_list()),
m_trackerList(d.tracker_list()),
m_chunksFailed(0) {
@@ -66,22 +67,22 @@ Download::Download(torrent::Download d) :
m_variables.insert("connection_current", new utils::VariableSlotString<const char*, const std::string&>(rak::mem_fn(this, &Download::connection_current),
rak::mem_fn(this, &Download::set_connection_current)));
m_variables.insert("connection_leech", new utils::VariableAny(connection_type_to_string(torrent::Download::CONNECTION_LEECH)));
m_variables.insert("connection_seed", new utils::VariableAny(connection_type_to_string(torrent::Download::CONNECTION_SEED)));
m_variables.insert("state", new utils::VariableObject(&m_download.bencode(), "rtorrent", "state", torrent::Object::TYPE_STRING));
m_variables.insert("tied_to_file", new utils::VariableObject(&m_download.bencode(), "rtorrent", "tied_to_file", torrent::Object::TYPE_STRING));
m_variables.insert("connection_leech", new utils::VariableAny(connection_type_to_string(download_type::CONNECTION_LEECH)));
m_variables.insert("connection_seed", new utils::VariableAny(connection_type_to_string(download_type::CONNECTION_SEED)));
m_variables.insert("state", new utils::VariableObject(bencode(), "rtorrent", "state", torrent::Object::TYPE_STRING));
m_variables.insert("tied_to_file", new utils::VariableObject(bencode(), "rtorrent", "tied_to_file", torrent::Object::TYPE_STRING));
m_variables.insert("directory", new utils::VariableSlotString<const std::string&>(rak::mem_fn(&m_fileList, &torrent::FileList::root_dir),
rak::mem_fn(this, &Download::set_root_directory)));
m_variables.insert("min_peers", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(&m_download, &torrent::Download::peers_min),
rak::mem_fn(&m_download, &torrent::Download::set_peers_min),
m_variables.insert("min_peers", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(&m_download, &download_type::peers_min),
rak::mem_fn(&m_download, &download_type::set_peers_min),
"%u"));
m_variables.insert("max_peers", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(&m_download, &torrent::Download::peers_max),
rak::mem_fn(&m_download, &torrent::Download::set_peers_max),
m_variables.insert("max_peers", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(&m_download, &download_type::peers_max),
rak::mem_fn(&m_download, &download_type::set_peers_max),
"%u"));
m_variables.insert("max_uploads", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(&m_download, &torrent::Download::uploads_max),
rak::mem_fn(&m_download, &torrent::Download::set_uploads_max),
m_variables.insert("max_uploads", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(&m_download, &download_type::uploads_max),
rak::mem_fn(&m_download, &download_type::set_uploads_max),
"%u"));
m_variables.insert("priority", new utils::VariableSlotValue<uint32_t, uint32_t>(rak::mem_fn(this, &Download::priority),
rak::mem_fn(this, &Download::set_priority),
@@ -96,7 +97,7 @@ Download::~Download() {
m_connTrackerFailed.disconnect();
m_connStorageError.disconnect();
m_download = torrent::Download();
m_download = download_type();
}
void
@@ -132,7 +133,7 @@ Download::enable_udp_trackers(bool state) {
uint32_t
Download::priority() {
return get_bencode().get_key("rtorrent").get_key("priority").as_value();
return bencode()->get_key("rtorrent").get_key("priority").as_value();
}
void
@@ -146,7 +147,7 @@ Download::set_priority(uint32_t p) {
else
torrent::download_set_priority(m_download, p * p);
get_bencode().get_key("rtorrent").insert_key("priority", (int64_t)p);
bencode()->get_key("rtorrent").insert_key("priority", (int64_t)p);
}
void
@@ -169,23 +170,23 @@ Download::receive_storage_error(std::string msg) {
m_message = "Storage error: [" + msg + "]";
}
torrent::Download::ConnectionType
Download::download_type::ConnectionType
Download::string_to_connection_type(const std::string& name) {
// Return default if the name isn't found.
if (name == "leech")
return torrent::Download::CONNECTION_LEECH;
return download_type::CONNECTION_LEECH;
else if (name == "seed")
return torrent::Download::CONNECTION_SEED;
return download_type::CONNECTION_SEED;
else
throw torrent::input_error("Unknown peer connection type selected: \"" + name + "\"");
}
const char*
Download::connection_type_to_string(torrent::Download::ConnectionType t) {
Download::connection_type_to_string(download_type::ConnectionType t) {
switch (t) {
case torrent::Download::CONNECTION_LEECH:
case download_type::CONNECTION_LEECH:
return "leech";
case torrent::Download::CONNECTION_SEED:
case download_type::CONNECTION_SEED:
return "seed";
default:
return "unknown";
@@ -263,7 +264,7 @@ Download::set_root_directory(const std::string& path) {
(m_fileList.size() > 1 ? m_download.name() : ""));
}
m_download.bencode().get_key("rtorrent").insert_key("directory", path);
bencode()->get_key("rtorrent").insert_key("directory", path);
}
}
+51 -49
View File
@@ -40,6 +40,7 @@
#include <sigc++/connection.h>
#include <torrent/download.h>
#include <torrent/file_list.h>
#include <torrent/tracker_list.h>
#include <torrent/torrent.h>
#include "utils/variable_map.h"
@@ -48,91 +49,92 @@ namespace core {
class Download {
public:
typedef torrent::Download::ConnectionType ConnType;
typedef torrent::Download download_type;
typedef torrent::FileList file_list_type;
typedef torrent::TrackerList tracker_list_type;
typedef download_type::ConnectionType connection_type;
typedef utils::VariableMap variable_map_type;
Download(torrent::Download d);
Download(download_type d);
~Download();
bool is_open() { return m_download.is_open(); }
inline bool is_done();
bool is_open() const { return m_download.is_open(); }
inline bool is_done() const { return m_download.chunks_done() == m_download.chunks_total(); }
void start();
void stop();
void start();
void stop();
// Add functions like pause/etc.
utils::VariableMap* variables() { return &m_variables; }
std::string variable_string(const std::string& key) { return m_variables.get_string(key); }
variable_map_type* variable() { return &m_variables; }
std::string variable_string(const std::string& key) { return m_variables.get_string(key); }
torrent::FileList* file_list() { return &m_fileList; }
download_type* download() { return &m_download; }
const download_type* download() const { return &m_download; }
torrent::Download& get_download() { return m_download; }
const torrent::Download& get_download() const { return m_download; }
std::string get_hash() { return m_download.info_hash(); }
torrent::Object& get_bencode() { return m_download.bencode(); }
const std::string& get_message() { return m_message; }
torrent::Object* bencode() { return m_download.bencode(); }
file_list_type* file_list() { return &m_fileList; }
tracker_list_type* tracker_list() { return &m_trackerList; }
uint32_t chunks_failed() const { return m_chunksFailed; }
const std::string& info_hash() const { return m_download.info_hash(); }
const std::string& message() const { return m_message; }
void enable_udp_trackers(bool state);
uint32_t chunks_failed() const { return m_chunksFailed; }
uint32_t priority();
void set_priority(uint32_t p);
void enable_udp_trackers(bool state);
// Helper functions for calling functions in torrent::Download
uint32_t priority();
void set_priority(uint32_t p);
// Helper functions for calling functions in download_type
// through sigc++.
template <typename Ret, Ret (torrent::Download::*func)()>
void call() { (m_download.*func)(); }
template <typename Ret, Ret (download_type::*func)()>
void call() { (m_download.*func)(); }
template <typename Ret, typename Arg1, Ret (torrent::Download::*func)(Arg1)>
void call(Arg1 a1) { (m_download.*func)(a1); }
template <typename Ret, typename Arg1, Ret (download_type::*func)(Arg1)>
void call(Arg1 a1) { (m_download.*func)(a1); }
bool operator == (const std::string& str) { return str == m_download.info_hash(); }
void receive_finished();
void receive_finished();
static ConnType string_to_connection_type(const std::string& name);
static const char* connection_type_to_string(ConnType t);
static connection_type string_to_connection_type(const std::string& name);
static const char* connection_type_to_string(connection_type t);
static uint32_t string_to_priority(const std::string& name);
static const char* priority_to_string(uint32_t p);
static uint32_t string_to_priority(const std::string& name);
static const char* priority_to_string(uint32_t p);
float distributed_copies() const;
float distributed_copies() const;
private:
Download(const Download&);
void operator () (const Download&);
void receive_tracker_msg(std::string msg);
void receive_storage_error(std::string msg);
void receive_tracker_msg(std::string msg);
void receive_storage_error(std::string msg);
void receive_chunk_failed(uint32_t idx);
void receive_chunk_failed(uint32_t idx);
const char* connection_current() const { return connection_type_to_string(m_download.connection_type()); }
void set_connection_current(const std::string& t) { return m_download.set_connection_type(string_to_connection_type(t.c_str())); }
const char* connection_current() const { return connection_type_to_string(m_download.connection_type()); }
void set_connection_current(const std::string& t) { return m_download.set_connection_type(string_to_connection_type(t.c_str())); }
void set_root_directory(const std::string& path);
void set_root_directory(const std::string& path);
// Store the FileList instance so we can use slots etc on it.
torrent::Download m_download;
torrent::FileList m_fileList;
download_type m_download;
file_list_type m_fileList;
tracker_list_type m_trackerList;
std::string m_message;
uint32_t m_chunksFailed;
std::string m_message;
uint32_t m_chunksFailed;
sigc::connection m_connTrackerSucceded;
sigc::connection m_connTrackerFailed;
sigc::connection m_connStorageError;
variable_map_type m_variables;
utils::VariableMap m_variables;
sigc::connection m_connTrackerSucceded;
sigc::connection m_connTrackerFailed;
sigc::connection m_connStorageError;
};
inline bool
Download::is_done() {
return m_download.chunks_done() == m_download.chunks_total();
}
}
#endif
+37 -37
View File
@@ -70,9 +70,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.insert("connection_leech", new utils::VariableAny(control->variables()->get("connection_leech")));
m_variables.insert("connection_seed", new utils::VariableAny(control->variables()->get("connection_seed")));
m_variables.insert("directory", new utils::VariableAny(control->variables()->get("directory")));
m_variables.insert("connection_leech", new utils::VariableAny(control->variable()->get("connection_leech")));
m_variables.insert("connection_seed", new utils::VariableAny(control->variable()->get("connection_seed")));
m_variables.insert("directory", new utils::VariableAny(control->variable()->get("directory")));
m_variables.insert("tied_to_file", new utils::VariableBool(false));
}
@@ -149,65 +149,65 @@ DownloadFactory::receive_success() {
return;
}
torrent::Object& root = (*itr)->get_bencode();
torrent::Object* root = (*itr)->bencode();
if (!m_session) {
// We only allow session torrents to keep their
// 'rtorrent/libtorrent' sections.
root.erase_key("rtorrent");
root.erase_key("libtorrent");
root->erase_key("rtorrent");
root->erase_key("libtorrent");
}
if (!root.has_key("rtorrent") ||
!root.get_key("rtorrent").is_map())
root.insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
if (!root->has_key("rtorrent") ||
!root->get_key("rtorrent").is_map())
root->insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
torrent::Object& rtorrent = root.get_key("rtorrent");
torrent::Object* rtorrent = &root->get_key("rtorrent");
if (!rtorrent.has_key("state") ||
!rtorrent.get_key("state").is_string() ||
(rtorrent.get_key("state").as_string() != "stopped" &&
rtorrent.get_key("state").as_string() != "started"))
rtorrent.insert_key("state", "stopped");
if (!rtorrent->has_key("state") ||
!rtorrent->get_key("state").is_string() ||
(rtorrent->get_key("state").as_string() != "stopped" &&
rtorrent->get_key("state").as_string() != "started"))
rtorrent->insert_key("state", "stopped");
if (!rtorrent.has_key("tied_to_file") ||
!rtorrent.get_key("tied_to_file").is_string())
rtorrent.insert_key("tied_to_file", std::string());
if (!rtorrent->has_key("tied_to_file") ||
!rtorrent->get_key("tied_to_file").is_string())
rtorrent->insert_key("tied_to_file", std::string());
if (rtorrent.has_key("priority") &&
rtorrent.get_key("priority").is_value())
(*itr)->variables()->set("priority", rtorrent.get_key("priority").as_value() % 4);
if (rtorrent->has_key("priority") &&
rtorrent->get_key("priority").is_value())
(*itr)->variable()->set("priority", rtorrent->get_key("priority").as_value() % 4);
else
(*itr)->variables()->set("priority", (int64_t)2);
(*itr)->variable()->set("priority", (int64_t)2);
// Move to 'rtorrent'.
(*itr)->variables()->set("connection_leech", m_variables.get("connection_leech"));
(*itr)->variables()->set("connection_seed", m_variables.get("connection_seed"));
(*itr)->variables()->set("min_peers", control->variables()->get("min_peers"));
(*itr)->variables()->set("max_peers", control->variables()->get("max_peers"));
(*itr)->variables()->set("max_uploads", control->variables()->get("max_uploads"));
(*itr)->variable()->set("connection_leech", m_variables.get("connection_leech"));
(*itr)->variable()->set("connection_seed", m_variables.get("connection_seed"));
(*itr)->variable()->set("min_peers", control->variable()->get("min_peers"));
(*itr)->variable()->set("max_peers", control->variable()->get("max_peers"));
(*itr)->variable()->set("max_uploads", control->variable()->get("max_uploads"));
if (control->variables()->get_string("use_udp_trackers") == "no")
if (control->variable()->get_string("use_udp_trackers") == "no")
(*itr)->enable_udp_trackers(false);
if (rtorrent.has_key("total_uploaded") && rtorrent.get_key("total_uploaded").is_value())
(*itr)->get_download().up_rate()->set_total(rtorrent.get_key("total_uploaded").as_value());
if (rtorrent->has_key("total_uploaded") && rtorrent->get_key("total_uploaded").is_value())
(*itr)->download()->up_rate()->set_total(rtorrent->get_key("total_uploaded").as_value());
if (m_session) {
if (!rtorrent.has_key("directory") ||
!rtorrent.get_key("directory").is_string())
(*itr)->variables()->set("directory", m_variables.get("directory"));
if (!rtorrent->has_key("directory") ||
!rtorrent->get_key("directory").is_string())
(*itr)->variable()->set("directory", m_variables.get("directory"));
else
(*itr)->variables()->set("directory", rtorrent.get_key("directory"));
(*itr)->variable()->set("directory", rtorrent->get_key("directory"));
if ((*itr)->variables()->get_string("state") == "started")
if ((*itr)->variable()->get_string("state") == "started")
m_manager->download_list().resume(*itr);
} else {
(*itr)->variables()->set("directory", m_variables.get("directory"));
(*itr)->variable()->set("directory", m_variables.get("directory"));
if (m_variables.get("tied_to_file").as_value())
(*itr)->variables()->set("tied_to_file", m_uri);
(*itr)->variable()->set("tied_to_file", m_uri);
if (m_start)
m_manager->download_list().start(*itr);
+3 -3
View File
@@ -67,7 +67,7 @@ public:
void load();
void commit();
utils::VariableMap* variables() { return &m_variables; }
utils::VariableMap* variable() { return &m_variables; }
bool get_session() const { return m_session; }
void set_session(bool v) { m_session = v; }
@@ -75,8 +75,8 @@ public:
bool get_start() const { return m_start; }
void set_start(bool v) { m_start = v; }
bool print_log() const { return m_printLog; }
void set_print_log(bool v) { m_printLog = v; }
bool print_log() const { return m_printLog; }
void set_print_log(bool v) { m_printLog = v; }
void slot_finished(Slot s) { m_slotFinished = s; }
+11 -11
View File
@@ -80,7 +80,7 @@ DownloadList::insert(std::istream* str, bool printLog) {
iterator itr = Base::insert(end(), new Download(d));
(*itr)->get_download().signal_download_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::finished), *itr));
(*itr)->download()->signal_download_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::finished), *itr));
std::for_each(m_slotMapInsert.begin(), m_slotMapInsert.end(), download_list_call(*itr));
return itr;
@@ -99,12 +99,12 @@ DownloadList::iterator
DownloadList::erase(iterator itr) {
// Make safe to erase active downloads.
if ((*itr)->get_download().is_active())
if ((*itr)->download()->is_active())
throw std::logic_error("DownloadList::erase(...) called on an active download.");
std::for_each(m_slotMapErase.begin(), m_slotMapErase.end(), download_list_call(*itr));
torrent::download_remove((*itr)->get_download());
torrent::download_remove(*(*itr)->download());
delete *itr;
return Base::erase(itr);
@@ -114,7 +114,7 @@ void
DownloadList::open(Download* d) {
try {
if (!d->get_download().is_open())
if (!d->download()->is_open())
std::for_each(m_slotMapOpen.begin(), m_slotMapOpen.end(), download_list_call(d));
} catch (torrent::local_error& e) {
@@ -126,10 +126,10 @@ void
DownloadList::close(Download* d) {
try {
if (d->get_download().is_active())
if (d->download()->is_active())
std::for_each(m_slotMapStop.begin(), m_slotMapStop.end(), download_list_call(d));
if (d->get_download().is_open())
if (d->download()->is_open())
std::for_each(m_slotMapClose.begin(), m_slotMapClose.end(), download_list_call(d));
} catch (torrent::local_error& e) {
@@ -139,14 +139,14 @@ DownloadList::close(Download* d) {
void
DownloadList::start(Download* d) {
d->variables()->set("state", "started");
d->variable()->set("state", "started");
resume(d);
}
void
DownloadList::stop(Download* d) {
d->variables()->set("state", "stopped");
d->variable()->set("state", "stopped");
pause(d);
}
@@ -154,10 +154,10 @@ DownloadList::stop(Download* d) {
void
DownloadList::resume(Download* d) {
try {
if (!d->get_download().is_open())
if (!d->download()->is_open())
std::for_each(m_slotMapOpen.begin(), m_slotMapOpen.end(), download_list_call(d));
if (d->get_download().is_hash_checked())
if (d->download()->is_hash_checked())
std::for_each(m_slotMapStart.begin(), m_slotMapStart.end(), download_list_call(d));
else
// TODO: This can cause infinit looping?
@@ -172,7 +172,7 @@ void
DownloadList::pause(Download* d) {
try {
if (d->get_download().is_active())
if (d->download()->is_active())
std::for_each(m_slotMapStop.begin(), m_slotMapStop.end(), download_list_call(d));
} catch (torrent::local_error& e) {
+3 -3
View File
@@ -101,9 +101,9 @@ DownloadStore::save(Download* d) {
return;
// Move this somewhere else.
d->get_bencode().get_key("rtorrent").insert_key("total_uploaded", d->get_download().up_rate()->total());
d->bencode()->get_key("rtorrent").insert_key("total_uploaded", d->download()->up_rate()->total());
f << d->get_bencode();
f << *d->bencode();
if (!f.good())
return;
@@ -162,7 +162,7 @@ DownloadStore::is_correct_format(std::string f) {
std::string
DownloadStore::create_filename(Download* d) {
return m_path + rak::transform_hex(d->get_hash()) + ".torrent";
return m_path + rak::transform_hex(d->info_hash()) + ".torrent";
}
}
+9 -9
View File
@@ -48,19 +48,19 @@ namespace core {
void
HashQueue::insert(Download* d, Slot s) {
if (d->get_download().is_hash_checking() ||
if (d->download()->is_hash_checking() ||
find(d) != end())
return;
if (d->get_download().is_hash_checked()) {
if (d->download()->is_hash_checked()) {
s();
return;
}
iterator itr = Base::insert(end(), new HashQueueNode(d, s));
(*itr)->set_connection(d->get_download().signal_hash_done(sigc::bind(sigc::mem_fun(*this, &HashQueue::receive_hash_done),
(*itr)->get_download())));
(*itr)->set_connection(d->download()->signal_hash_done(sigc::bind(sigc::mem_fun(*this, &HashQueue::receive_hash_done),
(*itr)->download())));
fill_queue();
}
@@ -73,7 +73,7 @@ HashQueue::remove(Download* d) {
return;
// We don't do anything if we're already checking, just disconnect.
// if ((*itr)->get_download()->get_download().is_hash_checking()) {
// if ((*itr)->download()->download()->is_hash_checking()) {
// // What do we do if we're already checking?
// }
@@ -85,7 +85,7 @@ HashQueue::remove(Download* d) {
HashQueue::iterator
HashQueue::find(Download* d) {
return std::find_if(begin(), end(), rak::equal(d, std::mem_fun(&HashQueueNode::get_download)));
return std::find_if(begin(), end(), rak::equal(d, std::mem_fun(&HashQueueNode::download)));
}
void
@@ -107,13 +107,13 @@ HashQueue::receive_hash_done(Download* d) {
void
HashQueue::fill_queue() {
if (empty() || front()->get_download()->get_download().is_hash_checking())
if (empty() || front()->download()->download()->is_hash_checking())
return;
if (front()->get_download()->get_download().is_hash_checked())
if (front()->download()->download()->is_hash_checked())
throw std::logic_error("core::HashQueue::fill_queue() encountered a checked hash");
front()->get_download()->get_download().hash_check();
front()->download()->download()->hash_check();
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ public:
void disconnect() { m_connection.disconnect(); }
Download* get_download() { return m_download; }
Download* download() { return m_download; }
HashQueue::Slot get_slot() { return m_slot; }
void set_connection(sigc::connection c) { m_connection = c; }
+13 -13
View File
@@ -65,18 +65,18 @@ namespace core {
static void
connect_signal_network_log(Download* d, torrent::Download::slot_string_type s) {
d->get_download().signal_network_log(s);
d->download()->signal_network_log(s);
}
static void
connect_signal_storage_log(Download* d, torrent::Download::slot_string_type s) {
d->get_download().signal_storage_error(s);
d->download()->signal_storage_error(s);
}
// Hmm... find some better place for all this.
static void
delete_tied(Download* d) {
const std::string tie = d->variables()->get("tied_to_file").as_string();
const std::string tie = d->variable()->get("tied_to_file").as_string();
// This should be configurable, need to wait for the variable
// thingie to be implemented.
@@ -158,7 +158,7 @@ Manager::shutdown(bool force) {
void
Manager::check_hash(Download* d) {
bool restart = d->get_download().is_active();
bool restart = d->download()->is_active();
try {
prepare_hash_check(d);
@@ -176,7 +176,7 @@ Manager::check_hash(Download* d) {
void
Manager::receive_download_done(Download* d) {
if (control->variables()->get("check_hash").as_string() == "yes") {
if (control->variable()->get("check_hash").as_string() == "yes") {
// Start the hash checking, send completed to tracker after
// finishing.
prepare_hash_check(d);
@@ -191,13 +191,13 @@ Manager::receive_download_done(Download* d) {
void
Manager::listen_open() {
if (control->variables()->get_string("port_open") != "yes")
if (control->variable()->get_string("port_open") != "yes")
return;
if (m_portFirst > m_portLast)
throw torrent::input_error("Invalid port range for listening");
if (control->variables()->get("port_random").as_string() == "yes") {
if (control->variable()->get("port_random").as_string() == "yes") {
int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1);
if (!torrent::connection_manager()->listen_open(boundary, m_portLast) &&
@@ -264,11 +264,11 @@ Manager::set_local_address(const std::string& addr) {
void
Manager::prepare_hash_check(Download* d) {
m_downloadList.close(d);
d->get_download().hash_resume_clear();
d->download()->hash_resume_clear();
m_downloadList.open(d);
if (d->get_download().is_hash_checking() ||
d->get_download().is_hash_checked())
if (d->download()->is_hash_checking() ||
d->download()->is_hash_checked())
throw std::logic_error("Manager::check_hash(...) closed the torrent but is_hash_check{ing,ed}() == true");
if (m_hashQueue.find(d) != m_hashQueue.end())
@@ -285,12 +285,12 @@ void
Manager::receive_download_done_hash_checked(Download* d) {
m_downloadList.resume(d);
if (control->variables()->get_string("session_on_completion") == "yes")
if (control->variable()->get_string("session_on_completion") == "yes")
m_downloadStore.save(d);
// Don't send if we did a hash check and found incompelete chunks.
if (d->is_done())
d->get_download().tracker_list().send_completed();
d->download()->tracker_list().send_completed();
}
void
@@ -298,7 +298,7 @@ Manager::try_create_download(const std::string& uri, bool start, bool printLog,
// Adding download.
DownloadFactory* f = new DownloadFactory(uri, this);
f->variables()->set("tied_to_file", tied ? "yes" : "no");
f->variable()->set("tied_to_file", tied ? "yes" : "no");
f->set_start(start);
f->set_print_log(printLog);
+22 -22
View File
@@ -108,29 +108,29 @@ print_address(char* first, char* last, const sockaddr* sa) {
char*
print_download_title(char* first, char* last, core::Download* d) {
return print_buffer(first, last, " %s", d->get_download().name().c_str());
return print_buffer(first, last, " %s", d->download()->name().c_str());
}
char*
print_download_info(char* first, char* last, core::Download* d) {
first = print_buffer(first, last, "Torrent: ");
if (!d->get_download().is_open())
if (!d->download()->is_open())
first = print_buffer(first, last, "closed ");
else if (d->is_done())
first = print_buffer(first, last, "done %10.1f MB", (double)d->get_download().bytes_total() / (double)(1 << 20));
first = print_buffer(first, last, "done %10.1f MB", (double)d->download()->bytes_total() / (double)(1 << 20));
else
first = print_buffer(first, last, "%6.1f / %6.1f MB",
(double)d->get_download().bytes_done() / (double)(1 << 20),
(double)d->get_download().bytes_total() / (double)(1 << 20));
(double)d->download()->bytes_done() / (double)(1 << 20),
(double)d->download()->bytes_total() / (double)(1 << 20));
first = print_buffer(first, last, " Rate: %5.1f / %5.1f KB Uploaded: %7.1f MB",
(double)d->get_download().up_rate()->rate() / (1 << 10),
(double)d->get_download().down_rate()->rate() / (1 << 10),
(double)d->get_download().up_rate()->total() / (1 << 20));
(double)d->download()->up_rate()->rate() / (1 << 10),
(double)d->download()->down_rate()->rate() / (1 << 10),
(double)d->download()->up_rate()->total() / (1 << 20));
if (d->get_download().is_active() && !d->is_done()) {
if (d->download()->is_active() && !d->is_done()) {
first = print_buffer(first, last, " ");
first = print_download_percentage_done(first, last, d);
@@ -151,25 +151,25 @@ print_download_info(char* first, char* last, core::Download* d) {
char*
print_download_status(char* first, char* last, core::Download* d) {
if (!d->get_download().is_active())
if (!d->download()->is_active())
first = print_buffer(first, last, "Inactive: ");
if (d->get_download().is_hash_checking())
if (d->download()->is_hash_checking()) {
first = print_buffer(first, last, "Checking hash [%2i%%]",
(d->get_download().chunks_hashed() * 100) / d->get_download().chunks_total());
(d->download()->chunks_hashed() * 100) / d->download()->chunks_total());
else if (d->get_download().is_tracker_busy() &&
d->get_download().tracker_list().focus() < d->get_download().tracker_list().size()) {
torrent::TrackerList tl = d->get_download().tracker_list();
} else if (d->tracker_list()->is_busy() && d->tracker_list()->focus() < d->tracker_list()->size()) {
torrent::TrackerList* tl = d->tracker_list();
first = print_buffer(first, last, "Tracker[%i:%i]: Connecting to %s",
tl.get(tl.focus()).group(), tl.focus(), tl.get(tl.focus()).url().c_str());
tl->get(tl->focus()).group(), tl->focus(), tl->get(tl->focus()).url().c_str());
} else if (!d->get_message().empty())
first = print_buffer(first, last, "%s", d->get_message().c_str());
} else if (!d->message().empty()) {
first = print_buffer(first, last, "%s", d->message().c_str());
else
} else {
*first = '\0';
}
if (first > last)
throw torrent::internal_error("print_download_status(...) wrote past end of the buffer.");
@@ -179,12 +179,12 @@ print_download_status(char* first, char* last, core::Download* d) {
char*
print_download_time_left(char* first, char* last, core::Download* d) {
uint32_t rate = d->get_download().down_rate()->rate();
uint32_t rate = d->download()->down_rate()->rate();
if (rate < 512)
return print_buffer(first, last, "--:--:--");
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
time_t remaining = (d->download()->bytes_total() - d->download()->bytes_done()) / (rate & ~(uint32_t)(512 - 1));
return print_ddhhmm(first, last, remaining);
}
@@ -195,7 +195,7 @@ print_download_percentage_done(char* first, char* last, core::Download* d) {
//return print_buffer(first, last, "[--%%]");
return print_buffer(first, last, " ");
else
return print_buffer(first, last, "[%2u%%]", (d->get_download().chunks_done() * 100) / d->get_download().chunks_total());
return print_buffer(first, last, "[%2u%%]", (d->download()->chunks_done() * 100) / d->download()->chunks_total());
}
char*
+4 -4
View File
@@ -61,11 +61,11 @@ WindowDownloadChunksSeen::redraw() {
return;
m_canvas->print(2, 0, "Chunks seen: [C/A/D %i/%i/%.2f]",
(int)m_download->get_download().peers_complete(),
(int)m_download->get_download().peers_accounted(),
(int)m_download->download()->peers_complete(),
(int)m_download->download()->peers_accounted(),
std::floor(m_download->distributed_copies() * 100.0f) / 100.0f);
const uint8_t* seen = m_download->get_download().chunks_seen();
const uint8_t* seen = m_download->download()->chunks_seen();
if (seen == NULL) {
m_canvas->print(2, 2, "Not available.");
@@ -77,7 +77,7 @@ WindowDownloadChunksSeen::redraw() {
char* end = buffer + m_canvas->get_width() - 2;
const uint8_t* chunk = seen;
const uint8_t* last = seen + m_download->get_download().chunks_total();
const uint8_t* last = seen + m_download->download()->chunks_total();
for (int y = 1; y < m_canvas->get_height() && chunk < last; ++y) {
position = buffer + std::max(snprintf(buffer, end - buffer, "%5d", chunk - seen), 0);
+12 -12
View File
@@ -67,26 +67,26 @@ WindowDownloadStatusbar::redraw() {
m_canvas->print(0, 0, "%s", buffer);
position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C/A: %i/%i/%i/%i Failed: %i",
(int)m_download->get_download().peers_connected(),
(int)m_download->get_download().peers_not_connected(),
(int)m_download->get_download().peers_min(),
(int)m_download->get_download().peers_max(),
(int)m_download->get_download().uploads_max(),
(int)m_download->get_download().peers_currently_unchoked(),
(int)m_download->get_download().peers_currently_interested(),
(int)m_download->get_download().peers_complete(),
(int)m_download->get_download().peers_accounted(),
(int)m_download->download()->peers_connected(),
(int)m_download->download()->peers_not_connected(),
(int)m_download->download()->peers_min(),
(int)m_download->download()->peers_max(),
(int)m_download->download()->uploads_max(),
(int)m_download->download()->peers_currently_unchoked(),
(int)m_download->download()->peers_currently_interested(),
(int)m_download->download()->peers_complete(),
(int)m_download->download()->peers_accounted(),
(int)m_download->chunks_failed()),
0);
// position = buffer + std::max(snprintf(position, last - buffer, " Priority: %s",
// core::Download::priority_to_string(m_download->variables()->get("priority").as_value())),
// core::Download::priority_to_string(m_download->variable()->get("priority").as_value())),
// 0);
m_canvas->print(0, 1, "%s", buffer);
position = print_download_status(buffer, last, m_download);
m_canvas->print(0, 2, "[%c:%i] %s",
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(m_download->get_download().tracker_list().timeout() / 1000000),
m_download->tracker_list()->is_busy() ? 'C' : ' ',
(int)(m_download->download()->tracker_list().timeout() / 1000000),
buffer);
}
+1 -1
View File
@@ -76,7 +76,7 @@ WindowFileList::redraw() {
m_slotSchedule(this, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
m_canvas->erase();
torrent::FileList fl = m_download->get_download().file_list();
torrent::FileList fl = m_download->download()->file_list();
if (fl.size() == 0 || m_canvas->get_height() < 2)
return;
+13 -13
View File
@@ -66,29 +66,29 @@ WindowPeerInfo::redraw() {
m_canvas->erase();
int y = 0;
torrent::Download d = m_download->get_download();
torrent::Download* d = m_download->download();
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d.info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d.local_id()).c_str());
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d->info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d->local_id()).c_str());
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
d.chunks_done(),
d.chunks_total(),
d.chunks_size());
d->chunks_done(),
d->chunks_total(),
d->chunks_size());
char buffer[32], *position;
position = print_ddmmyyyy(buffer, buffer + 32, static_cast<time_t>(d.creation_date()));
position = print_ddmmyyyy(buffer, buffer + 32, static_cast<time_t>(d->creation_date()));
position = print_string(position, buffer + 32, " ");
position = print_hhmmss(position, buffer + 32, static_cast<time_t>(d.creation_date()));
position = print_hhmmss(position, buffer + 32, static_cast<time_t>(d->creation_date()));
m_canvas->print(0, y++, "Created: %s", buffer);
y++;
m_canvas->print(0, y++, "Connection Type: %s ( %s / %s )",
m_download->variables()->get("connection_current").as_string().c_str(),
m_download->variables()->get("connection_seed").as_string().c_str(),
m_download->variables()->get("connection_leech").as_string().c_str());
m_canvas->print(0, y++, "Priority: %u", torrent::download_priority(m_download->get_download()));
m_download->variable()->get("connection_current").as_string().c_str(),
m_download->variable()->get("connection_seed").as_string().c_str(),
m_download->variable()->get("connection_leech").as_string().c_str());
m_canvas->print(0, y++, "Priority: %u", torrent::download_priority(*m_download->download()));
m_canvas->print(0, y++, "Directory: %s", m_download->variable_string("directory").c_str());
m_canvas->print(0, y++, "Tied to file: %s", m_download->variable_string("tied_to_file").c_str());
@@ -135,7 +135,7 @@ WindowPeerInfo::redraw() {
int
WindowPeerInfo::done_percentage(torrent::Peer& p) {
int chunks = m_download->get_download().chunks_total();
int chunks = m_download->download()->chunks_total();
return chunks ? (100 * p.chunks_done()) / chunks : 0;
}
+2 -2
View File
@@ -86,7 +86,7 @@ WindowPeerList::redraw() {
m_list->end(),
m_canvas->get_height() - y);
if (m_download->get_download().chunks_total() <= 0)
if (m_download->download()->chunks_total() <= 0)
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
while (range.first != range.second) {
@@ -141,7 +141,7 @@ WindowPeerList::redraw() {
int
WindowPeerList::done_percentage(torrent::Peer& p) {
int chunks = m_download->get_download().chunks_total();
int chunks = m_download->download()->chunks_total();
return chunks ? (100 * p.chunks_done()) / chunks : 0;
}
+1 -1
View File
@@ -66,7 +66,7 @@ WindowTrackerList::redraw() {
++pos;
torrent::TrackerList tl = m_download->get_download().tracker_list();
torrent::TrackerList tl = m_download->download()->tracker_list();
if (tl.size() == 0)
return;
+8 -8
View File
@@ -78,14 +78,14 @@ parse_options(Control* c, int argc, char** argv) {
// Converted.
optionParser.insert_flag('h', sigc::ptr_fun(&print_help));
optionParser.insert_option('b', sigc::bind<0>(sigc::mem_fun(c->variables(), &utils::VariableMap::set_string), "bind"));
optionParser.insert_option('d', sigc::bind<0>(sigc::mem_fun(c->variables(), &utils::VariableMap::set_string), "directory"));
optionParser.insert_option('i', sigc::bind<0>(sigc::mem_fun(c->variables(), &utils::VariableMap::set_string), "ip"));
optionParser.insert_option('p', sigc::bind<0>(sigc::mem_fun(c->variables(), &utils::VariableMap::set_string), "port_range"));
optionParser.insert_option('s', sigc::bind<0>(sigc::mem_fun(c->variables(), &utils::VariableMap::set_string), "session"));
optionParser.insert_option('b', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::set_string), "bind"));
optionParser.insert_option('d', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::set_string), "directory"));
optionParser.insert_option('i', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::set_string), "ip"));
optionParser.insert_option('p', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::set_string), "port_range"));
optionParser.insert_option('s', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::set_string), "session"));
optionParser.insert_option('O', sigc::mem_fun(c->variables(), &utils::VariableMap::process_command));
optionParser.insert_option_list('o', sigc::mem_fun(c->variables(), &utils::VariableMap::set_string));
optionParser.insert_option('O', sigc::mem_fun(c->variable(), &utils::VariableMap::process_command));
optionParser.insert_option_list('o', sigc::mem_fun(c->variable(), &utils::VariableMap::set_string));
return optionParser.process(argc, argv);
@@ -163,7 +163,7 @@ main(int argc, char** argv) {
initialize_option_handler(control);
// Move env and go through "try_import".
if (!control->variables()->process_file("~/.rtorrent.rc"))
if (!control->variable()->process_file("~/.rtorrent.rc"))
control->core()->get_log_important().push_front("Could not load \"~/.rtorrent.rc\".");
int firstArg = parse_options(control, argc, argv);
+7 -7
View File
@@ -121,7 +121,7 @@ apply_stop_untied(Control* m, __UNUSED const std::string& arg) {
rak::file_stat fs;
if (!fs.update(rak::path_expand((*itr)->variable_string("tied_to_file")))) {
(*itr)->variables()->set("tied_to_file", std::string());
(*itr)->variable()->set("tied_to_file", std::string());
m->core()->download_list().stop(*itr);
}
@@ -140,7 +140,7 @@ apply_remove_untied(Control* m, __UNUSED const std::string& arg) {
rak::file_stat fs;
if (!fs.update(rak::path_expand((*itr)->variable_string("tied_to_file")))) {
(*itr)->variables()->set("tied_to_file", std::string());
(*itr)->variable()->set("tied_to_file", std::string());
m->core()->download_list().stop(*itr);
itr = m->core()->download_list().erase(itr);
@@ -161,7 +161,7 @@ apply_enable_trackers(Control* m, __UNUSED const std::string& arg) {
for (core::Manager::DListItr itr = m->core()->download_list().begin(), last = m->core()->download_list().end(); itr != last; ++itr) {
torrent::TrackerList tl = (*itr)->get_download().tracker_list();
torrent::TrackerList tl = (*itr)->download()->tracker_list();
for (int i = 0, last = tl.size(); i < last; ++i)
if (state)
@@ -169,14 +169,14 @@ apply_enable_trackers(Control* m, __UNUSED const std::string& arg) {
else
tl.get(i).disable();
if (state && control->variables()->get_string("use_udp_trackers") == "no")
if (state && control->variable()->get_string("use_udp_trackers") == "no")
(*itr)->enable_udp_trackers(false);
}
}
void
initialize_option_handler(Control* c) {
utils::VariableMap* variables = control->variables();
utils::VariableMap* variables = control->variable();
// Cleaned up.
variables->insert("check_hash", new utils::VariableAny("yes"));
@@ -208,8 +208,8 @@ initialize_option_handler(Control* c) {
variables->insert("max_open_sockets", new utils::VariableSlotValue<int, uint32_t>(NULL, rak::ptr_fn(&torrent::set_max_open_sockets), "%i"));
variables->insert("print", new utils::VariableSlotString<>(NULL, rak::mem_fn(control->core(), &core::Manager::push_log)));
variables->insert("import", new utils::VariableSlotString<>(NULL, rak::mem_fn(control->variables(), &utils::VariableMap::process_file_throw)));
variables->insert("try_import", new utils::VariableSlotString<>(NULL, rak::mem_fn(control->variables(), &utils::VariableMap::process_file_nothrow)));
variables->insert("import", new utils::VariableSlotString<>(NULL, rak::mem_fn(control->variable(), &utils::VariableMap::process_file_throw)));
variables->insert("try_import", new utils::VariableSlotString<>(NULL, rak::mem_fn(control->variable(), &utils::VariableMap::process_file_nothrow)));
variables->insert("schedule", new utils::VariableSlotString<>(NULL, rak::mem_fn<const std::string&>(c->command_scheduler(), &CommandScheduler::parse)));
variables->insert("schedule_remove", new utils::VariableSlotString<>(NULL, rak::mem_fn<const std::string&>(c->command_scheduler(), &CommandScheduler::erase)));
+10 -15
View File
@@ -62,7 +62,7 @@ Download::Download(DPtr d, Control* c) :
m_download(d),
m_state(DISPLAY_MAX_SIZE),
m_windowTitle(new WTitle(d->get_download().name())),
m_windowTitle(new WTitle(d->download()->name())),
m_windowDownloadStatus(new WDownloadStatus(d)),
m_window(c->display()->end()),
@@ -80,10 +80,10 @@ Download::Download(DPtr d, Control* c) :
bind_keys();
m_download->get_download().peer_list(m_peers);
m_download->download()->peer_list(m_peers);
m_connPeerConnected = m_download->get_download().signal_peer_connected(sigc::mem_fun(*this, &Download::receive_peer_connected));
m_connPeerDisconnected = m_download->get_download().signal_peer_disconnected(sigc::mem_fun(*this, &Download::receive_peer_disconnected));
m_connPeerConnected = m_download->download()->signal_peer_connected(sigc::mem_fun(*this, &Download::receive_peer_connected));
m_connPeerDisconnected = m_download->download()->signal_peer_disconnected(sigc::mem_fun(*this, &Download::receive_peer_disconnected));
}
Download::~Download() {
@@ -179,7 +179,7 @@ Download::receive_disconnect_peer() {
if (m_focus == m_peers.end())
return;
m_download->get_download().disconnect_peer(*m_focus);
m_download->download()->disconnect_peer(*m_focus);
mark_dirty();
}
@@ -206,21 +206,21 @@ void
Download::receive_max_uploads(int t) {
m_windowDownloadStatus->mark_dirty();
m_download->get_download().set_uploads_max(std::max(m_download->get_download().uploads_max() + t, (uint32_t)2));
m_download->download()->set_uploads_max(std::max(m_download->download()->uploads_max() + t, (uint32_t)2));
}
void
Download::receive_min_peers(int t) {
m_windowDownloadStatus->mark_dirty();
m_download->get_download().set_peers_min(std::max(m_download->get_download().peers_min() + t, (uint32_t)5));
m_download->download()->set_peers_min(std::max(m_download->download()->peers_min() + t, (uint32_t)5));
}
void
Download::receive_max_peers(int t) {
m_windowDownloadStatus->mark_dirty();
m_download->get_download().set_peers_max(std::max(m_download->get_download().peers_max() + t, (uint32_t)5));
m_download->download()->set_peers_max(std::max(m_download->download()->peers_max() + t, (uint32_t)5));
}
void
@@ -252,11 +252,6 @@ Download::receive_prev_priority() {
m_download->set_priority((m_download->priority() - 1) % 4);
}
void
Download::receive_manual_request(bool force) {
m_download->get_download().tracker_list().manual_request(force);
}
void
Download::bind_keys() {
(*m_bindings)['1'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), -1);
@@ -270,8 +265,8 @@ Download::bind_keys() {
(*m_bindings)['k'] = sigc::mem_fun(this, &Download::receive_disconnect_peer);
(*m_bindings)['t'] = sigc::bind(sigc::mem_fun(this, &Download::receive_manual_request), false);
(*m_bindings)['T'] = sigc::bind(sigc::mem_fun(this, &Download::receive_manual_request), true);
(*m_bindings)['t'] = sigc::bind(sigc::mem_fun(m_download->tracker_list(), &torrent::TrackerList::manual_request), false);
(*m_bindings)['T'] = sigc::bind(sigc::mem_fun(m_download->tracker_list(), &torrent::TrackerList::manual_request), true);
(*m_bindings)['p'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_INFO);
(*m_bindings)['o'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_TRACKER_LIST);
-1
View File
@@ -110,7 +110,6 @@ private:
void receive_change(Display d);
void receive_snub_peer();
void receive_manual_request(bool force);
void bind_keys();
+5 -5
View File
@@ -200,7 +200,7 @@ DownloadList::receive_stop_download() {
if (m_downloadList.get_focus() == m_downloadList.end())
return;
if ((*m_downloadList.get_focus())->get_download().is_active())
if ((*m_downloadList.get_focus())->download()->is_active())
m_control->core()->download_list().stop(*m_downloadList.get_focus());
else
m_downloadList.set_focus(m_control->core()->download_list().erase(m_downloadList.get_focus()));
@@ -282,7 +282,7 @@ DownloadList::receive_view_input(Input type) {
m_windowTextInput->set_focus(true);
if (type == INPUT_CHANGE_DIRECTORY) {
m_windowTextInput->get_input()->str() = m_control->variables()->get_string("directory");
m_windowTextInput->get_input()->str() = m_control->variable()->get_string("directory");
m_windowTextInput->get_input()->set_pos(m_windowTextInput->get_input()->str().length());
}
@@ -315,12 +315,12 @@ DownloadList::receive_exit_input(Input type) {
if (m_downloadList.get_focus() == m_downloadList.end())
throw torrent::input_error("No download in focus to change root directory.");
(*m_downloadList.get_focus())->variables()->set("directory", rak::trim(m_windowTextInput->get_input()->str()));
m_control->core()->push_log("New root dir \"" + (*m_downloadList.get_focus())->variables()->get_string("directory") + "\" for torrent.");
(*m_downloadList.get_focus())->variable()->set("directory", rak::trim(m_windowTextInput->get_input()->str()));
m_control->core()->push_log("New root dir \"" + (*m_downloadList.get_focus())->variable()->get_string("directory") + "\" for torrent.");
break;
case INPUT_COMMAND:
m_control->variables()->process_command(m_windowTextInput->get_input()->str());
m_control->variable()->process_command(m_windowTextInput->get_input()->str());
break;
}
+3 -3
View File
@@ -82,10 +82,10 @@ ElementChunksSeen::disable(Control* c) {
// if (m_window == NULL)
// throw std::logic_error("ui::ElementChunksSeen::receive_disable(...) called on a disabled object");
// if (m_download->get_download().tracker(m_focus).is_enabled())
// m_download->get_download().tracker(m_focus).disable();
// if (m_download->download()->tracker(m_focus).is_enabled())
// m_download->download()->tracker(m_focus).disable();
// else
// m_download->get_download().tracker(m_focus).enable();
// m_download->download()->tracker(m_focus).enable();
// m_window->mark_dirty();
// }
+6 -6
View File
@@ -84,7 +84,7 @@ ElementFileList::receive_next() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_next(...) called on a disabled object");
if (++m_focus >= m_download->get_download().file_list().size())
if (++m_focus >= m_download->download()->file_list().size())
m_focus = 0;
m_window->mark_dirty();
@@ -95,7 +95,7 @@ ElementFileList::receive_prev() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
torrent::FileList fl = m_download->get_download().file_list();
torrent::FileList fl = m_download->download()->file_list();
if (fl.size() == 0)
return;
@@ -113,7 +113,7 @@ ElementFileList::receive_priority() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
torrent::FileList fl = m_download->get_download().file_list();
torrent::FileList fl = m_download->download()->file_list();
if (m_focus >= fl.size())
return;
@@ -122,7 +122,7 @@ ElementFileList::receive_priority() {
file.set_priority(next_priority(file.priority()));
m_download->get_download().update_priorities();
m_download->download()->update_priorities();
m_window->mark_dirty();
}
@@ -131,7 +131,7 @@ ElementFileList::receive_change_all() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
torrent::FileList fl = m_download->get_download().file_list();
torrent::FileList fl = m_download->download()->file_list();
if (m_focus >= fl.size())
return;
@@ -141,7 +141,7 @@ ElementFileList::receive_change_all() {
for (int i = 0, last = fl.size(); i != last; ++i)
fl.get(i).set_priority(p);
m_download->get_download().update_priorities();
m_download->download()->update_priorities();
m_window->mark_dirty();
}
+5 -5
View File
@@ -85,7 +85,7 @@ ElementTrackerList::receive_disable() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementTrackerList::receive_disable(...) called on a disabled object");
torrent::Tracker t = m_download->get_download().tracker_list().get(m_focus);
torrent::Tracker t = m_download->download()->tracker_list().get(m_focus);
if (t.is_enabled())
t.disable();
@@ -100,7 +100,7 @@ ElementTrackerList::receive_next() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementTrackerList::receive_next(...) called on a disabled object");
if (++m_focus >= m_download->get_download().tracker_list().size())
if (++m_focus >= m_download->download()->tracker_list().size())
m_focus = 0;
m_window->mark_dirty();
@@ -111,13 +111,13 @@ ElementTrackerList::receive_prev() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementTrackerList::receive_prev(...) called on a disabled object");
if (m_download->get_download().tracker_list().size() == 0)
if (m_download->download()->tracker_list().size() == 0)
return;
if (m_focus != 0)
--m_focus;
else
m_focus = m_download->get_download().tracker_list().size() - 1;
m_focus = m_download->download()->tracker_list().size() - 1;
m_window->mark_dirty();
}
@@ -127,7 +127,7 @@ ElementTrackerList::receive_cycle_group() {
if (m_window == NULL)
throw torrent::internal_error("ui::ElementTrackerList::receive_group_cycle(...) called on a disabled object");
torrent::TrackerList tl = m_download->get_download().tracker_list();
torrent::TrackerList tl = m_download->download()->tracker_list();
if (m_focus >= tl.size())
throw torrent::internal_error("ui::ElementTrackerList::receive_group_cycle(...) called with an invalid focus");