fixed python bindings for recent api updates and added support for extensions

This commit is contained in:
Arvid Norberg 2007-04-07 03:37:23 +00:00
parent baecc64131
commit 516d8b72f6
2 changed files with 17 additions and 11 deletions

View File

@ -1,4 +1,4 @@
// Copyright Daniel Wallin 2007. Use, modification and distribution is
// Copyright Daniel Wallin, Arvid Norberg 2007. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -6,6 +6,8 @@
#include <libtorrent/entry.hpp>
#include <libtorrent/peer_request.hpp>
#include <libtorrent/peer_connection.hpp>
#include <libtorrent/extensions/ut_pex.hpp>
#include <libtorrent/extensions/metadata_transfer.hpp>
#include <boost/python.hpp>
#include "gil.hpp"
@ -139,5 +141,8 @@ void bind_extensions()
// TODO move to it's own file
class_<peer_connection, boost::noncopyable>("peer_connection", no_init);
def("create_ut_pex_plugin", create_ut_pex_plugin);
def("create_metadata_plugin", create_metadata_plugin);
}

View File

@ -1,9 +1,10 @@
// Copyright Daniel Wallin 2006. Use, modification and distribution is
// Copyright Daniel Wallin, Arvid Norberg 2006. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <libtorrent/session.hpp>
#include <libtorrent/torrent.hpp>
#include <libtorrent/storage.hpp>
#include <boost/python.hpp>
#include "gil.hpp"
@ -75,6 +76,14 @@ namespace
s.add_extension(invoke_extension_factory(e));
}
torrent_handle add_torrent(session& s, torrent_info const& ti
, boost::filesystem::path const& save, entry const& resume
, bool compact, int block_size)
{
return s.add_torrent(ti, save, resume, compact, block_size
, default_storage_constructor);
}
} // namespace unnamed
void bind_session()
@ -136,14 +145,6 @@ void bind_session()
#endif
;
torrent_handle (session::*add_torrent0)(
torrent_info const&
, boost::filesystem::path const&
, entry const&
, bool
, int
) = &session::add_torrent;
class_<session, boost::noncopyable>("session", session_doc, no_init)
.def(
init<fingerprint>(arg("fingerprint")=fingerprint("LT",0,1,0,0), session_init_doc)
@ -162,7 +163,7 @@ void bind_session()
.def("dht_state", allow_threads(&session::dht_state), session_dht_state_doc)
#endif
.def(
"add_torrent", allow_threads(add_torrent0)
"add_torrent", &add_torrent
, (
arg("torrent_info"), "save_path", arg("resume_data") = entry()
, arg("compact_mode") = true, arg("block_size") = 16 * 1024