From d86505924ba8db1c20503bc4aa5ebe4e124a259d Mon Sep 17 00:00:00 2001 From: rakshasa Date: Thu, 15 Nov 2007 14:26:12 +0000 Subject: [PATCH] * Moved ConnectionList into the API and made rtorrent use it. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1010 e378c898-3ddf-0310-93e7-cc216c733640 --- src/command_download.cc | 7 +++---- src/core/download.h | 4 ++++ src/ui/download.cc | 5 +++-- src/ui/element_peer_list.cc | 8 +++++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/command_download.cc b/src/command_download.cc index 0317b009..e54674d8 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include "core/download.h" #include "core/manager.h" @@ -438,12 +439,10 @@ initialize_command_download() { ADD_CD_VALUE_MEM_BI("max_file_size", &core::Download::file_list, &torrent::FileList::set_max_file_size, &torrent::FileList::max_file_size); // Deprecated. - ADD_CD_VALUE_MEM_BI("min_peers", &core::Download::download, &torrent::Download::set_peers_min, &torrent::Download::peers_min); - ADD_CD_VALUE_MEM_BI("max_peers", &core::Download::download, &torrent::Download::set_peers_max, &torrent::Download::peers_max); ADD_CD_VALUE_MEM_BI("max_uploads", &core::Download::download, &torrent::Download::set_uploads_max, &torrent::Download::uploads_max); - ADD_CD_VALUE_MEM_BI("peers_min", &core::Download::download, &torrent::Download::set_peers_min, &torrent::Download::peers_min); - ADD_CD_VALUE_MEM_BI("peers_max", &core::Download::download, &torrent::Download::set_peers_max, &torrent::Download::peers_max); + ADD_CD_VALUE_MEM_BI("peers_min", &core::Download::connection_list, &torrent::ConnectionList::set_min_size, &torrent::ConnectionList::min_size); + ADD_CD_VALUE_MEM_BI("peers_max", &core::Download::connection_list, &torrent::ConnectionList::set_max_size, &torrent::ConnectionList::max_size); ADD_CD_VALUE_MEM_BI("uploads_max", &core::Download::download, &torrent::Download::set_uploads_max, &torrent::Download::uploads_max); ADD_CD_VALUE_UNI("peers_connected", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_connected))); ADD_CD_VALUE_UNI("peers_not_connected", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_not_connected))); diff --git a/src/core/download.h b/src/core/download.h index 171338b6..a78601ce 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -56,6 +56,7 @@ public: typedef torrent::Download download_type; typedef torrent::FileList file_list_type; typedef torrent::TrackerList tracker_list_type; + typedef torrent::ConnectionList connection_list_type; typedef download_type::ConnectionType connection_type; static const int variable_hashing_stopped = 0; @@ -88,9 +89,12 @@ public: const file_list_type* c_file_list() const { return m_download.file_list(); } torrent::Object* bencode() { return m_download.bencode(); } + tracker_list_type* tracker_list() { return m_download.tracker_list(); } uint32_t tracker_list_size() const { return m_download.tracker_list()->size(); } + connection_list_type* connection_list() { return m_download.connection_list(); } + const std::string& message() const { return m_message; } void set_message(const std::string& msg) { m_message = msg; } diff --git a/src/ui/download.cc b/src/ui/download.cc index 331e3e73..1ab4ae77 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -45,6 +45,7 @@ #include #include #include +#include #include "core/download.h" #include "input/manager.h" @@ -293,14 +294,14 @@ void Download::receive_min_peers(int t) { m_windowDownloadStatus->mark_dirty(); - m_download->download()->set_peers_min(std::max(m_download->download()->peers_min() + t, (uint32_t)5)); + m_download->download()->connection_list()->set_min_size(std::max(m_download->download()->connection_list()->min_size() + t, (uint32_t)5)); } void Download::receive_max_peers(int t) { m_windowDownloadStatus->mark_dirty(); - m_download->download()->set_peers_max(std::max(m_download->download()->peers_max() + t, (uint32_t)5)); + m_download->download()->connection_list()->set_max_size(std::max(m_download->download()->connection_list()->max_size() + t, (uint32_t)5)); } void diff --git a/src/ui/element_peer_list.cc b/src/ui/element_peer_list.cc index 88ef85b0..14c5d036 100644 --- a/src/ui/element_peer_list.cc +++ b/src/ui/element_peer_list.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "display/frame.h" @@ -61,10 +62,11 @@ ElementPeerList::ElementPeerList(core::Download* d) : m_listItr = m_list.end(); - m_download->download()->peer_list(m_list); + std::for_each(m_download->download()->connection_list()->begin(), m_download->download()->connection_list()->end(), + rak::bind1st(std::mem_fun(&PList::push_back), &m_list)); - m_connPeerConnected = m_download->download()->signal_peer_connected(sigc::mem_fun(*this, &ElementPeerList::receive_peer_connected)); - m_connPeerDisconnected = m_download->download()->signal_peer_disconnected(sigc::mem_fun(*this, &ElementPeerList::receive_peer_disconnected)); + m_connPeerConnected = m_download->download()->connection_list()->signal_connected().connect(sigc::mem_fun(*this, &ElementPeerList::receive_peer_connected)); + m_connPeerDisconnected = m_download->download()->connection_list()->signal_disconnected().connect(sigc::mem_fun(*this, &ElementPeerList::receive_peer_disconnected)); m_windowList = new display::WindowPeerList(m_download, &m_list, &m_listItr); m_elementInfo = create_info();