mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
* Reverse the color of currently downloading chunks in chunks
seen. Patch by Josef Drexler, public domain. * Moving various stuff from Delegator to TransferList. * Added checks in HandshakeManager::receive_* to check for invalid handshakes. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@716 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -40,6 +40,8 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <rak/string_manip.h>
|
#include <rak/string_manip.h>
|
||||||
#include <torrent/bitfield.h>
|
#include <torrent/bitfield.h>
|
||||||
|
#include <torrent/transfer_list.h>
|
||||||
|
#include <torrent/block_list.h>
|
||||||
|
|
||||||
#include "core/download.h"
|
#include "core/download.h"
|
||||||
|
|
||||||
@@ -74,12 +76,25 @@ WindowDownloadChunksSeen::redraw() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_download->is_done()) {
|
||||||
|
m_canvas->print(36, 0, "X downloaded missing downloading");
|
||||||
|
m_canvas->print_char(50, 0, 'X' | A_BOLD);
|
||||||
|
m_canvas->print_char(61, 0, 'X' | A_REVERSE);
|
||||||
|
}
|
||||||
|
|
||||||
*m_focus = std::min(*m_focus, max_focus());
|
*m_focus = std::min(*m_focus, max_focus());
|
||||||
|
|
||||||
const uint8_t* chunk = seen + *m_focus * chunks_per_row();
|
const uint8_t* chunk = seen + *m_focus * chunks_per_row();
|
||||||
const uint8_t* last = seen + m_download->download()->chunks_total();
|
const uint8_t* last = seen + m_download->download()->chunks_total();
|
||||||
|
|
||||||
const torrent::Bitfield* bitfield = m_download->download()->bitfield();
|
const torrent::Bitfield* bitfield = m_download->download()->bitfield();
|
||||||
|
const torrent::TransferList* transfers = m_download->download()->transfer_list();
|
||||||
|
std::vector<uint32_t> transferChunks(transfers->size(), 0);
|
||||||
|
|
||||||
|
std::transform(transfers->begin(), transfers->end(), transferChunks.begin(), std::mem_fun(&torrent::BlockList::index));
|
||||||
|
std::sort(transferChunks.begin(), transferChunks.end());
|
||||||
|
|
||||||
|
std::vector<uint32_t>::const_iterator itrTransfer = transferChunks.begin();
|
||||||
|
|
||||||
for (int y = 1; y < m_canvas->get_height() && chunk < last; ++y) {
|
for (int y = 1; y < m_canvas->get_height() && chunk < last; ++y) {
|
||||||
m_canvas->print(0, y, "%5d ", (int)(chunk - seen));
|
m_canvas->print(0, y, "%5d ", (int)(chunk - seen));
|
||||||
@@ -87,12 +102,14 @@ WindowDownloadChunksSeen::redraw() {
|
|||||||
while (chunk < last) {
|
while (chunk < last) {
|
||||||
chtype attr;
|
chtype attr;
|
||||||
|
|
||||||
if (bitfield->get(chunk - seen))
|
if (bitfield->get(chunk - seen)) {
|
||||||
attr = A_NORMAL;
|
attr = A_NORMAL;
|
||||||
// else if (foo->is_downloading(chunk - seen))
|
} else if (itrTransfer != transferChunks.end() && (uint32_t)(chunk - seen) == *itrTransfer) {
|
||||||
// attr = A_UNDERLINE;
|
attr = A_REVERSE;
|
||||||
else
|
itrTransfer++;
|
||||||
|
} else {
|
||||||
attr = A_BOLD;
|
attr = A_BOLD;
|
||||||
|
}
|
||||||
|
|
||||||
m_canvas->print_char(attr | rak::value_to_hexchar<0>(std::min<uint8_t>(*chunk, 0xF)));
|
m_canvas->print_char(attr | rak::value_to_hexchar<0>(std::min<uint8_t>(*chunk, 0xF)));
|
||||||
chunk++;
|
chunk++;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <rak/socket_address.h>
|
#include <rak/socket_address.h>
|
||||||
|
#include <torrent/block_transfer.h>
|
||||||
#include <torrent/rate.h>
|
#include <torrent/rate.h>
|
||||||
#include <torrent/piece.h>
|
#include <torrent/piece.h>
|
||||||
|
|
||||||
@@ -83,9 +84,9 @@ WindowPeerList::redraw() {
|
|||||||
typedef std::pair<PList::iterator, PList::iterator> Range;
|
typedef std::pair<PList::iterator, PList::iterator> Range;
|
||||||
|
|
||||||
Range range = rak::advance_bidirectional(m_list->begin(),
|
Range range = rak::advance_bidirectional(m_list->begin(),
|
||||||
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
||||||
m_list->end(),
|
m_list->end(),
|
||||||
m_canvas->get_height() - y);
|
m_canvas->get_height() - y);
|
||||||
|
|
||||||
if (m_download->download()->chunks_total() <= 0)
|
if (m_download->download()->chunks_total() <= 0)
|
||||||
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
||||||
@@ -96,8 +97,8 @@ WindowPeerList::redraw() {
|
|||||||
x = 0;
|
x = 0;
|
||||||
|
|
||||||
m_canvas->print(x, y, "%c %s",
|
m_canvas->print(x, y, "%c %s",
|
||||||
range.first == *m_focus ? '*' : ' ',
|
range.first == *m_focus ? '*' : ' ',
|
||||||
rak::socket_address::cast_from(p.address())->address_str().c_str());
|
rak::socket_address::cast_from(p.address())->address_str().c_str());
|
||||||
x += 18;
|
x += 18;
|
||||||
|
|
||||||
m_canvas->print(x, y, "%.1f", (double)p.up_rate()->rate() / 1024); x += 7;
|
m_canvas->print(x, y, "%.1f", (double)p.up_rate()->rate() / 1024); x += 7;
|
||||||
@@ -105,23 +106,23 @@ WindowPeerList::redraw() {
|
|||||||
m_canvas->print(x, y, "%.1f", (double)p.peer_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",
|
m_canvas->print(x, y, "%c/%c%c/%c%c",
|
||||||
p.is_incoming() ? 'r' : 'l',
|
p.is_incoming() ? 'r' : 'l',
|
||||||
p.is_remote_choked() ? 'c' : 'u',
|
p.is_remote_choked() ? 'c' : 'u',
|
||||||
p.is_remote_interested() ? 'i' : 'n',
|
p.is_remote_interested() ? 'i' : 'n',
|
||||||
p.is_local_choked() ? 'c' : 'u',
|
p.is_local_choked() ? 'c' : 'u',
|
||||||
p.is_local_interested() ? 'i' : 'n');
|
p.is_local_interested() ? 'i' : 'n');
|
||||||
x += 9;
|
x += 9;
|
||||||
|
|
||||||
m_canvas->print(x, y, "%i/%i",
|
m_canvas->print(x, y, "%i/%i", p.outgoing_queue_size(), p.incoming_queue_size());
|
||||||
p.outgoing_queue_size(),
|
|
||||||
p.incoming_queue_size());
|
|
||||||
x += 6;
|
x += 6;
|
||||||
|
|
||||||
m_canvas->print(x, y, "%3i", done_percentage(*range.first));
|
m_canvas->print(x, y, "%3i", done_percentage(*range.first));
|
||||||
x += 6;
|
x += 6;
|
||||||
|
|
||||||
if (p.incoming_queue_size())
|
const torrent::BlockTransfer* transfer = p.transfer();
|
||||||
m_canvas->print(x, y, "%i", p.incoming_queue(0)->index());
|
|
||||||
|
if (transfer != NULL)
|
||||||
|
m_canvas->print(x, y, "%i", transfer->index());
|
||||||
|
|
||||||
x += 6;
|
x += 6;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user