mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-06 22:29:23 +00:00
* Bind udp and http tracker requests to the bind address.
* Allow the torrent's priority to be changed with '+'. * More work on the variables thing. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@625 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -36,6 +36,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "canvas.h"
|
||||
|
||||
namespace display {
|
||||
@@ -74,4 +77,14 @@ Canvas::cleanup() {
|
||||
endwin();
|
||||
}
|
||||
|
||||
std::pair<int, int>
|
||||
Canvas::term_size() {
|
||||
struct winsize ws;
|
||||
|
||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == 0)
|
||||
return std::pair<int, int>(ws.ws_col, ws.ws_row);
|
||||
else
|
||||
return std::pair<int, int>(80, 24);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,10 +51,14 @@ public:
|
||||
void refresh() { wnoutrefresh(m_window); }
|
||||
static void refresh_std() { wnoutrefresh(stdscr); }
|
||||
void redraw() { redrawwin(m_window); }
|
||||
static void redraw_std() { redrawwin(stdscr); }
|
||||
|
||||
void resize(int w, int h) { wresize(m_window, h, w); }
|
||||
void resize(int x, int y, int w, int h);
|
||||
|
||||
static void resize_term(int x, int y) { resizeterm(y, x); }
|
||||
static void resize_term(std::pair<int, int> dim) { resizeterm(dim.second, dim.first); }
|
||||
|
||||
int get_x() { int x, y; getyx(m_window, y, x); return x; }
|
||||
int get_y() { int x, y; getyx(m_window, y, x); return y; }
|
||||
int get_width() { int x, y; getmaxyx(m_window, y, x); return x; }
|
||||
@@ -116,6 +120,8 @@ public:
|
||||
static int get_screen_width() { int x, y; getmaxyx(stdscr, y, x); return x; }
|
||||
static int get_screen_height() { int x, y; getmaxyx(stdscr, y, x); return y; }
|
||||
|
||||
static std::pair<int, int> term_size();
|
||||
|
||||
static void do_update() { doupdate(); }
|
||||
|
||||
private:
|
||||
|
||||
+16
-1
@@ -47,7 +47,8 @@
|
||||
|
||||
namespace display {
|
||||
|
||||
Manager::Manager() {
|
||||
Manager::Manager() :
|
||||
m_forceRedraw(false) {
|
||||
m_taskUpdate.set_slot(rak::mem_fn(this, &Manager::receive_update));
|
||||
}
|
||||
|
||||
@@ -55,6 +56,12 @@ Manager::~Manager() {
|
||||
priority_queue_erase(&taskScheduler, &m_taskUpdate);
|
||||
}
|
||||
|
||||
void
|
||||
Manager::force_redraw() {
|
||||
m_forceRedraw = true;
|
||||
}
|
||||
|
||||
|
||||
Manager::iterator
|
||||
Manager::insert(iterator pos, Window* w) {
|
||||
return Base::insert(pos, w);
|
||||
@@ -131,6 +138,14 @@ Manager::adjust_layout() {
|
||||
|
||||
void
|
||||
Manager::receive_update() {
|
||||
if (m_forceRedraw) {
|
||||
m_forceRedraw = false;
|
||||
|
||||
display::Canvas::resize_term(display::Canvas::term_size());
|
||||
Canvas::redraw_std();
|
||||
adjust_layout();
|
||||
}
|
||||
|
||||
Canvas::refresh_std();
|
||||
|
||||
rak::priority_queue_perform(&m_scheduler, cachedTime);
|
||||
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
Manager();
|
||||
~Manager();
|
||||
|
||||
void force_redraw();
|
||||
|
||||
iterator insert(iterator pos, Window* w);
|
||||
iterator erase(iterator pos);
|
||||
iterator erase(Window* w);
|
||||
@@ -80,6 +82,7 @@ private:
|
||||
|
||||
void schedule_update();
|
||||
|
||||
bool m_forceRedraw;
|
||||
rak::timer m_timeLastUpdate;
|
||||
|
||||
rak::priority_queue_default m_scheduler;
|
||||
|
||||
@@ -123,6 +123,8 @@ print_download_info(char* buf, unsigned int length, core::Download* d) {
|
||||
|
||||
buf = print_download_time_left(buf, last - buf, d);
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -159,7 +161,7 @@ print_download_time_left(char* buf, unsigned int length, core::Download* d) {
|
||||
|
||||
if (!d->get_download().is_active() ||
|
||||
(rate = d->get_download().down_rate()->rate()) < 512) {
|
||||
buf += std::max(0, snprintf(buf, length, "--:--:--"));
|
||||
buf += std::max(snprintf(buf, length, "--:--:--"), 0);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ WindowDownloadList::redraw() {
|
||||
int pos = 0;
|
||||
|
||||
while (range.first != range.second) {
|
||||
char buffer[m_canvas->get_width() - 2];
|
||||
char buffer[m_canvas->get_width()];
|
||||
char* position;
|
||||
char* last = buffer + m_canvas->get_width() - 2;
|
||||
|
||||
|
||||
@@ -65,15 +65,20 @@ WindowDownloadStatusbar::redraw() {
|
||||
position = print_download_info(buffer, last - buffer, m_download);
|
||||
m_canvas->print(0, 0, "%s", buffer);
|
||||
|
||||
m_canvas->print(0, 1, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I: %i/%i Failed: %i",
|
||||
(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(),
|
||||
(int)m_download->chunks_failed());
|
||||
position = buffer + std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I: %i/%i Failed: %i",
|
||||
(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(),
|
||||
(int)m_download->chunks_failed()),
|
||||
0);
|
||||
position = buffer + std::max(snprintf(position, last - buffer, " Priority: %s",
|
||||
core::Download::priority_to_string(m_download->variables()->get("priority").as_value())),
|
||||
0);
|
||||
m_canvas->print(0, 1, "%s", buffer);
|
||||
|
||||
position = print_download_status(buffer, last - buffer, m_download);
|
||||
m_canvas->print(0, 2, "[%c:%i] %s",
|
||||
|
||||
@@ -52,6 +52,21 @@ WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
|
||||
m_focus(focus) {
|
||||
}
|
||||
|
||||
std::wstring
|
||||
hack_wstring(const std::string& src) {
|
||||
size_t length = ::mbstowcs(NULL, src.c_str(), src.size());
|
||||
|
||||
if (length == (size_t)-1)
|
||||
return std::wstring(L"<invalid>");
|
||||
|
||||
std::wstring dest;
|
||||
dest.resize(length);
|
||||
|
||||
::mbstowcs(&*dest.begin(), src.c_str(), src.size());
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
void
|
||||
WindowFileList::redraw() {
|
||||
m_slotSchedule(this, (cachedTime + 10 * 1000000).round_seconds());
|
||||
|
||||
Reference in New Issue
Block a user