mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 22:52:31 +00:00
* Cleanup of the API, got rid of "get_" prefix for alot of the calls.
* Tweaked the http get timeout, now it has a 60 second connect timeout and a 360 second download timeout. * Moved libtorrent/src/parse/download_constructor to src/download. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@595 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+11
-11
@@ -62,7 +62,7 @@ print_string(char* buf, unsigned int length, char* str) {
|
||||
char*
|
||||
print_download_title(char* buf, unsigned int length, core::Download* d) {
|
||||
return buf + std::max(0, snprintf(buf, length, "%s",
|
||||
d->get_download().get_name().c_str()));
|
||||
d->get_download().name().c_str()));
|
||||
}
|
||||
|
||||
char*
|
||||
@@ -75,16 +75,16 @@ print_download_info(char* buf, unsigned int length, core::Download* d) {
|
||||
buf += std::max(0, snprintf(buf, last - buf, "closed "));
|
||||
else if (d->is_done())
|
||||
buf += std::max(0, snprintf(buf, last - buf, "done %10.1f MB",
|
||||
(double)d->get_download().get_bytes_total() / (double)(1 << 20)));
|
||||
(double)d->get_download().bytes_total() / (double)(1 << 20)));
|
||||
else
|
||||
buf += std::max(0, snprintf(buf, last - buf, "%6.1f / %6.1f MB",
|
||||
(double)d->get_download().get_bytes_done() / (double)(1 << 20),
|
||||
(double)d->get_download().get_bytes_total() / (double)(1 << 20)));
|
||||
(double)d->get_download().bytes_done() / (double)(1 << 20),
|
||||
(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().get_up_rate().rate() / (1 << 10),
|
||||
(double)d->get_download().get_down_rate().rate() / (1 << 10),
|
||||
(double)d->get_download().get_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;
|
||||
}
|
||||
@@ -98,11 +98,11 @@ print_download_status(char* buf, unsigned int length, core::Download* d) {
|
||||
buf += std::max(0, snprintf(buf, length, "Checking hash"));
|
||||
|
||||
else if (d->get_download().is_tracker_busy() &&
|
||||
d->get_download().get_tracker_focus() < d->get_download().get_tracker_size())
|
||||
d->get_download().tracker_focus() < d->get_download().size_trackers())
|
||||
buf += std::max(0, snprintf(buf, length, "Tracker[%i:%i]: Connecting to %s",
|
||||
d->get_download().get_tracker(d->get_download().get_tracker_focus()).get_group(),
|
||||
d->get_download().get_tracker_focus(),
|
||||
d->get_download().get_tracker(d->get_download().get_tracker_focus()).get_url().c_str()));
|
||||
d->get_download().tracker(d->get_download().tracker_focus()).group(),
|
||||
d->get_download().tracker_focus(),
|
||||
d->get_download().tracker(d->get_download().tracker_focus()).url().c_str()));
|
||||
|
||||
else if (!d->get_message().empty())
|
||||
buf += std::max(0, snprintf(buf, length, "%s", d->get_message().c_str()));
|
||||
|
||||
@@ -80,18 +80,18 @@ WindowDownloadStatusbar::redraw() {
|
||||
// (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().get_peers_connected(),
|
||||
(int)m_download->get_download().get_peers_not_connected(),
|
||||
(int)m_download->get_download().get_peers_min(),
|
||||
(int)m_download->get_download().get_peers_max(),
|
||||
(int)m_download->get_download().get_uploads_max(),
|
||||
(int)m_download->get_download().peers_connected(),
|
||||
(int)m_download->get_download().peers_not_connected(),
|
||||
(int)m_download->get_download().peers_min(),
|
||||
(int)m_download->get_download().peers_max(),
|
||||
(int)m_download->get_download().uploads_max(),
|
||||
(int)m_download->get_download().peers_currently_unchoked(),
|
||||
(int)m_download->get_download().peers_currently_interested());
|
||||
|
||||
position = print_download_status(buffer, last - buffer, m_download);
|
||||
m_canvas->print(0, 2, "[%c:%i] %s",
|
||||
m_download->get_download().is_tracker_busy() ? 'C' : ' ',
|
||||
(int)(m_download->get_download().get_tracker_timeout() / 1000000),
|
||||
(int)(m_download->get_download().tracker_timeout() / 1000000),
|
||||
buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ WindowFileList::redraw() {
|
||||
utils::displayScheduler.insert(&m_taskUpdate, (utils::Timer::cache() + 10 * 1000000).round_seconds());
|
||||
m_canvas->erase();
|
||||
|
||||
if (m_download->get_download().get_entry_size() == 0 ||
|
||||
if (m_download->get_download().size_file_entries() == 0 ||
|
||||
m_canvas->get_height() < 2)
|
||||
return;
|
||||
|
||||
@@ -72,18 +72,18 @@ WindowFileList::redraw() {
|
||||
|
||||
++pos;
|
||||
|
||||
if (*m_focus >= m_download->get_download().get_entry_size())
|
||||
if (*m_focus >= m_download->get_download().size_file_entries())
|
||||
throw std::logic_error("WindowFileList::redraw() called on an object with a bad focus value");
|
||||
|
||||
Range range = rak::advance_bidirectional<unsigned int>(0,
|
||||
*m_focus,
|
||||
m_download->get_download().get_entry_size(),
|
||||
m_download->get_download().size_file_entries(),
|
||||
m_canvas->get_height() - pos);
|
||||
|
||||
while (range.first != range.second) {
|
||||
torrent::Entry e = m_download->get_download().get_entry(range.first);
|
||||
torrent::Entry e = m_download->get_download().file_entry(range.first);
|
||||
|
||||
std::string path = e.get_path();
|
||||
std::string path = e.path_str();
|
||||
|
||||
if (path.length() <= 50)
|
||||
path = path + std::string(50 - path.length(), ' ');
|
||||
@@ -92,8 +92,8 @@ WindowFileList::redraw() {
|
||||
|
||||
std::string priority;
|
||||
|
||||
switch (e.get_priority()) {
|
||||
case torrent::Entry::STOPPED:
|
||||
switch (e.priority()) {
|
||||
case torrent::Entry::OFF:
|
||||
priority = "off";
|
||||
break;
|
||||
|
||||
@@ -113,14 +113,14 @@ WindowFileList::redraw() {
|
||||
m_canvas->print(0, pos, "%c %s %6.1f %s %3d %9s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
path.c_str(),
|
||||
(double)e.get_size() / (double)(1 << 20),
|
||||
(double)e.size_bytes() / (double)(1 << 20),
|
||||
priority.c_str(),
|
||||
done_percentage(e),
|
||||
e.path_list()->encoding().c_str());
|
||||
e.path()->encoding().c_str());
|
||||
|
||||
m_canvas->print(84, pos, "%i - %i",
|
||||
e.get_chunk_begin(),
|
||||
e.get_chunk_end());
|
||||
e.chunk_begin(),
|
||||
e.chunk_end());
|
||||
|
||||
++range.first;
|
||||
++pos;
|
||||
@@ -130,9 +130,9 @@ WindowFileList::redraw() {
|
||||
|
||||
int
|
||||
WindowFileList::done_percentage(torrent::Entry& e) {
|
||||
int chunks = e.get_chunk_end() - e.get_chunk_begin();
|
||||
int chunks = e.chunk_end() - e.chunk_begin();
|
||||
|
||||
return chunks ? (e.get_completed() * 100) / chunks : 100;
|
||||
return chunks ? (e.completed_chunks() * 100) / chunks : 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ WindowHttpQueue::redraw() {
|
||||
if (itr->m_http == NULL)
|
||||
m_canvas->print(pos, 0, "%s done", itr->m_name.c_str());
|
||||
|
||||
else if (itr->m_http->get_size_total() == 0)
|
||||
else if (itr->m_http->size_total() == 0)
|
||||
m_canvas->print(pos, 0, "%s ---%%", itr->m_name.c_str());
|
||||
|
||||
else
|
||||
m_canvas->print(pos, 0, "%s %3i%%",
|
||||
itr->m_name.c_str(),
|
||||
(int)(100.0 * itr->m_http->get_size_done() / itr->m_http->get_size_total()));
|
||||
(int)(100.0 * itr->m_http->size_done() / itr->m_http->size_total()));
|
||||
|
||||
pos += itr->m_name.size() + 6;
|
||||
++itr;
|
||||
@@ -105,9 +105,9 @@ WindowHttpQueue::cleanup_list() {
|
||||
|
||||
std::string
|
||||
WindowHttpQueue::create_name(core::CurlGet* h) {
|
||||
size_t p = h->get_url().rfind('/', h->get_url().size() - std::min<int>(10, h->get_url().size()));
|
||||
size_t p = h->url().rfind('/', h->url().size() - std::min<int>(10, h->url().size()));
|
||||
|
||||
std::string n = p != std::string::npos ? h->get_url().substr(p) : h->get_url();
|
||||
std::string n = p != std::string::npos ? h->url().substr(p) : h->url();
|
||||
|
||||
if (n.empty())
|
||||
throw std::logic_error("WindowHttpQueue::create_name(...) made a bad string");
|
||||
|
||||
@@ -63,17 +63,17 @@ WindowPeerInfo::redraw() {
|
||||
int y = 0;
|
||||
torrent::Download d = m_download->get_download();
|
||||
|
||||
m_canvas->print(0, y++, "Hash: %s", utils::string_to_hex(d.get_hash()).c_str());
|
||||
m_canvas->print(0, y++, "Id: %s", utils::escape_string(d.get_id()).c_str());
|
||||
m_canvas->print(0, y++, "Hash: %s", utils::string_to_hex(d.info_hash()).c_str());
|
||||
m_canvas->print(0, y++, "Id: %s", utils::escape_string(d.local_id()).c_str());
|
||||
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
|
||||
d.get_chunks_done(),
|
||||
d.get_chunks_total(),
|
||||
d.get_chunks_size());
|
||||
d.chunks_done(),
|
||||
d.chunks_total(),
|
||||
d.chunks_size());
|
||||
|
||||
char buffer[32], *position;
|
||||
position = print_ddmmyyyy(buffer, 32, static_cast<time_t>(d.get_creation_date()));
|
||||
position = print_ddmmyyyy(buffer, 32, static_cast<time_t>(d.creation_date()));
|
||||
position = print_string(position, buffer + 32 - position, " ");
|
||||
position = print_hhmmss(position, buffer + 32 - position, static_cast<time_t>(d.get_creation_date()));
|
||||
position = print_hhmmss(position, buffer + 32 - position, static_cast<time_t>(d.creation_date()));
|
||||
|
||||
m_canvas->print(0, y++, "Created: %s", buffer);
|
||||
|
||||
@@ -94,26 +94,26 @@ WindowPeerInfo::redraw() {
|
||||
|
||||
m_canvas->print(0, y++, "*** Peer Info ***");
|
||||
|
||||
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->get_dns().c_str(), (*m_focus)->get_port());
|
||||
m_canvas->print(0, y++, "Id: %s" , utils::escape_string((*m_focus)->get_id()).c_str());
|
||||
m_canvas->print(0, y++, "Options: %s" , utils::string_to_hex(std::string((*m_focus)->get_options(), 8)).c_str());
|
||||
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->get_snubbed() ? "yes" : "no");
|
||||
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->address().c_str(), (*m_focus)->port());
|
||||
m_canvas->print(0, y++, "Id: %s" , utils::escape_string((*m_focus)->id()).c_str());
|
||||
m_canvas->print(0, y++, "Options: %s" , utils::string_to_hex(std::string((*m_focus)->options(), 8)).c_str());
|
||||
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->is_snubbed() ? "yes" : "no");
|
||||
m_canvas->print(0, y++, "Connected: %s", (*m_focus)->is_incoming() ? "remote" : "local");
|
||||
|
||||
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)->get_up_rate().rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->get_down_rate().rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->get_up_rate().total() / (double)(1 << 20),
|
||||
(double)(*m_focus)->get_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
|
||||
WindowPeerInfo::done_percentage(torrent::Peer& p) {
|
||||
int chunks = m_download->get_download().get_chunks_total();
|
||||
int chunks = m_download->get_download().chunks_total();
|
||||
|
||||
return chunks ? (100 * p.get_chunks_done()) / chunks : 0;
|
||||
return chunks ? (100 * p.chunks_done()) / chunks : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ WindowPeerList::redraw() {
|
||||
m_list->end(),
|
||||
m_canvas->get_height() - y);
|
||||
|
||||
if (m_download->get_download().get_chunks_total() <= 0)
|
||||
if (m_download->get_download().chunks_total() <= 0)
|
||||
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
||||
|
||||
while (range.first != range.second) {
|
||||
@@ -94,35 +94,35 @@ WindowPeerList::redraw() {
|
||||
|
||||
m_canvas->print(x, y, "%c %s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
p.get_dns().c_str());
|
||||
p.address().c_str());
|
||||
x += 18;
|
||||
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_up_rate().rate() / 1024); x += 7;
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_down_rate().rate() / 1024); x += 7;
|
||||
m_canvas->print(x, y, "%.1f", (double)p.get_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',
|
||||
p.get_remote_choked() ? 'c' : 'u',
|
||||
p.get_remote_interested() ? 'i' : 'n',
|
||||
p.get_local_choked() ? 'c' : 'u',
|
||||
p.get_local_interested() ? 'i' : 'n');
|
||||
p.is_remote_choked() ? 'c' : 'u',
|
||||
p.is_remote_interested() ? 'i' : 'n',
|
||||
p.is_local_choked() ? 'c' : 'u',
|
||||
p.is_local_interested() ? 'i' : 'n');
|
||||
x += 9;
|
||||
|
||||
m_canvas->print(x, y, "%i/%i",
|
||||
p.get_outgoing_queue_size(),
|
||||
p.get_incoming_queue_size());
|
||||
p.outgoing_queue_size(),
|
||||
p.incoming_queue_size());
|
||||
x += 6;
|
||||
|
||||
m_canvas->print(x, y, "%3i", done_percentage(*range.first));
|
||||
x += 6;
|
||||
|
||||
if (p.get_incoming_queue_size())
|
||||
m_canvas->print(x, y, "%i", p.get_incoming_index(0));
|
||||
if (p.incoming_queue_size())
|
||||
m_canvas->print(x, y, "%i", p.incoming_index(0));
|
||||
|
||||
x += 6;
|
||||
|
||||
if (p.get_snubbed())
|
||||
if (p.is_snubbed())
|
||||
m_canvas->print(x, y, "*");
|
||||
|
||||
++y;
|
||||
@@ -132,9 +132,9 @@ WindowPeerList::redraw() {
|
||||
|
||||
int
|
||||
WindowPeerList::done_percentage(torrent::Peer& p) {
|
||||
int chunks = m_download->get_download().get_chunks_total();
|
||||
int chunks = m_download->get_download().chunks_total();
|
||||
|
||||
return chunks ? (100 * p.get_chunks_done()) / chunks : 0;
|
||||
return chunks ? (100 * p.chunks_done()) / chunks : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,34 +64,34 @@ WindowStatusbar::redraw() {
|
||||
int pos = 0;
|
||||
char buf[128];
|
||||
|
||||
if (torrent::get_up_throttle() == 0)
|
||||
if (torrent::up_throttle() == 0)
|
||||
pos = snprintf(buf, 128, "off/");
|
||||
else
|
||||
pos = snprintf(buf, 128, "%3i/", torrent::get_up_throttle() / 1024);
|
||||
pos = snprintf(buf, 128, "%3i/", torrent::up_throttle() / 1024);
|
||||
|
||||
if (torrent::get_down_throttle() == 0)
|
||||
if (torrent::down_throttle() == 0)
|
||||
pos = snprintf(buf + pos, 128 - pos, "off");
|
||||
else
|
||||
pos = snprintf(buf + pos, 128 - pos, "%-3i", torrent::get_down_throttle() / 1024);
|
||||
pos = snprintf(buf + pos, 128 - pos, "%-3i", torrent::down_throttle() / 1024);
|
||||
|
||||
m_canvas->print(0, 0, "Throttle U/D: %s Rate: %5.1f / %5.1f KB Listen: %s:%i%s",
|
||||
buf,
|
||||
(double)torrent::get_up_rate().rate() / 1024.0,
|
||||
(double)torrent::get_down_rate().rate() / 1024.0,
|
||||
!torrent::get_local_address().empty() ? torrent::get_local_address().c_str() : "<default>",
|
||||
(int)torrent::get_listen_port(),
|
||||
!torrent::get_bind_address().empty() ? (" Bind: " + torrent::get_bind_address()).c_str() : "");
|
||||
(double)torrent::up_rate().rate() / 1024.0,
|
||||
(double)torrent::down_rate().rate() / 1024.0,
|
||||
!torrent::local_address().empty() ? torrent::local_address().c_str() : "<default>",
|
||||
(int)torrent::listen_port(),
|
||||
!torrent::bind_address().empty() ? (" Bind: " + torrent::bind_address()).c_str() : "");
|
||||
|
||||
// pos = snprintf(buf, 128, "[U %i/%i][S %i/%i/%i][F %i/%i]",
|
||||
pos = snprintf(buf, 128, "%i [U %i/%i][S %i/%i/%i][F %i/%i]",
|
||||
countTicks,
|
||||
torrent::currently_unchoked(),
|
||||
torrent::max_unchoked(),
|
||||
torrent::get_total_handshakes(),
|
||||
torrent::get_open_sockets(),
|
||||
torrent::get_max_open_sockets(),
|
||||
torrent::get_open_files(),
|
||||
torrent::get_max_open_files());
|
||||
torrent::total_handshakes(),
|
||||
torrent::open_sockets(),
|
||||
torrent::max_open_sockets(),
|
||||
torrent::open_files(),
|
||||
torrent::max_open_files());
|
||||
|
||||
countTicks = 0;
|
||||
|
||||
|
||||
@@ -64,31 +64,31 @@ WindowTrackerList::redraw() {
|
||||
|
||||
++pos;
|
||||
|
||||
if (m_download->get_download().get_tracker_size() == 0)
|
||||
if (m_download->get_download().size_trackers() == 0)
|
||||
return;
|
||||
|
||||
if (*m_focus >= m_download->get_download().get_tracker_size())
|
||||
if (*m_focus >= m_download->get_download().size_trackers())
|
||||
throw std::logic_error("WindowTrackerList::redraw() called on an object with a bad focus value");
|
||||
|
||||
typedef std::pair<unsigned int, unsigned int> Range;
|
||||
|
||||
Range range = rak::advance_bidirectional<unsigned int>(0,
|
||||
*m_focus,
|
||||
m_download->get_download().get_tracker_size(),
|
||||
m_download->get_download().size_trackers(),
|
||||
(m_canvas->get_height() + 1) / 2);
|
||||
|
||||
while (range.first != range.second) {
|
||||
torrent::Tracker t = m_download->get_download().get_tracker(range.first);
|
||||
torrent::Tracker t = m_download->get_download().tracker(range.first);
|
||||
|
||||
m_canvas->print(0, pos++, "%c %s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
t.get_url().c_str());
|
||||
t.url().c_str());
|
||||
|
||||
m_canvas->print(0, pos++, "%c Group: %2i Id: %s Focus: %s Enabled: %s Open: %s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
t.get_group(),
|
||||
utils::escape_string(t.get_tracker_id()).c_str(),
|
||||
range.first == m_download->get_download().get_tracker_focus() ? "yes" : " no",
|
||||
t.group(),
|
||||
utils::escape_string(t.tracker_id()).c_str(),
|
||||
range.first == m_download->get_download().tracker_focus() ? "yes" : " no",
|
||||
t.is_enabled() ? "yes" : " no",
|
||||
t.is_open() ? "yes" : " no");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user