From d911ed456ab0a33c8cf26ad54745ba7dfda5ce45 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sun, 12 Jul 2015 20:17:45 -0700 Subject: [PATCH] stub out disabled functions rather than removing them --- include/libtorrent/peer_connection_handle.hpp | 6 ----- src/peer_connection_handle.cpp | 22 ++++++++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/peer_connection_handle.hpp b/include/libtorrent/peer_connection_handle.hpp index db7da8ac9..51af70808 100644 --- a/include/libtorrent/peer_connection_handle.hpp +++ b/include/libtorrent/peer_connection_handle.hpp @@ -58,10 +58,8 @@ struct TORRENT_EXPORT peer_connection_handle int type() const; -#ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::shared_ptr); peer_plugin const* find_plugin(char const* type); -#endif bool is_seed() const; @@ -96,10 +94,8 @@ struct TORRENT_EXPORT peer_connection_handle bool failed() const; -#ifndef TORRENT_DISABLE_LOGGING void peer_log(peer_log_alert::direction_t direction , char const* event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5); -#endif bool can_disconnect(error_code const& ec) const; @@ -130,12 +126,10 @@ struct TORRENT_EXPORT bt_peer_connection_handle : public peer_connection_handle bool packet_finished() const; bool support_extensions() const; -#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) bool supports_encryption() const; void switch_send_crypto(boost::shared_ptr crypto); void switch_recv_crypto(boost::shared_ptr crypto); -#endif boost::shared_ptr native_handle() const; }; diff --git a/src/peer_connection_handle.cpp b/src/peer_connection_handle.cpp index 2abea1e8a..f8043258f 100644 --- a/src/peer_connection_handle.cpp +++ b/src/peer_connection_handle.cpp @@ -48,21 +48,25 @@ int peer_connection_handle::type() const return pc->type(); } -#ifndef TORRENT_DISABLE_EXTENSIONS void peer_connection_handle::add_extension(boost::shared_ptr ext) { +#ifndef TORRENT_DISABLE_EXTENSIONS boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->add_extension(ext); +#endif } peer_plugin const* peer_connection_handle::find_plugin(char const* type) { +#ifndef TORRENT_DISABLE_EXTENSIONS boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->find_plugin(type); -} +#else + return NULL; #endif +} bool peer_connection_handle::is_seed() const { @@ -213,18 +217,18 @@ bool peer_connection_handle::failed() const return pc->failed(); } -#ifndef TORRENT_DISABLE_LOGGING void peer_connection_handle::peer_log(peer_log_alert::direction_t direction , char const* event, char const* fmt, ...) const { +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); va_list v; va_start(v, fmt); pc->peer_log(direction, event, fmt, v); va_end(v); -} #endif +} bool peer_connection_handle::can_disconnect(error_code const& ec) const { @@ -282,28 +286,34 @@ bool bt_peer_connection_handle::support_extensions() const return pc->support_extensions(); } -#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) bool bt_peer_connection_handle::supports_encryption() const { +#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->supports_encryption(); +#else + return false; +#endif } void bt_peer_connection_handle::switch_send_crypto(boost::shared_ptr crypto) { +#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->switch_send_crypto(crypto); +#endif } void bt_peer_connection_handle::switch_recv_crypto(boost::shared_ptr crypto) { +#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->switch_recv_crypto(crypto); -} #endif +} boost::shared_ptr bt_peer_connection_handle::native_handle() const {