mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +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:
@@ -4,8 +4,6 @@ SUBDIRS = \
|
||||
|
||||
EXTRA_DIST= \
|
||||
autogen.sh \
|
||||
doc/rtorrent.1.txt \
|
||||
doc/rtorrent.rc \
|
||||
rak/algorithm.h \
|
||||
rak/functional.h \
|
||||
scripts/checks.m4 \
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
AC_INIT(rtorrent, 0.2.6, jaris@ifi.uio.no)
|
||||
AC_INIT(rtorrent, 0.2.7, jaris@ifi.uio.no)
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
@@ -20,7 +20,7 @@ TORRENT_CHECK_EXECINFO()
|
||||
TORRENT_CHECK_CURL()
|
||||
TORRENT_OTFD()
|
||||
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.6.6,
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.6.7,
|
||||
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
|
||||
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
|
||||
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
man_MANS = rtorrent.1
|
||||
|
||||
EXTRA_DIST= \
|
||||
faq.xml \
|
||||
rtorrent.1 \
|
||||
rtorrent.1.xml \
|
||||
rtorrent.rc
|
||||
|
||||
+8
-1
@@ -352,7 +352,7 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>port = <replaceable>a-b</replaceable></term>
|
||||
<term>port_range = <replaceable>a-b</replaceable></term>
|
||||
<listitem><para>
|
||||
Try to open a listening port in the range
|
||||
<emphasis>a</emphasis> up to and including
|
||||
@@ -360,6 +360,13 @@
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>port_random = <replaceable>yes | no</replaceable></term>
|
||||
<listitem><para>
|
||||
Open the listening port at a random position in the port range.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>check_hash = <replaceable>yes | no</replaceable></term>
|
||||
<listitem><para>
|
||||
|
||||
+4
-1
@@ -34,7 +34,10 @@
|
||||
#bind = 127.0.0.1
|
||||
|
||||
# Port range to use for listening.
|
||||
#port = 6890-6999
|
||||
#port_range = 6890-6999
|
||||
|
||||
# Start opening ports at a random position within the port range.
|
||||
#port_random = no
|
||||
|
||||
# Check hash for finished torrents. Might be usefull until the bug is
|
||||
# fixed that causes lack of diskspace not to be properly reported.
|
||||
|
||||
@@ -22,12 +22,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "download.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sigc++/bind.h>
|
||||
#include <sigc++/hide.h>
|
||||
#include <sigc++/signal.h>
|
||||
|
||||
#include "download.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
void
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
|
||||
void set_root_directory(const std::string& d);
|
||||
|
||||
// Helper functions for calling functions in torrent::Download
|
||||
// through sigc++.
|
||||
template <typename Ret, Ret (torrent::Download::*func)()>
|
||||
void call() { (m_download.*func)(); }
|
||||
|
||||
|
||||
+62
-14
@@ -50,13 +50,11 @@ Manager::initialize() {
|
||||
m_httpQueue.slot_factory(m_poll.get_http_factory());
|
||||
|
||||
CurlStack::init();
|
||||
|
||||
if (!torrent::listen_open(m_portFirst, m_portLast))
|
||||
throw std::runtime_error("Could not open port for listening.");
|
||||
listen_open();
|
||||
|
||||
// Register slots to be called when a download is inserted/erased,
|
||||
// opened or closed.
|
||||
m_downloadList.slot_map_insert().insert("2_connect_network_log", sigc::bind(sigc::ptr_fun(&connect_signal_network_log), sigc::mem_fun(m_logComplete, &Log::push_front)));
|
||||
m_downloadList.slot_map_insert().insert("1_connect_network_log", sigc::bind(sigc::ptr_fun(&connect_signal_network_log), sigc::mem_fun(m_logComplete, &Log::push_front)));
|
||||
m_downloadList.slot_map_insert().insert("3_manager_start", sigc::mem_fun(*this, &Manager::start));
|
||||
m_downloadList.slot_map_insert().insert("4_store_save", sigc::mem_fun(m_downloadStore, &DownloadStore::save));
|
||||
|
||||
@@ -76,6 +74,8 @@ Manager::initialize() {
|
||||
m_downloadList.slot_map_stop().insert("1_download_stop", sigc::mem_fun(&Download::call<void, &torrent::Download::stop>));
|
||||
m_downloadList.slot_map_stop().insert("2_hash_resume_save", sigc::mem_fun(&Download::call<void, &torrent::Download::hash_resume_save>));
|
||||
m_downloadList.slot_map_stop().insert("3_store_save", sigc::mem_fun(m_downloadStore, &DownloadStore::save));
|
||||
|
||||
m_downloadList.slot_map_finished().insert("1_download_done", sigc::bind(sigc::mem_fun(*this, &Manager::receive_download_done), false));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -145,16 +145,7 @@ Manager::check_hash(Download* d) {
|
||||
bool restart = d->get_download().is_active();
|
||||
|
||||
try {
|
||||
m_downloadList.close(d);
|
||||
d->get_download().hash_resume_clear();
|
||||
m_downloadList.open(d);
|
||||
|
||||
if (d->get_download().is_hash_checking() ||
|
||||
d->get_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())
|
||||
throw std::logic_error("Manager::check_hash(...) closed the torrent but it was found in m_hashQueue");
|
||||
prepare_hash_check(d);
|
||||
|
||||
if (restart)
|
||||
m_hashQueue.insert(d, sigc::bind(sigc::mem_fun(m_downloadList, &DownloadList::start), d));
|
||||
@@ -167,6 +158,39 @@ Manager::check_hash(Download* d) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_download_done(Download* d, bool check_hash) {
|
||||
if (check_hash) {
|
||||
// Start the hash checking, send completed to tracker after
|
||||
// finishing.
|
||||
prepare_hash_check(d);
|
||||
|
||||
// TODO: Need to restart the torrent.
|
||||
m_hashQueue.insert(d, sigc::bind(sigc::mem_fun(*this, &Manager::receive_download_done_hash_checked), d));
|
||||
|
||||
} else {
|
||||
receive_download_done_hash_checked(d);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::listen_open() {
|
||||
if (m_portFirst > m_portLast)
|
||||
throw std::runtime_error("Invalid port range for listening");
|
||||
|
||||
if (m_portRandom) {
|
||||
int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1);
|
||||
|
||||
if (!torrent::listen_open(boundary, m_portLast) &&
|
||||
!torrent::listen_open(m_portFirst, boundary))
|
||||
throw std::runtime_error("Could not open port for listening.");
|
||||
|
||||
} else {
|
||||
if (!torrent::listen_open(m_portFirst, m_portLast))
|
||||
throw std::runtime_error("Could not open port for listening.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::create_http(const std::string& uri) {
|
||||
core::HttpQueue::iterator itr = m_httpQueue.insert(uri);
|
||||
@@ -188,10 +212,34 @@ Manager::create_final(std::istream* s) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::prepare_hash_check(Download* d) {
|
||||
m_downloadList.close(d);
|
||||
d->get_download().hash_resume_clear();
|
||||
m_downloadList.open(d);
|
||||
|
||||
if (d->get_download().is_hash_checking() ||
|
||||
d->get_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())
|
||||
throw std::logic_error("Manager::check_hash(...) closed the torrent but it was found in m_hashQueue");
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_http_failed(std::string msg) {
|
||||
m_logImportant.push_front("Http download error: \"" + msg + "\"");
|
||||
m_logComplete.push_front("Http download error: \"" + msg + "\"");
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_download_done_hash_checked(Download* d) {
|
||||
if (!d->get_download().is_active())
|
||||
m_downloadList.start(d);
|
||||
|
||||
// Don't send if we did a hash check and found incompelete chunks.
|
||||
//if (d->is_done())
|
||||
d->get_download().tracker_send_completed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-3
@@ -44,7 +44,7 @@ public:
|
||||
typedef sigc::slot1<void, DownloadList::iterator> SlotReady;
|
||||
typedef sigc::slot0<void> SlotFailed;
|
||||
|
||||
Manager() : m_portFirst(6890), m_portLast(6999) {}
|
||||
Manager() : m_portRandom(false), m_portFirst(6890), m_portLast(6999) {}
|
||||
|
||||
DownloadList& get_download_list() { return m_downloadList; }
|
||||
DownloadStore& get_download_store() { return m_downloadStore; }
|
||||
@@ -55,6 +55,9 @@ public:
|
||||
Log& get_log_important() { return m_logImportant; }
|
||||
Log& get_log_complete() { return m_logComplete; }
|
||||
|
||||
void set_port_random(bool v) { m_portRandom = v; }
|
||||
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
|
||||
|
||||
void initialize();
|
||||
void cleanup();
|
||||
|
||||
@@ -66,14 +69,18 @@ public:
|
||||
|
||||
void check_hash(Download* d);
|
||||
|
||||
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
|
||||
void receive_download_done(Download* d, bool check_hash);
|
||||
|
||||
private:
|
||||
void listen_open();
|
||||
|
||||
void create_http(const std::string& uri);
|
||||
void create_final(std::istream* s);
|
||||
|
||||
void receive_debug_tracker(std::istream* s);
|
||||
void prepare_hash_check(Download* d);
|
||||
|
||||
void receive_http_failed(std::string msg);
|
||||
void receive_download_done_hash_checked(Download* d);
|
||||
|
||||
DownloadList m_downloadList;
|
||||
DownloadStore m_downloadStore;
|
||||
@@ -84,6 +91,7 @@ private:
|
||||
Log m_logImportant;
|
||||
Log m_logComplete;
|
||||
|
||||
bool m_portRandom;
|
||||
int m_portFirst;
|
||||
int m_portLast;
|
||||
};
|
||||
|
||||
@@ -31,7 +31,8 @@ namespace input {
|
||||
|
||||
class Bindings : private std::map<int, sigc::slot0<void> > {
|
||||
public:
|
||||
typedef std::map<int, sigc::slot0<void> > Base;
|
||||
typedef sigc::slot0<void> Slot;
|
||||
typedef std::map<int, Slot > Base;
|
||||
|
||||
using Base::iterator;
|
||||
using Base::const_iterator;
|
||||
@@ -50,13 +51,15 @@ public:
|
||||
|
||||
Bindings() : m_active(true) {}
|
||||
|
||||
void activate() { m_active = true; }
|
||||
void disable() { m_active = false; }
|
||||
void activate() { m_active = true; }
|
||||
void disable() { m_active = false; }
|
||||
|
||||
bool pressed(int key);
|
||||
bool pressed(int key);
|
||||
|
||||
void ignore(int key) { (*this)[key] = Slot(); }
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+3
-2
@@ -107,7 +107,7 @@ parse_options(ui::Control* c, OptionHandler* optionHandler, int argc, char** arg
|
||||
optionParser.insert_option('b', sigc::bind<0>(sigc::mem_fun(*optionHandler, &OptionHandler::process), "bind"));
|
||||
optionParser.insert_option('d', sigc::bind<0>(sigc::mem_fun(*optionHandler, &OptionHandler::process), "directory"));
|
||||
optionParser.insert_option('i', sigc::bind<0>(sigc::mem_fun(*optionHandler, &OptionHandler::process), "ip"));
|
||||
optionParser.insert_option('p', sigc::bind<0>(sigc::mem_fun(*optionHandler, &OptionHandler::process), "port"));
|
||||
optionParser.insert_option('p', sigc::bind<0>(sigc::mem_fun(*optionHandler, &OptionHandler::process), "port_range"));
|
||||
optionParser.insert_option('s', sigc::bind<0>(sigc::mem_fun(*optionHandler, &OptionHandler::process), "session"));
|
||||
|
||||
optionParser.insert_option_list('o', sigc::mem_fun(*optionHandler, &OptionHandler::process));
|
||||
@@ -126,7 +126,8 @@ initialize_option_handler(ui::Control* c, OptionHandler* optionHandler) {
|
||||
|
||||
optionHandler->insert("bind", new OptionHandlerString(c, &apply_bind, &validate_ip));
|
||||
optionHandler->insert("ip", new OptionHandlerString(c, &apply_ip, &validate_ip));
|
||||
optionHandler->insert("port", new OptionHandlerString(c, &apply_port_range, &validate_port_range));
|
||||
optionHandler->insert("port_range", new OptionHandlerString(c, &apply_port_range, &validate_port_range));
|
||||
optionHandler->insert("port_random", new OptionHandlerString(c, &apply_port_random, &validate_yes_no));
|
||||
|
||||
optionHandler->insert("check_hash", new OptionHandlerString(c, &apply_check_hash, &validate_yes_no));
|
||||
optionHandler->insert("directory", new OptionHandlerString(c, &apply_download_directory, &validate_directory));
|
||||
|
||||
@@ -144,6 +144,11 @@ apply_port_range(ui::Control* m, const std::string& arg) {
|
||||
m->get_core().set_port_range(a, b);
|
||||
}
|
||||
|
||||
void
|
||||
apply_port_random(ui::Control* m, const std::string& arg) {
|
||||
m->get_core().set_port_random(arg == "yes");
|
||||
}
|
||||
|
||||
void
|
||||
apply_tracker_dump(ui::Control* m, const std::string& arg) {
|
||||
if (arg == "yes")
|
||||
@@ -155,9 +160,9 @@ apply_tracker_dump(ui::Control* m, const std::string& arg) {
|
||||
void
|
||||
apply_check_hash(ui::Control* m, const std::string& arg) {
|
||||
if (arg == "yes")
|
||||
m->get_core().get_download_list().slot_map_finished().insert("1_check_hash", sigc::mem_fun(m->get_core(), &core::Manager::check_hash));
|
||||
m->get_core().get_download_list().slot_map_finished().insert("1_download_done", sigc::bind(sigc::mem_fun(m->get_core(), &core::Manager::receive_download_done), true));
|
||||
else
|
||||
m->get_core().get_download_list().slot_map_finished().erase("1_check_hash");
|
||||
m->get_core().get_download_list().slot_map_finished().insert("1_download_done", sigc::bind(sigc::mem_fun(m->get_core(), &core::Manager::receive_download_done), false));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -59,6 +59,7 @@ void apply_max_open_files(ui::Control* m, int arg);
|
||||
void apply_ip(ui::Control* m, const std::string& arg);
|
||||
void apply_bind(ui::Control* m, const std::string& arg);
|
||||
void apply_port_range(ui::Control* m, const std::string& arg);
|
||||
void apply_port_random(ui::Control* m, const std::string& arg);
|
||||
void apply_tracker_dump(ui::Control* m, const std::string& arg);
|
||||
void apply_check_hash(ui::Control* m, const std::string& arg);
|
||||
|
||||
|
||||
+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