diff --git a/src/display/utils.cc b/src/display/utils.cc index 10a851ec..99948f58 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -59,6 +59,30 @@ print_string(char* buf, unsigned int length, char* str) { return buf; } +char* +print_hhmmss(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, "%02u:%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); + + if (u == NULL) + return "inv_time"; + + unsigned int s = snprintf(buf, length, "%02u/%02u/%04u", u->tm_mday, (u->tm_mon + 1), (1900 + u->tm_year)); + + return buf + std::min(s, length); +} + char* print_download_title(char* buf, unsigned int length, core::Download* d) { return buf + std::max(0, snprintf(buf, length, "%s", @@ -82,9 +106,9 @@ print_download_info(char* buf, unsigned int length, core::Download* d) { (double)d->get_download().bytes_total() / (double)(1 << 20))); buf += std::max(0, snprintf(buf, last - buf, " Rate: %5.1f / %5.1f KB Uploaded: %.1f MB", - (double)d->get_download().up_rate().rate() / (1 << 10), - (double)d->get_download().down_rate().rate() / (1 << 10), - (double)d->get_download().up_rate().total() / (1 << 20))); + (double)d->get_download().up_rate()->rate() / (1 << 10), + (double)d->get_download().down_rate()->rate() / (1 << 10), + (double)d->get_download().up_rate()->total() / (1 << 20))); return buf; } @@ -113,28 +137,12 @@ print_download_status(char* buf, unsigned int length, core::Download* d) { return buf; } -char* -print_hhmmss(char* buf, unsigned int length, time_t t) { - std::tm *u = std::localtime(&t); +// char* +// print_entry_tags(char* buf, unsigned int length) { - if (u == NULL) - return "inv_time"; +// } - unsigned int s = snprintf(buf, length, "%02u:%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); - - if (u == NULL) - return "inv_time"; - - unsigned int s = snprintf(buf, length, "%02u/%02u/%04u", u->tm_mday, (u->tm_mon + 1), (1900 + u->tm_year)); - - return buf + std::min(s, length); -} +// char* +// print_entry_file(char* buf, unsigned int length, const torrent::Entry& entry); } diff --git a/src/display/utils.h b/src/display/utils.h index ba674837..9a8ae0c1 100644 --- a/src/display/utils.h +++ b/src/display/utils.h @@ -48,16 +48,23 @@ namespace utils { class Timer; } +namespace torrent { + class Entry; +} + 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_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_hhmmss(char* buf, unsigned int length, time_t t); -char* print_ddmmyyyy(char* buf, unsigned int length, time_t t); +char* print_entry_tags(char* buf, unsigned int length); +char* print_entry_file(char* buf, unsigned int length, const torrent::Entry& entry); } diff --git a/src/display/window_download_statusbar.cc b/src/display/window_download_statusbar.cc index 4d63cbca..33c99e0e 100644 --- a/src/display/window_download_statusbar.cc +++ b/src/display/window_download_statusbar.cc @@ -64,21 +64,6 @@ WindowDownloadStatusbar::redraw() { position = print_download_info(buffer, last - buffer, m_download); m_canvas->print(0, 0, "%s", buffer); -// if (m_download->get_download().get_chunks_done() != m_download->get_download().get_chunks_total() || !m_download->get_download().is_open()) -// 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_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_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 U/I: %i/%i", (int)m_download->get_download().peers_connected(), (int)m_download->get_download().peers_not_connected(), diff --git a/src/display/window_peer_info.cc b/src/display/window_peer_info.cc index 4fb490d9..a3f7b5d6 100644 --- a/src/display/window_peer_info.cc +++ b/src/display/window_peer_info.cc @@ -103,10 +103,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)->up_rate().rate() / (double)(1 << 10), - (double)(*m_focus)->down_rate().rate() / (double)(1 << 10), - (double)(*m_focus)->up_rate().total() / (double)(1 << 20), - (double)(*m_focus)->down_rate().total() / (double)(1 << 20)); + (double)(*m_focus)->up_rate()->rate() / (double)(1 << 10), + (double)(*m_focus)->down_rate()->rate() / (double)(1 << 10), + (double)(*m_focus)->up_rate()->total() / (double)(1 << 20), + (double)(*m_focus)->down_rate()->total() / (double)(1 << 20)); } int diff --git a/src/display/window_peer_list.cc b/src/display/window_peer_list.cc index b3edab0a..9a92f337 100644 --- a/src/display/window_peer_list.cc +++ b/src/display/window_peer_list.cc @@ -97,9 +97,9 @@ WindowPeerList::redraw() { p.address().c_str()); x += 18; - m_canvas->print(x, y, "%.1f", (double)p.up_rate().rate() / 1024); x += 7; - m_canvas->print(x, y, "%.1f", (double)p.down_rate().rate() / 1024); x += 7; - m_canvas->print(x, y, "%.1f", (double)p.peer_rate().rate() / 1024); x += 7; + m_canvas->print(x, y, "%.1f", (double)p.up_rate()->rate() / 1024); x += 7; + m_canvas->print(x, y, "%.1f", (double)p.down_rate()->rate() / 1024); x += 7; + m_canvas->print(x, y, "%.1f", (double)p.peer_rate()->rate() / 1024); x += 7; m_canvas->print(x, y, "%c/%c%c/%c%c", p.is_incoming() ? 'r' : 'l', diff --git a/src/display/window_statusbar.cc b/src/display/window_statusbar.cc index 6a64e306..7409317e 100644 --- a/src/display/window_statusbar.cc +++ b/src/display/window_statusbar.cc @@ -76,8 +76,8 @@ WindowStatusbar::redraw() { m_canvas->print(0, 0, "Throttle U/D: %s Rate: %5.1f / %5.1f KB Listen: %s:%i%s", buf, - (double)torrent::up_rate().rate() / 1024.0, - (double)torrent::down_rate().rate() / 1024.0, + (double)torrent::up_rate()->rate() / 1024.0, + (double)torrent::down_rate()->rate() / 1024.0, !torrent::local_address().empty() ? torrent::local_address().c_str() : "", (int)torrent::listen_port(), !torrent::bind_address().empty() ? (" Bind: " + torrent::bind_address()).c_str() : "");