From 9c2472f7bbc35a33c5edda8e7d4dfab320dc663c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 5 Oct 2014 19:32:29 +0000 Subject: [PATCH] fix build with deprecated functions disabled --- bindings/python/src/peer_info.cpp | 2 + bindings/python/src/session.cpp | 112 ++++++++++------------- bindings/python/src/session_settings.cpp | 89 ++++++++++-------- examples/client_test.cpp | 30 +----- include/libtorrent/session_settings.hpp | 3 + include/libtorrent/settings_pack.hpp | 2 +- 6 files changed, 109 insertions(+), 129 deletions(-) diff --git a/bindings/python/src/peer_info.cpp b/bindings/python/src/peer_info.cpp index 5beacc2e8..3894b057c 100644 --- a/bindings/python/src/peer_info.cpp +++ b/bindings/python/src/peer_info.cpp @@ -124,7 +124,9 @@ void bind_peer_info() pi.attr("local_connection") = (int)peer_info::local_connection; pi.attr("handshake") = (int)peer_info::handshake; pi.attr("connecting") = (int)peer_info::connecting; +#ifndef TORRENT_NO_DEPRECATE pi.attr("queued") = (int)peer_info::queued; +#endif pi.attr("on_parole") = (int)peer_info::on_parole; pi.attr("seed") = (int)peer_info::seed; pi.attr("optimistic_unchoke") = (int)peer_info::optimistic_unchoke; diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index fcf4a2d5c..9a6910198 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -441,20 +441,9 @@ namespace } return pieces; } -#endif -#ifndef TORRENT_DISABLE_GEO_IP - void load_asnum_db(lt::session& s, std::string file) - { - allow_threading_guard guard; - s.load_asnum_db(file.c_str()); - } - - void load_country_db(lt::session& s, std::string file) - { - allow_threading_guard guard; - s.load_country_db(file.c_str()); - } + void load_asnum_db(lt::session& s, std::string file) {} + void load_country_db(lt::session& s, std::string file) {} #endif entry save_state(lt::session const& s, boost::uint32_t flags) @@ -615,12 +604,12 @@ void bind_session() .value("flag_use_resume_save_path", add_torrent_params::flag_use_resume_save_path) ; class_("cache_status") +#ifndef TORRENT_NO_DEPRECATE .def_readonly("blocks_written", &cache_status::blocks_written) .def_readonly("writes", &cache_status::writes) .def_readonly("blocks_read", &cache_status::blocks_read) .def_readonly("blocks_read_hit", &cache_status::blocks_read_hit) .def_readonly("reads", &cache_status::reads) -#ifndef TORRENT_NO_DEPRECATE .def_readonly("queued_bytes", &cache_status::queued_bytes) .def_readonly("cache_size", &cache_status::cache_size) #endif @@ -628,6 +617,7 @@ void bind_session() .def_readonly("read_cache_size", &cache_status::read_cache_size) .def_readonly("pinned_blocks", &cache_status::pinned_blocks) .def_readonly("total_used_buffers", &cache_status::total_used_buffers) +#ifndef TORRENT_NO_DEPRECATE .def_readonly("average_read_time", &cache_status::average_read_time) .def_readonly("average_write_time", &cache_status::average_write_time) .def_readonly("average_hash_time", &cache_status::average_hash_time) @@ -637,6 +627,7 @@ void bind_session() .def_readonly("cumulative_write_time", &cache_status::cumulative_write_time) .def_readonly("cumulative_hash_time", &cache_status::cumulative_hash_time) .def_readonly("total_read_back", &cache_status::total_read_back) +#endif .def_readonly("read_queue_size", &cache_status::read_queue_size) .def_readonly("blocked_jobs", &cache_status::blocked_jobs) .def_readonly("queued_jobs", &cache_status::queued_jobs) @@ -665,12 +656,6 @@ void bind_session() , arg("alert_mask")=alert::error_notification)) ) .def("post_torrent_updates", allow_threads(<::session::post_torrent_updates)) -#ifndef TORRENT_NO_DEPRECATE - .def( - "listen_on", &listen_on - , (arg("min"), "max", arg("interface") = (char const*)0, arg("flags") = 0) - ) -#endif .def("outgoing_ports", &outgoing_ports) .def("is_listening", allow_threads(<::session::is_listening)) .def("listen_port", allow_threads(<::session::listen_port)) @@ -683,14 +668,6 @@ void bind_session() ) .def("is_dht_running", allow_threads(<::session::is_dht_running)) .def("set_dht_settings", allow_threads(<::session::set_dht_settings)) -#ifndef TORRENT_NO_DEPRECATE - .def("start_dht", allow_threads(start_dht0)) - .def("stop_dht", allow_threads(<::session::stop_dht)) - .def("start_dht", allow_threads(start_dht1)) - .def("dht_state", allow_threads(<::session::dht_state)) - .def("set_dht_proxy", allow_threads(<::session::set_dht_proxy)) - .def("dht_proxy", allow_threads(<::session::dht_proxy)) -#endif #endif .def("add_torrent", &add_torrent) .def("async_add_torrent", &async_add_torrent) @@ -709,22 +686,6 @@ void bind_session() .def("add_feed", &add_feed) .def("remove_torrent", allow_threads(<::session::remove_torrent), arg("option") = 0) #ifndef TORRENT_NO_DEPRECATE - .def("set_local_download_rate_limit", allow_threads(<::session::set_local_download_rate_limit)) - .def("local_download_rate_limit", allow_threads(<::session::local_download_rate_limit)) - - .def("set_local_upload_rate_limit", allow_threads(<::session::set_local_upload_rate_limit)) - .def("local_upload_rate_limit", allow_threads(<::session::local_upload_rate_limit)) - - .def("set_download_rate_limit", allow_threads(<::session::set_download_rate_limit)) - .def("download_rate_limit", allow_threads(<::session::download_rate_limit)) - - .def("set_upload_rate_limit", allow_threads(<::session::set_upload_rate_limit)) - .def("upload_rate_limit", allow_threads(<::session::upload_rate_limit)) - - .def("set_max_uploads", allow_threads(<::session::set_max_uploads)) - .def("set_max_connections", allow_threads(<::session::set_max_connections)) - .def("max_connections", allow_threads(<::session::max_connections)) - .def("num_connections", allow_threads(<::session::num_connections)) .def("set_settings", <::session::set_settings) .def("settings", <::session::settings) .def("get_settings", &session_get_settings) @@ -733,40 +694,24 @@ void bind_session() .def("get_settings", &session_get_settings) #endif .def("set_settings", &session_set_settings) +#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_DISABLE_ENCRYPTION .def("set_pe_settings", allow_threads(<::session::set_pe_settings)) .def("get_pe_settings", allow_threads(<::session::get_pe_settings)) #endif -#ifndef TORRENT_DISABLE_GEO_IP - .def("load_asnum_db", &load_asnum_db) - .def("load_country_db", &load_country_db) #endif .def("load_state", &load_state) .def("save_state", &save_state, (arg("entry"), arg("flags") = 0xffffffff)) -#ifndef TORRENT_NO_DEPRECATE - .def("set_max_half_open_connections", allow_threads(<::session::set_max_half_open_connections)) - .def("set_severity_level", allow_threads(<::session::set_severity_level)) - .def("set_alert_queue_size_limit", allow_threads(<::session::set_alert_queue_size_limit)) - .def("set_alert_mask", allow_threads(<::session::set_alert_mask)) -#endif .def("pop_alert", &pop_alert) .def("pop_alerts", &pop_alerts) .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)) - .def("tracker_proxy", allow_threads(<::session::tracker_proxy)) - .def("web_seed_proxy", allow_threads(<::session::web_seed_proxy)) -#endif #if TORRENT_USE_I2P .def("set_i2p_proxy", allow_threads(<::session::set_i2p_proxy)) .def("i2p_proxy", allow_threads(<::session::i2p_proxy)) #endif - .def("set_proxy", allow_threads(<::session::set_proxy)) - .def("proxy", allow_threads(<::session::proxy)) +#endif .def("set_ip_filter", allow_threads(<::session::set_ip_filter)) .def("get_ip_filter", allow_threads(<::session::get_ip_filter)) .def("find_torrent", allow_threads(<::session::find_torrent)) @@ -776,7 +721,46 @@ void bind_session() .def("is_paused", allow_threads(<::session::is_paused)) .def("id", allow_threads(<::session::id)) .def("get_cache_info", &get_cache_info1, (arg("handle") = torrent_handle(), arg("flags") = 0)) + #ifndef TORRENT_NO_DEPRECATE + .def( + "listen_on", &listen_on + , (arg("min"), "max", arg("interface") = (char const*)0, arg("flags") = 0) + ) +#ifndef TORRENT_DISABLE_DHT + .def("start_dht", allow_threads(start_dht0)) + .def("stop_dht", allow_threads(<::session::stop_dht)) + .def("start_dht", allow_threads(start_dht1)) + .def("dht_state", allow_threads(<::session::dht_state)) + .def("set_dht_proxy", allow_threads(<::session::set_dht_proxy)) + .def("dht_proxy", allow_threads(<::session::dht_proxy)) +#endif + .def("set_local_download_rate_limit", allow_threads(<::session::set_local_download_rate_limit)) + .def("local_download_rate_limit", allow_threads(<::session::local_download_rate_limit)) + .def("set_local_upload_rate_limit", allow_threads(<::session::set_local_upload_rate_limit)) + .def("local_upload_rate_limit", allow_threads(<::session::local_upload_rate_limit)) + .def("set_download_rate_limit", allow_threads(<::session::set_download_rate_limit)) + .def("download_rate_limit", allow_threads(<::session::download_rate_limit)) + .def("set_upload_rate_limit", allow_threads(<::session::set_upload_rate_limit)) + .def("upload_rate_limit", allow_threads(<::session::upload_rate_limit)) + .def("set_max_uploads", allow_threads(<::session::set_max_uploads)) + .def("set_max_connections", allow_threads(<::session::set_max_connections)) + .def("max_connections", allow_threads(<::session::max_connections)) + .def("num_connections", allow_threads(<::session::num_connections)) + .def("load_asnum_db", &load_asnum_db) + .def("load_country_db", &load_country_db) + .def("set_max_half_open_connections", allow_threads(<::session::set_max_half_open_connections)) + .def("set_severity_level", allow_threads(<::session::set_severity_level)) + .def("set_alert_queue_size_limit", allow_threads(<::session::set_alert_queue_size_limit)) + .def("set_alert_mask", allow_threads(<::session::set_alert_mask)) + .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)) + .def("tracker_proxy", allow_threads(<::session::tracker_proxy)) + .def("web_seed_proxy", allow_threads(<::session::web_seed_proxy)) + .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)) @@ -793,11 +777,11 @@ void bind_session() .value("save_settings", lt::session::save_settings) .value("save_dht_settings", lt::session::save_dht_settings) .value("save_dht_state", lt::session::save_dht_state) - .value("save_i2p_proxy", lt::session::save_i2p_proxy) .value("save_encryption_settings", lt::session:: save_encryption_settings) .value("save_as_map", lt::session::save_as_map) - .value("save_proxy", lt::session::save_proxy) #ifndef TORRENT_NO_DEPRECATE + .value("save_i2p_proxy", lt::session::save_i2p_proxy) + .value("save_proxy", lt::session::save_proxy) .value("save_dht_proxy", lt::session::save_dht_proxy) .value("save_peer_proxy", lt::session::save_peer_proxy) .value("save_web_proxy", lt::session::save_web_proxy) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index 33f393ce1..7c000e251 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -146,7 +146,6 @@ void bind_session_settings() .def_readwrite("local_download_rate_limit", &session_settings::local_download_rate_limit) .def_readwrite("dht_upload_rate_limit", &session_settings::dht_upload_rate_limit) .def_readwrite("unchoke_slots_limit", &session_settings::unchoke_slots_limit) - .def_readwrite("half_open_limit", &session_settings::half_open_limit) .def_readwrite("connections_limit", &session_settings::connections_limit) .def_readwrite("utp_target_delay", &session_settings::utp_target_delay) .def_readwrite("utp_gain_factor", &session_settings::utp_gain_factor) @@ -155,9 +154,8 @@ void bind_session_settings() .def_readwrite("utp_fin_resends", &session_settings::utp_fin_resends) .def_readwrite("utp_num_resends", &session_settings::utp_num_resends) .def_readwrite("utp_connect_timeout", &session_settings::utp_connect_timeout) -#ifndef TORRENT_NO_DEPRECATE + .def_readwrite("half_open_limit", &session_settings::half_open_limit) .def_readwrite("utp_delayed_ack", &session_settings::utp_delayed_ack) -#endif .def_readwrite("utp_dynamic_sock_buf", &session_settings::utp_dynamic_sock_buf) .def_readwrite("utp_loss_multiplier", &session_settings::utp_loss_multiplier) .def_readwrite("mixed_mode_algorithm", &session_settings::mixed_mode_algorithm) @@ -195,38 +193,62 @@ void bind_session_settings() .value("largest_contiguous", session_settings::largest_contiguous) .value("avoid_readback", session_settings::avoid_readback) ; +#endif // TORRENT_NO_DEPRECATE - enum_("choking_algorithm_t") - .value("fixed_slots_choker", session_settings::fixed_slots_choker) - .value("auto_expand_choker", session_settings::auto_expand_choker) - .value("rate_based_choker", session_settings::rate_based_choker) - .value("bittyrant_choker", session_settings::bittyrant_choker) + enum_("choking_algorithm_t") + .value("fixed_slots_choker", settings_pack::fixed_slots_choker) + .value("auto_expand_choker", settings_pack::auto_expand_choker) + .value("rate_based_choker", settings_pack::rate_based_choker) + .value("bittyrant_choker", settings_pack::bittyrant_choker) ; - enum_("seed_choking_algorithm_t") - .value("round_robin", session_settings::round_robin) - .value("fastest_upload", session_settings::fastest_upload) - .value("anti_leech", session_settings::anti_leech) + enum_("seed_choking_algorithm_t") + .value("round_robin", settings_pack::round_robin) + .value("fastest_upload", settings_pack::fastest_upload) + .value("anti_leech", settings_pack::anti_leech) ; - enum_("suggest_mode_t") - .value("no_piece_suggestions", session_settings::no_piece_suggestions) - .value("suggest_read_cache", session_settings::suggest_read_cache) - ; - - enum_("io_buffer_mode_t") - .value("enable_os_cache", session_settings::enable_os_cache) - .value("disable_os_cache_for_aligned_files", session_settings::disable_os_cache_for_aligned_files) - .value("disable_os_cache", session_settings::disable_os_cache) - ; - - enum_("bandwidth_mixed_algo_t") - .value("prefer_tcp", session_settings::prefer_tcp) - .value("peer_proportional", session_settings::peer_proportional) + enum_("suggest_mode_t") + .value("no_piece_suggestions", settings_pack::no_piece_suggestions) + .value("suggest_read_cache", settings_pack::suggest_read_cache) ; + enum_("io_buffer_mode_t") + .value("enable_os_cache", settings_pack::enable_os_cache) +#ifndef TORRENT_NO_DEPRECATE + .value("disable_os_cache_for_aligned_files", settings_pack::disable_os_cache_for_aligned_files) #endif + .value("disable_os_cache", settings_pack::disable_os_cache) + ; + enum_("bandwidth_mixed_algo_t") + .value("prefer_tcp", settings_pack::prefer_tcp) + .value("peer_proportional", settings_pack::peer_proportional) + ; + + enum_("enc_policy") + .value("pe_forced", settings_pack::pe_forced) + .value("pe_enabled", settings_pack::pe_enabled) + .value("pe_disabled", settings_pack::pe_disabled) +#ifndef TORRENT_NO_DEPRECATE + .value("forced", settings_pack::pe_forced) + .value("enabled", settings_pack::pe_enabled) + .value("disabled", settings_pack::pe_disabled) +#endif + ; + + enum_("enc_level") + .value("pe_rc4", settings_pack::pe_rc4) + .value("pe_plaintext", settings_pack::pe_plaintext) + .value("pe_both", settings_pack::pe_both) +#ifndef TORRENT_NO_DEPRECATE + .value("rc4", settings_pack::pe_rc4) + .value("plaintext", settings_pack::pe_plaintext) + .value("both", settings_pack::pe_both) +#endif + ; + +#ifndef TORRENT_NO_DEPRECATE enum_("proxy_type") .value("none", proxy_settings::none) .value("socks4", proxy_settings::socks4) @@ -246,6 +268,7 @@ void bind_session_settings() .def_readwrite("proxy_peer_connections", &proxy_settings::proxy_peer_connections) .def_readwrite("proxy_hostnames", &proxy_settings::proxy_hostnames) ; +#endif #ifndef TORRENT_DISABLE_DHT class_("dht_settings") @@ -262,19 +285,7 @@ void bind_session_settings() ; #endif -#ifndef TORRENT_DISABLE_ENCRYPTION - enum_("enc_policy") - .value("forced", pe_settings::forced) - .value("enabled", pe_settings::enabled) - .value("disabled", pe_settings::disabled) - ; - - enum_("enc_level") - .value("rc4", pe_settings::rc4) - .value("plaintext", pe_settings::plaintext) - .value("both", pe_settings::both) - ; - +#ifndef TORRENT_NO_DEPRECATE class_("pe_settings") .def_readwrite("out_enc_policy", &pe_settings::out_enc_policy) .def_readwrite("in_enc_policy", &pe_settings::in_enc_policy) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 650309185..2250d2bc3 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -339,9 +339,6 @@ void print_peer_info(std::string& out, std::vector const& { using namespace libtorrent; if (print_ip) out += "IP "; -#ifndef TORRENT_DISABLE_GEO_IP - if (print_as) out += "AS "; -#endif out += "progress down (total | peak ) up (total | peak ) sent-req tmo bsy rcv flags dn up source "; if (print_fails) out += "fail hshf "; if (print_send_bufs) out += "rq sndb rcvb q-bytes "; @@ -358,7 +355,7 @@ void print_peer_info(std::string& out, std::vector const& for (std::vector::const_iterator i = peers.begin(); i != peers.end(); ++i) { - if (i->flags & (peer_info::handshake | peer_info::connecting | peer_info::queued)) + if (i->flags & (peer_info::handshake | peer_info::connecting)) continue; if (print_ip) @@ -370,15 +367,6 @@ void print_peer_info(std::string& out, std::vector const& out += str; } -#ifndef TORRENT_DISABLE_GEO_IP - if (print_as) - { - error_code ec; - snprintf(str, sizeof(str), "%-42s ", i->inet_as_name.c_str()); - out += str; - } -#endif - char temp[10]; snprintf(temp, sizeof(temp), "%d/%d" , i->download_queue_length @@ -509,13 +497,6 @@ void print_peer_info(std::string& out, std::vector const& out += esc("0"); out += "\n"; } - else if (i->flags & peer_info::queued) - { - out += esc("33"); - out += " queued"; - out += esc("0"); - out += "\n"; - } else { out += " "; @@ -1032,9 +1013,11 @@ int main(int argc, char* argv[]) " -^ Set the max number of active seeds\n" "\n NETWORK OPTIONS\n" " -p sets the listen port\n" +#ifndef TORRENT_NO_DEPRECATE " -o limits the number of simultaneous\n" " half-open TCP connections to the\n" " given number.\n" +#endif " -w sets the retry time for failed web seeds\n" " -x loads an emule IP-filter file\n" " -P Use the specified SOCKS5 proxy\n" @@ -1116,11 +1099,6 @@ int main(int argc, char* argv[]) ses.load_state(e); } -#ifndef TORRENT_DISABLE_GEO_IP - ses.load_asnum_db("GeoIPASNum.dat"); - ses.load_country_db("GeoIP.dat"); -#endif - // load the torrents given on the commandline std::vector magnet_links; @@ -1167,7 +1145,9 @@ int main(int argc, char* argv[]) switch (argv[i][1]) { case 'f': g_log_file = fopen(arg, "w+"); break; +#ifndef TORRENT_NO_DEPRECATE case 'o': settings.set_int(settings_pack::half_open_limit, atoi(arg)); break; +#endif case 'h': settings.set_bool(settings_pack::allow_multiple_connections_per_ip, true); --i; break; case 'p': listen_port = atoi(arg); break; case 'k': high_performance_seed(settings); --i; break; diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index cc3175292..2f8764493 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -50,6 +50,9 @@ namespace libtorrent #define TORRENT_EXPORT_DEPRECATED #endif + // TODO: 2 this type is only used internally now. move it to an internal + // header and make this type properly deprecated. + // The ``proxy_settings`` structs contains the information needed to // direct certain traffic to a proxy. struct TORRENT_EXPORT_DEPRECATED proxy_settings diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 74de3e8f3..3291b35ef 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -1470,7 +1470,7 @@ namespace libtorrent num_int_settings = max_int_setting_internal - int_type_base }; - enum { no_piece_suggestions = 0, suggest_read_cache = 1 }; + enum suggest_mode_t { no_piece_suggestions = 0, suggest_read_cache = 1 }; enum choking_algorithm_t {