mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 14:49:21 +00:00
The client is now responsible for sending completed to tracker, fixes
the problem where doing hash checking of completed torrents would cause wrong messages to be sent. Added option to the client for opening a random port in the supplied port range. Cleaned up ui::Download and ui::DownloadList handling of throttle keys and status bar. Added 60s timeout for handshakes. Added ignore key function to input::Bindings. Made the time span of torrent::Rate configurable. Seperate torrent::Rate object for quick and slow time span in torrent::ThrottleControl. Also limited the amount the throttle could over-allocate per tick, not completely fixed. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@480 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+2
-36
@@ -31,7 +31,6 @@
|
||||
#include "input/bindings.h"
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_download_statusbar.h"
|
||||
#include "display/window_statusbar.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
@@ -48,7 +47,6 @@ Download::Download(DPtr d, Control* c) :
|
||||
|
||||
m_windowTitle(new WTitle(d->get_download().get_name())),
|
||||
m_windowDownloadStatus(new WDownloadStatus(d)),
|
||||
m_windowMainStatus(new WMainStatus(&c->get_core())),
|
||||
|
||||
m_window(c->get_display().end()),
|
||||
|
||||
@@ -83,7 +81,6 @@ Download::~Download() {
|
||||
|
||||
delete m_windowTitle;
|
||||
delete m_windowDownloadStatus;
|
||||
delete m_windowMainStatus;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -91,11 +88,9 @@ Download::activate() {
|
||||
if (m_window != m_control->get_display().end())
|
||||
throw std::logic_error("ui::Download::activate() called on an already activated object");
|
||||
|
||||
m_control->get_display().push_front(m_windowDownloadStatus);
|
||||
m_window = m_control->get_display().insert(m_control->get_display().begin(), NULL);
|
||||
|
||||
m_control->get_display().insert(m_control->get_display().begin(), m_windowTitle);
|
||||
m_control->get_display().insert(m_control->get_display().end(), m_windowDownloadStatus);
|
||||
m_control->get_display().insert(m_control->get_display().end(), m_windowMainStatus);
|
||||
m_control->get_display().push_front(m_windowTitle);
|
||||
|
||||
m_control->get_input().push_front(m_bindings);
|
||||
|
||||
@@ -112,7 +107,6 @@ Download::disable() {
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_windowTitle);
|
||||
m_control->get_display().erase(m_windowDownloadStatus);
|
||||
m_control->get_display().erase(m_windowMainStatus);
|
||||
|
||||
m_window = m_control->get_display().end();
|
||||
|
||||
@@ -180,20 +174,6 @@ Download::receive_peer_disconnected(torrent::Peer p) {
|
||||
m_peers.erase(itr);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_read_throttle(int t) {
|
||||
m_windowMainStatus->mark_dirty();
|
||||
|
||||
torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_write_throttle(int t) {
|
||||
m_windowMainStatus->mark_dirty();
|
||||
|
||||
torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_max_uploads(int t) {
|
||||
m_windowDownloadStatus->mark_dirty();
|
||||
@@ -236,20 +216,6 @@ Download::receive_snub_peer() {
|
||||
|
||||
void
|
||||
Download::bind_keys() {
|
||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), 1);
|
||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), -1);
|
||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), 5);
|
||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), -5);
|
||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), 50);
|
||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_write_throttle), -50);
|
||||
|
||||
(*m_bindings)['A'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), 1);
|
||||
(*m_bindings)['Z'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), -1);
|
||||
(*m_bindings)['S'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), 5);
|
||||
(*m_bindings)['X'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), -5);
|
||||
(*m_bindings)['D'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), 50);
|
||||
(*m_bindings)['C'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_read_throttle), -50);
|
||||
|
||||
(*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);
|
||||
|
||||
@@ -47,7 +47,6 @@ class ElementBase;
|
||||
class Download {
|
||||
public:
|
||||
typedef display::WindowTitle WTitle;
|
||||
typedef display::WindowStatusbar WMainStatus;
|
||||
typedef display::WindowDownloadStatusbar WDownloadStatus;
|
||||
|
||||
typedef core::Download* DPtr;
|
||||
@@ -83,8 +82,6 @@ private:
|
||||
void receive_peer_connected(torrent::Peer p);
|
||||
void receive_peer_disconnected(torrent::Peer p);
|
||||
|
||||
void receive_read_throttle(int t);
|
||||
void receive_write_throttle(int t);
|
||||
void receive_max_uploads(int t);
|
||||
void receive_min_peers(int t);
|
||||
void receive_max_peers(int t);
|
||||
@@ -106,7 +103,6 @@ private:
|
||||
|
||||
WTitle* m_windowTitle;
|
||||
WDownloadStatus* m_windowDownloadStatus;
|
||||
WMainStatus* m_windowMainStatus;
|
||||
|
||||
MItr m_window;
|
||||
|
||||
|
||||
+5
-39
@@ -36,7 +36,6 @@
|
||||
#include "display/window_http_queue.h"
|
||||
#include "display/window_input.h"
|
||||
#include "display/window_log.h"
|
||||
#include "display/window_statusbar.h"
|
||||
#include "display/window_title.h"
|
||||
|
||||
#include "control.h"
|
||||
@@ -54,7 +53,6 @@ DownloadList::DownloadList(Control* c) :
|
||||
m_window(c->get_display().end()),
|
||||
|
||||
m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + torrent::get_version())),
|
||||
m_windowStatus(new WStatus(&c->get_core())),
|
||||
m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())),
|
||||
|
||||
m_uiDownload(NULL),
|
||||
@@ -82,7 +80,6 @@ DownloadList::~DownloadList() {
|
||||
std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, rak::call_delete<ElementBase>());
|
||||
|
||||
delete m_windowTitle;
|
||||
delete m_windowStatus;
|
||||
delete m_bindings;
|
||||
|
||||
delete m_windowLog;
|
||||
@@ -100,14 +97,12 @@ DownloadList::activate() {
|
||||
|
||||
m_windowTextInput->set_active(false);
|
||||
|
||||
m_control->get_display().push_front(m_windowTextInput);
|
||||
m_control->get_display().push_front(m_windowHttpQueue);
|
||||
m_control->get_display().push_front(m_windowLog);
|
||||
m_window = m_control->get_display().insert(m_control->get_display().begin(), NULL);
|
||||
m_control->get_display().push_front(m_windowTitle);
|
||||
|
||||
m_control->get_display().push_back(m_windowLog);
|
||||
m_control->get_display().push_back(m_windowHttpQueue);
|
||||
m_control->get_display().push_back(m_windowTextInput);
|
||||
m_control->get_display().push_back(m_windowStatus);
|
||||
|
||||
m_control->get_input().push_front(m_bindings);
|
||||
|
||||
activate_display(DISPLAY_DOWNLOAD_LIST);
|
||||
@@ -129,7 +124,6 @@ DownloadList::disable() {
|
||||
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_windowTitle);
|
||||
m_control->get_display().erase(m_windowStatus);
|
||||
m_control->get_display().erase(m_windowTextInput);
|
||||
m_control->get_display().erase(m_windowLog);
|
||||
m_control->get_display().erase(m_windowHttpQueue);
|
||||
@@ -172,20 +166,6 @@ DownloadList::receive_prev() {
|
||||
m_downloadList.dec_focus();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_read_throttle(int t) {
|
||||
m_windowStatus->mark_dirty();
|
||||
|
||||
torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_write_throttle(int t) {
|
||||
m_windowStatus->mark_dirty();
|
||||
|
||||
torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_start_download() {
|
||||
if (m_downloadList.get_focus() == m_downloadList.end())
|
||||
@@ -245,7 +225,7 @@ DownloadList::receive_check_hash() {
|
||||
|
||||
void
|
||||
DownloadList::receive_view_input() {
|
||||
m_windowStatus->set_active(false);
|
||||
//m_windowStatus->set_active(false);
|
||||
m_windowTextInput->set_active(true);
|
||||
m_control->get_display().adjust_layout();
|
||||
|
||||
@@ -259,7 +239,7 @@ DownloadList::receive_view_input() {
|
||||
|
||||
void
|
||||
DownloadList::receive_exit_input() {
|
||||
m_windowStatus->set_active(true);
|
||||
//m_windowStatus->set_active(true);
|
||||
m_windowTextInput->set_active(false);
|
||||
|
||||
m_control->get_input().set_text_input();
|
||||
@@ -293,20 +273,6 @@ DownloadList::task_update() {
|
||||
|
||||
void
|
||||
DownloadList::setup_keys() {
|
||||
(*m_bindings)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), 1);
|
||||
(*m_bindings)['z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), -1);
|
||||
(*m_bindings)['s'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), 5);
|
||||
(*m_bindings)['x'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), -5);
|
||||
(*m_bindings)['d'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), 50);
|
||||
(*m_bindings)['c'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_write_throttle), -50);
|
||||
|
||||
(*m_bindings)['A'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), 1);
|
||||
(*m_bindings)['Z'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), -1);
|
||||
(*m_bindings)['S'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), 5);
|
||||
(*m_bindings)['X'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), -5);
|
||||
(*m_bindings)['D'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), 50);
|
||||
(*m_bindings)['C'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_read_throttle), -50);
|
||||
|
||||
(*m_bindings)['\x13'] = sigc::mem_fun(*this, &DownloadList::receive_start_download);
|
||||
(*m_bindings)['\x04'] = sigc::mem_fun(*this, &DownloadList::receive_stop_download);
|
||||
(*m_bindings)['\x12'] = sigc::mem_fun(*this, &DownloadList::receive_check_hash);
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace display {
|
||||
class WindowInput;
|
||||
class WindowLog;
|
||||
class WindowLogComplete;
|
||||
class WindowStatusbar;
|
||||
class WindowTitle;
|
||||
}
|
||||
|
||||
@@ -56,7 +55,6 @@ public:
|
||||
typedef display::WindowInput WInput;
|
||||
typedef display::WindowLog WLog;
|
||||
typedef display::WindowLogComplete WLogComplete;
|
||||
typedef display::WindowStatusbar WStatus;
|
||||
typedef display::WindowTitle WTitle;
|
||||
|
||||
typedef utils::ListFocus<core::DownloadList> DList;
|
||||
@@ -94,9 +92,6 @@ private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_read_throttle(int t);
|
||||
void receive_write_throttle(int t);
|
||||
|
||||
void receive_start_download();
|
||||
void receive_stop_download();
|
||||
|
||||
@@ -122,7 +117,6 @@ private:
|
||||
MItr m_window;
|
||||
|
||||
WTitle* m_windowTitle;
|
||||
WStatus* m_windowStatus;
|
||||
WLog* m_windowLog;
|
||||
WInput* m_windowTextInput;
|
||||
WHttp* m_windowHttpQueue;
|
||||
|
||||
@@ -97,7 +97,7 @@ ElementTrackerList::receive_cycle_group() {
|
||||
if (m_focus >= m_download->get_download().get_tracker_size())
|
||||
throw std::logic_error("ui::ElementTrackerList::receive_group_cycle(...) called with an invalid focus");
|
||||
|
||||
m_download->get_download().cycle_tracker_group(m_download->get_download().get_tracker(m_focus).get_group());
|
||||
m_download->get_download().tracker_cycle_group(m_download->get_download().get_tracker(m_focus).get_group());
|
||||
|
||||
m_window->mark_dirty();
|
||||
}
|
||||
|
||||
+49
-2
@@ -22,21 +22,37 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sigc++/bind.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "control.h"
|
||||
#include "download_list.h"
|
||||
#include "display/window_statusbar.h"
|
||||
|
||||
#include "root.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
Root::Root(Control* c) :
|
||||
m_shutdownReceived(false),
|
||||
m_control(c),
|
||||
m_downloadList(NULL),
|
||||
m_windowStatus(NULL) {
|
||||
}
|
||||
|
||||
void
|
||||
Root::init() {
|
||||
if (m_downloadList != NULL)
|
||||
throw std::logic_error("Root::init() called twice on the same object");
|
||||
|
||||
setup_keys();
|
||||
|
||||
m_windowStatus = new WStatus(&m_control->get_core());
|
||||
m_downloadList = new DownloadList(m_control);
|
||||
|
||||
m_control->get_display().push_back(m_windowStatus);
|
||||
|
||||
m_downloadList->activate();
|
||||
m_downloadList->slot_open_uri(sigc::mem_fun(m_control->get_core(), &core::Manager::insert));
|
||||
}
|
||||
@@ -46,7 +62,10 @@ Root::cleanup() {
|
||||
if (m_downloadList->is_active())
|
||||
m_downloadList->disable();
|
||||
|
||||
m_control->get_display().erase(m_windowStatus);
|
||||
|
||||
delete m_downloadList;
|
||||
delete m_windowStatus;
|
||||
|
||||
m_control->get_input().erase(&m_bindings);
|
||||
}
|
||||
@@ -55,8 +74,36 @@ void
|
||||
Root::setup_keys() {
|
||||
m_control->get_input().push_back(&m_bindings);
|
||||
|
||||
m_bindings[KEY_RESIZE] = sigc::mem_fun(m_control->get_display(), &display::Manager::adjust_layout);
|
||||
m_bindings['\x11'] = sigc::bind(sigc::mem_fun(*this, &Root::set_shutdown_received), true);
|
||||
m_bindings['a'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_write_throttle), 1);
|
||||
m_bindings['z'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_write_throttle), -1);
|
||||
m_bindings['s'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_write_throttle), 5);
|
||||
m_bindings['x'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_write_throttle), -5);
|
||||
m_bindings['d'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_write_throttle), 50);
|
||||
m_bindings['c'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_write_throttle), -50);
|
||||
|
||||
m_bindings['A'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), 1);
|
||||
m_bindings['Z'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), -1);
|
||||
m_bindings['S'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), 5);
|
||||
m_bindings['X'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), -5);
|
||||
m_bindings['D'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), 50);
|
||||
m_bindings['C'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), -50);
|
||||
|
||||
m_bindings[KEY_RESIZE] = sigc::mem_fun(m_control->get_display(), &display::Manager::adjust_layout);
|
||||
m_bindings['\x11'] = sigc::bind(sigc::mem_fun(*this, &Root::set_shutdown_received), true);
|
||||
}
|
||||
|
||||
void
|
||||
Root::receive_read_throttle(int t) {
|
||||
//m_downloadList->mark_dirty();
|
||||
|
||||
torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
Root::receive_write_throttle(int t) {
|
||||
//m_downloadList->mark_dirty();
|
||||
|
||||
torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-10
@@ -25,29 +25,40 @@
|
||||
|
||||
#include "input/bindings.h"
|
||||
|
||||
namespace display {
|
||||
class WindowStatusbar;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class DownloadList;
|
||||
|
||||
class Root {
|
||||
public:
|
||||
Root(Control* c) : m_shutdownReceived(false), m_control(c), m_downloadList(NULL) {}
|
||||
typedef display::WindowStatusbar WStatus;
|
||||
|
||||
void init();
|
||||
void cleanup();
|
||||
Root(Control* c);
|
||||
|
||||
bool get_shutdown_received() { return m_shutdownReceived; }
|
||||
void set_shutdown_received(bool v) { m_shutdownReceived = v; }
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
bool get_shutdown_received() { return m_shutdownReceived; }
|
||||
void set_shutdown_received(bool v) { m_shutdownReceived = v; }
|
||||
|
||||
private:
|
||||
void setup_keys();
|
||||
void setup_keys();
|
||||
|
||||
bool m_shutdownReceived;
|
||||
void receive_read_throttle(int t);
|
||||
void receive_write_throttle(int t);
|
||||
|
||||
Control* m_control;
|
||||
DownloadList* m_downloadList;
|
||||
bool m_shutdownReceived;
|
||||
|
||||
input::Bindings m_bindings;
|
||||
Control* m_control;
|
||||
DownloadList* m_downloadList;
|
||||
|
||||
WStatus* m_windowStatus;
|
||||
|
||||
input::Bindings m_bindings;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user