mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 20:52:30 +00:00
* Cleaned up rak::priority_queue.
* Added download time left display, need to tweak it. * Removed libtorrent/src/download/download_setup.cc. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@607 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+1
-1
@@ -89,7 +89,7 @@ Control::initialize() {
|
||||
|
||||
void
|
||||
Control::cleanup() {
|
||||
taskScheduler.erase(&m_taskShutdown);
|
||||
taskScheduler.erase(m_taskShutdown.clear());
|
||||
|
||||
m_inputStdin->remove(m_core->get_poll_manager()->get_torrent_poll());
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ DownloadFactory::DownloadFactory(const std::string& uri, Manager* m) :
|
||||
}
|
||||
|
||||
DownloadFactory::~DownloadFactory() {
|
||||
taskScheduler.erase(&m_taskLoad);
|
||||
taskScheduler.erase(&m_taskCommit);
|
||||
taskScheduler.erase(m_taskLoad.clear());
|
||||
taskScheduler.erase(m_taskCommit.clear());
|
||||
|
||||
delete m_stream;
|
||||
m_stream = NULL;
|
||||
|
||||
@@ -100,8 +100,10 @@ Manager::do_update() {
|
||||
|
||||
std::list<rak::priority_item*> workQueue;
|
||||
|
||||
std::copy(rak::queue_popper(displayScheduler, rak::priority_ready(cachedTime)), rak::queue_popper(), std::back_inserter(workQueue));
|
||||
std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::clear_time));
|
||||
std::copy(rak::queue_popper(displayScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), cachedTime)),
|
||||
rak::queue_popper(displayScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), rak::timer())),
|
||||
std::back_inserter(workQueue));
|
||||
std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::clear));
|
||||
std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::call));
|
||||
|
||||
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
||||
|
||||
@@ -71,6 +71,18 @@ print_hhmmss(char* buf, unsigned int length, time_t t) {
|
||||
return buf + std::min(s, length);
|
||||
}
|
||||
|
||||
char*
|
||||
print_hhhhmmss(char* buf, unsigned int length, time_t t) {
|
||||
std::tm *u = std::localtime(&t);
|
||||
|
||||
if (u == NULL)
|
||||
return "inv_time";
|
||||
|
||||
unsigned int s = snprintf(buf, length, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
||||
|
||||
return buf + std::min(s, length);
|
||||
}
|
||||
|
||||
char*
|
||||
print_ddmmyyyy(char* buf, unsigned int length, time_t t) {
|
||||
std::tm *u = std::gmtime(&t);
|
||||
@@ -110,6 +122,9 @@ print_download_info(char* buf, unsigned int length, core::Download* d) {
|
||||
(double)d->get_download().down_rate()->rate() / (1 << 10),
|
||||
(double)d->get_download().up_rate()->total() / (1 << 20)));
|
||||
|
||||
buf += std::max(0, snprintf(buf, length, " Left: "));
|
||||
buf = print_download_time_left(buf, length, d);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -138,6 +153,21 @@ print_download_status(char* buf, unsigned int length, core::Download* d) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_time_left(char* buf, unsigned int length, core::Download* d) {
|
||||
uint32_t rate;
|
||||
|
||||
if (!d->get_download().is_active() ||
|
||||
(rate = d->get_download().down_rate()->rate()) < 512) {
|
||||
buf += std::max(0, snprintf(buf, length, "--:--:--"));
|
||||
return buf;
|
||||
}
|
||||
|
||||
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
|
||||
|
||||
return print_hhhhmmss(buf, length, remaining);
|
||||
}
|
||||
|
||||
// char*
|
||||
// print_entry_tags(char* buf, unsigned int length) {
|
||||
|
||||
|
||||
@@ -57,11 +57,13 @@ namespace display {
|
||||
char* print_string(char* buf, unsigned int length, char* str);
|
||||
|
||||
char* print_hhmmss(char* buf, unsigned int length, time_t t);
|
||||
char* print_hhhhmmss(char* buf, unsigned int length, time_t t);
|
||||
char* print_ddmmyyyy(char* buf, unsigned int length, time_t t);
|
||||
|
||||
char* print_download_title(char* buf, unsigned int length, core::Download* d);
|
||||
char* print_download_info(char* buf, unsigned int length, core::Download* d);
|
||||
char* print_download_status(char* buf, unsigned int length, core::Download* d);
|
||||
char* print_download_time_left(char* buf, unsigned int length, core::Download* d);
|
||||
|
||||
char* print_entry_tags(char* buf, unsigned int length);
|
||||
char* print_entry_file(char* buf, unsigned int length, const torrent::Entry& entry);
|
||||
|
||||
@@ -54,7 +54,7 @@ Window::Window(Canvas* c, bool d, int h) :
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
displayScheduler.erase(&m_taskUpdate);
|
||||
displayScheduler.erase(m_taskUpdate.clear());
|
||||
delete m_canvas;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ Window::set_active(bool a) {
|
||||
if (a)
|
||||
mark_dirty();
|
||||
else
|
||||
displayScheduler.erase(&m_taskUpdate);
|
||||
displayScheduler.erase(m_taskUpdate.clear());
|
||||
|
||||
m_active = a;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ protected:
|
||||
|
||||
inline void
|
||||
Window::mark_dirty() {
|
||||
displayScheduler.erase(&m_taskUpdate);
|
||||
displayScheduler.erase(m_taskUpdate.clear());
|
||||
displayScheduler.push(m_taskUpdate.prepare(cachedTime));
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -223,8 +223,10 @@ main(int argc, char** argv) {
|
||||
|
||||
std::list<rak::priority_item*> workQueue;
|
||||
|
||||
std::copy(rak::queue_popper(taskScheduler, rak::priority_ready(cachedTime)), rak::queue_popper(), std::back_inserter(workQueue));
|
||||
std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::clear_time));
|
||||
std::copy(rak::queue_popper(taskScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), cachedTime)),
|
||||
rak::queue_popper(taskScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), rak::timer())),
|
||||
std::back_inserter(workQueue));
|
||||
std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::clear));
|
||||
std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::call));
|
||||
|
||||
// This needs to be called every second or so. Currently done by
|
||||
|
||||
@@ -138,7 +138,7 @@ DownloadList::disable() {
|
||||
|
||||
disable_display();
|
||||
|
||||
taskScheduler.erase(&m_taskUpdate);
|
||||
taskScheduler.erase(m_taskUpdate.clear());
|
||||
|
||||
m_control->display()->erase(m_window);
|
||||
m_control->display()->erase(m_windowTitle);
|
||||
|
||||
Reference in New Issue
Block a user