forked from premiere/premiere-libtorrent
pass torrent_handle by const ref in the plugin api
This commit is contained in:
parent
72dcc20073
commit
e6b3df3696
|
@ -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<boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> >
|
||||
std::vector<boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> >
|
||||
extensions;
|
||||
|
||||
// the default tracker id to be used when announcing to trackers. By
|
||||
|
|
|
@ -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<boost::shared_ptr<torrent_plugin>(
|
||||
torrent_handle, void*)> ext);
|
||||
torrent_handle const&, void*)> ext);
|
||||
void add_ses_extension(boost::shared_ptr<plugin> ext);
|
||||
#endif
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
|
|
@ -96,7 +96,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
//
|
||||
// The signature of the function is::
|
||||
//
|
||||
// boost::shared_ptr<torrent_plugin> (*)(torrent_handle, void*);
|
||||
// boost::shared_ptr<torrent_plugin> (*)(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<torrent_plugin> new_torrent(torrent_handle, void*)
|
||||
virtual boost::shared_ptr<torrent_plugin> new_torrent(torrent_handle const&, void*)
|
||||
{ return boost::shared_ptr<torrent_plugin>(); }
|
||||
|
||||
// called when plugin is added to a session
|
||||
|
|
|
@ -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_plugin> TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle, void*);
|
||||
boost::shared_ptr<torrent_plugin> TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle const&, void*);
|
||||
}
|
||||
|
||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||
|
|
|
@ -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<torrent_plugin>
|
||||
create_metadata_plugin(torrent_handle, void*);
|
||||
create_metadata_plugin(torrent_handle const&, void*);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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 <boost/shared_ptr.hpp>
|
||||
|
@ -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<torrent_plugin> create_smart_ban_plugin(torrent_handle, void*);
|
||||
TORRENT_EXPORT boost::shared_ptr<torrent_plugin> create_smart_ban_plugin(torrent_handle const&, void*);
|
||||
}
|
||||
|
||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||
|
|
|
@ -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<torrent_plugin> create_ut_metadata_plugin(torrent_handle, void*);
|
||||
TORRENT_EXPORT boost::shared_ptr<torrent_plugin> create_ut_metadata_plugin(torrent_handle const&, void*);
|
||||
}
|
||||
|
||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||
|
|
|
@ -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<torrent_plugin> create_ut_pex_plugin(torrent_handle, void*);
|
||||
TORRENT_EXPORT boost::shared_ptr<torrent_plugin> create_ut_pex_plugin(torrent_handle const&, void*);
|
||||
|
||||
bool was_introduced_by(peer_plugin const* pp, tcp::endpoint const& ep);
|
||||
}
|
||||
|
|
|
@ -482,7 +482,7 @@ namespace libtorrent
|
|||
//
|
||||
// .. _`libtorrent plugins`: libtorrent_plugins.html
|
||||
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(
|
||||
torrent_handle, void*)> ext);
|
||||
torrent_handle const&, void*)> ext);
|
||||
void add_extension(boost::shared_ptr<plugin> ext);
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
|
|
@ -301,7 +301,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
void add_extension(boost::shared_ptr<torrent_plugin>);
|
||||
void remove_extension(boost::shared_ptr<torrent_plugin>);
|
||||
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> const& ext
|
||||
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata);
|
||||
void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags);
|
||||
#endif
|
||||
|
|
|
@ -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<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> const& ext
|
||||
boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata = 0);
|
||||
|
||||
// ``set_metadata`` expects the *info* section of metadata. i.e. The
|
||||
|
|
|
@ -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_plugin> TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle th, void*)
|
||||
boost::shared_ptr<torrent_plugin> 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<torrent_plugin>();
|
||||
|
|
|
@ -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<torrent_plugin> create_metadata_plugin(torrent_handle th, void*)
|
||||
boost::shared_ptr<torrent_plugin> create_metadata_plugin(torrent_handle const& th, void*)
|
||||
{
|
||||
torrent* t = th.native_handle().get();
|
||||
// don't add this extension if the torrent is private
|
||||
|
|
|
@ -414,7 +414,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
||||
void session_handle::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> ext)
|
||||
void session_handle::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> ext)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
TORRENT_ASYNC_CALL1(add_extension, ext);
|
||||
|
|
|
@ -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<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> ext_function_t;
|
||||
typedef boost::function<boost::shared_ptr<torrent_plugin>(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<torrent_plugin> new_torrent(torrent_handle t, void* user)
|
||||
virtual boost::shared_ptr<torrent_plugin> 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<boost::function<
|
||||
boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> >
|
||||
boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> >
|
||||
torrent_plugins_t;
|
||||
|
||||
for (torrent_plugins_t::const_iterator i = params.extensions.begin()
|
||||
|
|
|
@ -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<torrent_plugin> create_smart_ban_plugin(torrent_handle th, void*)
|
||||
boost::shared_ptr<torrent_plugin> create_smart_ban_plugin(torrent_handle const& th, void*)
|
||||
{
|
||||
torrent* t = th.native_handle().get();
|
||||
return boost::shared_ptr<torrent_plugin>(new smart_ban_plugin(*t));
|
||||
|
|
|
@ -1499,7 +1499,7 @@ namespace libtorrent
|
|||
m_extensions.erase(i);
|
||||
}
|
||||
|
||||
void torrent::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> const& ext
|
||||
void torrent::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata)
|
||||
{
|
||||
boost::shared_ptr<torrent_plugin> tp(ext(get_handle(), userdata));
|
||||
|
|
|
@ -296,7 +296,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
void torrent_handle::add_extension(
|
||||
boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle, void*)> const& ext
|
||||
boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
|
|
|
@ -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<torrent_plugin> create_ut_metadata_plugin(torrent_handle th, void*)
|
||||
boost::shared_ptr<torrent_plugin> 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
|
||||
|
|
|
@ -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<torrent_plugin> create_ut_pex_plugin(torrent_handle th, void*)
|
||||
boost::shared_ptr<torrent_plugin> 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()
|
||||
|
|
|
@ -69,7 +69,7 @@ enum flags_t
|
|||
};
|
||||
|
||||
void test_transfer(int flags
|
||||
, boost::shared_ptr<libtorrent::torrent_plugin> (*constructor)(libtorrent::torrent_handle, void*)
|
||||
, boost::shared_ptr<libtorrent::torrent_plugin> (*constructor)(libtorrent::torrent_handle const&, void*)
|
||||
, int timeout)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
|
Loading…
Reference in New Issue