Renamed engine to core.

Added focus to WindowDownloadList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@249 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-01-31 17:59:16 +00:00
parent c3a4a7d554
commit cd9b014eb6
17 changed files with 107 additions and 47 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ AC_DEFINE(HAVE_CONFIG_H, 1, true if config.h was included)
AC_OUTPUT([
Makefile
src/Makefile
src/core/Makefile
src/display/Makefile
src/engine/Makefile
src/input/Makefile
])
+2 -2
View File
@@ -1,13 +1,13 @@
SUBDIRS = \
core \
display \
engine \
input
bin_PROGRAMS = rtorrent
rtorrent_LDADD = \
$(top_srcdir)/src/core/libsub_core.a \
$(top_srcdir)/src/display/libsub_display.a \
$(top_srcdir)/src/engine/libsub_engine.a \
$(top_srcdir)/src/input/libsub_input.a
rtorrent_SOURCES = \
@@ -1,6 +1,6 @@
noinst_LIBRARIES = libsub_engine.a
noinst_LIBRARIES = libsub_core.a
libsub_engine_a_SOURCES = \
libsub_core_a_SOURCES = \
curl_get.cc \
curl_get.h \
curl_stack.cc \
@@ -8,7 +8,7 @@
#include "curl_get.h"
#include "curl_stack.h"
namespace engine {
namespace core {
CurlGet::~CurlGet() {
close();
@@ -1,5 +1,5 @@
#ifndef RTORRENT_ENGINE_CURL_GET_H
#define RTORRENT_ENGINE_CURL_GET_H
#ifndef RTORRENT_CORE_CURL_GET_H
#define RTORRENT_CORE_CURL_GET_H
#include <iosfwd>
#include <string>
@@ -9,7 +9,7 @@
struct CURLMsg;
namespace engine {
namespace core {
class CurlGet : public torrent::Http {
public:
@@ -8,7 +8,7 @@
#include "curl_get.h"
#include "curl_stack.h"
namespace engine {
namespace core {
template <typename Type, typename Ftor>
struct _equal {
@@ -1,9 +1,9 @@
#ifndef RTORRENT_ENGINE_CURL_STACK_H
#define RTORRENT_ENGINE_CURL_STACK_H
#ifndef RTORRENT_CORE_CURL_STACK_H
#define RTORRENT_CORE_CURL_STACK_H
#include <list>
namespace engine {
namespace core {
class CurlStack {
public:
@@ -1,10 +1,10 @@
#ifndef RTORRENT_ENGINE_DOWNLOAD_H
#define RTORRENT_ENGINE_DOWNLOAD_H
#ifndef RTORRENT_CORE_DOWNLOAD_H
#define RTORRENT_CORE_DOWNLOAD_H
#include <sigc++/connection.h>
#include <torrent/download.h>
namespace engine {
namespace core {
class Download {
public:
@@ -7,7 +7,7 @@
#include "download_list.h"
namespace engine {
namespace core {
DownloadList::iterator
DownloadList::create(std::istream& str) {
@@ -1,11 +1,11 @@
#ifndef RTORRENT_ENGINE_DOWNLOAD_LIST_H
#define RTORRENT_ENGINE_DOWNLOAD_LIST_H
#ifndef RTORRENT_CORE_DOWNLOAD_LIST_H
#define RTORRENT_CORE_DOWNLOAD_LIST_H
#include <iosfwd>
#include "download.h"
namespace engine {
namespace core {
class DownloadList : private std::list<Download> {
public:
+23
View File
@@ -0,0 +1,23 @@
#include "config.h"
#include <torrent/torrent.h>
#include "downloads.h"
namespace engine {
void
Downloads::create(std::istream& str) {
torrent::Download d = torrent::download_create(str);
Base::push_back(d);
}
void
Downloads::erase(iterator itr) {
torrent::download_remove(itr->get_hash());
Base::erase(itr);
}
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef RTORRENT_ENGINE_DOWNLOADS_H
#define RTORRENT_ENGINE_DOWNLOADS_H
#include <iosfwd>
#include <torrent/download.h>
namespace engine {
class Downloads : private std::list<torrent::Download> {
public:
typedef std::list<torrent::Download> Base;
using Base::iterator;
using Base::const_iterator;
using Base::reverse_iterator;
using Base::const_reverse_iterator;
using Base::begin;
using Base::end;
using Base::rbegin;
using Base::rend;
void create(std::istream& str);
void erase(iterator itr);
};
}
#endif
+2 -2
View File
@@ -8,7 +8,7 @@
#include "poll.h"
#include "curl_get.h"
namespace engine {
namespace core {
void
Poll::poll() {
@@ -57,7 +57,7 @@ Poll::work() {
void
Poll::register_http() {
torrent::Http::set_factory(sigc::bind(sigc::ptr_fun(&engine::CurlGet::new_object), &m_curlStack));
torrent::Http::set_factory(sigc::bind(sigc::ptr_fun(&core::CurlGet::new_object), &m_curlStack));
}
}
+3 -3
View File
@@ -1,12 +1,12 @@
#ifndef RTORRENT_ENGINE_POLL_H
#define RTORRENT_ENGINE_POLL_H
#ifndef RTORRENT_CORE_POLL_H
#define RTORRENT_CORE_POLL_H
#include <sys/select.h>
#include <sigc++/slot.h>
#include "curl_stack.h"
namespace engine {
namespace core {
class Poll {
public:
+9 -8
View File
@@ -3,13 +3,14 @@
#include "canvas.h"
#include "window_download_list.h"
#include "engine/download_list.h"
namespace display {
WindowDownloadList::WindowDownloadList(engine::DownloadList* d) :
WindowDownloadList::WindowDownloadList(List* d) :
Window(new Canvas, true),
m_downloads(d) {
if (m_downloads)
m_focus = m_downloads->end();
}
void
@@ -21,14 +22,14 @@ WindowDownloadList::redraw() {
// Remember to check for end of screen too.
for (engine::DownloadList::iterator itr = m_downloads->begin(); itr != m_downloads->end(); ++itr) {
for (List::iterator itr = m_downloads->begin(); itr != m_downloads->end(); ++itr) {
m_canvas->print(0, pos++, "%c %s",
false ? '*' : ' ',
itr == m_focus ? '*' : ' ',
itr->get_download().get_name().c_str());
if (itr->get_download().get_chunks_done() != itr->get_download().get_chunks_total() || !itr->get_download().is_open())
m_canvas->print(0, pos++, "%c Torrent: %.1f / %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
false ? '*' : ' ',
itr == m_focus ? '*' : ' ',
(double)itr->get_download().get_bytes_done() / (double)(1 << 20),
(double)itr->get_download().get_bytes_total() / (double)(1 << 20),
(double)itr->get_download().get_rate_up() / 1024.0,
@@ -37,14 +38,14 @@ WindowDownloadList::redraw() {
else
m_canvas->print(0, pos++, "%c Torrent: Done %.1f MiB Rate:%5.1f /%5.1f KiB Uploaded: %.1f MiB",
false ? '*' : ' ',
itr == m_focus ? '*' : ' ',
(double)itr->get_download().get_bytes_total() / (double)(1 << 20),
(double)itr->get_download().get_rate_up() / 1024.0,
(double)itr->get_download().get_rate_down() / 1024.0,
(double)itr->get_download().get_bytes_up() / (double)(1 << 20));
m_canvas->print(0, pos++, "%c Tracker: [%c:%i] %s",
false ? '*' : ' ',
itr == m_focus ? '*' : ' ',
itr->get_download().is_tracker_busy() ? 'C' : ' ',
(int)(itr->get_download().get_tracker_timeout() / 1000000),
"");
+10 -7
View File
@@ -2,21 +2,24 @@
#define RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
#include "window.h"
namespace engine {
class DownloadList;
}
#include "core/download_list.h"
namespace display {
class WindowDownloadList : public Window {
public:
WindowDownloadList(engine::DownloadList* d);
typedef core::DownloadList List;
virtual void redraw();
WindowDownloadList(List* d);
List::iterator get_focus() { return m_focus; }
void set_focus(core::DownloadList::iterator itr) { m_focus = itr; }
virtual void redraw();
private:
engine::DownloadList* m_downloads;
List* m_downloads;
List::iterator m_focus;
};
}
+11 -7
View File
@@ -10,8 +10,8 @@
#include "display/window_title.h"
#include "display/window_download_list.h"
#include "engine/poll.h"
#include "engine/download_list.h"
#include "core/poll.h"
#include "core/download_list.h"
#include "input/bindings.h"
#include "input/manager.h"
@@ -21,8 +21,8 @@
bool start_shutdown = false;
bool is_shutting_down = false;
engine::Poll poll;
engine::DownloadList downloads;
core::Poll poll;
core::DownloadList downloads;
display::Manager displayManager;
input::Manager inputManager;
@@ -42,7 +42,7 @@ do_shutdown() {
torrent::listen_close();
std::for_each(downloads.begin(), downloads.end(), std::mem_fun_ref(&engine::Download::stop));
std::for_each(downloads.begin(), downloads.end(), std::mem_fun_ref(&core::Download::stop));
}
int
@@ -56,8 +56,10 @@ main(int argc, char** argv) {
poll.slot_read_stdin(sigc::mem_fun(inputManager, &input::Manager::pressed));
poll.register_http();
display::WindowDownloadList* wdl = new display::WindowDownloadList(&downloads);
displayManager.push_back(new display::WindowTitle);
displayManager.push_back(new display::WindowDownloadList(&downloads));
displayManager.push_back(wdl);
torrent::initialize();
torrent::listen_open(6880, 6999);
@@ -65,10 +67,12 @@ main(int argc, char** argv) {
for (int i = 1; i < argc; ++i) {
std::fstream f(argv[i], std::ios::in);
engine::DownloadList::iterator itr = downloads.create(f);
core::DownloadList::iterator itr = downloads.create(f);
itr->open();
itr->hash_check();
wdl->set_focus(itr);
}
SignalHandler::set_handler(SIGINT, sigc::ptr_fun(&set_shutdown));