* Made torrent::Piece part of the api.

* Made libtorrent locale agnostic.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@664 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-04-05 21:09:15 +00:00
parent 3fa08503bb
commit 8a8cfe5e3d
8 changed files with 263 additions and 94 deletions
+4
View File
@@ -111,6 +111,10 @@ public:
void print(int x, int y, char* str,
A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { mvwprintw(m_window, y, x, str, a1, a2, a3, a4, a5, a6, a7, a8); }
void print_char(const chtype ch) { waddch(m_window, ch); }
void print_char(int x, int y, const chtype ch) { mvwaddch(m_window, y, x, ch); }
void set_attr(int x, int y, int n, int attr, int color) { mvwchgat(m_window, y, x, n, attr, color, NULL); }
// Initialize stdscr.
+3 -2
View File
@@ -62,7 +62,7 @@ struct client_info_equal {
};
ClientInfo::ClientInfo() {
m_containers[TYPE_AZUREUS].reserve(28);
m_containers[TYPE_AZUREUS].reserve(30);
insert(TYPE_AZUREUS, "AZ", "Azureus");
insert(TYPE_AZUREUS, "BC", "BitComet");
@@ -85,6 +85,7 @@ ClientInfo::ClientInfo() {
insert(TYPE_AZUREUS, "QT", "Qt 4 Torrent example");
insert(TYPE_AZUREUS, "SZ", "Shareaza");
insert(TYPE_AZUREUS, "RT", "Retriever");
insert(TYPE_AZUREUS, "CD", "Enhanced CTorrent");
m_containers[TYPE_COMPACT].reserve(10);
@@ -94,7 +95,7 @@ ClientInfo::ClientInfo() {
insert(TYPE_COMPACT, "U", "UPnP NAT Bit Torrent");
insert(TYPE_COMPACT, "O", "Osprey Permaseed");
m_containers[TYPE_MAINLINE].reserve(4);
m_containers[TYPE_MAINLINE].reserve(5);
insert(TYPE_MAINLINE, "M", "Mainline");
}
+18 -13
View File
@@ -39,6 +39,7 @@
#include <cmath>
#include <stdexcept>
#include <rak/string_manip.h>
#include <torrent/bitfield.h>
#include "core/download.h"
@@ -72,30 +73,34 @@ WindowDownloadChunksSeen::redraw() {
return;
}
char buffer[m_canvas->get_width()];
char* position;
char* end = buffer + m_canvas->get_width() - 2;
const uint8_t* chunk = seen;
const uint8_t* last = seen + m_download->download()->chunks_total();
const torrent::Bitfield* bitfield = m_download->download()->bitfield();
for (int y = 1; y < m_canvas->get_height() && chunk < last; ++y) {
position = buffer + std::max(snprintf(buffer, end - buffer, "%5d", (int)(chunk - seen)), 0);
m_canvas->print(0, y, "%5d ", (int)(chunk - seen));
while (chunk < last) {
chtype attr;
if (bitfield->get(chunk - seen))
attr = A_NORMAL;
// else if (foo->is_downloading(chunk - seen))
// attr = A_UNDERLINE;
else
attr = A_BOLD;
m_canvas->print_char(attr | rak::value_to_hexchar<0>(std::min<uint8_t>(*chunk, 0xF)));
chunk++;
if ((chunk - seen) % 10 == 0) {
if (end - position < 11)
if (m_canvas->get_x() + 12 > m_canvas->get_width())
break;
*position++ = ' ';
m_canvas->print_char(' ');
}
*position++ = rak::value_to_hexchar<0>(std::min<uint8_t>(*chunk, 0xF));
chunk++;
}
*position = 0;
m_canvas->print(0, y, "%s", buffer);
}
}
+2 -1
View File
@@ -39,6 +39,7 @@
#include <stdexcept>
#include <rak/socket_address.h>
#include <torrent/rate.h>
#include <torrent/piece.h>
#include "core/download.h"
#include "rak/algorithm.h"
@@ -120,7 +121,7 @@ WindowPeerList::redraw() {
x += 6;
if (p.incoming_queue_size())
m_canvas->print(x, y, "%i", p.incoming_index(0));
m_canvas->print(x, y, "%i", p.incoming_queue(0)->index());
x += 6;