updated python bindings
This commit is contained in:
@@ -25,6 +25,8 @@ extern char const* peer_error_alert_doc;
|
|||||||
extern char const* invalid_request_alert_doc;
|
extern char const* invalid_request_alert_doc;
|
||||||
extern char const* peer_request_doc;
|
extern char const* peer_request_doc;
|
||||||
extern char const* torrent_finished_alert_doc;
|
extern char const* torrent_finished_alert_doc;
|
||||||
|
extern char const* torrent_paused_alert_doc;
|
||||||
|
extern char const* storage_moved_alert_doc;
|
||||||
extern char const* metadata_failed_alert_doc;
|
extern char const* metadata_failed_alert_doc;
|
||||||
extern char const* metadata_received_alert_doc;
|
extern char const* metadata_received_alert_doc;
|
||||||
extern char const* fastresume_rejected_alert_doc;
|
extern char const* fastresume_rejected_alert_doc;
|
||||||
@@ -140,7 +142,18 @@ void bind_alert()
|
|||||||
)
|
)
|
||||||
.def_readonly("handle", &torrent_finished_alert::handle)
|
.def_readonly("handle", &torrent_finished_alert::handle)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
class_<torrent_paused_alert, bases<alert>, noncopyable>(
|
||||||
|
"torrent_paused_alert", torrent_paused_alert_doc, no_init
|
||||||
|
)
|
||||||
|
.def_readonly("handle", &torrent_paused_alert::handle)
|
||||||
|
;
|
||||||
|
|
||||||
|
class_<storage_moved_alert, bases<alert>, noncopyable>(
|
||||||
|
"storage_moved_alert", storage_moved_alert_doc, no_init
|
||||||
|
)
|
||||||
|
.def_readonly("handle", &storage_moved_alert::handle)
|
||||||
|
;
|
||||||
class_<metadata_failed_alert, bases<alert>, noncopyable>(
|
class_<metadata_failed_alert, bases<alert>, noncopyable>(
|
||||||
"metadata_failed_alert", metadata_failed_alert_doc, no_init
|
"metadata_failed_alert", metadata_failed_alert_doc, no_init
|
||||||
)
|
)
|
||||||
|
@@ -246,6 +246,17 @@ char const* torrent_finished_alert_doc =
|
|||||||
"It contains a `torrent_handle` to the torrent in question. This alert\n"
|
"It contains a `torrent_handle` to the torrent in question. This alert\n"
|
||||||
"is generated as severity level `alert.severity_levels.info`.";
|
"is generated as severity level `alert.severity_levels.info`.";
|
||||||
|
|
||||||
|
char const* torrent_paused_alert_doc =
|
||||||
|
"This alert is generated when a torrent switches from being a\n"
|
||||||
|
"active to paused.\n"
|
||||||
|
"It contains a `torrent_handle` to the torrent in question. This alert\n"
|
||||||
|
"is generated as severity level `alert.severity_levels.warning`.";
|
||||||
|
|
||||||
|
char const* storage_moved_alert_doc =
|
||||||
|
"This alert is generated when a torrent moves storage.\n"
|
||||||
|
"It contains a `torrent_handle` to the torrent in question. This alert\n"
|
||||||
|
"is generated as severity level `alert.severity_levels.warning`.";
|
||||||
|
|
||||||
char const* metadata_failed_alert_doc =
|
char const* metadata_failed_alert_doc =
|
||||||
"This alert is generated when the metadata has been completely\n"
|
"This alert is generated when the metadata has been completely\n"
|
||||||
"received and the info-hash failed to match it. i.e. the\n"
|
"received and the info-hash failed to match it. i.e. the\n"
|
||||||
|
@@ -80,11 +80,10 @@ namespace
|
|||||||
|
|
||||||
torrent_handle add_torrent(session& s, torrent_info const& ti
|
torrent_handle add_torrent(session& s, torrent_info const& ti
|
||||||
, boost::filesystem::path const& save, entry const& resume
|
, boost::filesystem::path const& save, entry const& resume
|
||||||
, bool compact, int block_size)
|
, bool compact, bool paused)
|
||||||
{
|
{
|
||||||
allow_threading_guard guard;
|
allow_threading_guard guard;
|
||||||
return s.add_torrent(ti, save, resume, compact, block_size
|
return s.add_torrent(ti, save, resume, compact, paused, default_storage_constructor);
|
||||||
, default_storage_constructor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unnamed
|
} // namespace unnamed
|
||||||
@@ -169,7 +168,7 @@ void bind_session()
|
|||||||
"add_torrent", &add_torrent
|
"add_torrent", &add_torrent
|
||||||
, (
|
, (
|
||||||
arg("torrent_info"), "save_path", arg("resume_data") = entry()
|
arg("torrent_info"), "save_path", arg("resume_data") = entry()
|
||||||
, arg("compact_mode") = true, arg("block_size") = 16 * 1024
|
, arg("compact_mode") = true, arg("paused") = false
|
||||||
)
|
)
|
||||||
, session_add_torrent_doc
|
, session_add_torrent_doc
|
||||||
)
|
)
|
||||||
|
@@ -16,7 +16,6 @@ namespace
|
|||||||
return i.trackers().begin();
|
return i.trackers().begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<announce_entry>::const_iterator end_trackers(torrent_info& i)
|
std::vector<announce_entry>::const_iterator end_trackers(torrent_info& i)
|
||||||
{
|
{
|
||||||
return i.trackers().end();
|
return i.trackers().end();
|
||||||
@@ -41,6 +40,29 @@ namespace
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<file_entry>::const_iterator begin_files(torrent_info& i, bool storage)
|
||||||
|
{
|
||||||
|
return i.begin_files(storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<file_entry>::const_iterator end_files(torrent_info& i, bool storage)
|
||||||
|
{
|
||||||
|
return i.end_files(storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//list files(torrent_info const& ti, bool storage) {
|
||||||
|
list files(torrent_info const& ti, bool storage) {
|
||||||
|
list result;
|
||||||
|
|
||||||
|
typedef std::vector<file_entry> list_type;
|
||||||
|
|
||||||
|
for (list_type::const_iterator i = ti.begin_files(storage); i != ti.end_files(storage); ++i)
|
||||||
|
result.append(*i);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace unnamed
|
} // namespace unnamed
|
||||||
|
|
||||||
void bind_torrent_info()
|
void bind_torrent_info()
|
||||||
@@ -71,9 +93,9 @@ void bind_torrent_info()
|
|||||||
.def("hash_for_piece", &torrent_info::hash_for_piece, copy)
|
.def("hash_for_piece", &torrent_info::hash_for_piece, copy)
|
||||||
.def("piece_size", &torrent_info::piece_size)
|
.def("piece_size", &torrent_info::piece_size)
|
||||||
|
|
||||||
.def("num_files", &torrent_info::num_files)
|
.def("num_files", &torrent_info::num_files, (arg("storage")=false))
|
||||||
.def("file_at", &torrent_info::file_at, return_internal_reference<>())
|
.def("file_at", &torrent_info::file_at, return_internal_reference<>())
|
||||||
.def("files", range(&torrent_info::begin_files, &torrent_info::end_files))
|
.def("files", &files, (arg("storage")=false))
|
||||||
|
|
||||||
.def("priv", &torrent_info::priv)
|
.def("priv", &torrent_info::priv)
|
||||||
.def("set_priv", &torrent_info::set_priv)
|
.def("set_priv", &torrent_info::set_priv)
|
||||||
@@ -84,9 +106,8 @@ void bind_torrent_info()
|
|||||||
.def("add_node", &add_node)
|
.def("add_node", &add_node)
|
||||||
.def("nodes", &nodes)
|
.def("nodes", &nodes)
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<file_entry>("file_entry")
|
class_<file_entry>("file_entry")
|
||||||
.add_property(
|
.add_property(
|
||||||
"path"
|
"path"
|
||||||
, make_getter(
|
, make_getter(
|
||||||
&file_entry::path, return_value_policy<copy_non_const_reference>()
|
&file_entry::path, return_value_policy<copy_non_const_reference>()
|
||||||
|
Reference in New Issue
Block a user