* Cache the current ceiling in rak::partial_queue.

* Added "enable_trackers=yes|no" option that can turn on/off the use
of trackers on all torrents.

* Cleanup of the API, including a new TrackerList class.

* When requesting from seeders, either continue a chunk another seeder
started or try a new one. This means seeders don't end up downloading
non-rare chunks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@658 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-28 21:04:07 +00:00
parent a811f53301
commit 8ea6f78e21
10 changed files with 108 additions and 64 deletions
+30 -24
View File
@@ -38,8 +38,9 @@
#include <stdexcept>
#include <sigc++/bind.h>
#include <torrent/torrent.h>
#include <rak/functional.h>
#include <torrent/torrent.h>
#include <torrent/tracker_list.h>
#include "core/download.h"
#include "input/bindings.h"
@@ -251,39 +252,44 @@ 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);
(*m_bindings)['2'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_uploads), 1);
(*m_bindings)['3'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_min_peers), -5);
(*m_bindings)['4'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_min_peers), 5);
(*m_bindings)['5'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_peers), -5);
(*m_bindings)['6'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_peers), 5);
(*m_bindings)['+'] = sigc::mem_fun(*this, &Download::receive_next_priority);
(*m_bindings)['-'] = sigc::mem_fun(*this, &Download::receive_prev_priority);
(*m_bindings)['1'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), -1);
(*m_bindings)['2'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_uploads), 1);
(*m_bindings)['3'] = sigc::bind(sigc::mem_fun(this, &Download::receive_min_peers), -5);
(*m_bindings)['4'] = sigc::bind(sigc::mem_fun(this, &Download::receive_min_peers), 5);
(*m_bindings)['5'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_peers), -5);
(*m_bindings)['6'] = sigc::bind(sigc::mem_fun(this, &Download::receive_max_peers), 5);
(*m_bindings)['+'] = sigc::mem_fun(this, &Download::receive_next_priority);
(*m_bindings)['-'] = sigc::mem_fun(this, &Download::receive_prev_priority);
(*m_bindings)['k'] = sigc::mem_fun(*this, &Download::receive_disconnect_peer);
(*m_bindings)['k'] = sigc::mem_fun(this, &Download::receive_disconnect_peer);
(*m_bindings)['t'] = sigc::bind(sigc::mem_fun(m_download->get_download(), &torrent::Download::tracker_manual_request), false);
(*m_bindings)['T'] = sigc::bind(sigc::mem_fun(m_download->get_download(), &torrent::Download::tracker_manual_request), true);
(*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)['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);
(*m_bindings)['i'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_CHUNKS_SEEN);
(*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);
(*m_bindings)['i'] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_CHUNKS_SEEN);
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &Download::receive_prev);
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &Download::receive_next);
(*m_bindings)[KEY_UP] = sigc::mem_fun(this, &Download::receive_prev);
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(this, &Download::receive_next);
// Key bindings for sub-ui's.
m_uiArray[DISPLAY_PEER_LIST]->get_bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_FILE_LIST);
m_uiArray[DISPLAY_PEER_INFO]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_FILE_LIST]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_TRACKER_LIST]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_CHUNKS_SEEN]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(*this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_PEER_LIST]->get_bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_FILE_LIST);
m_uiArray[DISPLAY_PEER_INFO]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_FILE_LIST]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_TRACKER_LIST]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_CHUNKS_SEEN]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
// Doesn't belong here.
m_uiArray[DISPLAY_PEER_LIST]->get_bindings()['*'] = sigc::mem_fun(*this, &Download::receive_snub_peer);
m_uiArray[DISPLAY_PEER_INFO]->get_bindings()['*'] = sigc::mem_fun(*this, &Download::receive_snub_peer);
m_uiArray[DISPLAY_PEER_LIST]->get_bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
m_uiArray[DISPLAY_PEER_INFO]->get_bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
}
void
+1
View File
@@ -110,6 +110,7 @@ private:
void receive_change(Display d);
void receive_snub_peer();
void receive_manual_request(bool force);
void bind_keys();
+21 -16
View File
@@ -36,7 +36,8 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include <torrent/tracker_list.h>
#include "display/window_tracker_list.h"
#include "input/manager.h"
@@ -60,7 +61,7 @@ ElementTrackerList::ElementTrackerList(core::Download* d) :
void
ElementTrackerList::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementTrackerList::activate(...) called on an object in the wrong state");
throw torrent::internal_error("ui::ElementTrackerList::activate(...) called on an object in the wrong state");
c->input()->push_front(&m_bindings);
@@ -70,7 +71,7 @@ ElementTrackerList::activate(Control* c, MItr mItr) {
void
ElementTrackerList::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::disable(...) called on an object in the wrong state");
throw torrent::internal_error("ui::ElementTrackerList::disable(...) called on an object in the wrong state");
c->input()->erase(&m_bindings);
@@ -81,12 +82,14 @@ ElementTrackerList::disable(Control* c) {
void
ElementTrackerList::receive_disable() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_disable(...) called on a disabled object");
throw torrent::internal_error("ui::ElementTrackerList::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();
torrent::Tracker t = m_download->get_download().tracker_list().get(m_focus);
if (t.is_enabled())
t.disable();
else
m_download->get_download().tracker(m_focus).enable();
t.enable();
m_window->mark_dirty();
}
@@ -94,9 +97,9 @@ ElementTrackerList::receive_disable() {
void
ElementTrackerList::receive_next() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_next(...) called on a disabled object");
throw torrent::internal_error("ui::ElementTrackerList::receive_next(...) called on a disabled object");
if (++m_focus >= m_download->get_download().size_trackers())
if (++m_focus >= m_download->get_download().tracker_list().size())
m_focus = 0;
m_window->mark_dirty();
@@ -105,15 +108,15 @@ ElementTrackerList::receive_next() {
void
ElementTrackerList::receive_prev() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_prev(...) called on a disabled object");
throw torrent::internal_error("ui::ElementTrackerList::receive_prev(...) called on a disabled object");
if (m_download->get_download().size_trackers() == 0)
if (m_download->get_download().tracker_list().size() == 0)
return;
if (m_focus != 0)
--m_focus;
else
m_focus = m_download->get_download().size_trackers() - 1;
m_focus = m_download->get_download().tracker_list().size() - 1;
m_window->mark_dirty();
}
@@ -121,12 +124,14 @@ ElementTrackerList::receive_prev() {
void
ElementTrackerList::receive_cycle_group() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_group_cycle(...) called on a disabled object");
throw torrent::internal_error("ui::ElementTrackerList::receive_group_cycle(...) called on a disabled object");
if (m_focus >= m_download->get_download().size_trackers())
throw std::logic_error("ui::ElementTrackerList::receive_group_cycle(...) called with an invalid focus");
torrent::TrackerList tl = m_download->get_download().tracker_list();
m_download->get_download().tracker_cycle_group(m_download->get_download().tracker(m_focus).group());
if (m_focus >= tl.size())
throw torrent::internal_error("ui::ElementTrackerList::receive_group_cycle(...) called with an invalid focus");
tl.cycle_group(tl.get(m_focus).group());
m_window->mark_dirty();
}