mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-17 22:56:18 +00:00
Peer info properly displays data, added parse.* with escape_string(...).
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@261 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -14,6 +14,8 @@ rtorrent_LDADD = \
|
|||||||
|
|
||||||
rtorrent_SOURCES = \
|
rtorrent_SOURCES = \
|
||||||
main.cc \
|
main.cc \
|
||||||
|
parse.cc \
|
||||||
|
parse.h \
|
||||||
signal_handler.cc \
|
signal_handler.cc \
|
||||||
signal_handler.h \
|
signal_handler.h \
|
||||||
timer.h
|
timer.h
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "core/download.h"
|
||||||
|
|
||||||
|
#include "parse.h"
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "window_peer_info.h"
|
#include "window_peer_info.h"
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowPeerInfo::WindowPeerInfo(PList* l, PList::iterator* f) :
|
WindowPeerInfo::WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f) :
|
||||||
Window(new Canvas, true),
|
Window(new Canvas, true),
|
||||||
|
m_download(d),
|
||||||
m_list(l),
|
m_list(l),
|
||||||
m_focus(f) {
|
m_focus(f) {
|
||||||
}
|
}
|
||||||
@@ -21,12 +25,29 @@ WindowPeerInfo::redraw() {
|
|||||||
m_lastDraw = Timer::cache();
|
m_lastDraw = Timer::cache();
|
||||||
m_canvas->erase();
|
m_canvas->erase();
|
||||||
|
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
m_canvas->print(0, y++, "Hash: %s", escape_string(m_download->get_download().get_hash()).c_str());
|
||||||
|
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
|
||||||
|
m_download->get_download().get_chunks_done(),
|
||||||
|
m_download->get_download().get_chunks_total(),
|
||||||
|
m_download->get_download().get_chunks_size());
|
||||||
|
|
||||||
if (*m_focus == m_list->end())
|
if (*m_focus == m_list->end())
|
||||||
mvprintw(0, 0, "No focus");
|
return;
|
||||||
else
|
|
||||||
mvprintw(0, 0, "Focus on: %s:%i",
|
y++;
|
||||||
(*m_focus)->get_dns().c_str(),
|
|
||||||
(*m_focus)->get_port());
|
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" , escape_string((*m_focus)->get_id()).c_str());
|
||||||
|
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->get_snubbed() ? "Yes" : "No");
|
||||||
|
m_canvas->print(0, y++, "Done: %i%", (*m_focus)->get_chunks_done());
|
||||||
|
|
||||||
|
m_canvas->print(0, y++, "Rate: %5.1f/%5.1f KB Total: %.1f/%.1f MB",
|
||||||
|
(double)(*m_focus)->get_rate_up() / (double)(1 << 10),
|
||||||
|
(double)(*m_focus)->get_rate_down() / (double)(1 << 10),
|
||||||
|
(double)(*m_focus)->get_transfered_up() / (double)(1 << 20),
|
||||||
|
(double)(*m_focus)->get_transfered_down() / (double)(1 << 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
namespace core {
|
||||||
|
class Download;
|
||||||
|
}
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
class WindowPeerInfo : public Window {
|
class WindowPeerInfo : public Window {
|
||||||
@@ -14,13 +18,15 @@ public:
|
|||||||
typedef std::list<torrent::Peer> PList;
|
typedef std::list<torrent::Peer> PList;
|
||||||
typedef sigc::slot0<uint32_t> SlotChunksTotal;
|
typedef sigc::slot0<uint32_t> SlotChunksTotal;
|
||||||
|
|
||||||
WindowPeerInfo(PList* l, PList::iterator* f);
|
WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f);
|
||||||
|
|
||||||
void slot_chunks_total(SlotChunksTotal s) { m_slotChunksTotal = s; }
|
void slot_chunks_total(SlotChunksTotal s) { m_slotChunksTotal = s; }
|
||||||
|
|
||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
core::Download* m_download;
|
||||||
|
|
||||||
PList* m_list;
|
PList* m_list;
|
||||||
PList::iterator* m_focus;
|
PList::iterator* m_focus;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "parse.h"
|
||||||
|
|
||||||
|
std::string
|
||||||
|
escape_string(const std::string& src) {
|
||||||
|
std::stringstream stream;
|
||||||
|
|
||||||
|
// TODO: Correct would be to save the state.
|
||||||
|
stream << std::hex << std::uppercase;
|
||||||
|
|
||||||
|
for (std::string::const_iterator itr = src.begin(); itr != src.end(); ++itr)
|
||||||
|
if ((*itr >= 'A' && *itr <= 'Z') ||
|
||||||
|
(*itr >= 'a' && *itr <= 'z') ||
|
||||||
|
(*itr >= '0' && *itr <= '9') ||
|
||||||
|
*itr == '-')
|
||||||
|
stream << *itr;
|
||||||
|
else
|
||||||
|
stream << '%' << ((unsigned char)*itr >> 4) << ((unsigned char)*itr & 0xf);
|
||||||
|
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef RTORRENT_PARSE_H
|
||||||
|
#define RTORRENT_PARSE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Various functinos for manipulating strings.
|
||||||
|
|
||||||
|
std::string escape_string(const std::string& src);
|
||||||
|
|
||||||
|
#endif
|
||||||
+1
-1
@@ -93,7 +93,7 @@ Download::activate_display(Display d) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DISPLAY_PEER:
|
case DISPLAY_PEER:
|
||||||
*m_window = wpi = new WPeerInfo(&m_peers, &m_focus);
|
*m_window = wpi = new WPeerInfo(m_download, &m_peers, &m_focus);
|
||||||
|
|
||||||
wpi->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
wpi->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user