mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-16 23:22:31 +00:00
* Added the framework for a download scheduler.
* Added "state_changed" variable to downloads that returns the last time the download called DownloadList::pause/resume. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@674 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+12
-2
@@ -55,21 +55,31 @@ namespace display {
|
||||
|
||||
char*
|
||||
print_string(char* first, char* last, char* str) {
|
||||
if (first == last)
|
||||
return first;
|
||||
|
||||
// We don't have any nice simple functions for copying strings that
|
||||
// return the end address.
|
||||
while (first != last && *str != '\0')
|
||||
while (first + 1 != last && *str != '\0')
|
||||
*(first++) = *(str++);
|
||||
|
||||
*first = '\0';
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
char*
|
||||
print_hhmmss(char* first, char* last, time_t t) {
|
||||
return print_buffer(first, last, "%2d:%02d:%02d", (int)t / 3600, ((int)t / 60) % 60, (int)t % 60);
|
||||
}
|
||||
|
||||
char*
|
||||
print_hhmmss_local(char* first, char* last, time_t t) {
|
||||
std::tm *u = std::localtime(&t);
|
||||
|
||||
if (u == NULL)
|
||||
//return "inv_time";
|
||||
throw torrent::internal_error("print_hhmmss(...) failed.");
|
||||
throw torrent::internal_error("print_hhmmss_local(...) failed.");
|
||||
|
||||
return print_buffer(first, last, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace display {
|
||||
char* print_string(char* first, char* last, char* str);
|
||||
|
||||
char* print_hhmmss(char* first, char* last, time_t t);
|
||||
char* print_hhmmss_local(char* first, char* last, time_t t);
|
||||
char* print_ddhhmm(char* first, char* last, time_t t);
|
||||
char* print_ddmmyyyy(char* first, char* last, time_t t);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ WindowLog::redraw() {
|
||||
|
||||
for (core::Log::iterator itr = m_log->begin(), end = find_older(); itr != end && pos < m_canvas->get_height(); ++itr) {
|
||||
char buffer[16];
|
||||
print_hhmmss(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
||||
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
||||
|
||||
m_canvas->print(0, pos++, "(%s) %s", buffer, itr->second.c_str());
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ WindowLogComplete::redraw() {
|
||||
|
||||
for (core::Log::iterator itr = m_log->begin(), e = m_log->end(); itr != e && pos < m_canvas->get_height(); ++itr) {
|
||||
char buffer[16];
|
||||
print_hhmmss(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
||||
print_hhmmss_local(buffer, buffer + 16, static_cast<time_t>(itr->first.seconds()));
|
||||
|
||||
m_canvas->print(0, pos++, "(%s) %s", buffer, itr->second.c_str());
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ WindowPeerInfo::redraw() {
|
||||
m_canvas->erase();
|
||||
|
||||
int y = 0;
|
||||
char buffer[256];
|
||||
char* position;
|
||||
|
||||
torrent::Download* d = m_download->download();
|
||||
|
||||
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d->info_hash()).c_str());
|
||||
@@ -75,12 +78,13 @@ WindowPeerInfo::redraw() {
|
||||
d->chunks_total(),
|
||||
d->chunks_size());
|
||||
|
||||
char buffer[32], *position;
|
||||
position = print_ddmmyyyy(buffer, buffer + 32, static_cast<time_t>(d->creation_date()));
|
||||
position = print_string(position, buffer + 32, " ");
|
||||
position = print_hhmmss(position, buffer + 32, static_cast<time_t>(d->creation_date()));
|
||||
y++;
|
||||
|
||||
m_canvas->print(0, y++, "Created: %s", buffer);
|
||||
position = print_date(buffer, buffer + 256, static_cast<time_t>(d->creation_date()));
|
||||
m_canvas->print(0, y++, "Created: %s", buffer);
|
||||
|
||||
position = print_timer(buffer, buffer + 256, static_cast<time_t>(m_download->variable()->get_value("state_changed")));
|
||||
m_canvas->print(0, y++, "State Changed: %s", buffer);
|
||||
|
||||
y++;
|
||||
|
||||
@@ -140,4 +144,21 @@ WindowPeerInfo::done_percentage(torrent::Peer& p) {
|
||||
return chunks ? (100 * p.chunks_done()) / chunks : 0;
|
||||
}
|
||||
|
||||
char*
|
||||
WindowPeerInfo::print_date(char* buf, char* end, time_t t) {
|
||||
buf = print_ddmmyyyy(buf, end, t);
|
||||
buf = print_string(buf, end, " ");
|
||||
buf = print_hhmmss_local(buf, end, t);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char*
|
||||
WindowPeerInfo::print_timer(char* buf, char* end, time_t t) {
|
||||
if (t == 0)
|
||||
return print_string(buf, end, "--:--:--");
|
||||
else
|
||||
return print_hhmmss(buf, end, cachedTime.seconds() - t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#ifndef RTORRENT_DISPLAY_PEER_INFO_H
|
||||
#define RTORRENT_DISPLAY_PEER_INFO_H
|
||||
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
#include <torrent/peer.h>
|
||||
|
||||
@@ -54,15 +55,18 @@ public:
|
||||
|
||||
WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f);
|
||||
|
||||
virtual void redraw();
|
||||
virtual void redraw();
|
||||
|
||||
private:
|
||||
int done_percentage(torrent::Peer& p);
|
||||
int done_percentage(torrent::Peer& p);
|
||||
|
||||
core::Download* m_download;
|
||||
char* print_date(char* buf, char* end, time_t t);
|
||||
char* print_timer(char* buf, char* end, time_t t);
|
||||
|
||||
PList* m_list;
|
||||
PList::iterator* m_focus;
|
||||
core::Download* m_download;
|
||||
|
||||
PList* m_list;
|
||||
PList::iterator* m_focus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user