diff --git a/src/control.cc b/src/control.cc index 51400141..8c5e6aec 100644 --- a/src/control.cc +++ b/src/control.cc @@ -38,20 +38,38 @@ #include +#include "core/manager.h" #include "display/canvas.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" 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_taskShutdown.set_iterator(utils::taskScheduler.end()); + m_taskShutdown.set_slot(sigc::mem_fun(*this, &Control::receive_shutdown)); } Control::~Control() { delete m_inputStdin; + delete m_input; + + delete m_ui; + delete m_display; + delete m_core; } void @@ -59,22 +77,24 @@ Control::initialize() { display::Canvas::initialize(); 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::ptr_fun(display::Canvas::do_update)); + 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.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 Control::cleanup() { - m_inputStdin->remove(m_core.get_poll_manager()->get_torrent_poll()); + utils::taskScheduler.erase(&m_taskShutdown); - m_ui.cleanup(); - m_core.cleanup(); + m_inputStdin->remove(m_core->get_poll_manager()->get_torrent_poll()); + + m_ui->cleanup(); + m_core->cleanup(); display::Canvas::erase_std(); display::Canvas::refresh_std(); @@ -89,9 +109,13 @@ Control::receive_shutdown() { if (!m_shutdownReceived) { torrent::listen_close(); - m_core.shutdown(false); + m_core->shutdown(false); m_shutdownReceived = true; + + if (!utils::taskScheduler.is_scheduled(&m_taskShutdown)) + utils::taskScheduler.insert(&m_taskShutdown, utils::Timer::cache() + 5 * 1000000); + } else { - m_core.shutdown(true); + m_core->shutdown(true); } } diff --git a/src/control.h b/src/control.h index 3aeea3ab..e7ff082f 100644 --- a/src/control.h +++ b/src/control.h @@ -34,16 +34,29 @@ // Skomakerveien 33 // 3185 Skoppum, NORWAY -#ifndef RTORRENT_UI_CONTROL_H -#define RTORRENT_UI_CONTROL_H +#ifndef RTORRENT_CONTROL_H +#define RTORRENT_CONTROL_H #include -#include "core/manager.h" -#include "display/manager.h" -#include "input/manager.h" -#include "input/input_event.h" -#include "ui/root.h" +#include "utils/task.h" + +namespace ui { + class Root; +} + +namespace core { + class Manager; +} + +namespace display { + class Manager; +} + +namespace input { + class InputEvent; + class Manager; +} class Control { public: @@ -53,11 +66,11 @@ public: bool is_shutdown_completed() { return m_shutdownReceived && torrent::is_inactive(); } bool is_shutdown_received() { return m_shutdownReceived; } - ui::Root& get_ui() { return m_ui; } - core::Manager& get_core() { return m_core; } - display::Manager& get_display() { return m_display; } - input::Manager& get_input() { return m_input; } - input::InputEvent* get_input_stdin() { return m_inputStdin; } + ui::Root* ui() { return m_ui; } + core::Manager* core() { return m_core; } + display::Manager* display() { return m_display; } + input::Manager* input() { return m_input; } + input::InputEvent* input_stdin() { return m_inputStdin; } void initialize(); void cleanup(); @@ -70,11 +83,13 @@ private: bool m_shutdownReceived; - ui::Root m_ui; - core::Manager m_core; - display::Manager m_display; - input::Manager m_input; + ui::Root* m_ui; + core::Manager* m_core; + display::Manager* m_display; + input::Manager* m_input; input::InputEvent* m_inputStdin; + + utils::TaskItem m_taskShutdown; }; #endif diff --git a/src/core/poll_manager_epoll.cc b/src/core/poll_manager_epoll.cc index 63a93185..fbc9d286 100644 --- a/src/core/poll_manager_epoll.cc +++ b/src/core/poll_manager_epoll.cc @@ -88,8 +88,12 @@ PollManagerEPoll::poll(utils::Timer timeout) { m_httpStack.perform(); - if (!FD_ISSET(static_cast(m_poll)->get_fd(), m_readSet)) + if (!FD_ISSET(static_cast(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; + } // Clear the timeout since we've already used it in the select call. timeout = utils::Timer(); diff --git a/src/main.cc b/src/main.cc index 14cb8730..c580b13d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -56,8 +56,10 @@ #include "core/download.h" #include "core/download_factory.h" +#include "core/manager.h" #include "display/canvas.h" #include "display/window.h" +#include "display/manager.h" #include "input/bindings.h" #include "utils/task.h" @@ -162,10 +164,10 @@ load_option_file(const std::string& filename, OptionHandler* optionHandler, bool void load_session_torrents(Control* c) { // Load session torrents. - std::list l = c->get_core().get_download_store().get_formated_entries().make_list(); + std::list l = c->core()->get_download_store().get_formated_entries().make_list(); for (std::list::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. f->set_session(true); @@ -179,7 +181,7 @@ void 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())); 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. 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(SIGFPE, sigc::bind(sigc::ptr_fun(&do_panic), SIGFPE)); - uiControl.get_core().initialize_first(); + uiControl.core()->initialize_first(); if (getenv("HOME")) load_option_file(getenv("HOME") + std::string("/.rtorrent.rc"), &optionHandler); @@ -221,7 +223,7 @@ main(int argc, char** argv) { load_session_torrents(&uiControl); load_arg_torrents(&uiControl, argv + firstArg, argv + argc); - uiControl.get_display().adjust_layout(); + uiControl.display()->adjust_layout(); while (!uiControl.is_shutdown_completed()) { utils::Timer::update(); @@ -231,10 +233,10 @@ main(int argc, char** argv) { // the throttle task in libtorrent. if (!utils::displayScheduler.empty() && utils::displayScheduler.get_next_timeout() <= utils::Timer::cache()) - uiControl.get_display().do_update(); + uiControl.display()->do_update(); // 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() : 60 * 1000000); } diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 2c9ad686..58b931d3 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -40,7 +40,9 @@ #include #include +#include "core/manager.h" #include "utils/directory.h" + #include "control.h" #include "option_handler_rules.h" @@ -116,35 +118,35 @@ validate_throttle_interval(int arg) { void 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), arg); + m->core()->get_download_list().slot_map_insert()["1_min_peers"] = sigc::bind(sigc::mem_fun(&core::Download::call), arg); } void 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), arg); + m->core()->get_download_list().slot_map_insert()["1_max_peers"] = sigc::bind(sigc::mem_fun(&core::Download::call), arg); } void 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), arg); + m->core()->get_download_list().slot_map_insert()["1_max_uploads"] = sigc::bind(sigc::mem_fun(&core::Download::call), arg); } void apply_download_directory(Control* m, const std::string& arg) { 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 - m->get_core().get_download_list().slot_map_insert().erase("1_directory"); + m->core()->get_download_list().slot_map_insert().erase("1_directory"); } void 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 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 @@ -205,39 +207,39 @@ apply_port_range(Control* m, const std::string& arg) { 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 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 apply_tracker_dump(Control* m, const std::string& arg) { if (arg == "yes") - m->get_core().get_download_list().slot_map_insert()["1_tracker_dump"] = sigc::bind(sigc::mem_fun(&core::Download::call), 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::ptr_fun(&receive_tracker_dump)); 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 apply_use_udp_trackers(Control* m, const std::string& arg) { 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 - 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 apply_check_hash(Control* m, const std::string& arg) { if (arg == "yes") - m->get_core().set_check_hash(true); + m->core()->set_check_hash(true); else - m->get_core().set_check_hash(false); + m->core()->set_check_hash(false); } void apply_session_directory(Control* m, const std::string& arg) { - m->get_core().get_download_store().use(arg); + m->core()->get_download_store().use(arg); } diff --git a/src/ui/download.cc b/src/ui/download.cc index 7cd01bde..84e5c2b2 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -43,6 +43,7 @@ #include "core/download.h" #include "input/bindings.h" +#include "input/manager.h" #include "display/window_title.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_windowDownloadStatus(new WDownloadStatus(d)), - m_window(c->get_display().end()), + m_window(c->display()->end()), m_control(c), m_bindings(new input::Bindings) { @@ -83,7 +84,7 @@ Download::Download(DPtr d, Control* c) : } 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"); m_connPeerConnected.disconnect(); @@ -99,37 +100,37 @@ Download::~Download() { void 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"); - 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().push_front(m_windowTitle); + m_control->display()->push_front(m_windowDownloadStatus); + m_window = m_control->display()->insert(m_control->display()->begin(), NULL); + 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); } void 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"); disable_display(); - m_control->get_display().erase(m_window); - m_control->get_display().erase(m_windowTitle); - m_control->get_display().erase(m_windowDownloadStatus); + m_control->display()->erase(m_window); + m_control->display()->erase(m_windowTitle); + 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 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"); if (d >= DISPLAY_MAX_SIZE) @@ -138,7 +139,7 @@ Download::activate_display(Display d) { m_state = d; m_uiArray[d]->activate(m_control, m_window); - m_control->get_display().adjust_layout(); + m_control->display()->adjust_layout(); } // Does not delete disabled window. diff --git a/src/ui/download.h b/src/ui/download.h index 9fe66961..40730a52 100644 --- a/src/ui/download.h +++ b/src/ui/download.h @@ -41,6 +41,7 @@ #include #include +#include "display/manager.h" #include "utils/list_focus.h" class Control; diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index e1e4576a..e43e1ac0 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -44,8 +44,10 @@ #include "core/download.h" #include "core/download_factory.h" +#include "core/manager.h" #include "input/bindings.h" +#include "input/manager.h" #include "input/path_input.h" #include "display/window_http_queue.h" @@ -60,27 +62,28 @@ #include "element_download_list.h" #include "element_log_complete.h" #include "element_string_list.h" +#include "root.h" namespace ui { DownloadList::DownloadList(Control* c) : 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_windowHttpQueue(new WHttp(&c->get_core().get_http_queue())), + m_windowHttpQueue(new WHttp(&c->core()->get_http_queue())), m_uiDownload(NULL), - m_downloadList(&c->get_core().get_download_list()), + m_downloadList(&c->core()->get_download_list()), m_control(c), m_bindings(new input::Bindings) { m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList(&m_downloadList); - m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&m_control->get_core().get_log_complete()); - m_windowLog = new WLog(&m_control->get_core().get_log_important()); + m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&m_control->core()->get_log_complete()); + m_windowLog = new WLog(&m_control->core()->get_log_important()); m_taskUpdate.set_iterator(utils::taskScheduler.end()); m_taskUpdate.set_slot(sigc::mem_fun(*this, &DownloadList::task_update)), @@ -113,13 +116,13 @@ 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->display()->push_front(m_windowTextInput); + m_control->display()->push_front(m_windowHttpQueue); + m_control->display()->push_front(m_windowLog); + m_window = m_control->display()->insert(m_control->display()->begin(), NULL); + 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); } @@ -138,15 +141,15 @@ DownloadList::disable() { utils::taskScheduler.erase(&m_taskUpdate); - m_control->get_display().erase(m_window); - m_control->get_display().erase(m_windowTitle); - m_control->get_display().erase(m_windowTextInput); - m_control->get_display().erase(m_windowLog); - m_control->get_display().erase(m_windowHttpQueue); + m_control->display()->erase(m_window); + m_control->display()->erase(m_windowTitle); + m_control->display()->erase(m_windowTextInput); + m_control->display()->erase(m_windowLog); + 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 @@ -160,7 +163,7 @@ DownloadList::activate_display(Display d) { m_state = d; m_uiArray[d]->activate(m_control, m_window); - m_control->get_display().adjust_layout(); + m_control->display()->adjust_layout(); } // Does not delete disabled window. @@ -187,7 +190,7 @@ DownloadList::receive_start_download() { if (m_downloadList.get_focus() == m_downloadList.end()) return; - m_control->get_core().start(*m_downloadList.get_focus()); + m_control->core()->start(*m_downloadList.get_focus()); } void @@ -196,9 +199,9 @@ DownloadList::receive_stop_download() { return; 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 - 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 @@ -228,7 +231,7 @@ DownloadList::receive_exit_download() { activate(); - m_control->get_display().adjust_layout(); + m_control->display()->adjust_layout(); } void @@ -236,7 +239,7 @@ DownloadList::receive_check_hash() { if (m_downloadList.get_focus() == m_downloadList.end()) return; - m_control->get_core().check_hash(*m_downloadList.get_focus()); + m_control->core()->check_hash(*m_downloadList.get_focus()); } void @@ -244,11 +247,11 @@ DownloadList::receive_view_input(bool useDefault) { if (m_windowTextInput->get_active()) return; - m_control->get_ui().window_statusbar()->set_active(false); + m_control->ui()->window_statusbar()->set_active(false); 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); @@ -261,13 +264,13 @@ DownloadList::receive_exit_input(bool useDefault) { if (!m_windowTextInput->get_active()) return; - m_control->get_ui().window_statusbar()->set_active(true); + m_control->ui()->window_statusbar()->set_active(true); m_windowTextInput->set_active(false); - m_control->get_input().set_text_input(); + m_control->input()->set_text_input(); // 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->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func), f)); diff --git a/src/ui/download_list.h b/src/ui/download_list.h index 81b07b77..bf51dad8 100644 --- a/src/ui/download_list.h +++ b/src/ui/download_list.h @@ -40,6 +40,7 @@ #include #include "core/download_list.h" +#include "display/manager.h" #include "utils/task.h" #include "utils/list_focus.h" @@ -90,7 +91,7 @@ public: 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 disable(); diff --git a/src/ui/element_download_list.cc b/src/ui/element_download_list.cc index e7458241..fb5e152a 100644 --- a/src/ui/element_download_list.cc +++ b/src/ui/element_download_list.cc @@ -39,6 +39,7 @@ #include #include "display/window_download_list.h" +#include "input/manager.h" #include "control.h" #include "element_download_list.h" @@ -55,7 +56,7 @@ ElementDownloadList::activate(Control* c, MItr mItr) { if (m_window != NULL) 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); } @@ -65,7 +66,7 @@ ElementDownloadList::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/element_file_list.cc b/src/ui/element_file_list.cc index 85264aa9..6607ebb2 100644 --- a/src/ui/element_file_list.cc +++ b/src/ui/element_file_list.cc @@ -39,6 +39,7 @@ #include #include "display/window_file_list.h" +#include "input/manager.h" #include "control.h" #include "element_file_list.h" @@ -61,7 +62,7 @@ ElementFileList::activate(Control* c, MItr mItr) { if (m_window != NULL) 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); } @@ -71,7 +72,7 @@ ElementFileList::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/element_log_complete.cc b/src/ui/element_log_complete.cc index e52ebfc8..b0c7ccf4 100644 --- a/src/ui/element_log_complete.cc +++ b/src/ui/element_log_complete.cc @@ -39,6 +39,7 @@ #include #include "display/window_log_complete.h" +#include "input/manager.h" #include "control.h" #include "element_log_complete.h" @@ -55,7 +56,7 @@ ElementLogComplete::activate(Control* c, MItr mItr) { if (m_window != NULL) 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); } @@ -65,7 +66,7 @@ ElementLogComplete::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/element_peer_info.cc b/src/ui/element_peer_info.cc index f33584c5..55a63cbc 100644 --- a/src/ui/element_peer_info.cc +++ b/src/ui/element_peer_info.cc @@ -39,6 +39,7 @@ #include #include "display/window_peer_info.h" +#include "input/manager.h" #include "control.h" #include "element_peer_info.h" @@ -58,7 +59,7 @@ ElementPeerInfo::activate(Control* c, MItr mItr) { if (m_window != NULL) 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); } @@ -68,7 +69,7 @@ ElementPeerInfo::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/element_peer_list.cc b/src/ui/element_peer_list.cc index 460be077..e9ffe781 100644 --- a/src/ui/element_peer_list.cc +++ b/src/ui/element_peer_list.cc @@ -39,6 +39,7 @@ #include #include "display/window_peer_list.h" +#include "input/manager.h" #include "control.h" #include "element_peer_list.h" @@ -58,7 +59,7 @@ ElementPeerList::activate(Control* c, MItr mItr) { if (m_window != NULL) 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); } @@ -68,7 +69,7 @@ ElementPeerList::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/element_string_list.cc b/src/ui/element_string_list.cc index 7234e47b..39d99a50 100644 --- a/src/ui/element_string_list.cc +++ b/src/ui/element_string_list.cc @@ -38,6 +38,8 @@ #include +#include "input/manager.h" + #include "control.h" #include "element_string_list.h" @@ -52,7 +54,7 @@ ElementStringList::activate(Control* c, MItr mItr) { if (m_window != NULL) 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(); @@ -64,7 +66,7 @@ ElementStringList::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/element_tracker_list.cc b/src/ui/element_tracker_list.cc index 97d49f5a..b85a95ac 100644 --- a/src/ui/element_tracker_list.cc +++ b/src/ui/element_tracker_list.cc @@ -39,6 +39,7 @@ #include #include "display/window_tracker_list.h" +#include "input/manager.h" #include "control.h" #include "element_tracker_list.h" @@ -60,7 +61,7 @@ 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"); - c->get_input().push_front(&m_bindings); + c->input()->push_front(&m_bindings); *mItr = m_window = new WTrackerList(m_download, &m_focus); } @@ -70,7 +71,7 @@ ElementTrackerList::disable(Control* c) { if (m_window == NULL) 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; m_window = NULL; diff --git a/src/ui/root.cc b/src/ui/root.cc index 838be7fb..71ada55a 100644 --- a/src/ui/root.cc +++ b/src/ui/root.cc @@ -40,9 +40,11 @@ #include #include +#include "display/window_statusbar.h" +#include "input/manager.h" + #include "control.h" #include "download_list.h" -#include "display/window_statusbar.h" #include "root.h" @@ -62,10 +64,10 @@ Root::init(Control* c) { m_control = c; setup_keys(); - m_windowStatusbar = new WStatusbar(&m_control->get_core()); + m_windowStatusbar = new WStatusbar(m_control->core()); 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->slot_open_uri(sigc::mem_fun(m_control->get_core(), &core::Manager::insert)); @@ -79,18 +81,18 @@ Root::cleanup() { if (m_downloadList->is_active()) m_downloadList->disable(); - m_control->get_display().erase(m_windowStatusbar); + m_control->display()->erase(m_windowStatusbar); delete m_downloadList; delete m_windowStatusbar; - m_control->get_input().erase(&m_bindings); + m_control->input()->erase(&m_bindings); m_control = NULL; } void 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['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['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); }