diff --git a/encryption/libtorrent/include/libtorrent/socks5_stream.hpp b/encryption/libtorrent/include/libtorrent/socks5_stream.hpp index 9e8a0d04b..60873742f 100644 --- a/encryption/libtorrent/include/libtorrent/socks5_stream.hpp +++ b/encryption/libtorrent/include/libtorrent/socks5_stream.hpp @@ -1,32 +1,17 @@ -#include "libtorrent/io.hpp" -#include "libtorrent/socket.hpp" -#include -#include -#include -#include -#include - +#ifndef TORRENT_SOCKS5_STREAM_HPP_INCLUDED +#define TORRENT_SOCKS5_STREAM_HPP_INCLUDED +#include "libtorrent/proxy_base.hpp" namespace libtorrent { -class socks5_stream : boost::noncopyable +class socks5_stream : public proxy_base { public: - typedef stream_socket::lowest_layer_type lowest_layer_type; - typedef stream_socket::endpoint_type endpoint_type; - typedef stream_socket::protocol_type protocol_type; - explicit socks5_stream(asio::io_service& io_service) - : m_sock(io_service) - , m_resolver(io_service) - {} + : proxy_base(io_service) - void set_proxy(std::string hostname, int port) - { - m_hostname = hostname; - m_port = port; - } + {} void set_username(std::string const& user , std::string const& password) @@ -35,107 +20,6 @@ public: m_password = password; } - template - void async_read_some(Mutable_Buffers const& buffers, Handler const& handler) - { - m_sock.async_read_some(buffers, handler); - } - - template - std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec) - { - return m_sock.read_some(buffers, ec); - } - - template - std::size_t read_some(Mutable_Buffers const& buffers) - { - return m_sock.read_some(buffers); - } - - template - void io_control(IO_Control_Command& ioc) - { - m_sock.io_control(ioc); - } - - template - void io_control(IO_Control_Command& ioc, asio::error_code& ec) - { - m_sock.io_control(ioc, ec); - } - - template - void async_write_some(Const_Buffers const& buffers, Handler const& handler) - { - m_sock.async_write_some(buffers, handler); - } - - void bind(endpoint_type const& endpoint) - { - m_sock.bind(endpoint); - } - - template - void bind(endpoint_type const& endpoint, Error_Handler const& error_handler) - { - m_sock.bind(endpoint, error_handler); - } - - void open(protocol_type const& p) - { - m_sock.open(p); - } - - template - void open(protocol_type const& p, Error_Handler const& error_handler) - { - m_sock.open(p, error_handler); - } - - void close() - { - m_remote_endpoint = endpoint_type(); - m_sock.close(); - } - - template - void close(Error_Handler const& error_handler) - { - m_sock.close(error_handler); - } - - endpoint_type remote_endpoint() - { - return m_remote_endpoint; - } - - template - endpoint_type remote_endpoint(Error_Handler const& error_handler) - { - return m_remote_endpoint; - } - - endpoint_type local_endpoint() - { - return m_sock.local_endpoint(); - } - - template - endpoint_type local_endpoint(Error_Handler const& error_handler) - { - return m_sock.local_endpoint(error_handler); - } - - asio::io_service& io_service() - { - return m_sock.io_service(); - } - - lowest_layer_type& lowest_layer() - { - return m_sock.lowest_layer(); - } typedef boost::function handler_type; @@ -176,20 +60,14 @@ private: void connect2(asio::error_code const& e, boost::shared_ptr h); void connect3(asio::error_code const& e, boost::shared_ptr h); - stream_socket m_sock; - // the socks5 proxy - std::string m_hostname; - int m_port; // send and receive buffer std::vector m_buffer; // proxy authentication std::string m_user; std::string m_password; - endpoint_type m_remote_endpoint; - - tcp::resolver m_resolver; }; } +#endif diff --git a/encryption/libtorrent/src/torrent.cpp b/encryption/libtorrent/src/torrent.cpp index 1001cd2b0..135108540 100755 --- a/encryption/libtorrent/src/torrent.cpp +++ b/encryption/libtorrent/src/torrent.cpp @@ -1819,7 +1819,8 @@ namespace libtorrent bool torrent::want_more_peers() const { return int(m_connections.size()) < m_connections_quota.given - && m_ses.m_half_open.free_slots(); + && m_ses.m_half_open.free_slots() + && !m_paused;; } void torrent::disconnect_all() diff --git a/encryption/src/deluge_core.cpp b/encryption/src/deluge_core.cpp index 3285bf857..184747555 100644 --- a/encryption/src/deluge_core.cpp +++ b/encryption/src/deluge_core.cpp @@ -611,15 +611,6 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args) std::vector peers; t.handle.get_peer_info(peers); - long total_seeds = 0; - long total_peers = 0; - - for (unsigned long i = 0; i < peers.size(); i++) - if (peers[i].seed) - total_seeds++; - else - total_peers++; - return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:d,s:f,s:l,s:l,s:s,s:s,s:f,s:d,s:l,s:l,s:l,s:d,s:l,s:l,s:l,s:l,s:l,s:l,s:d,s:d,s:l,s:l}", "name", t.handle.get_torrent_info().name().c_str(), "num_files", t.handle.get_torrent_info().num_files(), @@ -642,8 +633,8 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args) "total_size", double(i.total_size()), "piece_length", long(i.piece_length()), "num_pieces", long(i.num_pieces()), - "total_seeds", total_seeds, - "total_peers", total_peers, + "total_seeds", s.num_complete != -1 ? s.num_complete: s.num_seeds, + "total_peers", s.num_incomplete != -1 ? s.num_incomplete : s.num_peers, "is_paused", long(t.handle.is_paused()), "is_seed", long(t.handle.is_seed()), "total_wanted", double(s.total_wanted), @@ -779,7 +770,7 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args) return NULL; if (handle_exists(handle)) - return Py_BuildValue("{s:i,s:i,s:s,s:s}", + return Py_BuildValue("{s:i,s:i,s:s,s:i,s:s}", "event_type", EVENT_TRACKER, "unique_ID", M_torrents->at(index).unique_ID, @@ -800,6 +791,7 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args) "unique_ID", M_torrents->at(index).unique_ID, "tracker_status", "Announce succeeded", + "num_peers", long(dynamic_cast(popped_alert)->num_peers), "message", a->msg().c_str()); else { Py_INCREF(Py_None); return Py_None; } diff --git a/encryption/src/interface.py b/encryption/src/interface.py index ccef5b39a..d9b8185a9 100644 --- a/encryption/src/interface.py +++ b/encryption/src/interface.py @@ -619,6 +619,8 @@ class DelugeGTK: ## Call via a timer to update the interface def update(self): + # Tell the core to handle messages (now, so we show their output on this tick) + self.manager.handle_events() # Make sure that the interface still exists try: tab = self.wtree.get_widget("torrent_info").get_current_page()