* 'I' key set the download to ignore the start/stop_try commands.

* Added options for timeout_sync/safe_sync and max_chunks_queued.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@739 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-07-07 22:19:20 +00:00
parent 63311270c9
commit 52bf80d704
8 changed files with 102 additions and 81 deletions
+8 -3
View File
@@ -94,9 +94,14 @@ Download::Download(download_type d) :
m_variables.insert("min_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_min), rak::mem_fn(&m_download, &download_type::set_peers_min)));
m_variables.insert("max_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_max), rak::mem_fn(&m_download, &download_type::set_peers_max)));
m_variables.insert("max_uploads", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::uploads_max), rak::mem_fn(&m_download, &download_type::set_uploads_max)));
m_variables.insert("max_chunks_queued", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::max_chunks_queued), rak::mem_fn(&m_download, &download_type::set_max_chunks_queued)));
m_variables.insert("timeout_sync", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::timeout_sync), rak::mem_fn(&m_download, &download_type::set_timeout_sync)));
m_variables.insert("timeout_safe_sync", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::timeout_safe_sync), rak::mem_fn(&m_download, &download_type::set_timeout_safe_sync)));
m_variables.insert("priority", new utils::VariableValueSlot(rak::mem_fn(this, &Download::priority), rak::mem_fn(this, &Download::set_priority)));
m_variables.insert("ignore_ratio", new utils::VariableObject(bencode(), "rtorrent", "ignore_ratio", torrent::Object::TYPE_VALUE));
m_variables.insert("ignore_commands", new utils::VariableObject(bencode(), "rtorrent", "ignore_commands", torrent::Object::TYPE_VALUE));
}
Download::~Download() {
@@ -117,9 +122,9 @@ Download::enable_udp_trackers(bool state) {
for (int i = 0, last = tl.size(); i < last; ++i)
if (tl.get(i).tracker_type() == torrent::Tracker::TRACKER_UDP)
if (state)
tl.get(i).enable();
tl.get(i).enable();
else
tl.get(i).disable();
tl.get(i).disable();
}
uint32_t
+3 -2
View File
@@ -78,8 +78,9 @@ public:
bool is_hash_failed() const { return m_hashFailed; }
void set_hash_failed(bool v) { m_hashFailed = v; }
variable_map_type* variable() { return &m_variables; }
std::string variable_string(const std::string& key) { return m_variables.get_string(key); }
variable_map_type* variable() { return &m_variables; }
int64_t variable_value(const std::string& key) const { return m_variables.get_value(key); }
const std::string& variable_string(const std::string& key) const { return m_variables.get_string(key); }
download_type* download() { return &m_download; }
const download_type* download() const { return &m_download; }
+11 -2
View File
@@ -176,6 +176,15 @@ DownloadFactory::receive_success() {
download->variable()->set("max_peers", control->variable()->get("max_peers"));
download->variable()->set("max_uploads", control->variable()->get("max_uploads"));
if (!control->variable()->get_value("timeout_sync") != 0)
download->variable()->set("timeout_sync", control->variable()->get("timeout_sync"));
if (!control->variable()->get_value("timeout_safe_sync") != 0)
download->variable()->set("timeout_safe_sync", control->variable()->get("timeout_safe_sync"));
if (!control->variable()->get_value("max_chunks_queued") != 0)
download->variable()->set("max_chunks_queued", control->variable()->get("max_chunks_queued"));
if (!control->variable()->get_value("use_udp_trackers"))
download->enable_udp_trackers(false);
@@ -277,8 +286,8 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
if (rtorrent->has_key_value("chunks_done"))
download->download()->set_chunks_done(std::min<uint32_t>(rtorrent->get_key_value("chunks_done"), download->download()->chunks_total()));
if (!rtorrent->has_key_value("ignore_ratio"))
rtorrent->insert_key("ignore_ratio", (int64_t)0);
if (!rtorrent->has_key_value("ignore_commands"))
rtorrent->insert_key("ignore_commands", (int64_t)0);
}
}
+18 -4
View File
@@ -241,25 +241,26 @@ DownloadList::start_normal(Download* download) {
resume(download);
}
void
bool
DownloadList::start_try(Download* download) {
check_contains(download);
// Also don't start if the state is one of those that indicate we
// were manually stopped?
if (download->is_hash_failed())
return;
if (download->is_hash_failed() || download->variable()->get_value("ignore_commands") != 0)
return false;
// Don't clear the hash failed as this function is used by scripts,
// etc.
download->variable()->set("state", (int64_t)1);
resume(download);
return true;
}
void
DownloadList::stop(Download* download) {
DownloadList::stop_normal(Download* download) {
check_contains(download);
download->variable()->set("state", (int64_t)0);
@@ -267,6 +268,19 @@ DownloadList::stop(Download* download) {
pause(download);
}
bool
DownloadList::stop_try(Download* download) {
check_contains(download);
if (download->variable()->get_value("ignore_commands") != 0)
return false;
download->variable()->set("state", (int64_t)0);
pause(download);
return true;
}
void
DownloadList::resume(Download* download) {
check_contains(download);
+9 -2
View File
@@ -72,6 +72,8 @@ public:
using base_type::empty;
using base_type::size;
DownloadList() { }
void clear();
void session_save();
@@ -93,8 +95,10 @@ public:
void close_throw(Download* d);
void start_normal(Download* d);
void start_try(Download* d);
void stop(Download* d);
bool start_try(Download* d);
void stop_normal(Download* d);
bool stop_try(Download* d);
void resume(Download* d);
void pause(Download* d);
@@ -168,6 +172,9 @@ public:
static void erase_key(slot_map& sm, const std::string& key) { sm.erase(key); }
private:
DownloadList(const DownloadList&);
void operator = (const DownloadList&);
void hash_done(Download* d);
void hash_queue(Download* d, int type);