mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 23:29:21 +00:00
* Finished keep-alive in PeerConnectionSeed.
* Display the connection types for a download. * Fixed HashTorrent so it properly erases the Chunks it holds. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@549 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+19
-7
@@ -46,16 +46,16 @@
|
||||
namespace core {
|
||||
|
||||
Download::Download() :
|
||||
m_connectionLeech("default"),
|
||||
m_connectionSeed("seed") {
|
||||
m_connectionLeech(torrent::Download::CONNECTION_LEECH),
|
||||
m_connectionSeed(torrent::Download::CONNECTION_SEED) {
|
||||
}
|
||||
|
||||
void
|
||||
Download::start() {
|
||||
if (is_done())
|
||||
m_download.set_connection_type(string_to_connection_type(m_connectionSeed));
|
||||
m_download.set_connection_type(m_connectionSeed);
|
||||
else
|
||||
m_download.set_connection_type(string_to_connection_type(m_connectionLeech));
|
||||
m_download.set_connection_type(m_connectionLeech);
|
||||
|
||||
m_download.start();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ Download::release_download() {
|
||||
|
||||
void
|
||||
Download::receive_finished() {
|
||||
m_download.set_connection_type(string_to_connection_type(m_connectionSeed));
|
||||
m_download.set_connection_type(m_connectionSeed);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -116,12 +116,24 @@ Download::receive_storage_error(std::string msg) {
|
||||
torrent::Download::ConnectionType
|
||||
Download::string_to_connection_type(const std::string& name) {
|
||||
// Return default if the name isn't found.
|
||||
if (name == "default")
|
||||
return torrent::Download::CONNECTION_DEFAULT;
|
||||
if (name == "leech")
|
||||
return torrent::Download::CONNECTION_LEECH;
|
||||
else if (name == "seed")
|
||||
return torrent::Download::CONNECTION_SEED;
|
||||
else
|
||||
throw std::runtime_error("Invalid connection type selected: \"" + name + "\"");
|
||||
}
|
||||
|
||||
const char*
|
||||
Download::connection_type_to_string(torrent::Download::ConnectionType t) {
|
||||
switch (t) {
|
||||
case torrent::Download::CONNECTION_LEECH:
|
||||
return "leech";
|
||||
case torrent::Download::CONNECTION_SEED:
|
||||
return "seed";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-6
@@ -45,6 +45,8 @@ namespace core {
|
||||
|
||||
class Download {
|
||||
public:
|
||||
typedef torrent::Download::ConnectionType ConnType;
|
||||
|
||||
Download();
|
||||
~Download() { release_download(); }
|
||||
|
||||
@@ -65,8 +67,12 @@ public:
|
||||
|
||||
void set_root_directory(const std::string& d);
|
||||
|
||||
void set_connection_leech(const std::string& name) { m_connectionLeech = name; }
|
||||
void set_connection_seed(const std::string& name) { m_connectionSeed = name; }
|
||||
ConnType get_connection_current() const { return m_download.get_connection_type(); }
|
||||
ConnType get_connection_leech() const { return m_connectionLeech; }
|
||||
ConnType get_connection_seed() const { return m_connectionSeed; }
|
||||
|
||||
void set_connection_leech(const std::string& name) { m_connectionLeech = string_to_connection_type(name); }
|
||||
void set_connection_seed(const std::string& name) { m_connectionSeed = string_to_connection_type(name); }
|
||||
|
||||
void enable_udp_trackers(bool state);
|
||||
|
||||
@@ -82,18 +88,19 @@ public:
|
||||
|
||||
void receive_finished();
|
||||
|
||||
static ConnType string_to_connection_type(const std::string& name);
|
||||
static const char* connection_type_to_string(ConnType t);
|
||||
|
||||
private:
|
||||
void receive_tracker_msg(std::string msg);
|
||||
void receive_storage_error(std::string msg);
|
||||
|
||||
static torrent::Download::ConnectionType string_to_connection_type(const std::string& name);
|
||||
|
||||
torrent::Download m_download;
|
||||
|
||||
std::string m_message;
|
||||
|
||||
std::string m_connectionLeech;
|
||||
std::string m_connectionSeed;
|
||||
ConnType m_connectionLeech;
|
||||
ConnType m_connectionSeed;
|
||||
|
||||
sigc::connection m_connTrackerSucceded;
|
||||
sigc::connection m_connTrackerFailed;
|
||||
|
||||
@@ -74,6 +74,13 @@ WindowPeerInfo::redraw() {
|
||||
|
||||
y++;
|
||||
|
||||
m_canvas->print(0, y++, "Connection Type: %s ( %s / %s )",
|
||||
core::Download::connection_type_to_string(m_download->get_connection_current()),
|
||||
core::Download::connection_type_to_string(m_download->get_connection_leech()),
|
||||
core::Download::connection_type_to_string(m_download->get_connection_seed()));
|
||||
|
||||
y++;
|
||||
|
||||
if (*m_focus == m_list->end()) {
|
||||
m_canvas->print(0, y++, "No peer in focus");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user