From e3e70d3412c5e4eff75e7cb5a3445eca6e032b03 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 5 Sep 2010 16:49:03 +0000 Subject: [PATCH] python bindings updates and build fixes --- bindings/python/src/session.cpp | 22 +++++++++++++++------- bindings/python/src/session_settings.cpp | 5 +++++ bindings/python/src/torrent_handle.cpp | 2 ++ bindings/python/src/torrent_info.cpp | 13 ++++++++++--- bindings/python/src/torrent_status.cpp | 5 +++++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 1355d4757..a698fa982 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -111,6 +111,10 @@ namespace p.duplicate_is_error = params["duplicate_is_error"]; if (params.has_key("seed_mode")) p.seed_mode = params["seed_mode"]; + if (params.has_key("upload_mode")) + p.upload_mode = params["upload_mode"]; + if (params.has_key("share_mode")) + p.upload_mode = params["share_mode"]; if (params.has_key("override_resume_data")) p.override_resume_data = params["override_resume_data"]; @@ -305,7 +309,7 @@ void bind_session() .def("dht_state", allow_threads(&session::dht_state)) #endif .def("set_dht_proxy", allow_threads(&session::set_dht_proxy)) - .def("dht_proxy", allow_threads(&session::dht_proxy), return_value_policy()) + .def("dht_proxy", allow_threads(&session::dht_proxy)) #endif .def("add_torrent", &add_torrent) #ifndef BOOST_NO_EXCEPTIONS @@ -339,10 +343,10 @@ void bind_session() .def("set_max_half_open_connections", allow_threads(&session::set_max_half_open_connections)) .def("num_connections", allow_threads(&session::num_connections)) .def("set_settings", allow_threads(&session::set_settings)) - .def("settings", allow_threads(&session::settings), return_value_policy()) + .def("settings", allow_threads(&session::settings)) #ifndef TORRENT_DISABLE_ENCRYPTION .def("set_pe_settings", allow_threads(&session::set_pe_settings)) - .def("get_pe_settings", allow_threads(&session::get_pe_settings), return_value_policy()) + .def("get_pe_settings", allow_threads(&session::get_pe_settings)) #endif #ifndef TORRENT_DISABLE_GEO_IP .def("load_asnum_db", &load_asnum_db) @@ -358,12 +362,16 @@ void bind_session() .def("pop_alert", allow_threads(&session::pop_alert)) .def("wait_for_alert", &wait_for_alert, return_internal_reference<>()) .def("add_extension", &add_extension) +#ifndef TORRENT_NO_DEPRECATE .def("set_peer_proxy", allow_threads(&session::set_peer_proxy)) .def("set_tracker_proxy", allow_threads(&session::set_tracker_proxy)) .def("set_web_seed_proxy", allow_threads(&session::set_web_seed_proxy)) - .def("peer_proxy", allow_threads(&session::peer_proxy), return_value_policy()) - .def("tracker_proxy", allow_threads(&session::tracker_proxy), return_value_policy()) - .def("web_seed_proxy", allow_threads(&session::web_seed_proxy), return_value_policy()) + .def("peer_proxy", allow_threads(&session::peer_proxy)) + .def("tracker_proxy", allow_threads(&session::tracker_proxy)) + .def("web_seed_proxy", allow_threads(&session::web_seed_proxy)) +#endif + .def("set_proxy", allow_threads(&session::set_proxy)) + .def("proxy", allow_threads(&session::proxy)) .def("start_upnp", &start_upnp) .def("stop_upnp", allow_threads(&session::stop_upnp)) .def("start_lsd", allow_threads(&session::start_lsd)) @@ -371,7 +379,7 @@ void bind_session() .def("start_natpmp", &start_natpmp) .def("stop_natpmp", allow_threads(&session::stop_natpmp)) .def("set_ip_filter", allow_threads(&session::set_ip_filter)) - .def("get_ip_filter", allow_threads(&session::get_ip_filter), return_value_policy()) + .def("get_ip_filter", allow_threads(&session::get_ip_filter)) .def("find_torrent", allow_threads(&session::find_torrent)) .def("get_torrents", &get_torrents) .def("pause", allow_threads(&session::pause)) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index cb56ea6a7..7d730c8ea 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -127,6 +127,11 @@ void bind_session_settings() .def_readwrite("report_true_downoaded", &session_settings::report_true_downloaded) .def_readwrite("strict_end_game_mode", &session_settings::strict_end_game_mode) .def_readwrite("broadcast_lsd", &session_settings::broadcast_lsd) + .def_readwrite("ignore_resume_timestamps", &session_settings::ignore_resume_timestamps) + .def_readwrite("anonymous_mode", &session_settings::anonymous_mode) + .def_readwrite("tick_interval", &session_settings::tick_interval) + .def_readwrite("report_web_seed_downloads", &session_settings::report_web_seed_downloads) + .def_readwrite("share_mode_target", &session_settings::share_mode_target) ; enum_("proxy_type") diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index a06825cb5..6aec7a05e 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -341,6 +341,8 @@ void bind_torrent_handle() .def("force_dht_announce", _(&torrent_handle::force_dht_announce)) .def("scrape_tracker", _(&torrent_handle::scrape_tracker)) .def("name", _(&torrent_handle::name)) + .def("set_upload_mode", _(&torrent_handle::set_upload_mode)) + .def("set_share_mode", _(&torrent_handle::set_share_mode)) .def("set_upload_limit", _(&torrent_handle::set_upload_limit)) .def("upload_limit", _(&torrent_handle::upload_limit)) .def("set_download_limit", _(&torrent_handle::set_download_limit)) diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index be43aed85..bbca0a214 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -168,8 +168,7 @@ void bind_torrent_info() ; class_("file_entry") - .add_property( - "path" + .add_property("path" , make_getter( &file_entry::path, return_value_policy() ) @@ -181,7 +180,7 @@ void bind_torrent_info() class_("announce_entry", init()) .def_readwrite("url", &announce_entry::url) - .def_readwrite("tier", &get_tier) + .add_property("tier", &get_tier) .add_property("fail_limit", &get_fail_limit) .add_property("fails", &get_fails) .add_property("source", &get_source) @@ -197,4 +196,12 @@ void bind_torrent_info() .def("is_working", &announce_entry::is_working) .def("trim", &announce_entry::trim) ; + + enum_("tracker_source") + .value("source_torrent", announce_entry::source_torrent) + .value("source_client", announce_entry::source_client) + .value("source_magnet_link", announce_entry::source_magnet_link) + .value("source_tex", announce_entry::source_tex) + ; } + diff --git a/bindings/python/src/torrent_status.cpp b/bindings/python/src/torrent_status.cpp index 92d2fbb64..f26a6b02c 100644 --- a/bindings/python/src/torrent_status.cpp +++ b/bindings/python/src/torrent_status.cpp @@ -78,6 +78,11 @@ void bind_torrent_status() .def_readonly("seeding_time", &torrent_status::seeding_time) .def_readonly("seed_rank", &torrent_status::seed_rank) .def_readonly("last_scrape", &torrent_status::last_scrape) + .def_readonly("has_incoming", &torrent_status::has_incoming) + .def_readonly("sparse_regions", &torrent_status::sparse_regions) + .def_readonly("seed_mode", &torrent_status::seed_mode) + .def_readonly("upload_mode", &torrent_status::upload_mode) + .def_readonly("share_mode", &torrent_status::share_mode) .def_readonly("error", &torrent_status::error) .def_readonly("priority", &torrent_status::priority) ;