* Scheduled tasks, like hash checking, didn't get called when

downloading with curl on epoll unless sockets triggered events.

* Checking whetever we're interested in a peer's pieces wasn't
finished, doh.

* Don't use shorter timeout for "stopped" tracker request, the client
now makes sure it shuts down within 5 seconds.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@577 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-10-07 20:01:38 +00:00
parent 65573ec1ee
commit 881f515d03
17 changed files with 182 additions and 119 deletions
+36 -12
View File
@@ -38,20 +38,38 @@
#include <unistd.h> #include <unistd.h>
#include "core/manager.h"
#include "display/canvas.h" #include "display/canvas.h"
#include "display/window.h" #include "display/window.h"
#include "display/manager.h"
#include "input/manager.h"
#include "input/input_event.h"
#include "ui/root.h"
#include "control.h" #include "control.h"
Control::Control() : Control::Control() :
m_shutdownReceived(false) { m_shutdownReceived(false),
m_ui(new ui::Root()),
m_core(new core::Manager()),
m_display(new display::Manager()),
m_input(new input::Manager()),
m_inputStdin(new input::InputEvent(STDIN_FILENO)) {
m_inputStdin = new input::InputEvent(STDIN_FILENO);
m_inputStdin->slot_pressed(sigc::mem_fun(m_input, &input::Manager::pressed)); m_inputStdin->slot_pressed(sigc::mem_fun(m_input, &input::Manager::pressed));
m_taskShutdown.set_iterator(utils::taskScheduler.end());
m_taskShutdown.set_slot(sigc::mem_fun(*this, &Control::receive_shutdown));
} }
Control::~Control() { Control::~Control() {
delete m_inputStdin; delete m_inputStdin;
delete m_input;
delete m_ui;
delete m_display;
delete m_core;
} }
void void
@@ -59,22 +77,24 @@ Control::initialize() {
display::Canvas::initialize(); display::Canvas::initialize();
display::Window::slot_adjust(sigc::mem_fun(m_display, &display::Manager::adjust_layout)); display::Window::slot_adjust(sigc::mem_fun(m_display, &display::Manager::adjust_layout));
m_core.get_poll_manager()->signal_interrupted().connect(sigc::mem_fun(*m_inputStdin, &input::InputEvent::event_read)); m_core->get_poll_manager()->signal_interrupted().connect(sigc::mem_fun(*m_inputStdin, &input::InputEvent::event_read));
m_core.get_poll_manager()->signal_interrupted().connect(sigc::ptr_fun(display::Canvas::do_update)); m_core->get_poll_manager()->signal_interrupted().connect(sigc::ptr_fun(display::Canvas::do_update));
m_core.initialize_second(); m_core->initialize_second();
m_ui.init(this); m_ui->init(this);
m_inputStdin->insert(m_core.get_poll_manager()->get_torrent_poll()); m_inputStdin->insert(m_core->get_poll_manager()->get_torrent_poll());
} }
void void
Control::cleanup() { Control::cleanup() {
m_inputStdin->remove(m_core.get_poll_manager()->get_torrent_poll()); utils::taskScheduler.erase(&m_taskShutdown);
m_ui.cleanup(); m_inputStdin->remove(m_core->get_poll_manager()->get_torrent_poll());
m_core.cleanup();
m_ui->cleanup();
m_core->cleanup();
display::Canvas::erase_std(); display::Canvas::erase_std();
display::Canvas::refresh_std(); display::Canvas::refresh_std();
@@ -89,9 +109,13 @@ Control::receive_shutdown() {
if (!m_shutdownReceived) { if (!m_shutdownReceived) {
torrent::listen_close(); torrent::listen_close();
m_core.shutdown(false); m_core->shutdown(false);
m_shutdownReceived = true; m_shutdownReceived = true;
if (!utils::taskScheduler.is_scheduled(&m_taskShutdown))
utils::taskScheduler.insert(&m_taskShutdown, utils::Timer::cache() + 5 * 1000000);
} else { } else {
m_core.shutdown(true); m_core->shutdown(true);
} }
} }
+31 -16
View File
@@ -34,16 +34,29 @@
// Skomakerveien 33 // Skomakerveien 33
// 3185 Skoppum, NORWAY // 3185 Skoppum, NORWAY
#ifndef RTORRENT_UI_CONTROL_H #ifndef RTORRENT_CONTROL_H
#define RTORRENT_UI_CONTROL_H #define RTORRENT_CONTROL_H
#include <torrent/torrent.h> #include <torrent/torrent.h>
#include "core/manager.h" #include "utils/task.h"
#include "display/manager.h"
#include "input/manager.h" namespace ui {
#include "input/input_event.h" class Root;
#include "ui/root.h" }
namespace core {
class Manager;
}
namespace display {
class Manager;
}
namespace input {
class InputEvent;
class Manager;
}
class Control { class Control {
public: public:
@@ -53,11 +66,11 @@ public:
bool is_shutdown_completed() { return m_shutdownReceived && torrent::is_inactive(); } bool is_shutdown_completed() { return m_shutdownReceived && torrent::is_inactive(); }
bool is_shutdown_received() { return m_shutdownReceived; } bool is_shutdown_received() { return m_shutdownReceived; }
ui::Root& get_ui() { return m_ui; } ui::Root* ui() { return m_ui; }
core::Manager& get_core() { return m_core; } core::Manager* core() { return m_core; }
display::Manager& get_display() { return m_display; } display::Manager* display() { return m_display; }
input::Manager& get_input() { return m_input; } input::Manager* input() { return m_input; }
input::InputEvent* get_input_stdin() { return m_inputStdin; } input::InputEvent* input_stdin() { return m_inputStdin; }
void initialize(); void initialize();
void cleanup(); void cleanup();
@@ -70,11 +83,13 @@ private:
bool m_shutdownReceived; bool m_shutdownReceived;
ui::Root m_ui; ui::Root* m_ui;
core::Manager m_core; core::Manager* m_core;
display::Manager m_display; display::Manager* m_display;
input::Manager m_input; input::Manager* m_input;
input::InputEvent* m_inputStdin; input::InputEvent* m_inputStdin;
utils::TaskItem m_taskShutdown;
}; };
#endif #endif
+5 -1
View File
@@ -88,8 +88,12 @@ PollManagerEPoll::poll(utils::Timer timeout) {
m_httpStack.perform(); m_httpStack.perform();
if (!FD_ISSET(static_cast<torrent::PollEPoll*>(m_poll)->get_fd(), m_readSet)) if (!FD_ISSET(static_cast<torrent::PollEPoll*>(m_poll)->get_fd(), m_readSet)) {
// Need to call perform here so that scheduled task get done
// even if there's no socket events outside of the http stuff.
torrent::perform();
return; return;
}
// Clear the timeout since we've already used it in the select call. // Clear the timeout since we've already used it in the select call.
timeout = utils::Timer(); timeout = utils::Timer();
+9 -7
View File
@@ -56,8 +56,10 @@
#include "core/download.h" #include "core/download.h"
#include "core/download_factory.h" #include "core/download_factory.h"
#include "core/manager.h"
#include "display/canvas.h" #include "display/canvas.h"
#include "display/window.h" #include "display/window.h"
#include "display/manager.h"
#include "input/bindings.h" #include "input/bindings.h"
#include "utils/task.h" #include "utils/task.h"
@@ -162,10 +164,10 @@ load_option_file(const std::string& filename, OptionHandler* optionHandler, bool
void void
load_session_torrents(Control* c) { load_session_torrents(Control* c) {
// Load session torrents. // Load session torrents.
std::list<std::string> l = c->get_core().get_download_store().get_formated_entries().make_list(); std::list<std::string> l = c->core()->get_download_store().get_formated_entries().make_list();
for (std::list<std::string>::iterator first = l.begin(), last = l.end(); first != last; ++first) { for (std::list<std::string>::iterator first = l.begin(), last = l.end(); first != last; ++first) {
core::DownloadFactory* f = new core::DownloadFactory(*first, &c->get_core()); core::DownloadFactory* f = new core::DownloadFactory(*first, c->core());
// Replace with session torrent flag. // Replace with session torrent flag.
f->set_session(true); f->set_session(true);
@@ -179,7 +181,7 @@ void
load_arg_torrents(Control* c, char** first, char** last) { load_arg_torrents(Control* c, char** first, char** last) {
//std::for_each(begin, end, std::bind1st(std::mem_fun(&core::Manager::insert), &c->get_core())); //std::for_each(begin, end, std::bind1st(std::mem_fun(&core::Manager::insert), &c->get_core()));
for (; first != last; ++first) { for (; first != last; ++first) {
core::DownloadFactory* f = new core::DownloadFactory(*first, &c->get_core()); core::DownloadFactory* f = new core::DownloadFactory(*first, c->core());
// Replace with session torrent flag. // Replace with session torrent flag.
f->set_start(true); f->set_start(true);
@@ -209,7 +211,7 @@ main(int argc, char** argv) {
SignalHandler::set_handler(SIGBUS, sigc::bind(sigc::ptr_fun(&do_panic), SIGBUS)); SignalHandler::set_handler(SIGBUS, sigc::bind(sigc::ptr_fun(&do_panic), SIGBUS));
SignalHandler::set_handler(SIGFPE, sigc::bind(sigc::ptr_fun(&do_panic), SIGFPE)); SignalHandler::set_handler(SIGFPE, sigc::bind(sigc::ptr_fun(&do_panic), SIGFPE));
uiControl.get_core().initialize_first(); uiControl.core()->initialize_first();
if (getenv("HOME")) if (getenv("HOME"))
load_option_file(getenv("HOME") + std::string("/.rtorrent.rc"), &optionHandler); load_option_file(getenv("HOME") + std::string("/.rtorrent.rc"), &optionHandler);
@@ -221,7 +223,7 @@ main(int argc, char** argv) {
load_session_torrents(&uiControl); load_session_torrents(&uiControl);
load_arg_torrents(&uiControl, argv + firstArg, argv + argc); load_arg_torrents(&uiControl, argv + firstArg, argv + argc);
uiControl.get_display().adjust_layout(); uiControl.display()->adjust_layout();
while (!uiControl.is_shutdown_completed()) { while (!uiControl.is_shutdown_completed()) {
utils::Timer::update(); utils::Timer::update();
@@ -231,10 +233,10 @@ main(int argc, char** argv) {
// the throttle task in libtorrent. // the throttle task in libtorrent.
if (!utils::displayScheduler.empty() && if (!utils::displayScheduler.empty() &&
utils::displayScheduler.get_next_timeout() <= utils::Timer::cache()) utils::displayScheduler.get_next_timeout() <= utils::Timer::cache())
uiControl.get_display().do_update(); uiControl.display()->do_update();
// Do shutdown check before poll, not after. // Do shutdown check before poll, not after.
uiControl.get_core().get_poll_manager()->poll(!utils::taskScheduler.empty() ? uiControl.core()->get_poll_manager()->poll(!utils::taskScheduler.empty() ?
utils::taskScheduler.get_next_timeout() - utils::Timer::cache() : utils::taskScheduler.get_next_timeout() - utils::Timer::cache() :
60 * 1000000); 60 * 1000000);
} }
+18 -16
View File
@@ -40,7 +40,9 @@
#include <torrent/torrent.h> #include <torrent/torrent.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "core/manager.h"
#include "utils/directory.h" #include "utils/directory.h"
#include "control.h" #include "control.h"
#include "option_handler_rules.h" #include "option_handler_rules.h"
@@ -116,35 +118,35 @@ validate_throttle_interval(int arg) {
void void
apply_download_min_peers(Control* m, int arg) { apply_download_min_peers(Control* m, int arg) {
m->get_core().get_download_list().slot_map_insert()["1_min_peers"] = sigc::bind(sigc::mem_fun(&core::Download::call<void, uint32_t, &torrent::Download::set_peers_min>), arg); m->core()->get_download_list().slot_map_insert()["1_min_peers"] = sigc::bind(sigc::mem_fun(&core::Download::call<void, uint32_t, &torrent::Download::set_peers_min>), arg);
} }
void void
apply_download_max_peers(Control* m, int arg) { apply_download_max_peers(Control* m, int arg) {
m->get_core().get_download_list().slot_map_insert()["1_max_peers"] = sigc::bind(sigc::mem_fun(&core::Download::call<void, uint32_t, &torrent::Download::set_peers_max>), arg); m->core()->get_download_list().slot_map_insert()["1_max_peers"] = sigc::bind(sigc::mem_fun(&core::Download::call<void, uint32_t, &torrent::Download::set_peers_max>), arg);
} }
void void
apply_download_max_uploads(Control* m, int arg) { apply_download_max_uploads(Control* m, int arg) {
m->get_core().get_download_list().slot_map_insert()["1_max_uploads"] = sigc::bind(sigc::mem_fun(&core::Download::call<void, uint32_t, &torrent::Download::set_uploads_max>), arg); m->core()->get_download_list().slot_map_insert()["1_max_uploads"] = sigc::bind(sigc::mem_fun(&core::Download::call<void, uint32_t, &torrent::Download::set_uploads_max>), arg);
} }
void void
apply_download_directory(Control* m, const std::string& arg) { apply_download_directory(Control* m, const std::string& arg) {
if (!arg.empty()) if (!arg.empty())
m->get_core().get_download_list().slot_map_insert()["1_directory"] = sigc::bind(sigc::mem_fun(&core::Download::set_root_directory), arg); m->core()->get_download_list().slot_map_insert()["1_directory"] = sigc::bind(sigc::mem_fun(&core::Download::set_root_directory), arg);
else else
m->get_core().get_download_list().slot_map_insert().erase("1_directory"); m->core()->get_download_list().slot_map_insert().erase("1_directory");
} }
void void
apply_connection_leech(Control* m, const std::string& arg) { apply_connection_leech(Control* m, const std::string& arg) {
m->get_core().get_download_list().slot_map_insert()["1_connection_leech"] = sigc::bind(sigc::mem_fun(&core::Download::set_connection_leech), arg); m->core()->get_download_list().slot_map_insert()["1_connection_leech"] = sigc::bind(sigc::mem_fun(&core::Download::set_connection_leech), arg);
} }
void void
apply_connection_seed(Control* m, const std::string& arg) { apply_connection_seed(Control* m, const std::string& arg) {
m->get_core().get_download_list().slot_map_insert()["1_connection_seed"] = sigc::bind(sigc::mem_fun(&core::Download::set_connection_seed), arg); m->core()->get_download_list().slot_map_insert()["1_connection_seed"] = sigc::bind(sigc::mem_fun(&core::Download::set_connection_seed), arg);
} }
void void
@@ -205,39 +207,39 @@ apply_port_range(Control* m, const std::string& arg) {
std::sscanf(arg.c_str(), "%i-%i", &a, &b); std::sscanf(arg.c_str(), "%i-%i", &a, &b);
m->get_core().set_port_range(a, b); m->core()->set_port_range(a, b);
} }
void void
apply_port_random(Control* m, const std::string& arg) { apply_port_random(Control* m, const std::string& arg) {
m->get_core().set_port_random(arg == "yes"); m->core()->set_port_random(arg == "yes");
} }
void void
apply_tracker_dump(Control* m, const std::string& arg) { apply_tracker_dump(Control* m, const std::string& arg) {
if (arg == "yes") if (arg == "yes")
m->get_core().get_download_list().slot_map_insert()["1_tracker_dump"] = sigc::bind(sigc::mem_fun(&core::Download::call<sigc::connection, torrent::Download::SlotIStream, &torrent::Download::signal_tracker_dump>), sigc::ptr_fun(&receive_tracker_dump)); m->core()->get_download_list().slot_map_insert()["1_tracker_dump"] = sigc::bind(sigc::mem_fun(&core::Download::call<sigc::connection, torrent::Download::SlotIStream, &torrent::Download::signal_tracker_dump>), sigc::ptr_fun(&receive_tracker_dump));
else else
m->get_core().get_download_list().slot_map_insert().erase("1_tracker_dump"); m->core()->get_download_list().slot_map_insert().erase("1_tracker_dump");
} }
void void
apply_use_udp_trackers(Control* m, const std::string& arg) { apply_use_udp_trackers(Control* m, const std::string& arg) {
if (arg == "yes") if (arg == "yes")
m->get_core().get_download_list().slot_map_insert().erase("1_use_udp_trackers"); m->core()->get_download_list().slot_map_insert().erase("1_use_udp_trackers");
else else
m->get_core().get_download_list().slot_map_insert()["1_use_udp_trackers"] = sigc::bind(sigc::mem_fun(&core::Download::enable_udp_trackers), false); m->core()->get_download_list().slot_map_insert()["1_use_udp_trackers"] = sigc::bind(sigc::mem_fun(&core::Download::enable_udp_trackers), false);
} }
void void
apply_check_hash(Control* m, const std::string& arg) { apply_check_hash(Control* m, const std::string& arg) {
if (arg == "yes") if (arg == "yes")
m->get_core().set_check_hash(true); m->core()->set_check_hash(true);
else else
m->get_core().set_check_hash(false); m->core()->set_check_hash(false);
} }
void void
apply_session_directory(Control* m, const std::string& arg) { apply_session_directory(Control* m, const std::string& arg) {
m->get_core().get_download_store().use(arg); m->core()->get_download_store().use(arg);
} }
+16 -15
View File
@@ -43,6 +43,7 @@
#include "core/download.h" #include "core/download.h"
#include "input/bindings.h" #include "input/bindings.h"
#include "input/manager.h"
#include "display/window_title.h" #include "display/window_title.h"
#include "display/window_download_statusbar.h" #include "display/window_download_statusbar.h"
@@ -62,7 +63,7 @@ Download::Download(DPtr d, Control* c) :
m_windowTitle(new WTitle(d->get_download().get_name())), m_windowTitle(new WTitle(d->get_download().get_name())),
m_windowDownloadStatus(new WDownloadStatus(d)), m_windowDownloadStatus(new WDownloadStatus(d)),
m_window(c->get_display().end()), m_window(c->display()->end()),
m_control(c), m_control(c),
m_bindings(new input::Bindings) { m_bindings(new input::Bindings) {
@@ -83,7 +84,7 @@ Download::Download(DPtr d, Control* c) :
} }
Download::~Download() { Download::~Download() {
if (m_window != m_control->get_display().end()) if (m_window != m_control->display()->end())
throw std::logic_error("ui::Download::~Download() called on an active object"); throw std::logic_error("ui::Download::~Download() called on an active object");
m_connPeerConnected.disconnect(); m_connPeerConnected.disconnect();
@@ -99,37 +100,37 @@ Download::~Download() {
void void
Download::activate() { Download::activate() {
if (m_window != m_control->get_display().end()) if (m_window != m_control->display()->end())
throw std::logic_error("ui::Download::activate() called on an already activated object"); throw std::logic_error("ui::Download::activate() called on an already activated object");
m_control->get_display().push_front(m_windowDownloadStatus); m_control->display()->push_front(m_windowDownloadStatus);
m_window = m_control->get_display().insert(m_control->get_display().begin(), NULL); m_window = m_control->display()->insert(m_control->display()->begin(), NULL);
m_control->get_display().push_front(m_windowTitle); m_control->display()->push_front(m_windowTitle);
m_control->get_input().push_front(m_bindings); m_control->input()->push_front(m_bindings);
activate_display(DISPLAY_PEER_LIST); activate_display(DISPLAY_PEER_LIST);
} }
void void
Download::disable() { Download::disable() {
if (m_window == m_control->get_display().end()) if (m_window == m_control->display()->end())
throw std::logic_error("ui::Download::disable() called on an already disabled object"); throw std::logic_error("ui::Download::disable() called on an already disabled object");
disable_display(); disable_display();
m_control->get_display().erase(m_window); m_control->display()->erase(m_window);
m_control->get_display().erase(m_windowTitle); m_control->display()->erase(m_windowTitle);
m_control->get_display().erase(m_windowDownloadStatus); m_control->display()->erase(m_windowDownloadStatus);
m_window = m_control->get_display().end(); m_window = m_control->display()->end();
m_control->get_input().erase(m_bindings); m_control->input()->erase(m_bindings);
} }
void void
Download::activate_display(Display d) { Download::activate_display(Display d) {
if (m_window == m_control->get_display().end()) if (m_window == m_control->display()->end())
throw std::logic_error("ui::Download::activate_display(...) could not find previous display iterator"); throw std::logic_error("ui::Download::activate_display(...) could not find previous display iterator");
if (d >= DISPLAY_MAX_SIZE) if (d >= DISPLAY_MAX_SIZE)
@@ -138,7 +139,7 @@ Download::activate_display(Display d) {
m_state = d; m_state = d;
m_uiArray[d]->activate(m_control, m_window); m_uiArray[d]->activate(m_control, m_window);
m_control->get_display().adjust_layout(); m_control->display()->adjust_layout();
} }
// Does not delete disabled window. // Does not delete disabled window.
+1
View File
@@ -41,6 +41,7 @@
#include <torrent/peer.h> #include <torrent/peer.h>
#include <sigc++/connection.h> #include <sigc++/connection.h>
#include "display/manager.h"
#include "utils/list_focus.h" #include "utils/list_focus.h"
class Control; class Control;
+33 -30
View File
@@ -44,8 +44,10 @@
#include "core/download.h" #include "core/download.h"
#include "core/download_factory.h" #include "core/download_factory.h"
#include "core/manager.h"
#include "input/bindings.h" #include "input/bindings.h"
#include "input/manager.h"
#include "input/path_input.h" #include "input/path_input.h"
#include "display/window_http_queue.h" #include "display/window_http_queue.h"
@@ -60,27 +62,28 @@
#include "element_download_list.h" #include "element_download_list.h"
#include "element_log_complete.h" #include "element_log_complete.h"
#include "element_string_list.h" #include "element_string_list.h"
#include "root.h"
namespace ui { namespace ui {
DownloadList::DownloadList(Control* c) : DownloadList::DownloadList(Control* c) :
m_state(DISPLAY_MAX_SIZE), m_state(DISPLAY_MAX_SIZE),
m_window(c->get_display().end()), m_window(c->display()->end()),
m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + std::string(torrent::get_version()))), m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + std::string(torrent::get_version()))),
m_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())), m_windowHttpQueue(new WHttp(&c->core()->get_http_queue())),
m_uiDownload(NULL), m_uiDownload(NULL),
m_downloadList(&c->get_core().get_download_list()), m_downloadList(&c->core()->get_download_list()),
m_control(c), m_control(c),
m_bindings(new input::Bindings) m_bindings(new input::Bindings)
{ {
m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList(&m_downloadList); m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList(&m_downloadList);
m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&m_control->get_core().get_log_complete()); m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&m_control->core()->get_log_complete());
m_windowLog = new WLog(&m_control->get_core().get_log_important()); m_windowLog = new WLog(&m_control->core()->get_log_important());
m_taskUpdate.set_iterator(utils::taskScheduler.end()); m_taskUpdate.set_iterator(utils::taskScheduler.end());
m_taskUpdate.set_slot(sigc::mem_fun(*this, &DownloadList::task_update)), m_taskUpdate.set_slot(sigc::mem_fun(*this, &DownloadList::task_update)),
@@ -113,13 +116,13 @@ DownloadList::activate() {
m_windowTextInput->set_active(false); m_windowTextInput->set_active(false);
m_control->get_display().push_front(m_windowTextInput); m_control->display()->push_front(m_windowTextInput);
m_control->get_display().push_front(m_windowHttpQueue); m_control->display()->push_front(m_windowHttpQueue);
m_control->get_display().push_front(m_windowLog); m_control->display()->push_front(m_windowLog);
m_window = m_control->get_display().insert(m_control->get_display().begin(), NULL); m_window = m_control->display()->insert(m_control->display()->begin(), NULL);
m_control->get_display().push_front(m_windowTitle); m_control->display()->push_front(m_windowTitle);
m_control->get_input().push_front(m_bindings); m_control->input()->push_front(m_bindings);
activate_display(DISPLAY_DOWNLOAD_LIST); activate_display(DISPLAY_DOWNLOAD_LIST);
} }
@@ -138,15 +141,15 @@ DownloadList::disable() {
utils::taskScheduler.erase(&m_taskUpdate); utils::taskScheduler.erase(&m_taskUpdate);
m_control->get_display().erase(m_window); m_control->display()->erase(m_window);
m_control->get_display().erase(m_windowTitle); m_control->display()->erase(m_windowTitle);
m_control->get_display().erase(m_windowTextInput); m_control->display()->erase(m_windowTextInput);
m_control->get_display().erase(m_windowLog); m_control->display()->erase(m_windowLog);
m_control->get_display().erase(m_windowHttpQueue); m_control->display()->erase(m_windowHttpQueue);
m_window = m_control->get_display().end(); m_window = m_control->display()->end();
m_control->get_input().erase(m_bindings); m_control->input()->erase(m_bindings);
} }
void void
@@ -160,7 +163,7 @@ DownloadList::activate_display(Display d) {
m_state = d; m_state = d;
m_uiArray[d]->activate(m_control, m_window); m_uiArray[d]->activate(m_control, m_window);
m_control->get_display().adjust_layout(); m_control->display()->adjust_layout();
} }
// Does not delete disabled window. // Does not delete disabled window.
@@ -187,7 +190,7 @@ DownloadList::receive_start_download() {
if (m_downloadList.get_focus() == m_downloadList.end()) if (m_downloadList.get_focus() == m_downloadList.end())
return; return;
m_control->get_core().start(*m_downloadList.get_focus()); m_control->core()->start(*m_downloadList.get_focus());
} }
void void
@@ -196,9 +199,9 @@ DownloadList::receive_stop_download() {
return; return;
if ((*m_downloadList.get_focus())->get_download().is_active()) if ((*m_downloadList.get_focus())->get_download().is_active())
m_control->get_core().stop(*m_downloadList.get_focus()); m_control->core()->stop(*m_downloadList.get_focus());
else else
m_downloadList.set_focus(m_control->get_core().erase(m_downloadList.get_focus())); m_downloadList.set_focus(m_control->core()->erase(m_downloadList.get_focus()));
} }
void void
@@ -228,7 +231,7 @@ DownloadList::receive_exit_download() {
activate(); activate();
m_control->get_display().adjust_layout(); m_control->display()->adjust_layout();
} }
void void
@@ -236,7 +239,7 @@ DownloadList::receive_check_hash() {
if (m_downloadList.get_focus() == m_downloadList.end()) if (m_downloadList.get_focus() == m_downloadList.end())
return; return;
m_control->get_core().check_hash(*m_downloadList.get_focus()); m_control->core()->check_hash(*m_downloadList.get_focus());
} }
void void
@@ -244,11 +247,11 @@ DownloadList::receive_view_input(bool useDefault) {
if (m_windowTextInput->get_active()) if (m_windowTextInput->get_active())
return; return;
m_control->get_ui().window_statusbar()->set_active(false); m_control->ui()->window_statusbar()->set_active(false);
m_windowTextInput->set_active(true); m_windowTextInput->set_active(true);
m_control->get_display().adjust_layout(); m_control->display()->adjust_layout();
m_control->get_input().set_text_input(m_windowTextInput->get_input()); m_control->input()->set_text_input(m_windowTextInput->get_input());
m_windowTextInput->set_focus(true); m_windowTextInput->set_focus(true);
@@ -261,13 +264,13 @@ DownloadList::receive_exit_input(bool useDefault) {
if (!m_windowTextInput->get_active()) if (!m_windowTextInput->get_active())
return; return;
m_control->get_ui().window_statusbar()->set_active(true); m_control->ui()->window_statusbar()->set_active(true);
m_windowTextInput->set_active(false); m_windowTextInput->set_active(false);
m_control->get_input().set_text_input(); m_control->input()->set_text_input();
// Adding download. // Adding download.
core::DownloadFactory* f = new core::DownloadFactory(m_windowTextInput->get_input()->str(), &m_control->get_core()); core::DownloadFactory* f = new core::DownloadFactory(m_windowTextInput->get_input()->str(), m_control->core());
f->set_start(useDefault); f->set_start(useDefault);
f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f)); f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f));
+2 -1
View File
@@ -40,6 +40,7 @@
#include <sigc++/slot.h> #include <sigc++/slot.h>
#include "core/download_list.h" #include "core/download_list.h"
#include "display/manager.h"
#include "utils/task.h" #include "utils/task.h"
#include "utils/list_focus.h" #include "utils/list_focus.h"
@@ -90,7 +91,7 @@ public:
input::Bindings& get_bindings() { return *m_bindings; } input::Bindings& get_bindings() { return *m_bindings; }
bool is_active() const { return m_window != m_control->get_display().end(); } bool is_active() const { return m_window != m_control->display()->end(); }
void activate(); void activate();
void disable(); void disable();
+3 -2
View File
@@ -39,6 +39,7 @@
#include <stdexcept> #include <stdexcept>
#include "display/window_download_list.h" #include "display/window_download_list.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_download_list.h" #include "element_download_list.h"
@@ -55,7 +56,7 @@ ElementDownloadList::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementDownloadList::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementDownloadList::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WDownloadList(m_list); *mItr = m_window = new WDownloadList(m_list);
} }
@@ -65,7 +66,7 @@ ElementDownloadList::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementDownloadList::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementDownloadList::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+3 -2
View File
@@ -39,6 +39,7 @@
#include <stdexcept> #include <stdexcept>
#include "display/window_file_list.h" #include "display/window_file_list.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_file_list.h" #include "element_file_list.h"
@@ -61,7 +62,7 @@ ElementFileList::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementFileList::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementFileList::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WFileList(m_download, &m_focus); *mItr = m_window = new WFileList(m_download, &m_focus);
} }
@@ -71,7 +72,7 @@ ElementFileList::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementFileList::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementFileList::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+3 -2
View File
@@ -39,6 +39,7 @@
#include <stdexcept> #include <stdexcept>
#include "display/window_log_complete.h" #include "display/window_log_complete.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_log_complete.h" #include "element_log_complete.h"
@@ -55,7 +56,7 @@ ElementLogComplete::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementLogComplete::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementLogComplete::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WLogComplete(m_log); *mItr = m_window = new WLogComplete(m_log);
} }
@@ -65,7 +66,7 @@ ElementLogComplete::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementLogComplete::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementLogComplete::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+3 -2
View File
@@ -39,6 +39,7 @@
#include <stdexcept> #include <stdexcept>
#include "display/window_peer_info.h" #include "display/window_peer_info.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_peer_info.h" #include "element_peer_info.h"
@@ -58,7 +59,7 @@ ElementPeerInfo::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementPeerInfo::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementPeerInfo::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WPeerInfo(m_download, m_list, m_focus); *mItr = m_window = new WPeerInfo(m_download, m_list, m_focus);
} }
@@ -68,7 +69,7 @@ ElementPeerInfo::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementPeerInfo::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementPeerInfo::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+3 -2
View File
@@ -39,6 +39,7 @@
#include <stdexcept> #include <stdexcept>
#include "display/window_peer_list.h" #include "display/window_peer_list.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_peer_list.h" #include "element_peer_list.h"
@@ -58,7 +59,7 @@ ElementPeerList::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementPeerList::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementPeerList::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WPeerList(m_download, m_list, m_focus); *mItr = m_window = new WPeerList(m_download, m_list, m_focus);
} }
@@ -68,7 +69,7 @@ ElementPeerList::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementPeerList::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementPeerList::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+4 -2
View File
@@ -38,6 +38,8 @@
#include <stdexcept> #include <stdexcept>
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_string_list.h" #include "element_string_list.h"
@@ -52,7 +54,7 @@ ElementStringList::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementStringList::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementStringList::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WStringList(); *mItr = m_window = new WStringList();
@@ -64,7 +66,7 @@ ElementStringList::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementStringList::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementStringList::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+3 -2
View File
@@ -39,6 +39,7 @@
#include <stdexcept> #include <stdexcept>
#include "display/window_tracker_list.h" #include "display/window_tracker_list.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "element_tracker_list.h" #include "element_tracker_list.h"
@@ -60,7 +61,7 @@ ElementTrackerList::activate(Control* c, MItr mItr) {
if (m_window != NULL) if (m_window != NULL)
throw std::logic_error("ui::ElementTrackerList::activate(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementTrackerList::activate(...) called on an object in the wrong state");
c->get_input().push_front(&m_bindings); c->input()->push_front(&m_bindings);
*mItr = m_window = new WTrackerList(m_download, &m_focus); *mItr = m_window = new WTrackerList(m_download, &m_focus);
} }
@@ -70,7 +71,7 @@ ElementTrackerList::disable(Control* c) {
if (m_window == NULL) if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::disable(...) called on an object in the wrong state"); throw std::logic_error("ui::ElementTrackerList::disable(...) called on an object in the wrong state");
c->get_input().erase(&m_bindings); c->input()->erase(&m_bindings);
delete m_window; delete m_window;
m_window = NULL; m_window = NULL;
+9 -7
View File
@@ -40,9 +40,11 @@
#include <sigc++/bind.h> #include <sigc++/bind.h>
#include <torrent/torrent.h> #include <torrent/torrent.h>
#include "display/window_statusbar.h"
#include "input/manager.h"
#include "control.h" #include "control.h"
#include "download_list.h" #include "download_list.h"
#include "display/window_statusbar.h"
#include "root.h" #include "root.h"
@@ -62,10 +64,10 @@ Root::init(Control* c) {
m_control = c; m_control = c;
setup_keys(); setup_keys();
m_windowStatusbar = new WStatusbar(&m_control->get_core()); m_windowStatusbar = new WStatusbar(m_control->core());
m_downloadList = new DownloadList(m_control); m_downloadList = new DownloadList(m_control);
m_control->get_display().push_back(m_windowStatusbar); m_control->display()->push_back(m_windowStatusbar);
m_downloadList->activate(); m_downloadList->activate();
// m_downloadList->slot_open_uri(sigc::mem_fun(m_control->get_core(), &core::Manager::insert)); // m_downloadList->slot_open_uri(sigc::mem_fun(m_control->get_core(), &core::Manager::insert));
@@ -79,18 +81,18 @@ Root::cleanup() {
if (m_downloadList->is_active()) if (m_downloadList->is_active())
m_downloadList->disable(); m_downloadList->disable();
m_control->get_display().erase(m_windowStatusbar); m_control->display()->erase(m_windowStatusbar);
delete m_downloadList; delete m_downloadList;
delete m_windowStatusbar; delete m_windowStatusbar;
m_control->get_input().erase(&m_bindings); m_control->input()->erase(&m_bindings);
m_control = NULL; m_control = NULL;
} }
void void
Root::setup_keys() { Root::setup_keys() {
m_control->get_input().push_back(&m_bindings); m_control->input()->push_back(&m_bindings);
m_bindings['a'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_up_throttle), 1); m_bindings['a'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_up_throttle), 1);
m_bindings['z'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_up_throttle), -1); m_bindings['z'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_up_throttle), -1);
@@ -106,7 +108,7 @@ Root::setup_keys() {
m_bindings['D'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_down_throttle), 50); m_bindings['D'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_down_throttle), 50);
m_bindings['C'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_down_throttle), -50); m_bindings['C'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_down_throttle), -50);
m_bindings[KEY_RESIZE] = sigc::mem_fun(m_control->get_display(), &display::Manager::adjust_layout); m_bindings[KEY_RESIZE] = sigc::mem_fun(*m_control->display(), &display::Manager::adjust_layout);
m_bindings['\x11'] = sigc::mem_fun(*m_control, &Control::receive_shutdown); m_bindings['\x11'] = sigc::mem_fun(*m_control, &Control::receive_shutdown);
} }