diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index f34cf4b5d..3e188a3ce 100755 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -25,6 +25,8 @@ extern char const* peer_error_alert_doc; extern char const* invalid_request_alert_doc; extern char const* peer_request_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_received_alert_doc; extern char const* fastresume_rejected_alert_doc; @@ -140,7 +142,18 @@ void bind_alert() ) .def_readonly("handle", &torrent_finished_alert::handle) ; - + + class_, noncopyable>( + "torrent_paused_alert", torrent_paused_alert_doc, no_init + ) + .def_readonly("handle", &torrent_paused_alert::handle) + ; + + class_, noncopyable>( + "storage_moved_alert", storage_moved_alert_doc, no_init + ) + .def_readonly("handle", &storage_moved_alert::handle) + ; class_, noncopyable>( "metadata_failed_alert", metadata_failed_alert_doc, no_init ) diff --git a/bindings/python/src/docstrings.cpp b/bindings/python/src/docstrings.cpp index f51487a23..572387fb1 100755 --- a/bindings/python/src/docstrings.cpp +++ b/bindings/python/src/docstrings.cpp @@ -246,6 +246,17 @@ char const* torrent_finished_alert_doc = "It contains a `torrent_handle` to the torrent in question. This alert\n" "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 = "This alert is generated when the metadata has been completely\n" "received and the info-hash failed to match it. i.e. the\n" diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 9f7d530af..d004356a0 100755 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -80,11 +80,10 @@ namespace torrent_handle add_torrent(session& s, torrent_info const& ti , boost::filesystem::path const& save, entry const& resume - , bool compact, int block_size) + , bool compact, bool paused) { allow_threading_guard guard; - return s.add_torrent(ti, save, resume, compact, block_size - , default_storage_constructor); + return s.add_torrent(ti, save, resume, compact, paused, default_storage_constructor); } } // namespace unnamed @@ -169,7 +168,7 @@ void bind_session() "add_torrent", &add_torrent , ( 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 ) diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index 301c4a5bf..a17c449e3 100755 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -16,7 +16,6 @@ namespace return i.trackers().begin(); } - std::vector::const_iterator end_trackers(torrent_info& i) { return i.trackers().end(); @@ -41,6 +40,29 @@ namespace return result; } + std::vector::const_iterator begin_files(torrent_info& i, bool storage) + { + return i.begin_files(storage); + } + + std::vector::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 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 void bind_torrent_info() @@ -71,9 +93,9 @@ void bind_torrent_info() .def("hash_for_piece", &torrent_info::hash_for_piece, copy) .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("files", range(&torrent_info::begin_files, &torrent_info::end_files)) + .def("files", &files, (arg("storage")=false)) .def("priv", &torrent_info::priv) .def("set_priv", &torrent_info::set_priv) @@ -84,9 +106,8 @@ void bind_torrent_info() .def("add_node", &add_node) .def("nodes", &nodes) ; - class_("file_entry") - .add_property( + .add_property( "path" , make_getter( &file_entry::path, return_value_policy()