mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 15:19:20 +00:00
* Cleaned up torrent::Rate and moved it to the API. Changed various
parts of the API to return torrent::Rate instead of specific functions for each stat. * Use 600 second time span for peer rates. * Added core::DownloadFactory which allows for an async http get and changing of settings. This will allow the implementation of a configuration screen when pressing "return", while the client is downloading or finished downloading a torrent file. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@491 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -14,7 +14,16 @@ USAGE
|
||||
|
||||
LICENSE
|
||||
|
||||
GNU GPL, see COPYING.
|
||||
GNU GPL, see COPYING. "libtorrent/src/utils/sha_fast.{cc,h}" is
|
||||
originally from the Mozilla NSS and is under a triple license; MPL,
|
||||
LGPL and GPL. An exception to non-NSS code has been added for linking
|
||||
to OpenSSL as requested by Debian, though the author considers that
|
||||
library to be part of the Operative System and thus linking is allowed
|
||||
according to the GPL.
|
||||
|
||||
Use whatever fits your purpose, the code required to compile with
|
||||
Mozilla's NSS implementation of SHA1 has been retained and can be
|
||||
compiled if the user wishes to avoid using OpenSSL.
|
||||
|
||||
DEPENDENCIES
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
AC_INIT(rtorrent, 0.2.7, jaris@ifi.uio.no)
|
||||
AC_INIT(rtorrent, 0.3.0, 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.7,
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.0,
|
||||
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
|
||||
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
|
||||
|
||||
|
||||
@@ -228,6 +228,12 @@ struct call_delete : public std::unary_function<T*, void> {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void
|
||||
call_delete_func(T* t) {
|
||||
delete t;
|
||||
}
|
||||
|
||||
template <typename Operation>
|
||||
class bind1st_t : public std::unary_function<typename Operation::second_argument_type,
|
||||
typename Operation::result_type> {
|
||||
|
||||
@@ -7,6 +7,8 @@ libsub_core_a_SOURCES = \
|
||||
curl_stack.h \
|
||||
download.cc \
|
||||
download.h \
|
||||
download_factory.cc \
|
||||
download_factory.h \
|
||||
download_list.cc \
|
||||
download_list.h \
|
||||
download_slot_map.h \
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <torrent/bencode.h>
|
||||
|
||||
#include "utils/task.h"
|
||||
#include "curl_get.h"
|
||||
#include "http_queue.h"
|
||||
#include "manager.h"
|
||||
|
||||
#include "download_factory.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
DownloadFactory::DownloadFactory(const std::string& uri, Manager* m) :
|
||||
m_manager(m),
|
||||
m_stream(NULL),
|
||||
m_commited(false),
|
||||
m_loaded(false),
|
||||
|
||||
m_uri(uri),
|
||||
m_session(false),
|
||||
m_start(false) {
|
||||
|
||||
m_taskLoad.set_iterator(utils::taskScheduler.end());
|
||||
m_taskLoad.set_slot(sigc::mem_fun(*this, &DownloadFactory::receive_load));
|
||||
|
||||
m_taskCommit.set_iterator(utils::taskScheduler.end());
|
||||
m_taskCommit.set_slot(sigc::mem_fun(*this, &DownloadFactory::receive_commit));
|
||||
}
|
||||
|
||||
DownloadFactory::~DownloadFactory() {
|
||||
utils::taskScheduler.erase(&m_taskLoad);
|
||||
utils::taskScheduler.erase(&m_taskCommit);
|
||||
|
||||
delete m_stream;
|
||||
m_stream = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::load() {
|
||||
utils::taskScheduler.insert(&m_taskLoad, utils::Timer::cache());
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::commit() {
|
||||
utils::taskScheduler.insert(&m_taskCommit, utils::Timer::cache());
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::receive_load() {
|
||||
if (m_stream)
|
||||
throw std::logic_error("DownloadFactory::load() called on an object with m_stream != NULL");
|
||||
|
||||
if (std::strncmp(m_uri.c_str(), "http://", 7) == 0) {
|
||||
// Http handling here.
|
||||
m_stream = new std::stringstream;
|
||||
HttpQueue::iterator itr = m_manager->get_http_queue().insert(m_uri, m_stream);
|
||||
|
||||
(*itr)->signal_done().slots().push_front(sigc::mem_fun(*this, &DownloadFactory::receive_loaded));
|
||||
(*itr)->signal_failed().slots().push_front(sigc::mem_fun(*this, &DownloadFactory::receive_failed));
|
||||
|
||||
} else {
|
||||
m_stream = new std::fstream(m_uri.c_str(), std::ios::in);
|
||||
|
||||
if (m_stream->good())
|
||||
receive_loaded();
|
||||
else
|
||||
receive_failed("Could not open file");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::receive_loaded() {
|
||||
m_loaded = true;
|
||||
|
||||
if (m_commited)
|
||||
receive_success();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::receive_commit() {
|
||||
m_commited = true;
|
||||
|
||||
if (m_loaded)
|
||||
receive_success();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::receive_success() {
|
||||
if (m_stream == NULL)
|
||||
throw std::logic_error("DownloadFactory::receive_success() called on an object with m_stream == NULL");
|
||||
|
||||
Manager::DListItr itr = m_manager->insert(m_stream);
|
||||
|
||||
if (itr == m_manager->get_download_list().end()) {
|
||||
// core::Manager should already have added the error message to
|
||||
// the log.
|
||||
m_slotFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_session) {
|
||||
torrent::Bencode& bencode = (*itr)->get_bencode();
|
||||
|
||||
if (bencode["rtorrent"]["state"].as_string() == "started")
|
||||
m_manager->start(*itr);
|
||||
|
||||
} else {
|
||||
if (m_start)
|
||||
m_manager->start(*itr);
|
||||
}
|
||||
|
||||
m_slotFinished();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadFactory::receive_failed(const std::string& msg) {
|
||||
if (m_stream == NULL)
|
||||
throw std::logic_error("DownloadFactory::receive_success() called on an object with m_stream == NULL");
|
||||
|
||||
// Add message to log.
|
||||
|
||||
m_slotFinished();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_CORE_DOWNLOAD_FACTORY_H
|
||||
#define RTORRENT_CORE_DOWNLOAD_FACTORY_H
|
||||
|
||||
#include <iosfwd>
|
||||
#include <sigc++/slot.h>
|
||||
|
||||
#include "utils/task_item.h"
|
||||
#include "http_queue.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
class Manager;
|
||||
|
||||
class DownloadFactory {
|
||||
public:
|
||||
typedef sigc::slot<void> Slot;
|
||||
|
||||
// Do not destroy this object while it is in a HttpQueue.
|
||||
DownloadFactory(const std::string& uri, Manager* m);
|
||||
~DownloadFactory();
|
||||
|
||||
// Calling of receive_load() is delayed so you can change whatever
|
||||
// you want without fear of the slots being triggered as you call
|
||||
// load() or commit().
|
||||
void load();
|
||||
void commit();
|
||||
|
||||
bool get_session() const { return m_session; }
|
||||
void set_session(bool v) { m_session = v; }
|
||||
|
||||
bool get_start() const { return m_start; }
|
||||
void set_start(bool v) { m_start = v; }
|
||||
|
||||
void slot_finished(Slot s) { m_slotFinished = s; }
|
||||
|
||||
private:
|
||||
void receive_load();
|
||||
void receive_loaded();
|
||||
void receive_commit();
|
||||
void receive_success();
|
||||
void receive_failed(const std::string& msg);
|
||||
|
||||
Manager* m_manager;
|
||||
std::iostream* m_stream;
|
||||
|
||||
bool m_commited;
|
||||
bool m_loaded;
|
||||
|
||||
std::string m_uri;
|
||||
bool m_session;
|
||||
bool m_start;
|
||||
|
||||
Slot m_slotFinished;
|
||||
utils::TaskItem m_taskLoad;
|
||||
utils::TaskItem m_taskCommit;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -49,7 +49,7 @@ namespace core {
|
||||
|
||||
DownloadList::iterator
|
||||
DownloadList::insert(std::istream* str) {
|
||||
torrent::Download d = torrent::download_create(str);
|
||||
torrent::Download d = torrent::download_add(str);
|
||||
|
||||
iterator itr = Base::insert(end(), new Download);
|
||||
(*itr)->set_download(d);
|
||||
|
||||
@@ -49,12 +49,13 @@
|
||||
namespace core {
|
||||
|
||||
HttpQueue::iterator
|
||||
HttpQueue::insert(const std::string& url) {
|
||||
HttpQueue::insert(const std::string& url, std::iostream* s) {
|
||||
std::auto_ptr<CurlGet> h(m_slotFactory());
|
||||
std::auto_ptr<std::stringstream> s(new std::stringstream);
|
||||
//std::auto_ptr<std::stringstream> s(new std::stringstream);
|
||||
|
||||
h->set_url(url);
|
||||
h->set_stream(s.get());
|
||||
//h->set_stream(s.get());
|
||||
h->set_stream(s);
|
||||
h->set_user_agent("rtorrent/" VERSION);
|
||||
|
||||
iterator itr = Base::insert(end(), h.get());
|
||||
@@ -65,7 +66,7 @@ HttpQueue::insert(const std::string& url) {
|
||||
(*itr)->start();
|
||||
|
||||
h.release();
|
||||
s.release();
|
||||
//s.release();
|
||||
|
||||
m_signalInsert.emit(*itr);
|
||||
|
||||
@@ -76,7 +77,7 @@ void
|
||||
HttpQueue::erase(iterator itr) {
|
||||
m_signalErase.emit(*itr);
|
||||
|
||||
delete (*itr)->get_stream();
|
||||
//delete (*itr)->get_stream();
|
||||
delete *itr;
|
||||
|
||||
Base::erase(itr);
|
||||
|
||||
@@ -69,7 +69,10 @@ public:
|
||||
|
||||
// Note that any slots connected to the CurlGet signals must be
|
||||
// pushed in front of the erase slot added by HttpQueue::insert.
|
||||
iterator insert(const std::string& url);
|
||||
//
|
||||
// Consider adding a flag to indicate whetever HttpQueue should
|
||||
// delete the stream.
|
||||
iterator insert(const std::string& url, std::iostream* s);
|
||||
void erase(iterator itr);
|
||||
|
||||
void clear();
|
||||
|
||||
+12
-41
@@ -69,7 +69,6 @@ Manager::initialize() {
|
||||
// opened or closed.
|
||||
m_downloadList.slot_map_insert().insert("0_initialize_bencode", sigc::mem_fun(*this, &Manager::initialize_bencode));
|
||||
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_inserted", sigc::mem_fun(*this, &Manager::receive_download_inserted));
|
||||
m_downloadList.slot_map_insert().insert("4_store_save", sigc::mem_fun(m_downloadStore, &DownloadStore::save));
|
||||
|
||||
m_downloadList.slot_map_erase().insert("1_hash_queue_remove", sigc::mem_fun(m_hashQueue, &HashQueue::remove));
|
||||
@@ -112,13 +111,16 @@ Manager::shutdown(bool force) {
|
||||
std::bind1st(std::mem_fun(&DownloadList::close), &m_downloadList));
|
||||
}
|
||||
|
||||
void
|
||||
Manager::insert(std::string uri) {
|
||||
if (std::strncmp(uri.c_str(), "http://", 7) == 0) {
|
||||
create_http(uri);
|
||||
} else {
|
||||
std::fstream f(uri.c_str(), std::ios::in);
|
||||
create_final(&f);
|
||||
Manager::DListItr
|
||||
Manager::insert(std::istream* s) {
|
||||
try {
|
||||
return m_downloadList.insert(s);
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
m_logImportant.push_front(e.what());
|
||||
m_logComplete.push_front(e.what());
|
||||
|
||||
return m_downloadList.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +129,8 @@ Manager::erase(DListItr itr) {
|
||||
if ((*itr)->get_download().is_active())
|
||||
throw std::logic_error("core::Manager::erase(...) called on an active download");
|
||||
|
||||
if (!(*itr)->get_download().is_open())
|
||||
throw std::logic_error("core::Manager::erase(...) called on an closed download");
|
||||
// if (!(*itr)->get_download().is_open())
|
||||
// throw std::logic_error("core::Manager::erase(...) called on an closed download");
|
||||
|
||||
return m_downloadList.erase(itr);
|
||||
}
|
||||
@@ -220,27 +222,6 @@ Manager::listen_open() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::create_http(const std::string& uri) {
|
||||
HttpQueue::iterator itr = m_httpQueue.insert(uri);
|
||||
|
||||
(*itr)->signal_done().slots().push_front(sigc::bind(sigc::mem_fun(*this, &Manager::create_final),
|
||||
(*itr)->get_stream()));
|
||||
(*itr)->signal_failed().slots().push_front(sigc::mem_fun(*this, &Manager::receive_http_failed));
|
||||
}
|
||||
|
||||
void
|
||||
Manager::create_final(std::istream* s) {
|
||||
try {
|
||||
m_downloadList.insert(s);
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
// What to do? Keep in list for now.
|
||||
m_logImportant.push_front(e.what());
|
||||
m_logComplete.push_front(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::initialize_bencode(Download* d) {
|
||||
torrent::Bencode& bencode = d->get_bencode();
|
||||
@@ -286,14 +267,4 @@ Manager::receive_download_done_hash_checked(Download* d) {
|
||||
d->get_download().tracker_send_completed();
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_download_inserted(Download* d) {
|
||||
// Check if there is an "rtorrent" section in the bencoded data.
|
||||
|
||||
torrent::Bencode& bencode = d->get_bencode();
|
||||
|
||||
if (bencode["rtorrent"]["state"].as_string() == "started")
|
||||
start(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
void shutdown(bool force);
|
||||
|
||||
void insert(std::string uri);
|
||||
DListItr insert(std::istream* s);
|
||||
DListItr erase(DListItr itr);
|
||||
|
||||
void start(Download* d);
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <torrent/rate.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "rak/algorithm.h"
|
||||
|
||||
@@ -91,17 +93,17 @@ WindowDownloadList::redraw() {
|
||||
m_canvas->print(0, pos++, "%c Torrent: Done %10.1f MiB Rate: %5.1f / %5.1f KiB Uploaded: %.1f MiB",
|
||||
range.first == m_list->get_focus() ? '*' : ' ',
|
||||
(double)d.get_bytes_total() / (double)(1 << 20),
|
||||
(double)d.get_rate_up() / 1024.0,
|
||||
(double)d.get_rate_down() / 1024.0,
|
||||
(double)d.get_bytes_up() / (double)(1 << 20));
|
||||
(double)d.get_write_rate().rate() / 1024.0,
|
||||
(double)d.get_read_rate().rate() / 1024.0,
|
||||
(double)d.get_write_rate().total() / (double)(1 << 20));
|
||||
else
|
||||
m_canvas->print(0, pos++, "%c Torrent: %6.1f / %6.1f MiB Rate: %5.1f / %5.1f KiB Uploaded: %.1f MiB",
|
||||
range.first == m_list->get_focus() ? '*' : ' ',
|
||||
(double)d.get_bytes_done() / (double)(1 << 20),
|
||||
(double)d.get_bytes_total() / (double)(1 << 20),
|
||||
(double)d.get_rate_up() / 1024.0,
|
||||
(double)d.get_rate_down() / 1024.0,
|
||||
(double)d.get_bytes_up() / (double)(1 << 20));
|
||||
(double)d.get_write_rate().rate() / 1024.0,
|
||||
(double)d.get_read_rate().rate() / 1024.0,
|
||||
(double)d.get_write_rate().total() / (double)(1 << 20));
|
||||
|
||||
m_canvas->print(0, pos++, "%c %s",
|
||||
range.first == m_list->get_focus() ? '*' : ' ',
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <torrent/rate.h>
|
||||
|
||||
#include "canvas.h"
|
||||
#include "utils.h"
|
||||
#include "window_download_statusbar.h"
|
||||
@@ -59,16 +61,16 @@ WindowDownloadStatusbar::redraw() {
|
||||
m_canvas->print(0, 0, "Torrent: %.1f / %.1f MiB Rate: %5.1f / %5.1f KiB Uploaded: %.1f MiB",
|
||||
(double)m_download->get_download().get_bytes_done() / (double)(1 << 20),
|
||||
(double)m_download->get_download().get_bytes_total() / (double)(1 << 20),
|
||||
(double)m_download->get_download().get_rate_up() / 1024.0,
|
||||
(double)m_download->get_download().get_rate_down() / 1024.0,
|
||||
(double)m_download->get_download().get_bytes_up() / (double)(1 << 20));
|
||||
(double)m_download->get_download().get_write_rate().rate() / 1024.0,
|
||||
(double)m_download->get_download().get_read_rate().rate() / 1024.0,
|
||||
(double)m_download->get_download().get_write_rate().total() / (double)(1 << 20));
|
||||
|
||||
else
|
||||
m_canvas->print(0, 0, "Torrent: Done %.1f MiB Rate: %5.1f / %5.1f KiB Uploaded: %.1f MiB",
|
||||
(double)m_download->get_download().get_bytes_total() / (double)(1 << 20),
|
||||
(double)m_download->get_download().get_rate_up() / 1024.0,
|
||||
(double)m_download->get_download().get_rate_down() / 1024.0,
|
||||
(double)m_download->get_download().get_bytes_up() / (double)(1 << 20));
|
||||
(double)m_download->get_download().get_write_rate().rate() / 1024.0,
|
||||
(double)m_download->get_download().get_read_rate().rate() / 1024.0,
|
||||
(double)m_download->get_download().get_write_rate().total() / (double)(1 << 20));
|
||||
|
||||
m_canvas->print(0, 1, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i",
|
||||
(int)m_download->get_download().get_peers_connected(),
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <torrent/rate.h>
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
@@ -88,10 +89,10 @@ WindowPeerInfo::redraw() {
|
||||
m_canvas->print(0, y++, "Done: %i%", done_percentage(**m_focus));
|
||||
|
||||
m_canvas->print(0, y++, "Rate: %5.1f/%5.1f KB Total: %.1f/%.1f MB",
|
||||
(double)(*m_focus)->get_rate_up() / (double)(1 << 10),
|
||||
(double)(*m_focus)->get_rate_down() / (double)(1 << 10),
|
||||
(double)(*m_focus)->get_transfered_up() / (double)(1 << 20),
|
||||
(double)(*m_focus)->get_transfered_down() / (double)(1 << 20));
|
||||
(double)(*m_focus)->get_write_rate().rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->get_read_rate().rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->get_write_rate().total() / (double)(1 << 20),
|
||||
(double)(*m_focus)->get_read_rate().total() / (double)(1 << 20));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <torrent/rate.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "rak/algorithm.h"
|
||||
@@ -96,14 +97,9 @@ WindowPeerList::redraw() {
|
||||
p.get_dns().c_str());
|
||||
x += 18;
|
||||
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_rate_up() / 1024);
|
||||
x += 7;
|
||||
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_rate_down() / 1024);
|
||||
x += 7;
|
||||
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_rate_peer() / 1024);
|
||||
x += 7;
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_write_rate().rate() / 1024); x += 7;
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_read_rate().rate() / 1024); x += 7;
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_peer_rate().rate() / 1024); x += 7;
|
||||
|
||||
m_canvas->print(x, y, "%c%c/%c%c",
|
||||
p.get_remote_choked() ? 'c' : 'u',
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "core/manager.h"
|
||||
@@ -73,8 +74,8 @@ WindowStatusbar::redraw() {
|
||||
|
||||
m_canvas->print(0, 0, "Throttle U/D: %s Rate: %5.1f / %5.1f KiB Listen: %s:%i%s",
|
||||
buf,
|
||||
(double)torrent::get_write_rate() / 1024.0,
|
||||
(double)torrent::get_read_rate() / 1024.0,
|
||||
(double)torrent::get_write_rate().rate() / 1024.0,
|
||||
(double)torrent::get_read_rate().rate() / 1024.0,
|
||||
!torrent::get_ip().empty() ? torrent::get_ip().c_str() : "<default>",
|
||||
(int)torrent::get_listen_port(),
|
||||
!torrent::get_bind().empty() ? (" Bind: " + torrent::get_bind()).c_str() : "");
|
||||
|
||||
+22
-3
@@ -47,12 +47,14 @@
|
||||
#include <sigc++/retype_return.h>
|
||||
#include <torrent/http.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <rak/functional.h>
|
||||
|
||||
#ifdef USE_EXECINFO
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/download_factory.h"
|
||||
#include "display/canvas.h"
|
||||
#include "display/window.h"
|
||||
#include "ui/control.h"
|
||||
@@ -177,12 +179,29 @@ load_session_torrents(ui::Control* c) {
|
||||
// Load session torrents.
|
||||
std::list<std::string> l = c->get_core().get_download_store().get_formated_entries().make_list();
|
||||
|
||||
std::for_each(l.begin(), l.end(), std::bind1st(std::mem_fun(&core::Manager::insert), &c->get_core()));
|
||||
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());
|
||||
|
||||
// Replace with session torrent flag.
|
||||
f->set_session(true);
|
||||
f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f));
|
||||
f->load();
|
||||
f->commit();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
load_arg_torrents(ui::Control* c, char** begin, char** end) {
|
||||
std::for_each(begin, end, std::bind1st(std::mem_fun(&core::Manager::insert), &c->get_core()));
|
||||
load_arg_torrents(ui::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());
|
||||
|
||||
// Replace with session torrent flag.
|
||||
f->set_start(true);
|
||||
f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f));
|
||||
f->load();
|
||||
f->commit();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+18
-8
@@ -43,6 +43,7 @@
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/download_factory.h"
|
||||
|
||||
#include "input/bindings.h"
|
||||
#include "input/path_input.h"
|
||||
@@ -130,7 +131,7 @@ DownloadList::disable() {
|
||||
|
||||
if (m_windowTextInput->is_active()) {
|
||||
m_windowTextInput->get_input()->clear();
|
||||
receive_exit_input();
|
||||
receive_exit_input(true);
|
||||
}
|
||||
|
||||
disable_display();
|
||||
@@ -239,7 +240,7 @@ DownloadList::receive_check_hash() {
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_view_input() {
|
||||
DownloadList::receive_view_input(bool useDefault) {
|
||||
m_control->get_ui().window_statusbar()->set_active(false);
|
||||
m_windowTextInput->set_active(true);
|
||||
m_control->get_display().adjust_layout();
|
||||
@@ -248,19 +249,26 @@ DownloadList::receive_view_input() {
|
||||
|
||||
m_windowTextInput->set_focus(true);
|
||||
|
||||
(*m_bindings)['\n'] = sigc::mem_fun(*this, &DownloadList::receive_exit_input);
|
||||
(*m_bindings)[KEY_ENTER] = sigc::mem_fun(*this, &DownloadList::receive_exit_input);
|
||||
(*m_bindings)['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), useDefault);
|
||||
(*m_bindings)[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), useDefault);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_exit_input() {
|
||||
DownloadList::receive_exit_input(bool useDefault) {
|
||||
m_control->get_ui().window_statusbar()->set_active(true);
|
||||
m_windowTextInput->set_active(false);
|
||||
|
||||
m_control->get_input().set_text_input();
|
||||
|
||||
m_slotOpenUri(m_windowTextInput->get_input()->str());
|
||||
// Adding download.
|
||||
core::DownloadFactory* f = new core::DownloadFactory(m_windowTextInput->get_input()->str(), &m_control->get_core());
|
||||
|
||||
f->set_start(useDefault);
|
||||
f->slot_finished(sigc::bind(sigc::ptr_fun(&rak::call_delete_func<core::DownloadFactory>), f));
|
||||
f->load();
|
||||
f->commit();
|
||||
|
||||
// Clean up.
|
||||
m_windowTextInput->get_input()->clear();
|
||||
m_windowTextInput->set_focus(false);
|
||||
|
||||
@@ -292,8 +300,10 @@ DownloadList::setup_keys() {
|
||||
(*m_bindings)['\x04'] = sigc::mem_fun(*this, &DownloadList::receive_stop_download);
|
||||
(*m_bindings)['\x12'] = sigc::mem_fun(*this, &DownloadList::receive_check_hash);
|
||||
|
||||
(*m_bindings)['\x7f'] = sigc::mem_fun(*this, &DownloadList::receive_view_input);
|
||||
(*m_bindings)[KEY_BACKSPACE] = sigc::mem_fun(*this, &DownloadList::receive_view_input);
|
||||
(*m_bindings)['\x7f'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), true);
|
||||
(*m_bindings)[KEY_BACKSPACE] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), true);
|
||||
(*m_bindings)['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), false);
|
||||
(*m_bindings)[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), false);
|
||||
|
||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
|
||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
|
||||
|
||||
@@ -114,8 +114,8 @@ private:
|
||||
|
||||
void receive_check_hash();
|
||||
|
||||
void receive_view_input();
|
||||
void receive_exit_input();
|
||||
void receive_view_input(bool useDefault);
|
||||
void receive_exit_input(bool useDefault);
|
||||
|
||||
void receive_change(Display d);
|
||||
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ Root::init(Control* c) {
|
||||
m_control->get_display().push_back(m_windowStatusbar);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user