mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-09 11:42:33 +00:00
Moved TrackerList and TrackerController out of the public API.
This commit is contained in:
+11
-8
@@ -10,7 +10,6 @@
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/throttle.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
#include <torrent/tracker/tracker.h>
|
||||
#include <torrent/data/file_list.h>
|
||||
#include <torrent/data/file_manager.h>
|
||||
@@ -160,14 +159,18 @@ print_download_status(char* first, char* last, core::Download* d) {
|
||||
first = print_buffer(first, last, "Checking hash [%2i%%]",
|
||||
(d->download()->chunks_hashed() * 100) / d->download()->file_list()->size_chunks());
|
||||
|
||||
} else if (d->tracker_list()->has_active_not_scrape()) {
|
||||
torrent::TrackerList::iterator itr =
|
||||
std::find_if(d->tracker_list()->begin(), d->tracker_list()->end(),
|
||||
std::mem_fn(&torrent::tracker::Tracker::is_busy_not_scrape));
|
||||
auto status = itr->status();
|
||||
} else if (d->tracker_controller().has_active_trackers_not_scrape()) {
|
||||
auto tracker = d->tracker_controller().find_if([](const auto& t) {
|
||||
return t.is_busy_not_scrape();
|
||||
});
|
||||
|
||||
first = print_buffer(first, last, "Tracker[%i:%i]: Connecting to %s %s",
|
||||
itr->group(), std::distance(d->tracker_list()->begin(), itr), itr->url().c_str(), status.c_str());
|
||||
if (tracker.is_valid()) {
|
||||
auto status = tracker.status();
|
||||
|
||||
first = print_buffer(first, last, "Tracker[%i]: Connecting to %s %s", tracker.group(), tracker.url().c_str(), status.c_str());
|
||||
} else {
|
||||
first = print_buffer(first, last, "Tracker: Connecting ...");
|
||||
}
|
||||
|
||||
} else if (!d->message().empty()) {
|
||||
first = print_buffer(first, last, "%s", d->message().c_str());
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "window_download_statusbar.h"
|
||||
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/data/transfer_list.h>
|
||||
#include <torrent/tracker_controller.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
#include <torrent/peer/connection_list.h>
|
||||
#include <torrent/peer/peer_list.h>
|
||||
|
||||
#include "canvas.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "window_download_statusbar.h"
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
namespace display {
|
||||
@@ -57,7 +55,7 @@ WindowDownloadStatusbar::redraw() {
|
||||
|
||||
print_download_status(buffer.data(), last, m_download);
|
||||
m_canvas->print(0, 2, "[%c:%i] %s",
|
||||
m_download->tracker_list()->has_active() ? 'C' : ' ',
|
||||
m_download->tracker_controller().has_active_trackers() ? 'C' : ' ',
|
||||
(int)(m_download->download()->tracker_controller().seconds_to_next_timeout()),
|
||||
buffer.data());
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "window_tracker_list.h"
|
||||
|
||||
#include <rak/algorithm.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
#include <torrent/tracker_controller.h>
|
||||
#include <torrent/tracker/tracker.h>
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
#include "window_tracker_list.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
|
||||
@@ -25,27 +23,25 @@ WindowTrackerList::redraw() {
|
||||
schedule_update(10);
|
||||
m_canvas->erase();
|
||||
|
||||
unsigned int pos = 0;
|
||||
auto tl = m_download->tracker_list();
|
||||
auto pos = 0u;
|
||||
auto tc = m_download->tracker_controller();
|
||||
auto tc_size = tc.size();
|
||||
|
||||
m_canvas->print(2, pos, "Trackers: [Key: %08x] [%s %s %s]",
|
||||
tl->key(),
|
||||
tc.key(),
|
||||
tc.is_requesting() ? "req" : " ",
|
||||
tc.is_promiscuous_mode() ? "prom" : " ",
|
||||
tc.is_failure_mode() ? "fail" : " ");
|
||||
++pos;
|
||||
|
||||
if (tl->size() == 0 || *m_focus >= tl->size())
|
||||
if (tc_size == 0 || *m_focus >= tc_size)
|
||||
return;
|
||||
|
||||
typedef std::pair<unsigned int, unsigned int> Range;
|
||||
|
||||
Range range = rak::advance_bidirectional<unsigned int>(0, *m_focus, tl->size(), (m_canvas->height() - 1) / 2);
|
||||
unsigned int group = tl->at(range.first).group();
|
||||
auto range = rak::advance_bidirectional<unsigned int>(0, *m_focus, tc_size, (m_canvas->height() - 1) / 2);
|
||||
auto group = tc.at(range.first).group();
|
||||
|
||||
while (range.first != range.second) {
|
||||
auto tracker = tl->at(range.first);
|
||||
auto tracker = tc.at(range.first);
|
||||
|
||||
if (tracker.group() == group)
|
||||
m_canvas->print(0, pos, "%2i:", group++);
|
||||
@@ -93,7 +89,7 @@ WindowTrackerList::redraw() {
|
||||
|
||||
// If we're at the end of the range, check if we can
|
||||
// show one more line for the following tracker.
|
||||
if (range.first == range.second && pos < m_canvas->height() && range.first < tl->size())
|
||||
if (range.first == range.second && pos < m_canvas->height() && range.first < tc_size)
|
||||
range.second++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user