add load_state/save_state to python bindings and made them build

This commit is contained in:
Arvid Norberg
2009-12-05 07:24:22 +00:00
parent ff2063651b
commit a6ed83e7fe
8 changed files with 25 additions and 17 deletions

View File

@@ -4,6 +4,7 @@
#include <boost/python.hpp>
#include <libtorrent/extensions.hpp>
#include <libtorrent/torrent.hpp>
#include <libtorrent/entry.hpp>
#include <libtorrent/peer_request.hpp>
#include <libtorrent/peer_connection.hpp>

View File

@@ -159,6 +159,18 @@ namespace
return s.load_country_db(file.c_str());
}
#endif
entry save_state(session const& s)
{
entry e;
s.save_state(e);
return e;
}
void load_state(session& s, entry const& e)
{
s.load_state(e);
}
} // namespace unnamed
@@ -316,8 +328,8 @@ void bind_session()
.def("load_asnum_db", &load_asnum_db)
.def("load_country_db", &load_country_db)
#endif
.def("load_state", allow_threads(&session::load_state))
.def("state", allow_threads(&session::state))
.def("load_state", &load_state)
.def("save_state", &save_state)
#ifndef TORRENT_NO_DEPRECATE
.def("set_severity_level", allow_threads(&session::set_severity_level))
#endif

View File

@@ -5,6 +5,7 @@
#include <boost/python.hpp>
#include <boost/python/tuple.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/peer_info.hpp>
#include <boost/lexical_cast.hpp>
#include "gil.hpp"
@@ -274,11 +275,6 @@ void add_piece(torrent_handle& th, int piece, char const *data, int flags)
th.add_piece(piece, data, flags);
}
void set_piece_deadline(torrent_handle const& th, int index, int deadline_ms, int flags)
{
th.set_piece_deadline(index, milliseconds(deadline_ms), flags);
}
void bind_torrent_handle()
{
void (torrent_handle::*force_reannounce0)() const = &torrent_handle::force_reannounce;
@@ -342,7 +338,7 @@ void bind_torrent_handle()
#endif
.def("add_piece", add_piece)
.def("read_piece", _(&torrent_handle::read_piece))
.def("set_piece_deadline", &set_piece_deadline
.def("set_piece_deadline", _(&torrent_handle::set_piece_deadline)
, (arg("index"), arg("deadline"), arg("flags") = 0))
.def("piece_availability", &piece_availability)
.def("piece_priority", _(piece_priority0))