From e9dd8ce0501784de7a356bda038abfd68ea2e1c5 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 28 Oct 2008 06:29:30 +0000 Subject: [PATCH] Fix building bindings when TORRENT_NO_DEPRECATE is defined Add 'performance_alert' to the bindings --- bindings/python/src/alert.cpp | 82 +++++++++++++++----------- bindings/python/src/session.cpp | 28 ++++----- bindings/python/src/torrent_handle.cpp | 18 +++--- bindings/python/src/torrent_info.cpp | 14 +++-- 4 files changed, 82 insertions(+), 60 deletions(-) diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 1772bf8be..1fcb724c8 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -56,7 +56,9 @@ void bind_alert() .def("message", &alert::message, alert_msg_doc) .def("what", &alert::what) .def("category", &alert::category) +#ifndef TORRENT_NO_DEPRECATE .def("severity", &alert::severity, alert_severity_doc) +#endif .def("__str__", &alert::message, alert_msg_doc) ; @@ -67,7 +69,7 @@ void bind_alert() .value("critical", alert::critical) .value("fatal", alert::fatal) .value("none", alert::none) - ; + ; enum_("category_t") .value("error_notification", alert::error_notification) @@ -79,8 +81,10 @@ void bind_alert() .value("status_notification", alert::status_notification) .value("progress_notification", alert::progress_notification) .value("ip_block_notification", alert::ip_block_notification) + .value("performance_warning", alert::performance_warning) .value("all_categories", alert::all_categories) - ; + ; + } class_, noncopyable>( @@ -153,20 +157,20 @@ void bind_alert() class_, noncopyable>( "torrent_finished_alert", torrent_finished_alert_doc, no_init ); - + class_, noncopyable>( "piece_finished_alert", piece_finished_alert_doc, no_init ) .def_readonly("piece_index", &piece_finished_alert::piece_index) ; - + class_, noncopyable>( "block_finished_alert", block_finished_alert_doc, no_init ) .def_readonly("block_index", &block_finished_alert::block_index) .def_readonly("piece_index", &block_finished_alert::piece_index) ; - + class_, noncopyable>( "block_downloading_alert", block_downloading_alert_doc, no_init ) @@ -174,7 +178,7 @@ void bind_alert() .def_readonly("block_index", &block_downloading_alert::block_index) .def_readonly("piece_index", &block_downloading_alert::piece_index) ; - + class_, noncopyable>( "storage_moved_alert", storage_moved_alert_doc, no_init ); @@ -182,7 +186,7 @@ void bind_alert() class_, noncopyable>( "torrent_deleted_alert", torrent_deleted_alert_doc, no_init ); - + class_, noncopyable>( "torrent_paused_alert", torrent_paused_alert_doc, no_init ); @@ -190,19 +194,19 @@ void bind_alert() class_, noncopyable>( "torrent_checked_alert", torrent_checked_alert_doc, no_init ); - + class_, noncopyable>( "url_seed_alert", url_seed_alert_doc, no_init ) .def_readonly("url", &url_seed_alert::url) ; - + class_, noncopyable>( "file_error_alert", file_error_alert_doc, no_init ) .def_readonly("file", &file_error_alert::file) ; - + class_, noncopyable>( "metadata_failed_alert", metadata_failed_alert_doc, no_init ); @@ -214,20 +218,20 @@ void bind_alert() class_, noncopyable>( "listen_failed_alert", listen_failed_alert_doc, no_init ); - + class_, noncopyable>( "listen_succeeded_alert", listen_succeeded_alert_doc, no_init ) .def_readonly("endpoint", &listen_succeeded_alert::endpoint) ; - + class_, noncopyable>( "portmap_error_alert", portmap_error_alert_doc, no_init ) .def_readonly("mapping", &portmap_error_alert::mapping) .def_readonly("type", &portmap_error_alert::type) ; - + class_, noncopyable>( "portmap_alert", portmap_alert_doc, no_init ) @@ -235,34 +239,34 @@ void bind_alert() .def_readonly("external_port", &portmap_alert::external_port) .def_readonly("type", &portmap_alert::type) ; - + class_, noncopyable>( "fastresume_rejected_alert", fastresume_rejected_alert_doc, no_init ); - + class_, noncopyable>( "peer_blocked_alert", peer_blocked_alert_doc, no_init ) .def_readonly("ip", &peer_blocked_alert::ip) ; - + class_, noncopyable>( "scrape_reply_alert", scrape_reply_alert_doc, no_init ) .def_readonly("incomplete", &scrape_reply_alert::incomplete) .def_readonly("complete", &scrape_reply_alert::complete) ; - + class_, noncopyable>( "scrape_failed_alert", scrape_failed_alert_doc, no_init ); - + class_, noncopyable>( "udp_error_alert", udp_error_alert_doc, no_init ) .def_readonly("endpoint", &udp_error_alert::endpoint) ; - + class_, noncopyable>( "external_ip_alert", external_ip_alert_doc, no_init ) @@ -288,11 +292,11 @@ void bind_alert() .def_readonly("index", &file_rename_failed_alert::index) .def_readonly("msg", &file_rename_failed_alert::msg) ; - - class_, noncopyable>( - "torrent_resumed_alert", no_init + + class_, noncopyable>( + "torrent_resumed_alert", no_init ); - + class_, noncopyable>( "state_changed_alert", no_init ) @@ -304,50 +308,62 @@ void bind_alert() ) .def_readonly("num_peers", &dht_reply_alert::num_peers) ; - + class_, noncopyable>( "peer_unsnubbed_alert", no_init ); - + class_, noncopyable>( "peer_snubbed_alert", no_init ); - + class_, noncopyable>( "peer_connect_alert", no_init ); - + class_, noncopyable>( "peer_disconnected_alert", no_init ); - + class_, noncopyable>( "request_dropped_alert", no_init ) .def_readonly("block_index", &request_dropped_alert::block_index) .def_readonly("piece_index", &request_dropped_alert::piece_index) ; - + class_, noncopyable>( "block_timeout_alert", no_init ) .def_readonly("block_index", &block_timeout_alert::block_index) .def_readonly("piece_index", &block_timeout_alert::piece_index) ; - + class_, noncopyable>( "unwanted_block_alert", no_init ) .def_readonly("block_index", &unwanted_block_alert::block_index) .def_readonly("piece_index", &unwanted_block_alert::piece_index) ; - + class_, noncopyable>( "torrent_delete_failed_alert", no_init ); - + class_, noncopyable>( "save_resume_data_failed_alert", no_init ); - + + class_, noncopyable>( + "performance_alert", no_init + ) + .def_readonly("warning_code", &performance_alert::warning_code) + ; + enum_("performance_warning_t") + .value("outstanding_disk_buffer_limit_reached", performance_alert::outstanding_disk_buffer_limit_reached) + .value("outstanding_request_limit_reached", performance_alert::outstanding_request_limit_reached) + ; + + + } diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index b1b675b74..9202079de 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -49,7 +49,7 @@ extern char const* session_set_max_half_open_connections_doc; extern char const* session_num_connections_doc; extern char const* session_set_settings_doc; extern char const* session_set_pe_settings_doc; -extern char const* session_get_pe_settings_doc; +extern char const* session_get_pe_settings_doc; extern char const* session_set_severity_level_doc; extern char const* session_pop_alert_doc; extern char const* session_start_upnp_doc; @@ -106,11 +106,11 @@ namespace } #ifndef TORRENT_NO_DEPRECATE - torrent_handle add_torrent_depr(session& s, torrent_info const& ti - , boost::filesystem::path const& save, entry const& resume - , storage_mode_t storage_mode, bool paused) + torrent_handle add_torrent_depr(session& s, torrent_info const& ti + , boost::filesystem::path const& save, entry const& resume + , storage_mode_t storage_mode, bool paused) { - allow_threading_guard guard; + allow_threading_guard guard; return s.add_torrent(ti, save, resume, storage_mode, paused, default_storage_constructor); } #endif @@ -183,7 +183,7 @@ namespace } return ret; } - + #ifndef TORRENT_DISABLE_GEO_IP bool load_asnum_db(session& s, std::string file) { @@ -273,7 +273,7 @@ void bind_session() .value("add_default_plugins", session::add_default_plugins) .value("start_default_features", session::start_default_features) ; - + class_("session", session_doc, no_init) .def( init(( @@ -305,11 +305,11 @@ void bind_session() #ifndef TORRENT_NO_DEPRECATE .def( "add_torrent", &add_torrent_depr - , ( - arg("resume_data") = entry(), arg("storage_mode") = storage_mode_sparse, - arg("paused") = false - ) - , session_add_torrent_doc + , ( + arg("resume_data") = entry(), arg("storage_mode") = storage_mode_sparse, + arg("paused") = false + ) + , session_add_torrent_doc ) #endif .def("remove_torrent", allow_threads(&session::remove_torrent), arg("option") = session::none @@ -361,10 +361,12 @@ void bind_session() #endif .def("load_state", allow_threads(&session::load_state)) .def("state", allow_threads(&session::state)) +#ifndef TORRENT_NO_DEPRECATE .def( "set_severity_level", allow_threads(&session::set_severity_level) , session_set_severity_level_doc ) +#endif .def("set_alert_mask", allow_threads(&session::set_alert_mask)) .def("pop_alert", allow_threads(&session::pop_alert), session_pop_alert_doc) .def("add_extension", &add_extension) @@ -387,5 +389,3 @@ void bind_session() register_ptr_to_python >(); } - - diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index a4f1953e2..588173cee 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -152,10 +152,10 @@ list file_priorities(torrent_handle& handle) { list ret; std::vector priorities = handle.file_priorities(); - + for (std::vector::iterator i = priorities.begin(); i != priorities.end(); ++i) ret.append(*i); - + return ret; } @@ -253,7 +253,7 @@ void bind_torrent_handle() int (torrent_handle::*piece_priority0)(int) const = &torrent_handle::piece_priority; void (torrent_handle::*piece_priority1)(int, int) const = &torrent_handle::piece_priority; -#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES bool (torrent_handle::*resolve_countries0)() const = &torrent_handle::resolve_countries; void (torrent_handle::*resolve_countries1)(bool) = &torrent_handle::resolve_countries; #endif @@ -281,7 +281,7 @@ void bind_torrent_handle() .def("pause", _(&torrent_handle::pause)) .def("resume", _(&torrent_handle::resume)) .def("clear_error", _(&torrent_handle::clear_error)) - + .def("is_auto_managed", _(&torrent_handle::is_auto_managed)) .def("auto_managed", _(&torrent_handle::auto_managed)) .def("queue_position", _(&torrent_handle::queue_position)) @@ -289,15 +289,17 @@ void bind_torrent_handle() .def("queue_position_down", _(&torrent_handle::queue_position_down)) .def("queue_position_top", _(&torrent_handle::queue_position_top)) .def("queue_position_bottom", _(&torrent_handle::queue_position_bottom)) - -#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES + +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES .def("resolve_countries", _(resolve_countries0)) .def("resolve_countries", _(resolve_countries1)) #endif // deprecated +#ifndef TORRENT_NO_DEPRECATE .def("filter_piece", _(&torrent_handle::filter_piece)) .def("is_piece_filtered", _(&torrent_handle::is_piece_filtered)) - + .def("write_resume_data", _(&torrent_handle::write_resume_data)) +#endif .def("piece_availability", piece_availability) .def("piece_priority", _(piece_priority0)) .def("piece_priority", _(piece_priority1)) @@ -306,7 +308,6 @@ void bind_torrent_handle() .def("prioritize_files", prioritize_files) .def("file_priorities", file_priorities) .def("use_interface", &torrent_handle::use_interface) - .def("write_resume_data", _(&torrent_handle::write_resume_data)) .def("save_resume_data", _(&torrent_handle::save_resume_data)) .def("force_reannounce", _(force_reannounce0)) .def("force_reannounce", force_reannounce) @@ -331,4 +332,3 @@ void bind_torrent_handle() .def("rename_file", _(&torrent_handle::rename_file)) ; } - diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index a3c95f313..a373b091c 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -67,6 +67,10 @@ namespace std::string result(ti.metadata().get(), ti.metadata_size()); return result; } + + torrent_info construct0(std::string path) { + return torrent_info(fs::path(path)); + } } // namespace unnamed void bind_torrent_info() @@ -74,10 +78,13 @@ void bind_torrent_info() return_value_policy copy; class_ >("torrent_info", no_init) +#ifndef TORRENT_NO_DEPRECATE .def(init()) +#endif .def(init()) .def(init()) - + .def(init()) + .def("add_tracker", &torrent_info::add_tracker, (arg("url"), arg("tier")=0)) .def("add_url_seed", &torrent_info::add_url_seed) @@ -87,8 +94,9 @@ void bind_torrent_info() .def("total_size", &torrent_info::total_size) .def("piece_length", &torrent_info::piece_length) .def("num_pieces", &torrent_info::num_pieces) +#ifndef TORRENT_NO_DEPRECATE .def("info_hash", &torrent_info::info_hash, copy) - +#endif .def("hash_for_piece", &torrent_info::hash_for_piece) .def("piece_size", &torrent_info::piece_size) @@ -123,5 +131,3 @@ void bind_torrent_info() .def_readwrite("tier", &announce_entry::tier) ; } - -