* 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:
rakshasa
2005-11-12 15:31:12 +00:00
parent 3db8179274
commit a97408328a
22 changed files with 142 additions and 138 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ Control::initialize() {
m_core->get_poll_manager()->signal_interrupted().connect(sigc::mem_fun(*m_inputStdin, &input::InputEvent::event_read));
m_core->get_poll_manager()->signal_interrupted().connect(sigc::ptr_fun(display::Canvas::do_update));
m_core->get_poll_manager()->get_http_stack()->set_user_agent(std::string(PACKAGE "/" VERSION "/") + torrent::get_version());
m_core->get_poll_manager()->get_http_stack()->set_user_agent(std::string(PACKAGE "/" VERSION "/") + torrent::version());
m_core->initialize_second();
+5 -4
View File
@@ -48,7 +48,7 @@ namespace core {
size_t
curl_get_receive_write(void* data, size_t size, size_t nmemb, void* handle) {
if (!((CurlGet*)handle)->get_stream()->write((char*)data, size * nmemb).fail())
if (!((CurlGet*)handle)->stream()->write((char*)data, size * nmemb).fail())
return size * nmemb;
else
return 0;
@@ -84,7 +84,8 @@ CurlGet::start() {
curl_easy_setopt(m_handle, CURLOPT_URL, m_url.c_str());
curl_easy_setopt(m_handle, CURLOPT_WRITEFUNCTION, &curl_get_receive_write);
curl_easy_setopt(m_handle, CURLOPT_WRITEDATA, this);
curl_easy_setopt(m_handle, CURLOPT_TIMEOUT, 60);
curl_easy_setopt(m_handle, CURLOPT_CONNECTTIMEOUT, 60);
curl_easy_setopt(m_handle, CURLOPT_TIMEOUT, 360);
curl_easy_setopt(m_handle, CURLOPT_FORBID_REUSE, 1);
curl_easy_setopt(m_handle, CURLOPT_NOSIGNAL, 1);
@@ -108,7 +109,7 @@ CurlGet::close() {
double
CurlGet::get_size_done() {
CurlGet::size_done() {
double d = 0.0;
curl_easy_getinfo(m_handle, CURLINFO_SIZE_DOWNLOAD, &d);
@@ -116,7 +117,7 @@ CurlGet::get_size_done() {
}
double
CurlGet::get_size_total() {
CurlGet::size_total() {
double d = 0.0;
curl_easy_getinfo(m_handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
+2 -2
View File
@@ -63,8 +63,8 @@ class CurlGet : public torrent::Http {
bool is_busy() { return m_handle; }
double get_size_done();
double get_size_total();
double size_done();
double size_total();
void set_user_agent(const char* s);
+7 -4
View File
@@ -76,14 +76,17 @@ void
Download::set_root_directory(const std::string& d) {
m_download.set_root_dir(d +
(!d.empty() && *d.rbegin() != '/' ? "/" : "") +
(m_download.get_entry_size() > 1 ? m_download.get_name() : ""));
(m_download.size_file_entries() > 1 ? m_download.name() : ""));
}
void
Download::enable_udp_trackers(bool state) {
for (int i = 0, last = m_download.get_tracker_size(); i < last; ++i)
if (m_download.get_tracker(i).get_type() == torrent::Tracker::TRACKER_UDP)
m_download.get_tracker(i).enable(state);
for (int i = 0, last = m_download.size_trackers(); i < last; ++i)
if (m_download.tracker(i).tracker_type() == torrent::Tracker::TRACKER_UDP)
if (state)
m_download.tracker(i).enable();
else
m_download.tracker(i).disable();
}
void
+5 -5
View File
@@ -60,14 +60,14 @@ public:
torrent::Download& get_download() { return m_download; }
const torrent::Download& get_download() const { return m_download; }
std::string get_hash() { return m_download.get_hash(); }
torrent::Bencode& get_bencode() { return m_download.get_bencode(); }
std::string get_hash() { return m_download.info_hash(); }
torrent::Bencode& get_bencode() { return m_download.bencode(); }
const std::string& get_message() { return m_message; }
void set_root_directory(const std::string& d);
ConnType get_connection_current() const { return m_download.get_connection_type(); }
ConnType get_connection_current() const { return m_download.connection_type(); }
ConnType get_connection_leech() const { return m_connectionLeech; }
ConnType get_connection_seed() const { return m_connectionSeed; }
@@ -84,7 +84,7 @@ public:
template <typename Ret, typename Arg1, Ret (torrent::Download::*func)(Arg1)>
void call(Arg1 a1) { (m_download.*func)(a1); }
bool operator == (const std::string& str) { return str == m_download.get_hash(); }
bool operator == (const std::string& str) { return str == m_download.info_hash(); }
void receive_finished();
@@ -109,7 +109,7 @@ private:
inline bool
Download::is_done() {
return m_download.get_chunks_done() == m_download.get_chunks_total();
return m_download.chunks_done() == m_download.chunks_total();
}
}
+2 -2
View File
@@ -50,7 +50,7 @@ PollManager::PollManager(torrent::Poll* poll) :
throw std::logic_error("PollManager::PollManager(...) received poll == NULL");
#if defined USE_VARIABLE_FDSET
m_setSize = m_poll->get_open_max() / 8;
m_setSize = m_poll->open_max() / 8;
m_readSet = (fd_set*)new char[m_setSize];
m_writeSet = (fd_set*)new char[m_setSize];
m_errorSet = (fd_set*)new char[m_setSize];
@@ -59,7 +59,7 @@ PollManager::PollManager(torrent::Poll* poll) :
std::memset(m_writeSet, 0, m_setSize);
std::memset(m_errorSet, 0, m_setSize);
#else
if (m_poll->get_open_max() > FD_SETSIZE)
if (m_poll->open_max() > FD_SETSIZE)
throw std::logic_error("PollManager::PollManager(...) received a max open sockets >= FD_SETSIZE, but USE_VARIABLE_FDSET was not defined");
m_setSize = FD_SETSIZE / 8;
+1 -1
View File
@@ -56,7 +56,7 @@ public:
PollManager(torrent::Poll* poll);
virtual ~PollManager();
unsigned int get_open_max() const { return m_poll->get_open_max(); }
unsigned int get_open_max() const { return m_poll->open_max(); }
CurlStack* get_http_stack() { return &m_httpStack; }
torrent::Poll* get_torrent_poll() { return m_poll; }
+4 -4
View File
@@ -65,7 +65,7 @@ PollManagerEPoll::poll(utils::Timer timeout) {
// Add 1ms to ensure we don't idle loop due to the lack of
// resolution.
torrent::perform();
timeout = std::min(timeout, utils::Timer(torrent::get_next_timeout()));
timeout = std::min(timeout, utils::Timer(torrent::next_timeout()));
if (m_httpStack.is_busy()) {
// When we're using libcurl we need to use select, but as this is
@@ -79,9 +79,9 @@ PollManagerEPoll::poll(utils::Timer timeout) {
FD_ZERO(m_writeSet);
FD_ZERO(m_errorSet);
#endif
FD_SET(static_cast<torrent::PollEPoll*>(m_poll)->get_fd(), m_readSet);
FD_SET(static_cast<torrent::PollEPoll*>(m_poll)->file_descriptor(), m_readSet);
unsigned int maxFd = std::max((unsigned int)static_cast<torrent::PollEPoll*>(m_poll)->get_fd(),
unsigned int maxFd = std::max((unsigned int)static_cast<torrent::PollEPoll*>(m_poll)->file_descriptor(),
m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
timeval t = timeout.tval();
@@ -91,7 +91,7 @@ PollManagerEPoll::poll(utils::Timer timeout) {
m_httpStack.perform();
if (!FD_ISSET(static_cast<torrent::PollEPoll*>(m_poll)->get_fd(), m_readSet)) {
if (!FD_ISSET(static_cast<torrent::PollEPoll*>(m_poll)->file_descriptor(), m_readSet)) {
// Need to call perform here so that scheduled task get done
// even if there's no socket events outside of the http stuff.
torrent::perform();
+1 -1
View File
@@ -63,7 +63,7 @@ PollManagerSelect::~PollManagerSelect() {
void
PollManagerSelect::poll(utils::Timer timeout) {
torrent::perform();
timeout = std::min(timeout, utils::Timer(torrent::get_next_timeout()));
timeout = std::min(timeout, utils::Timer(torrent::next_timeout()));
#if defined USE_VARIABLE_FDSET
std::memset(m_readSet, 0, m_setSize);
+11 -11
View File
@@ -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()));
+6 -6
View File
@@ -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);
}
+13 -13
View File
@@ -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;
}
}
+4 -4
View File
@@ -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");
+17 -17
View File
@@ -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;
}
}
+16 -16
View File
@@ -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;
}
}
+14 -14
View File
@@ -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;
+8 -8
View File
@@ -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");
+5 -5
View File
@@ -60,7 +60,7 @@ Download::Download(DPtr d, Control* c) :
m_download(d),
m_state(DISPLAY_MAX_SIZE),
m_windowTitle(new WTitle(d->get_download().get_name())),
m_windowTitle(new WTitle(d->get_download().name())),
m_windowDownloadStatus(new WDownloadStatus(d)),
m_window(c->display()->end()),
@@ -193,21 +193,21 @@ void
Download::receive_max_uploads(int t) {
m_windowDownloadStatus->mark_dirty();
m_download->get_download().set_uploads_max(std::max(m_download->get_download().get_uploads_max() + t, (uint32_t)2));
m_download->get_download().set_uploads_max(std::max(m_download->get_download().uploads_max() + t, (uint32_t)2));
}
void
Download::receive_min_peers(int t) {
m_windowDownloadStatus->mark_dirty();
m_download->get_download().set_peers_min(std::max(m_download->get_download().get_peers_min() + t, (uint32_t)5));
m_download->get_download().set_peers_min(std::max(m_download->get_download().peers_min() + t, (uint32_t)5));
}
void
Download::receive_max_peers(int t) {
m_windowDownloadStatus->mark_dirty();
m_download->get_download().set_peers_max(std::max(m_download->get_download().get_peers_max() + t, (uint32_t)5));
m_download->get_download().set_peers_max(std::max(m_download->get_download().peers_max() + t, (uint32_t)5));
}
void
@@ -224,7 +224,7 @@ Download::receive_snub_peer() {
if (m_focus == m_peers.end())
return;
m_focus->set_snubbed(!m_focus->get_snubbed());
m_focus->set_snubbed(!m_focus->is_snubbed());
mark_dirty();
}
+1 -1
View File
@@ -71,7 +71,7 @@ DownloadList::DownloadList(Control* c) :
m_window(c->display()->end()),
m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + std::string(torrent::get_version()))),
m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + std::string(torrent::version()))),
m_windowHttpQueue(new WHttp(&c->core()->get_http_queue())),
m_uiDownload(NULL),
+12 -12
View File
@@ -83,7 +83,7 @@ ElementFileList::receive_next() {
if (m_window == NULL)
throw std::logic_error("ui::ElementFileList::receive_next(...) called on a disabled object");
if (++m_focus >= m_download->get_download().get_entry_size())
if (++m_focus >= m_download->get_download().size_file_entries())
m_focus = 0;
m_window->mark_dirty();
@@ -94,13 +94,13 @@ ElementFileList::receive_prev() {
if (m_window == NULL)
throw std::logic_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
if (m_download->get_download().get_entry_size() == 0)
if (m_download->get_download().size_file_entries() == 0)
return;
if (m_focus != 0)
--m_focus;
else
m_focus = m_download->get_download().get_entry_size() - 1;
m_focus = m_download->get_download().size_file_entries() - 1;
m_window->mark_dirty();
}
@@ -110,12 +110,12 @@ ElementFileList::receive_priority() {
if (m_window == NULL)
throw std::logic_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
if (m_focus >= m_download->get_download().get_entry_size())
if (m_focus >= m_download->get_download().size_file_entries())
return;
torrent::Entry e = m_download->get_download().get_entry(m_focus);
torrent::Entry e = m_download->get_download().file_entry(m_focus);
e.set_priority(next_priority(e.get_priority()));
e.set_priority(next_priority(e.priority()));
m_download->get_download().update_priorities();
m_window->mark_dirty();
@@ -126,13 +126,13 @@ ElementFileList::receive_change_all() {
if (m_window == NULL)
throw std::logic_error("ui::ElementFileList::receive_prev(...) called on a disabled object");
if (m_focus >= m_download->get_download().get_entry_size())
if (m_focus >= m_download->get_download().size_file_entries())
return;
Priority p = next_priority(m_download->get_download().get_entry(m_focus).get_priority());
Priority p = next_priority(m_download->get_download().file_entry(m_focus).priority());
for (int i = 0, e = m_download->get_download().get_entry_size(); i != e; ++i)
m_download->get_download().get_entry(i).set_priority(p);
for (int i = 0, e = m_download->get_download().size_file_entries(); i != e; ++i)
m_download->get_download().file_entry(i).set_priority(p);
m_download->get_download().update_priorities();
m_window->mark_dirty();
@@ -141,11 +141,11 @@ ElementFileList::receive_change_all() {
ElementFileList::Priority
ElementFileList::next_priority(Priority p) {
switch(p) {
case torrent::Entry::STOPPED:
case torrent::Entry::OFF:
return torrent::Entry::HIGH;
case torrent::Entry::NORMAL:
return torrent::Entry::STOPPED;
return torrent::Entry::OFF;
case torrent::Entry::HIGH:
return torrent::Entry::NORMAL;
+5 -5
View File
@@ -82,7 +82,7 @@ ElementTrackerList::receive_next() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_next(...) called on a disabled object");
if (++m_focus >= m_download->get_download().get_tracker_size())
if (++m_focus >= m_download->get_download().size_trackers())
m_focus = 0;
m_window->mark_dirty();
@@ -93,13 +93,13 @@ ElementTrackerList::receive_prev() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_prev(...) called on a disabled object");
if (m_download->get_download().get_tracker_size() == 0)
if (m_download->get_download().size_trackers() == 0)
return;
if (m_focus != 0)
--m_focus;
else
m_focus = m_download->get_download().get_tracker_size() - 1;
m_focus = m_download->get_download().size_trackers() - 1;
m_window->mark_dirty();
}
@@ -109,10 +109,10 @@ ElementTrackerList::receive_cycle_group() {
if (m_window == NULL)
throw std::logic_error("ui::ElementTrackerList::receive_group_cycle(...) called on a disabled object");
if (m_focus >= m_download->get_download().get_tracker_size())
if (m_focus >= m_download->get_download().size_trackers())
throw std::logic_error("ui::ElementTrackerList::receive_group_cycle(...) called with an invalid focus");
m_download->get_download().tracker_cycle_group(m_download->get_download().get_tracker(m_focus).get_group());
m_download->get_download().tracker_cycle_group(m_download->get_download().tracker(m_focus).group());
m_window->mark_dirty();
}
+2 -2
View File
@@ -117,7 +117,7 @@ Root::receive_down_throttle(int t) {
if (m_windowStatusbar != NULL)
m_windowStatusbar->mark_dirty();
torrent::set_down_throttle(std::max<int>(torrent::get_down_throttle() + t * 1024, 0));
torrent::set_down_throttle(std::max<int>(torrent::down_throttle() + t * 1024, 0));
}
void
@@ -125,7 +125,7 @@ Root::receive_up_throttle(int t) {
if (m_windowStatusbar != NULL)
m_windowStatusbar->mark_dirty();
uint32_t throttle = std::max<int>(torrent::get_up_throttle() + t * 1024, 0);
uint32_t throttle = std::max<int>(torrent::up_throttle() + t * 1024, 0);
torrent::set_up_throttle(throttle);