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))

View File

@ -1964,7 +1964,7 @@ Its declaration looks like this::
bool resolve_countries() const;
enum deadline_flags { alert_when_available = 1 };
void set_piece_deadline(int index, time_duration deadline, int flags = 0) const;
void set_piece_deadline(int index, int deadline, int flags = 0) const;
void piece_availability(std::vector<int>& avail) const;
void piece_priority(int index, int priority) const;
@ -2021,7 +2021,7 @@ set_piece_deadline()
::
enum deadline_flags { alert_when_available = 1 };
void set_piece_deadline(int index, time_duration deadline, int flags = 0) const;
void set_piece_deadline(int index, int deadline, int flags = 0) const;
This function sets or resets the deadline associated with a specific piece
index (``index``). libtorrent will attempt to download this entire piece before
@ -2038,8 +2038,7 @@ If the piece is already downloaded when this call is made, nothing happens, unle
the ``alert_when_available`` flag is set, in which case it will do the same thing
as calling `read_piece()`_ for ``index``.
In the python binding for this function, the ``deadline`` is the number of milliseconds
as an integer.
``deadline`` is the number of milliseconds until this piece should be completed.
piece_availability()

View File

@ -278,7 +278,7 @@ namespace libtorrent
void prioritize_files(std::vector<int> const& files);
void file_priorities(std::vector<int>&) const;
void set_piece_deadline(int piece, time_duration t, int flags);
void set_piece_deadline(int piece, int t, int flags);
void update_piece_priorities();
torrent_status status() const;

View File

@ -394,7 +394,7 @@ namespace libtorrent
void get_download_queue(std::vector<partial_piece_info>& queue) const;
enum deadline_flags { alert_when_available = 1 };
void set_piece_deadline(int index, time_duration deadline, int flags = 0) const;
void set_piece_deadline(int index, int deadline, int flags = 0) const;
void set_priority(int prio) const;

View File

@ -2402,9 +2402,9 @@ namespace libtorrent
return m_username + ":" + m_password;
}
void torrent::set_piece_deadline(int piece, time_duration t, int flags)
void torrent::set_piece_deadline(int piece, int t, int flags)
{
ptime deadline = time_now() + t;
ptime deadline = time_now() + milliseconds(t);
if (is_seed() || m_picker->have_piece(piece))
{

View File

@ -731,7 +731,7 @@ namespace libtorrent
TORRENT_FORWARD(get_download_queue(queue));
}
void torrent_handle::set_piece_deadline(int index, time_duration deadline, int flags) const
void torrent_handle::set_piece_deadline(int index, int deadline, int flags) const
{
INVARIANT_CHECK;
TORRENT_FORWARD(set_piece_deadline(index, deadline, flags));