diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index 9de2d1e0e..27cd0467b 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -39,14 +39,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/storage_defs.hpp" #include "libtorrent/peer_id.hpp" // sha1_hash -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/version.hpp" namespace libtorrent { class torrent_info; - class torrent; struct torrent_plugin; + struct torrent_handle; // The add_torrent_params is a parameter pack for adding torrents to a // session. The key fields when adding a torrent are: @@ -332,7 +331,7 @@ namespace libtorrent // to avoid race conditions. For instance it may be important to have the // plugin catch events that happen very early on after the torrent is // created. - std::vector(torrent_handle, void*)> > + std::vector(torrent_handle const&, void*)> > extensions; // the default tracker id to be used when announcing to trackers. By diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 5b5661970..a55e6208c 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -62,7 +62,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" // for user_load_function_t #include "libtorrent/ip_voter.hpp" -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/peer_id.hpp" @@ -111,6 +110,7 @@ namespace libtorrent class torrent; class alert; struct cache_info; + struct torrent_handle; namespace dht { @@ -193,7 +193,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::function( - torrent_handle, void*)> ext); + torrent_handle const&, void*)> ext); void add_ses_extension(boost::shared_ptr ext); #endif #if TORRENT_USE_ASSERTS diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index 2cf21efa3..275540241 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -96,7 +96,7 @@ POSSIBILITY OF SUCH DAMAGE. // // The signature of the function is:: // -// boost::shared_ptr (*)(torrent_handle, void*); +// boost::shared_ptr (*)(torrent_handle const&, void*); // // The second argument is the userdata passed to ``session::add_torrent()`` or // ``torrent_handle::add_extension()``. @@ -177,7 +177,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" // for sha1_hash #include "libtorrent/error_code.hpp" #include "libtorrent/session_handle.hpp" -#include "libtorrent/torrent_handle.hpp" namespace libtorrent { @@ -191,6 +190,7 @@ namespace libtorrent struct torrent_plugin; struct add_torrent_params; struct peer_connection_handle; + struct torrent_handle; // this is the base class for a session plugin. One primary feature // is that it is notified of all torrents that are added to the session, @@ -208,7 +208,7 @@ namespace libtorrent // If the plugin returns a torrent_plugin instance, it will be added // to the new torrent. Otherwise, return an empty shared_ptr to a // torrent_plugin (the default). - virtual boost::shared_ptr new_torrent(torrent_handle, void*) + virtual boost::shared_ptr new_torrent(torrent_handle const&, void*) { return boost::shared_ptr(); } // called when plugin is added to a session diff --git a/include/libtorrent/extensions/lt_trackers.hpp b/include/libtorrent/extensions/lt_trackers.hpp index 39fbce9a3..963fff8d8 100644 --- a/include/libtorrent/extensions/lt_trackers.hpp +++ b/include/libtorrent/extensions/lt_trackers.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS #include "libtorrent/config.hpp" -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -47,12 +46,12 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; // constructor function for the trackers exchange extension. This can // either be passed in the add_torrent_params::extensions field, or // via torrent_handle::add_extension(). - boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle, void*); + boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle const&, void*); } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/extensions/metadata_transfer.hpp b/include/libtorrent/extensions/metadata_transfer.hpp index bc45fcf28..72681b3ab 100644 --- a/include/libtorrent/extensions/metadata_transfer.hpp +++ b/include/libtorrent/extensions/metadata_transfer.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS #include "libtorrent/config.hpp" -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -49,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; #ifndef TORRENT_NO_DEPRECATE // constructor function for the metadata transfer extension. This @@ -59,7 +58,7 @@ namespace libtorrent // via torrent_handle::add_extension(). TORRENT_DEPRECATED TORRENT_EXPORT boost::shared_ptr - create_metadata_plugin(torrent_handle, void*); + create_metadata_plugin(torrent_handle const&, void*); #endif } #endif diff --git a/include/libtorrent/extensions/smart_ban.hpp b/include/libtorrent/extensions/smart_ban.hpp index 4926acce8..a2a5e35c9 100644 --- a/include/libtorrent/extensions/smart_ban.hpp +++ b/include/libtorrent/extensions/smart_ban.hpp @@ -35,8 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#include "libtorrent/torrent_handle.hpp" - #include "libtorrent/aux_/disable_warnings_push.hpp" #include @@ -47,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct torrent_plugin; + struct torrent_handle; // constructor function for the smart ban extension. The extension keeps // track of the data peers have sent us for failing pieces and once the @@ -54,7 +53,7 @@ namespace libtorrent // out to have sent corrupt data. // This function can either be passed in the add_torrent_params::extensions // field, or via torrent_handle::add_extension(). - TORRENT_EXPORT boost::shared_ptr create_smart_ban_plugin(torrent_handle, void*); + TORRENT_EXPORT boost::shared_ptr create_smart_ban_plugin(torrent_handle const&, void*); } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/extensions/ut_metadata.hpp b/include/libtorrent/extensions/ut_metadata.hpp index 9cad086d3..7080ee76a 100644 --- a/include/libtorrent/extensions/ut_metadata.hpp +++ b/include/libtorrent/extensions/ut_metadata.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS #include "libtorrent/config.hpp" -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -47,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; // constructor function for the ut_metadata extension. The ut_metadata // extension allows peers to request the .torrent file (or more @@ -58,7 +57,7 @@ namespace libtorrent // // This can either be passed in the add_torrent_params::extensions field, or // via torrent_handle::add_extension(). - TORRENT_EXPORT boost::shared_ptr create_ut_metadata_plugin(torrent_handle, void*); + TORRENT_EXPORT boost::shared_ptr create_ut_metadata_plugin(torrent_handle const&, void*); } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/extensions/ut_pex.hpp b/include/libtorrent/extensions/ut_pex.hpp index ff15616e2..00da8c1f9 100644 --- a/include/libtorrent/extensions/ut_pex.hpp +++ b/include/libtorrent/extensions/ut_pex.hpp @@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS #include "libtorrent/socket.hpp" // for endpoint -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -50,6 +49,7 @@ namespace libtorrent { struct torrent_plugin; struct peer_plugin; + struct torrent_handle; // constructor function for the ut_pex extension. The ut_pex // extension allows peers to gossip about their connections, allowing @@ -59,7 +59,7 @@ namespace libtorrent // // This can either be passed in the add_torrent_params::extensions field, or // via torrent_handle::add_extension(). - TORRENT_EXPORT boost::shared_ptr create_ut_pex_plugin(torrent_handle, void*); + TORRENT_EXPORT boost::shared_ptr create_ut_pex_plugin(torrent_handle const&, void*); bool was_introduced_by(peer_plugin const* pp, tcp::endpoint const& ep); } diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index dc08dfe29..e2bbd9376 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -482,7 +482,7 @@ namespace libtorrent // // .. _`libtorrent plugins`: libtorrent_plugins.html void add_extension(boost::function( - torrent_handle, void*)> ext); + torrent_handle const&, void*)> ext); void add_extension(boost::shared_ptr ext); #ifndef TORRENT_NO_DEPRECATE diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 276f82fc2..dc4c1001e 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -301,7 +301,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::shared_ptr); void remove_extension(boost::shared_ptr); - void add_extension(boost::function(torrent_handle, void*)> const& ext + void add_extension(boost::function(torrent_handle const&, void*)> const& ext , void* userdata); void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags); #endif diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 02ae65b58..84d27df6a 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -501,7 +501,7 @@ namespace libtorrent // pointer. The function is expected to return a shared pointer to // a torrent_plugin instance. void add_extension( - boost::function(torrent_handle, void*)> const& ext + boost::function(torrent_handle const&, void*)> const& ext , void* userdata = 0); // ``set_metadata`` expects the *info* section of metadata. i.e. The diff --git a/src/lt_trackers.cpp b/src/lt_trackers.cpp index 6f3647b21..c333173f3 100644 --- a/src/lt_trackers.cpp +++ b/src/lt_trackers.cpp @@ -55,6 +55,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/io.hpp" #include "libtorrent/parse_url.hpp" +#include "libtorrent/torrent_handle.hpp" namespace libtorrent { namespace { @@ -378,7 +379,7 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle th, void*) + boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); if (t->valid_metadata() && t->torrent_file().priv()) return boost::shared_ptr(); diff --git a/src/metadata_transfer.cpp b/src/metadata_transfer.cpp index f0a8c6e37..fd59ee273 100644 --- a/src/metadata_transfer.cpp +++ b/src/metadata_transfer.cpp @@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/extensions/metadata_transfer.hpp" #include "libtorrent/alert_types.hpp" @@ -591,7 +592,7 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr create_metadata_plugin(torrent_handle th, void*) + boost::shared_ptr create_metadata_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); // don't add this extension if the torrent is private diff --git a/src/session_handle.cpp b/src/session_handle.cpp index c259476d2..b06ff13a5 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -414,7 +414,7 @@ namespace libtorrent } #endif // TORRENT_NO_DEPRECATE - void session_handle::add_extension(boost::function(torrent_handle, void*)> ext) + void session_handle::add_extension(boost::function(torrent_handle const&, void*)> ext) { #ifndef TORRENT_DISABLE_EXTENSIONS TORRENT_ASYNC_CALL1(add_extension, ext); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 07f1fbbf6..75cd01ca7 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -96,6 +96,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/magnet_uri.hpp" #include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/torrent_peer.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/choker.hpp" #include "libtorrent/error.hpp" @@ -868,13 +869,13 @@ namespace aux { #ifndef TORRENT_DISABLE_EXTENSIONS - typedef boost::function(torrent_handle, void*)> ext_function_t; + typedef boost::function(torrent_handle const&, void*)> ext_function_t; struct session_plugin_wrapper : plugin { session_plugin_wrapper(ext_function_t const& f) : m_f(f) {} - virtual boost::shared_ptr new_torrent(torrent_handle t, void* user) + virtual boost::shared_ptr new_torrent(torrent_handle const& t, void* user) { return m_f(t, user); } ext_function_t m_f; }; @@ -4634,7 +4635,7 @@ retry: #ifndef TORRENT_DISABLE_EXTENSIONS typedef std::vector(torrent_handle, void*)> > + boost::shared_ptr(torrent_handle const&, void*)> > torrent_plugins_t; for (torrent_plugins_t::const_iterator i = params.extensions.begin() diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index d4e51011d..77356a96e 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/extensions/smart_ban.hpp" #include "libtorrent/disk_io_thread.hpp" @@ -389,7 +390,7 @@ namespace namespace libtorrent { - boost::shared_ptr create_smart_ban_plugin(torrent_handle th, void*) + boost::shared_ptr create_smart_ban_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); return boost::shared_ptr(new smart_ban_plugin(*t)); diff --git a/src/torrent.cpp b/src/torrent.cpp index d073e8802..49dce1564 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1499,7 +1499,7 @@ namespace libtorrent m_extensions.erase(i); } - void torrent::add_extension(boost::function(torrent_handle, void*)> const& ext + void torrent::add_extension(boost::function(torrent_handle const&, void*)> const& ext , void* userdata) { boost::shared_ptr tp(ext(get_handle(), userdata)); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 1a7c0d116..5e7ea29de 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -296,7 +296,7 @@ namespace libtorrent } void torrent_handle::add_extension( - boost::function(torrent_handle, void*)> const& ext + boost::function(torrent_handle const&, void*)> const& ext , void* userdata) { #ifndef TORRENT_DISABLE_EXTENSIONS diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index 37ee812a8..8adde205f 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/extensions/ut_metadata.hpp" #include "libtorrent/alert_types.hpp" @@ -656,7 +657,7 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr create_ut_metadata_plugin(torrent_handle th, void*) + boost::shared_ptr create_ut_metadata_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); // don't add this extension if the torrent is private diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index a148ac07d..16a6bd59b 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/socket_io.hpp" @@ -659,7 +660,7 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr create_ut_pex_plugin(torrent_handle th, void*) + boost::shared_ptr create_ut_pex_plugin(torrent_handle const& th, void*) { torrent* t = th.native_handle().get(); if (t->torrent_file().priv() || (t->torrent_file().is_i2p() diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 6f5c0dc23..58c7a9e8b 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -69,7 +69,7 @@ enum flags_t }; void test_transfer(int flags - , boost::shared_ptr (*constructor)(libtorrent::torrent_handle, void*) + , boost::shared_ptr (*constructor)(libtorrent::torrent_handle const&, void*) , int timeout) { using namespace libtorrent;