* Moving download variables into command_download.cc.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@902 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-05-18 14:24:57 +00:00
parent 9fe72cb3b5
commit 7d1bb524ba
14 changed files with 243 additions and 175 deletions
+4 -4
View File
@@ -182,7 +182,7 @@ DownloadFactory::receive_success() {
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 (download->get_value("get_complete") != 0) {
if (control->variable()->call_command_value("get_min_peers_seed") >= 0)
download->set("min_peers", control->variable()->call_command_void("get_min_peers_seed"));
@@ -211,7 +211,7 @@ DownloadFactory::receive_success() {
download->set("directory", rtorrent->get_key("directory"));
if (!m_session && m_variables["tied_to_file"].as_value())
download->set("tied_to_file", m_uri);
download->set("set_tied_to_file", m_uri);
torrent::Object& resumeObject = root->has_key_map("libtorrent_resume")
? root->get_key("libtorrent_resume")
@@ -236,8 +236,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("hashing") != Download::variable_hashing_stopped ||
download->get_value("state") != 0)
if (download->get_value("get_hashing") != Download::variable_hashing_stopped ||
download->get_value("get_state") != 0)
m_manager->download_list()->resume(download);
} else {
+24 -24
View File
@@ -242,7 +242,7 @@ DownloadList::close_throw(Download* download) {
download->download()->close();
if (!download->is_hash_failed() && download->get_value("hashing") != Download::variable_hashing_stopped)
if (!download->is_hash_failed() && download->get_value("get_hashing") != 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("state", (int64_t)1);
download->set("set_state", (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("ignore_commands") != 0)
if (download->is_hash_failed() || download->get_value("get_ignore_commands") != 0)
return false;
// Don't clear the hash failed as this function is used by scripts,
// etc.
download->set("state", (int64_t)1);
download->set("set_state", (int64_t)1);
resume(download);
return true;
@@ -283,7 +283,7 @@ void
DownloadList::stop_normal(Download* download) {
check_contains(download);
download->set("state", (int64_t)0);
download->set("set_state", (int64_t)0);
pause(download);
}
@@ -292,10 +292,10 @@ bool
DownloadList::stop_try(Download* download) {
check_contains(download);
if (download->get_value("ignore_commands") != 0)
if (download->get_value("get_ignore_commands") != 0)
return false;
download->set("state", (int64_t)0);
download->set("set_state", (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("hashing") == Download::variable_hashing_stopped)
download->set("hashing", Download::variable_hashing_initial);
if (download->get_value("get_hashing") == Download::variable_hashing_stopped)
download->set("set_hashing", Download::variable_hashing_initial);
std::for_each(slot_map_hash_queued().begin(), slot_map_hash_queued().end(), download_list_call(download));
return;
@@ -331,7 +331,7 @@ DownloadList::resume(Download* download) {
// This will never actually do anything due to the above hash check.
// open_throw(download);
download->set("state_changed", cachedTime.seconds());
download->set("set_state_changed", cachedTime.seconds());
if (download->is_done()) {
download->set_connection_type(download->get_string("connection_seed"));
@@ -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("hashing") != Download::variable_hashing_stopped) {
if (download->get_value("get_hashing") != Download::variable_hashing_stopped) {
download->download()->hash_stop();
download->set_value("hashing", Download::variable_hashing_stopped);
download->set_value("set_hashing", 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("state_changed", cachedTime.seconds());
download->set("set_state_changed", 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("hashing") != Download::variable_hashing_stopped)
if (download->get_value("get_hashing") != 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("hashing");
download->set_value("hashing", Download::variable_hashing_stopped);
int64_t hashing = download->get_value("get_hashing");
download->set_value("set_hashing", 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("complete") && !download->is_done()) {
download->set("state", (int64_t)0);
if (download->get_value("get_complete") && !download->is_done()) {
download->set("set_state", (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("complete", (int64_t)download->is_done());
download->set("set_complete", (int64_t)download->is_done());
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
if (download->get_value("state") == 1)
if (download->get_value("get_state") == 1)
resume(download);
break;
@@ -480,14 +480,14 @@ void
DownloadList::hash_queue(Download* download, int type) {
check_contains(download);
if (download->get_value("hashing") != Download::variable_hashing_stopped)
if (download->get_value("get_hashing") != 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("hashing", type);
download->set_value("set_hashing", type);
if (download->is_open())
throw torrent::internal_error("DownloadList::hash_clear(...) download still open.");
@@ -516,7 +516,7 @@ void
DownloadList::confirm_finished(Download* download) {
check_contains(download);
download->set("complete", (int64_t)1);
download->set("set_complete", (int64_t)1);
download->set_connection_type(download->get_string("connection_seed"));
download->set_priority(download->priority());
@@ -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("state") == 1)
if (!download->is_active() && download->get_value("get_state") == 1)
resume(download);
}
+6 -6
View File
@@ -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("tied_to_file");
const std::string& tie = download->get_string("get_tied_to_file");
// 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("tied_to_file", std::string());
download->set("set_tied_to_file", std::string());
}
Manager::Manager() :
@@ -482,7 +482,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), "tied_to_file")))
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")))
!= m_downloadList->end())
itr = paths.erase(itr);
else
@@ -514,7 +514,7 @@ Manager::receive_hashing_changed() {
continue;
bool tryQuick =
(*itr)->get_value("hashing") == Download::variable_hashing_initial &&
(*itr)->get_value("get_hashing") == Download::variable_hashing_initial &&
(*itr)->download()->file_list()->bitfield()->empty();
if (!tryQuick && foundHashing)
@@ -537,7 +537,7 @@ Manager::receive_hashing_changed() {
(*itr)->download()->hash_stop();
if (foundHashing) {
(*itr)->set_value("hashing", Download::variable_hashing_rehash);
(*itr)->set_value("set_hashing", Download::variable_hashing_rehash);
continue;
}
}
@@ -548,7 +548,7 @@ Manager::receive_hashing_changed() {
} catch (torrent::local_error& e) {
if (tryQuick) {
// Make sure we don't repeat the quick hashing.
(*itr)->set_value("hashing", Download::variable_hashing_rehash);
(*itr)->set_value("set_hashing", Download::variable_hashing_rehash);
} else {
(*itr)->set_hash_failed(true);
+11 -11
View File
@@ -134,19 +134,19 @@ ViewManager::ViewManager(DownloadList* dl) :
m_sort["name"] = new ViewSortName();
m_sort["name_reverse"] = new ViewSortReverse(new ViewSortName());
m_sort["stopped"] = new ViewSortVariableValue("state");
m_sort["started"] = new ViewSortVariableValue("state", true);
m_sort["complete"] = new ViewSortVariableValue("complete");
m_sort["incomplete"] = new ViewSortVariableValue("complete", true);
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["state_changed"] = new ViewSortVariableValue("state_changed");
m_sort["state_changed_reverse"] = new ViewSortVariableValue("state_changed", true);
m_sort["state_changed"] = new ViewSortVariableValue("get_state_changed");
m_sort["state_changed_reverse"] = new ViewSortVariableValue("get_state_changed", true);
m_filter["started"] = new ViewFilterVariableValue("state", 1);
m_filter["stopped"] = new ViewFilterVariableValue("state", 0);
m_filter["complete"] = new ViewFilterVariableValue("complete", 0, true);
m_filter["incomplete"] = new ViewFilterVariableValue("complete", 0);
m_filter["hashing"] = new ViewFilterVariableValue("hashing", 0, 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);
}
void