From fe612ca167b01f0ee6b69c980528d8b6355eaf12 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 26 Apr 2018 03:01:14 -0400 Subject: [PATCH] replace the TORRENT_CFG ABI check with inline namespaces around the symbol that can change ABI based on build configuration options --- CMakeLists.txt | 1 - Jamfile | 2 +- bindings/python/Jamfile | 2 +- bindings/python/src/alert.cpp | 78 ++++----- bindings/python/src/converters.cpp | 2 +- bindings/python/src/create_torrent.cpp | 16 +- bindings/python/src/error_code.cpp | 4 +- bindings/python/src/fingerprint.cpp | 4 +- bindings/python/src/magnet_uri.cpp | 6 +- bindings/python/src/peer_info.cpp | 6 +- bindings/python/src/session.cpp | 56 +++---- bindings/python/src/session_settings.cpp | 14 +- bindings/python/src/torrent_handle.cpp | 16 +- bindings/python/src/torrent_info.cpp | 18 +-- bindings/python/src/torrent_status.cpp | 12 +- bindings/python/src/utility.cpp | 4 +- bindings/python/src/version.cpp | 2 +- docs/features.rst | 1 + docs/gen_reference_doc.py | 10 +- docs/gen_settings_doc.py | 2 +- docs/gen_stats_doc.py | 2 +- include/libtorrent/Makefile.am | 1 - include/libtorrent/add_torrent_params.hpp | 20 +-- include/libtorrent/alert.hpp | 10 +- include/libtorrent/alert_types.hpp | 144 +++++++++-------- include/libtorrent/announce_entry.hpp | 21 +-- include/libtorrent/aux_/escape_string.hpp | 2 +- include/libtorrent/aux_/proxy_settings.hpp | 2 +- include/libtorrent/aux_/session_impl.hpp | 33 ++-- include/libtorrent/aux_/session_interface.hpp | 11 +- include/libtorrent/aux_/storage_utils.hpp | 4 +- include/libtorrent/bdecode.hpp | 4 +- include/libtorrent/bencode.hpp | 2 +- include/libtorrent/bitfield.hpp | 2 +- include/libtorrent/block_cache.hpp | 2 +- include/libtorrent/build_config.hpp | 74 --------- include/libtorrent/config.hpp | 19 ++- include/libtorrent/create_torrent.hpp | 6 +- include/libtorrent/disk_interface.hpp | 13 +- include/libtorrent/disk_io_job.hpp | 4 +- include/libtorrent/disk_io_thread.hpp | 9 +- include/libtorrent/entry.hpp | 4 +- include/libtorrent/error_code.hpp | 6 +- include/libtorrent/export.hpp | 18 ++- include/libtorrent/extensions.hpp | 13 +- include/libtorrent/file_pool.hpp | 13 +- include/libtorrent/file_storage.hpp | 16 +- include/libtorrent/fingerprint.hpp | 2 +- include/libtorrent/flags.hpp | 2 +- include/libtorrent/fwd.hpp | 58 ++++--- include/libtorrent/gzip.hpp | 2 +- include/libtorrent/hex.hpp | 2 +- include/libtorrent/i2p_stream.hpp | 2 +- include/libtorrent/identify_client.hpp | 6 +- include/libtorrent/ip_filter.hpp | 4 + include/libtorrent/kademlia/dht_settings.hpp | 2 +- include/libtorrent/kademlia/dht_storage.hpp | 2 +- include/libtorrent/kademlia/dht_tracker.hpp | 4 +- include/libtorrent/kademlia/node.hpp | 9 +- include/libtorrent/kademlia/routing_table.hpp | 11 +- .../kademlia/traversal_algorithm.hpp | 3 +- include/libtorrent/lazy_entry.hpp | 4 +- include/libtorrent/magnet_uri.hpp | 4 +- include/libtorrent/operations.hpp | 2 +- include/libtorrent/peer_connection_handle.hpp | 5 +- .../libtorrent/peer_connection_interface.hpp | 2 +- include/libtorrent/peer_info.hpp | 15 +- include/libtorrent/peer_list.hpp | 4 +- include/libtorrent/performance_counters.hpp | 2 +- include/libtorrent/read_resume_data.hpp | 4 +- include/libtorrent/session.hpp | 25 +-- include/libtorrent/session_handle.hpp | 43 +++-- include/libtorrent/session_settings.hpp | 4 +- include/libtorrent/session_status.hpp | 6 +- include/libtorrent/settings_pack.hpp | 50 +++--- include/libtorrent/sha1_hash.hpp | 2 +- include/libtorrent/socks5_stream.hpp | 2 +- include/libtorrent/storage.hpp | 3 +- include/libtorrent/storage_defs.hpp | 6 +- include/libtorrent/torrent.hpp | 37 ++--- include/libtorrent/torrent_flags.hpp | 9 +- include/libtorrent/torrent_handle.hpp | 50 +++--- include/libtorrent/torrent_info.hpp | 21 ++- include/libtorrent/torrent_status.hpp | 65 ++------ include/libtorrent/tracker_manager.hpp | 5 +- include/libtorrent/union_endpoint.hpp | 3 + include/libtorrent/units.hpp | 2 +- include/libtorrent/upnp.hpp | 2 +- include/libtorrent/write_resume_data.hpp | 7 +- simulation/setup_dht.hpp | 7 +- simulation/setup_swarm.hpp | 12 +- simulation/test_auto_manage.cpp | 26 +-- simulation/test_error_handling.cpp | 2 +- simulation/test_ip_filter.cpp | 8 +- simulation/test_optimistic_unchoke.cpp | 2 +- simulation/test_pause.cpp | 3 +- simulation/test_socks5.cpp | 2 +- simulation/test_swarm.cpp | 2 +- simulation/test_transfer.cpp | 2 +- src/add_torrent_params.cpp | 4 +- src/alert.cpp | 152 +++++++++++------- src/announce_entry.cpp | 6 +- src/block_cache.cpp | 2 +- src/create_torrent.cpp | 6 +- src/disk_io_thread.cpp | 4 +- src/entry.cpp | 4 +- src/error_code.cpp | 2 +- src/escape_string.cpp | 2 +- src/file_pool.cpp | 31 ---- src/file_storage.cpp | 20 +-- src/fingerprint.cpp | 4 +- src/http_tracker_connection.cpp | 2 +- src/identify_client.cpp | 2 +- src/kademlia/dht_storage.cpp | 2 +- src/kademlia/dht_tracker.cpp | 2 +- src/kademlia/node.cpp | 2 +- src/kademlia/routing_table.cpp | 4 +- src/lazy_bdecode.cpp | 9 +- src/magnet_uri.cpp | 4 +- src/peer_connection.cpp | 4 +- src/peer_info.cpp | 4 +- src/read_resume_data.cpp | 2 +- src/session.cpp | 12 +- src/session_handle.cpp | 52 +++--- src/session_impl.cpp | 61 ++++--- src/session_stats.cpp | 6 +- src/settings_pack.cpp | 2 +- src/storage.cpp | 11 -- src/torrent.cpp | 91 +++++------ src/torrent_handle.cpp | 98 ++++------- src/torrent_info.cpp | 16 +- src/torrent_status.cpp | 2 +- src/write_resume_data.cpp | 2 +- test/settings.cpp | 6 +- test/setup_transfer.cpp | 2 +- test/setup_transfer.hpp | 9 +- test/swarm_suite.cpp | 2 +- test/test_alert_types.cpp | 10 +- test/test_auto_unchoke.cpp | 2 +- test/test_bencoding.cpp | 6 +- test/test_checking.cpp | 2 +- test/test_fast_extension.cpp | 2 +- test/test_lsd.cpp | 2 +- test/test_magnet.cpp | 2 +- test/test_pex.cpp | 4 +- test/test_priority.cpp | 6 +- test/test_privacy.cpp | 2 +- test/test_read_piece.cpp | 2 +- test/test_resume.cpp | 20 +-- test/test_session.cpp | 2 +- test/test_settings_pack.cpp | 4 +- test/test_storage.cpp | 8 +- test/test_string.cpp | 2 +- test/test_torrent.cpp | 4 +- test/test_torrent_info.cpp | 6 +- test/test_transfer.cpp | 4 +- test/test_utp.cpp | 2 +- test/test_web_seed_redirect.cpp | 2 +- test/web_seed_suite.cpp | 2 +- tools/gen_fwd.py | 86 ++++++---- 160 files changed, 948 insertions(+), 1150 deletions(-) delete mode 100644 include/libtorrent/build_config.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 27c40da32..2231961c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ set(libtorrent_include_files broadcast_socket bt_peer_connection buffer - build_config chained_buffer choker close_reason diff --git a/Jamfile b/Jamfile index 845b19ab3..260a4da97 100644 --- a/Jamfile +++ b/Jamfile @@ -662,6 +662,7 @@ SOURCES = peer_connection_handle i2p_stream instantiate_connection + lazy_bdecode natpmp packet_buffer piece_picker @@ -815,7 +816,6 @@ lib torrent on:src/kademlia/$(KADEMLIA_SOURCES).cpp on:ed25519/src/$(ED25519_SOURCES).cpp on:src/hasher512.cpp - on:src/lazy_bdecode.cpp @building @warnings diff --git a/bindings/python/Jamfile b/bindings/python/Jamfile index d30936734..db847b1fc 100644 --- a/bindings/python/Jamfile +++ b/bindings/python/Jamfile @@ -12,7 +12,7 @@ BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ; # this is used to make bjam use the same version of python which is executing setup.py LIBTORRENT_PYTHON_INTERPRETER = [ modules.peek : LIBTORRENT_PYTHON_INTERPRETER ] ; -feature visibility : default hidden : composite ; +feature visibility : default hidden : composite propagated ; feature.compose hidden : -fvisibility=hidden -fvisibility-inlines-hidden ; feature libtorrent-link : shared static : composite propagated ; diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 6ecf6af1c..02a35a96a 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -228,7 +228,7 @@ namespace boost POLY(session_stats_alert) POLY(dht_get_peers_reply_alert) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 POLY(torrent_added_alert) POLY(torrent_update_alert) #endif @@ -257,13 +257,13 @@ void bind_alert() .def("message", &alert::message) .def("what", &alert::what) .def("category", &alert::category) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("severity", &alert::severity) #endif .def("__str__", &alert::message) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum_("severity_levels") .value("debug", alert::debug) .value("info", alert::info) @@ -282,7 +282,7 @@ void bind_alert() s.attr("tracker_notification") = alert::tracker_notification; s.attr("debug_notification") = alert::debug_notification; s.attr("status_notification") = alert::status_notification; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 s.attr("progress_notification") = alert::progress_notification; #endif s.attr("ip_block_notification") = alert::ip_block_notification; @@ -356,14 +356,14 @@ void bind_alert() class_, noncopyable>( "tracker_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("url", &tracker_alert::url) #endif .add_property("local_endpoint", make_getter(&tracker_alert::local_endpoint, by_value())) .def("tracker_url", &tracker_alert::tracker_url) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 class_, noncopyable>( "torrent_added_alert", no_init) ; @@ -377,7 +377,7 @@ void bind_alert() class_, noncopyable>( "read_piece_alert", nullptr, no_init) .def_readonly("error", &read_piece_alert::error) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("ec", &read_piece_alert::ec) #endif .add_property("buffer", get_buffer) @@ -387,7 +387,7 @@ void bind_alert() class_, noncopyable>( "peer_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("ip", make_getter(&peer_alert::ip, by_value())) #endif .add_property("endpoint", make_getter(&peer_alert::endpoint, by_value())) @@ -395,7 +395,7 @@ void bind_alert() ; class_, noncopyable>( "tracker_error_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("msg", &tracker_error_alert::msg) .def_readonly("status_code", &tracker_error_alert::status_code) #endif @@ -464,7 +464,7 @@ void bind_alert() class_, noncopyable>( "block_downloading_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("peer_speedmsg", &block_downloading_alert::peer_speedmsg) #endif .add_property("block_index", make_getter(&block_downloading_alert::block_index, by_value())) @@ -473,7 +473,7 @@ void bind_alert() class_, noncopyable>( "storage_moved_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("path", &storage_moved_alert::path) #endif .def("storage_path", &storage_moved_alert::storage_path) @@ -484,7 +484,7 @@ void bind_alert() .def_readonly("error", &storage_moved_failed_alert::error) .def("file_path", &storage_moved_failed_alert::file_path) .def_readonly("op", &storage_moved_failed_alert::op) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("operation", &storage_moved_failed_alert::operation) #endif ; @@ -502,7 +502,7 @@ void bind_alert() class_, noncopyable>( "url_seed_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("url", &url_seed_alert::url) .def_readonly("msg", &url_seed_alert::msg) #endif @@ -515,7 +515,7 @@ void bind_alert() "file_error_alert", no_init) .def_readonly("error", &file_error_alert::error) .def("filename", &file_error_alert::filename) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("file", &file_error_alert::file) .def_readonly("msg", &file_error_alert::msg) #endif @@ -531,7 +531,7 @@ void bind_alert() class_, noncopyable>( "listen_failed_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("endpoint", make_getter(&listen_failed_alert::endpoint, by_value())) #endif .add_property("address", make_getter(&listen_failed_alert::address, by_value())) @@ -539,7 +539,7 @@ void bind_alert() .def("listen_interface", &listen_failed_alert::listen_interface) .def_readonly("error", &listen_failed_alert::error) .def_readonly("op", &listen_failed_alert::op) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("operation", &listen_failed_alert::operation) .def_readonly("sock_type", &listen_failed_alert::sock_type) #endif @@ -548,18 +548,18 @@ void bind_alert() class_, noncopyable>( "listen_succeeded_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("endpoint", make_getter(&listen_succeeded_alert::endpoint, by_value())) #endif .add_property("address", make_getter(&listen_succeeded_alert::address, by_value())) .def_readonly("port", &listen_succeeded_alert::port) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("sock_type", &listen_succeeded_alert::sock_type) #endif .def_readonly("socket_type", &listen_succeeded_alert::socket_type) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum_("listen_succeded_alert_socket_type_t") .value("tcp", listen_succeeded_alert::socket_type_t::tcp) .value("tcp_ssl", listen_succeeded_alert::socket_type_t::tcp_ssl) @@ -593,7 +593,7 @@ void bind_alert() .add_property("mapping", make_getter(&portmap_error_alert::mapping, by_value())) .def_readonly("error", &portmap_error_alert::error) .def_readonly("map_transport", &portmap_error_alert::map_transport) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("map_type", &portmap_error_alert::map_type) .def_readonly("type", &portmap_error_alert::map_type) .def_readonly("msg", &portmap_error_alert::msg) @@ -605,7 +605,7 @@ void bind_alert() .def_readonly("external_port", &portmap_alert::external_port) .def_readonly("map_protocol", &portmap_alert::map_protocol) .def_readonly("map_transport", &portmap_alert::map_transport) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("type", &portmap_alert::map_type) .def_readonly("map_type", &portmap_alert::map_type) #endif @@ -615,7 +615,7 @@ void bind_alert() class_, noncopyable>("portmap_log_alert", no_init) .def_readonly("map_transport", &portmap_log_alert::map_transport) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("type", &portmap_log_alert::map_type) .def_readonly("msg", &portmap_log_alert::msg) .def_readonly("map_type", &portmap_log_alert::map_type) @@ -629,7 +629,7 @@ void bind_alert() .def_readonly("error", &fastresume_rejected_alert::error) .def("file_path", &fastresume_rejected_alert::file_path) .def_readonly("op", &fastresume_rejected_alert::op) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("operation", &fastresume_rejected_alert::operation) .def_readonly("msg", &fastresume_rejected_alert::msg) #endif @@ -637,7 +637,7 @@ void bind_alert() class_, noncopyable>( "peer_blocked_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("ip", make_getter(&peer_blocked_alert::ip, by_value())) #endif .add_property("reason", &peer_blocked_alert::reason) @@ -661,7 +661,7 @@ void bind_alert() class_, noncopyable>( "scrape_failed_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("msg", &scrape_failed_alert::msg) #endif .def("error_message", &scrape_failed_alert::error_message) @@ -682,7 +682,7 @@ void bind_alert() class_, noncopyable>( "save_resume_data_alert", no_init) .def_readonly("params", &save_resume_data_alert::params) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("resume_data", make_function(get_resume_data_entry, by_value())) #endif ; @@ -695,7 +695,7 @@ void bind_alert() class_, noncopyable>( "file_renamed_alert", no_init) .add_property("index", make_getter(&file_renamed_alert::index, by_value())) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("name", &file_renamed_alert::name) #endif .def("new_name", &file_renamed_alert::new_name) @@ -763,7 +763,7 @@ void bind_alert() .def_readonly("op", &peer_disconnected_alert::op) .def_readonly("error", &peer_disconnected_alert::error) .def_readonly("reason", &peer_disconnected_alert::reason) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("msg", &peer_disconnected_alert::msg) #endif ; @@ -788,7 +788,7 @@ void bind_alert() class_, noncopyable>( "torrent_delete_failed_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("msg", &torrent_delete_failed_alert::msg) #endif .def_readonly("error", &torrent_delete_failed_alert::error) @@ -797,7 +797,7 @@ void bind_alert() class_, noncopyable>( "save_resume_data_failed_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("msg", &save_resume_data_failed_alert::msg) #endif .def_readonly("error", &save_resume_data_failed_alert::error) @@ -830,14 +830,14 @@ void bind_alert() .value("upload_payload", stats_alert::upload_payload) .value("upload_protocol", stats_alert::upload_protocol) .value("upload_ip_protocol", stats_alert::upload_ip_protocol) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .value("upload_dht_protocol", stats_alert::upload_dht_protocol) .value("upload_tracker_protocol", stats_alert::upload_tracker_protocol) #endif .value("download_payload", stats_alert::download_payload) .value("download_protocol", stats_alert::download_protocol) .value("download_ip_protocol", stats_alert::download_ip_protocol) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .value("download_dht_protocol", stats_alert::download_dht_protocol) .value("download_tracker_protocol", stats_alert::download_tracker_protocol) #endif @@ -860,14 +860,14 @@ void bind_alert() class_, noncopyable>( "incoming_connection_alert", no_init) .def_readonly("socket_type", &incoming_connection_alert::socket_type) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("ip", make_getter(&incoming_connection_alert::ip, by_value())) #endif .add_property("endpoint", make_getter(&incoming_connection_alert::endpoint, by_value())) ; class_, noncopyable>( "torrent_need_cert_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("error", &torrent_need_cert_alert::error) #endif ; @@ -878,7 +878,7 @@ void bind_alert() .add_property("params", &add_torrent_alert::params) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 class_, noncopyable>( "torrent_update_alert", no_init) .def_readonly("old_ih", &torrent_update_alert::old_ih) @@ -890,7 +890,7 @@ void bind_alert() "dht_outgoing_get_peers_alert", no_init) .def_readonly("info_hash", &dht_outgoing_get_peers_alert::info_hash) .def_readonly("obfuscated_info_hash", &dht_outgoing_get_peers_alert::obfuscated_info_hash) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("ip", make_getter(&dht_outgoing_get_peers_alert::ip, by_value())) #endif .add_property("endpoint", make_getter(&dht_outgoing_get_peers_alert::endpoint, by_value())) @@ -898,7 +898,7 @@ void bind_alert() class_, noncopyable>( "log_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("msg", &log_alert::msg) #endif .def("log_message", &log_alert::log_message) @@ -906,7 +906,7 @@ void bind_alert() class_, noncopyable>( "torrent_log_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("msg", &torrent_log_alert::msg) #endif .def("log_message", &torrent_log_alert::log_message) @@ -914,7 +914,7 @@ void bind_alert() class_, noncopyable>( "peer_log_alert", no_init) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("msg", &peer_log_alert::msg) #endif .def("log_message", &peer_log_alert::log_message) diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index 75b7f475f..cb93fb32a 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -433,7 +433,7 @@ void bind_converters() to_python_converter>, map_to_dict>>>(); to_python_converter, map_to_dict>>(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 to_python_converter>, vector_to_list>>>(); list_to_vector>>(); #endif diff --git a/bindings/python/src/create_torrent.cpp b/bindings/python/src/create_torrent.cpp index 3f33a02d6..55d693f0a 100644 --- a/bindings/python/src/create_torrent.cpp +++ b/bindings/python/src/create_torrent.cpp @@ -57,7 +57,7 @@ namespace ct.add_node(std::make_pair(addr, port)); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void add_file_deprecated(file_storage& ct, file_entry const& fe) { ct.add_file(fe); @@ -106,7 +106,7 @@ namespace { fs.add_file(file, size, flags, md, link); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void add_files_callback(file_storage& fs, std::string const& file , boost::python::object cb, create_flags_t const flags) @@ -133,7 +133,7 @@ void bind_create_torrent() { void (file_storage::*set_name0)(std::string const&) = &file_storage::set_name; void (file_storage::*rename_file0)(file_index_t, std::string const&) = &file_storage::rename_file; -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void (file_storage::*set_name1)(std::wstring const&) = &file_storage::set_name; void (file_storage::*rename_file1)(file_index_t, std::wstring const&) = &file_storage::rename_file; #endif @@ -151,7 +151,7 @@ void bind_create_torrent() std::int64_t (file_storage::*file_storage_file_offset)(file_index_t) const = &file_storage::file_offset; file_flags_t (file_storage::*file_storage_file_flags)(file_index_t) const = &file_storage::file_flags; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 file_entry (file_storage::*at)(int) const = &file_storage::at; #endif @@ -161,13 +161,13 @@ void bind_create_torrent() .def("is_valid", &file_storage::is_valid) .def("add_file", add_file, (arg("path"), arg("size"), arg("flags") = 0, arg("mtime") = 0, arg("linkpath") = "")) .def("num_files", &file_storage::num_files) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("at", at) .def("add_file", add_file_deprecated, arg("entry")) .def("__iter__", boost::python::range(&begin_files, &end_files)) .def("__len__", &file_storage::num_files) .def("add_file", add_file_wstring, (arg("path"), arg("size"), arg("flags") = 0, arg("mtime") = 0, arg("linkpath") = "")) -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION .def("hash", file_storage_hash) .def("symlink", file_storage_symlink, return_value_policy()) .def("file_path", file_storage_file_path, (arg("idx"), arg("save_path") = "")) @@ -184,7 +184,7 @@ void bind_create_torrent() .def("piece_size", &file_storage::piece_size) .def("set_name", set_name0) .def("rename_file", rename_file0) -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("set_name", set_name1) .def("rename_file", rename_file1) #endif @@ -239,7 +239,7 @@ void bind_create_torrent() { scope s = class_("create_torrent_flags_t"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 s.attr("optimize") = create_torrent::optimize; #endif s.attr("optimize_alignment") = create_torrent::optimize_alignment; diff --git a/bindings/python/src/error_code.cpp b/bindings/python/src/error_code.cpp index cd17cac84..ce972ce6b 100644 --- a/bindings/python/src/error_code.cpp +++ b/bindings/python/src/error_code.cpp @@ -158,7 +158,7 @@ using return_existing = return_value_policy; def("i2p_category", &i2p_category, return_existing()); #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 def("get_libtorrent_category", &libtorrent_category, return_existing()); def("get_upnp_category", &upnp_category, return_existing()); def("get_http_category", &http_category, return_existing()); @@ -167,7 +167,7 @@ using return_existing = return_value_policy; #if TORRENT_USE_I2P def("get_i2p_category", &i2p_category, return_existing()); #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION def("generic_category", &boost::system::generic_category, return_existing()); diff --git a/bindings/python/src/fingerprint.cpp b/bindings/python/src/fingerprint.cpp index 207fdcd3d..e9be89126 100644 --- a/bindings/python/src/fingerprint.cpp +++ b/bindings/python/src/fingerprint.cpp @@ -12,7 +12,7 @@ void bind_fingerprint() def("generate_fingerprint", &generate_fingerprint); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -47,5 +47,5 @@ void bind_fingerprint() #ifdef _MSC_VER #pragma warning(pop) #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION } diff --git a/bindings/python/src/magnet_uri.cpp b/bindings/python/src/magnet_uri.cpp index 4e141dcb5..130fac0e1 100644 --- a/bindings/python/src/magnet_uri.cpp +++ b/bindings/python/src/magnet_uri.cpp @@ -17,7 +17,7 @@ extern void dict_to_add_torrent_params(dict params, add_torrent_params& p); namespace { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_handle _add_magnet_uri(lt::session& s, std::string uri, dict params) { add_torrent_params p; @@ -61,7 +61,7 @@ namespace { ret["name"] = p.name; ret["save_path"] = p.save_path; ret["storage_mode"] = p.storage_mode; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 ret["url"] = p.url; ret["uuid"] = p.uuid; #endif @@ -83,7 +83,7 @@ namespace { void bind_magnet_uri() { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 def("add_magnet_uri", &_add_magnet_uri); #endif def("make_magnet_uri", make_magnet_uri0); diff --git a/bindings/python/src/peer_info.cpp b/bindings/python/src/peer_info.cpp index 879a98bd8..51785a806 100644 --- a/bindings/python/src/peer_info.cpp +++ b/bindings/python/src/peer_info.cpp @@ -64,7 +64,7 @@ void bind_peer_info() .def_readonly("total_upload", &peer_info::total_upload) .def_readonly("pid", &peer_info::pid) .add_property("pieces", get_pieces) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("upload_limit", &peer_info::upload_limit) .def_readonly("download_limit", &peer_info::download_limit) .def_readonly("load_balancing", &peer_info::load_balancing) @@ -111,7 +111,7 @@ void bind_peer_info() pi.attr("local_connection") = peer_info::local_connection; pi.attr("handshake") = peer_info::handshake; pi.attr("connecting") = peer_info::connecting; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pi.attr("queued") = peer_info::queued; #endif pi.attr("on_parole") = peer_info::on_parole; @@ -139,7 +139,7 @@ void bind_peer_info() // read/write state pi.attr("bw_idle") = peer_info::bw_idle; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pi.attr("bw_torrent") = peer_info::bw_torrent; pi.attr("bw_global") = peer_info::bw_global; #endif diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index dab759a6e..146a26f72 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -52,7 +52,7 @@ using namespace lt; namespace { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct dummy {}; void listen_on(lt::session& s, int min_, int max_, char const* interface, int flags) @@ -74,7 +74,7 @@ namespace s.apply_settings(p); return; } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #ifndef TORRENT_DISABLE_DHT void add_dht_node(lt::session& s, tuple n) @@ -85,7 +85,7 @@ namespace s.add_dht_node(std::make_pair(ip, port)); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void add_dht_router(lt::session& s, std::string router_, int port_) { allow_threading_guard guard; @@ -211,7 +211,7 @@ namespace } #ifndef BOOST_NO_EXCEPTIONS -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_handle add_torrent_depr(lt::session& s, torrent_info const& ti , std::string const& save, entry const& resume , storage_mode_t storage_mode, bool paused) @@ -261,7 +261,7 @@ namespace p.save_path = extract(value); continue; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 else if(key == "resume_data") { std::string resume = extract(value); @@ -321,7 +321,7 @@ namespace p.trackerid = extract(value); continue; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 else if(key == "url") { p.url = extract(value); @@ -374,7 +374,7 @@ namespace s.async_add_torrent(p); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void start_natpmp(lt::session& s) { allow_threading_guard guard; @@ -386,7 +386,7 @@ namespace allow_threading_guard guard; s.start_upnp(); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION alert const* wait_for_alert(lt::session& s, int ms) @@ -444,7 +444,7 @@ namespace return cached_piece_info_list(cs.pieces); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 cache_status get_cache_status(lt::session& s) { cache_status ret; @@ -646,7 +646,7 @@ namespace } // anonymous namespace struct dummy1 {}; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct dummy2 {}; #endif struct dummy9 {}; @@ -660,7 +660,7 @@ void bind_session() sha1_hash (lt::session::*dht_put_immutable_item)(entry data) = <::session::dht_put_item; #endif // TORRENT_DISABLE_DHT -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifndef TORRENT_DISABLE_DHT void (lt::session::*start_dht0)() = <::session::start_dht; void (lt::session::*start_dht1)(entry const&) = <::session::start_dht; @@ -730,7 +730,7 @@ void bind_session() .def_readonly("branch_factor", &dht_lookup::branch_factor) ; #endif // TORRENT_DISABLE_DHT -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #define PROP(val) \ make_getter(val, return_value_policy()), \ @@ -778,7 +778,7 @@ void bind_session() .add_property("merkle_tree", PROP(&add_torrent_params::merkle_tree)) .add_property("renamed_files", PROP(&add_torrent_params::renamed_files)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readwrite("url", &add_torrent_params::url) .def_readwrite("uuid", &add_torrent_params::uuid) .add_property("resume_data", PROP(&add_torrent_params::resume_data)) @@ -818,7 +818,7 @@ void bind_session() s.attr("override_web_seeds") = torrent_flags::override_web_seeds; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 { scope s = class_("add_torrent_params_flags_t"); s.attr("flag_seed_mode") = add_torrent_params::flag_seed_mode; @@ -844,7 +844,7 @@ void bind_session() class_("cache_status") .add_property("pieces", cache_status_pieces) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("blocks_written", &cache_status::blocks_written) .def_readonly("writes", &cache_status::writes) .def_readonly("blocks_read", &cache_status::blocks_read) @@ -923,7 +923,7 @@ void bind_session() , arg("flags")=lt::session::start_default_features | lt::session::add_default_plugins)) ) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def( init(( arg("fingerprint")=fingerprint("LT",0,1,0,0) @@ -939,12 +939,12 @@ void bind_session() .def("listen_port", allow_threads(<::session::listen_port)) #ifndef TORRENT_DISABLE_DHT .def("add_dht_node", &add_dht_node) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def( "add_dht_router", &add_dht_router , (arg("router"), "port") ) -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION .def("is_dht_running", allow_threads(<::session::is_dht_running)) .def("set_dht_settings", allow_threads(<::session::set_dht_settings)) .def("get_dht_settings", allow_threads(<::session::get_dht_settings)) @@ -960,7 +960,7 @@ void bind_session() .def("async_add_torrent", <::session::async_add_torrent) .def("add_torrent", allow_threads((lt::torrent_handle (session_handle::*)(add_torrent_params const&))<::session::add_torrent)) #ifndef BOOST_NO_EXCEPTIONS -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def( "add_torrent", &add_torrent_depr , ( @@ -969,15 +969,15 @@ void bind_session() arg("paused") = false ) ) -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #endif // BOOST_NO_EXCEPTIONS .def("remove_torrent", allow_threads(<::session::remove_torrent), arg("option") = 0) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("status", allow_threads(<::session::status)) #endif .def("get_settings", &session_get_settings) .def("apply_settings", &session_apply_settings) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifndef TORRENT_DISABLE_ENCRYPTION .def("set_pe_settings", allow_threads(<::session::set_pe_settings)) .def("get_pe_settings", allow_threads(<::session::get_pe_settings)) @@ -988,7 +988,7 @@ void bind_session() .def("pop_alerts", &pop_alerts) .def("wait_for_alert", &wait_for_alert, return_internal_reference<>()) .def("add_extension", &add_extension) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #if TORRENT_USE_I2P .def("set_i2p_proxy", allow_threads(<::session::set_i2p_proxy)) .def("i2p_proxy", allow_threads(<::session::i2p_proxy)) @@ -1012,7 +1012,7 @@ void bind_session() .def("get_peer_class", &get_peer_class) .def("set_peer_class", &set_peer_class) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("id", allow_threads(<::session::id)) .def( "listen_on", &listen_on @@ -1059,7 +1059,7 @@ void bind_session() .def("get_cache_status", &get_cache_status) .def("get_cache_info", &get_cache_info2) .def("set_peer_id", allow_threads(<::session::set_peer_id)) -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION ; s.attr("tcp") = lt::portmap_protocol::tcp; @@ -1072,7 +1072,7 @@ void bind_session() s.attr("reopen_map_ports") = lt::session::reopen_map_ports; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 { scope s = class_("protocol_type"); s.attr("udp") = lt::portmap_protocol::udp; @@ -1085,7 +1085,7 @@ void bind_session() s.attr("save_settings") = lt::session::save_settings; s.attr("save_dht_settings") = lt::session::save_dht_settings; s.attr("save_dht_state") = lt::session::save_dht_state; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 s.attr("save_encryption_settings") = lt::session:: save_encryption_settings; s.attr("save_as_map") = lt::session::save_as_map; s.attr("save_i2p_proxy") = lt::session::save_i2p_proxy; @@ -1097,7 +1097,7 @@ void bind_session() #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum_("listen_on_flags_t") .value("listen_reuse_address", lt::session::listen_reuse_address) .value("listen_no_system_port", lt::session::listen_no_system_port) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index 7e28b905f..5c7b4d9cf 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -12,7 +12,7 @@ void bind_session_settings() { enum_("choking_algorithm_t") .value("fixed_slots_choker", settings_pack::fixed_slots_choker) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .value("auto_expand_choker", settings_pack::rate_based_choker) #endif .value("rate_based_choker", settings_pack::rate_based_choker) @@ -32,7 +32,7 @@ void bind_session_settings() enum_("io_buffer_mode_t") .value("enable_os_cache", settings_pack::enable_os_cache) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .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) @@ -47,7 +47,7 @@ void bind_session_settings() .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 +#if TORRENT_ABI_VERSION == 1 .value("forced", settings_pack::pe_forced) .value("enabled", settings_pack::pe_enabled) .value("disabled", settings_pack::pe_disabled) @@ -58,7 +58,7 @@ void bind_session_settings() .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 +#if TORRENT_ABI_VERSION == 1 .value("rc4", settings_pack::pe_rc4) .value("plaintext", settings_pack::pe_plaintext) .value("both", settings_pack::pe_both) @@ -75,7 +75,7 @@ void bind_session_settings() .value("i2p_proxy", settings_pack::i2p_proxy) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum_("proxy_type") .value("none", proxy_settings::none) .value("socks4", proxy_settings::socks4) @@ -101,7 +101,7 @@ void bind_session_settings() class_("dht_settings") .def_readwrite("max_peers_reply", &dht::dht_settings::max_peers_reply) .def_readwrite("search_branching", &dht::dht_settings::search_branching) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readwrite("service_port", &dht::dht_settings::service_port) #endif .def_readwrite("max_fail_count", &dht::dht_settings::max_fail_count) @@ -122,7 +122,7 @@ void bind_session_settings() ; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 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/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index eb88da870..9e1daff27 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -263,7 +263,7 @@ list trackers(torrent_handle& h) d["source"] = i->source; d["verified"] = i->verified; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (!i->endpoints.empty()) { announce_endpoint const& aep = i->endpoints.front(); @@ -344,7 +344,7 @@ list trackers(torrent_handle& h) } d["endpoints"] = aeps; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 d["send_stats"] = i->send_stats; #endif ret.append(d); @@ -395,7 +395,7 @@ void set_metadata(torrent_handle& handle, std::string const& buf) handle.set_metadata(buf); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #if BOOST_VERSION > 104200 std::shared_ptr get_torrent_info(torrent_handle const& h) @@ -438,7 +438,7 @@ void bind_torrent_handle() // arguments are: number of seconds and tracker index void (torrent_handle::*force_reannounce0)(int, int) const = &torrent_handle::force_reannounce; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 bool (torrent_handle::*super_seeding0)() const = &torrent_handle::super_seeding; void (torrent_handle::*super_seeding1)(bool) const = &torrent_handle::super_seeding; #endif @@ -451,7 +451,7 @@ void bind_torrent_handle() void (torrent_handle::*move_storage0)(std::string const&, lt::move_flags_t) const = &torrent_handle::move_storage; void (torrent_handle::*rename_file0)(file_index_t, std::string const&) const = &torrent_handle::rename_file; -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void (torrent_handle::*move_storage1)(std::wstring const&, int) const = &torrent_handle::move_storage; void (torrent_handle::*rename_file1)(file_index_t, std::wstring const&) const = &torrent_handle::rename_file; #endif @@ -466,7 +466,7 @@ void bind_torrent_handle() .value("dont_replace", move_flags_t::dont_replace) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum_("deprecated_move_flags_t") .value("always_replace_files", deprecated_move_flags_t::always_replace_files) .value("fail_if_exist", deprecated_move_flags_t::fail_if_exist) @@ -549,7 +549,7 @@ void bind_torrent_handle() .def("set_flags", _(set_flags1)) .def("unset_flags", _(&torrent_handle::unset_flags)) // deprecated -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("piece_priorities", &piece_priorities) .def("file_priorities", &file_priorities) .def("stop_when_ready", _(&torrent_handle::stop_when_ready)) @@ -595,7 +595,7 @@ void bind_torrent_handle() s.attr("sparse") = file_open_mode::sparse; s.attr("no_atime") = file_open_mode::no_atime; s.attr("random_access") = file_open_mode::random_access; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 s.attr("locked") = 0; #endif } diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index e5b69d9e2..11fd91146 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -123,7 +123,7 @@ namespace return result; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // Create getters for announce_entry data members with non-trivial types which need converting. lt::time_point get_next_announce(announce_entry const& ae) { return ae.endpoints.empty() ? lt::time_point() : lt::time_point(ae.endpoints.front().next_announce); } @@ -151,7 +151,7 @@ namespace int get_source(announce_entry const& ae) { return ae.source; } bool get_verified(announce_entry const& ae) { return ae.verified; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string get_message(announce_entry const& ae) { return ae.endpoints.empty() ? "" : ae.endpoints.front().message; } error_code get_last_error(announce_entry const& ae) @@ -224,7 +224,7 @@ void bind_torrent_info() return_value_policy copy; void (torrent_info::*rename_file0)(file_index_t, std::string const&) = &torrent_info::rename_file; -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void (torrent_info::*rename_file1)(file_index_t, std::wstring const&) = &torrent_info::rename_file; #endif @@ -241,7 +241,7 @@ void bind_torrent_info() .def("__init__", make_constructor(&file_constructor0)) .def(init((arg("ti")))) -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def(init((arg("file")))) #endif @@ -271,11 +271,11 @@ void bind_torrent_info() .def("remap_files", &torrent_info::remap_files) .def("files", &torrent_info::files, return_internal_reference<>()) .def("orig_files", &torrent_info::orig_files, return_internal_reference<>()) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def("file_at", &torrent_info::file_at) .def("file_at_offset", &torrent_info::file_at_offset) .def("rename_file", rename_file1) -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION .def("is_valid", &torrent_info::is_valid) .def("priv", &torrent_info::priv) @@ -293,7 +293,7 @@ void bind_torrent_info() .def("map_file", &torrent_info::map_file) ; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 class_("file_entry") .def_readwrite("path", &file_entry::path) .def_readwrite("symlink_path", &file_entry::symlink_path) @@ -311,7 +311,7 @@ void bind_torrent_info() class_("announce_entry", init()) .def_readwrite("url", &announce_entry::url) .def_readonly("trackerid", &announce_entry::trackerid) -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("message", &get_message) .add_property("last_error", &get_last_error) .add_property("next_announce", &get_next_announce) @@ -324,7 +324,7 @@ void bind_torrent_info() .def_readwrite("fail_limit", &announce_entry::fail_limit) .add_property("source", &get_source) .add_property("verified", &get_verified) -#if !defined TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("fails", &get_fails) .add_property("updating", &get_updating) .add_property("start_sent", &get_start_sent) diff --git a/bindings/python/src/torrent_status.cpp b/bindings/python/src/torrent_status.cpp index 6a5f8167e..b9acf00e9 100644 --- a/bindings/python/src/torrent_status.cpp +++ b/bindings/python/src/torrent_status.cpp @@ -24,7 +24,7 @@ void bind_torrent_status() .def_readonly("info_hash", &torrent_status::info_hash) .add_property("torrent_file", &get_torrent_file) .def_readonly("state", &torrent_status::state) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("paused", &torrent_status::paused) .def_readonly("stop_when_ready", &torrent_status::stop_when_ready) .def_readonly("auto_managed", &torrent_status::auto_managed) @@ -36,7 +36,7 @@ void bind_torrent_status() .def_readonly("progress", &torrent_status::progress) .def_readonly("progress_ppm", &torrent_status::progress_ppm) .add_property("next_announce", make_getter(&torrent_status::next_announce, by_value())) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .add_property("announce_interval", make_getter(&torrent_status::announce_interval, by_value())) #endif .def_readonly("current_tracker", &torrent_status::current_tracker) @@ -78,7 +78,7 @@ void bind_torrent_status() .def_readonly("all_time_download", &torrent_status::all_time_download) .def_readonly("seed_rank", &torrent_status::seed_rank) .def_readonly("has_incoming", &torrent_status::has_incoming) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("seed_mode", &torrent_status::seed_mode) .def_readonly("upload_mode", &torrent_status::upload_mode) .def_readonly("share_mode", &torrent_status::share_mode) @@ -101,11 +101,11 @@ void bind_torrent_status() .def_readonly("last_seen_complete", &torrent_status::last_seen_complete) .add_property("queue_position", make_getter(&torrent_status::queue_position, by_value())) .def_readonly("need_save_resume", &torrent_status::need_save_resume) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("ip_filter_applies", &torrent_status::ip_filter_applies) #endif .def_readonly("moving_storage", &torrent_status::moving_storage) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .def_readonly("is_loaded", &torrent_status::is_loaded) #endif .def_readonly("announcing_to_trackers", &torrent_status::announcing_to_trackers) @@ -121,7 +121,7 @@ void bind_torrent_status() ; enum_("states") -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 .value("queued_for_checking", torrent_status::queued_for_checking) #endif .value("checking_files", torrent_status::checking_files) diff --git a/bindings/python/src/utility.cpp b/bindings/python/src/utility.cpp index 11cc8bcee..3f1ac4e6c 100644 --- a/bindings/python/src/utility.cpp +++ b/bindings/python/src/utility.cpp @@ -64,7 +64,7 @@ struct bytes_from_python } }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 object client_fingerprint_(peer_id const& id) { boost::optional result = client_fingerprint(id); @@ -90,7 +90,7 @@ void bind_utility() to_python_converter(); bytes_from_python(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 def("identify_client", <::identify_client); def("client_fingerprint", &client_fingerprint_); #endif diff --git a/bindings/python/src/version.cpp b/bindings/python/src/version.cpp index 2e1a662de..e38976cff 100644 --- a/bindings/python/src/version.cpp +++ b/bindings/python/src/version.cpp @@ -12,7 +12,7 @@ void bind_version() { scope().attr("__version__") = version(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 scope().attr("version") = LIBTORRENT_VERSION; scope().attr("version_major") = LIBTORRENT_VERSION_MAJOR; scope().attr("version_minor") = LIBTORRENT_VERSION_MINOR; diff --git a/docs/features.rst b/docs/features.rst index f412d0e54..6f8e3fe2a 100644 --- a/docs/features.rst +++ b/docs/features.rst @@ -122,6 +122,7 @@ network .. _`BEP 24`: https://bittorrent.org/beps/bep_0024.html .. _`BEP 27`: https://bittorrent.org/beps/bep_0027.html .. _`BEP 29`: https://bittorrent.org/beps/bep_0029.html +.. _`BEP 53`: https://bittorrent.org/beps/bep_0053.html .. _`extension protocol`: extension_protocol.html highlighted features diff --git a/docs/gen_reference_doc.py b/docs/gen_reference_doc.py index 47157df63..db83ea8f7 100644 --- a/docs/gen_reference_doc.py +++ b/docs/gen_reference_doc.py @@ -545,7 +545,7 @@ def consume_comment(lno, lines): def trim_define(l): return l.replace('#ifndef', '').replace('#ifdef', '') \ .replace('#if', '').replace('defined', '') \ - .replace('TORRENT_USE_IPV6', '').replace('TORRENT_NO_DEPRECATE', '') \ + .replace('TORRENT_USE_IPV6', '').replace('TORRENT_ABI_VERSION == 1', '') \ .replace('||', '').replace('&&', '').replace('(', '').replace(')','') \ .replace('!', '').replace('\\', '').strip() @@ -564,7 +564,7 @@ def consume_ifdef(lno, lines, warn_on_ifdefs = False): l += lines[lno].strip() if verbose: print 'prep %s' % lines[lno].trim() define = trim_define(l) - if 'TORRENT_' in define: + if 'TORRENT_' in define and not 'TORRENT_ABI_VERSION' in define: print '\x1b[31mWARNING: possible ABI breakage in public struct! "%s" \x1b[34m %s:%d\x1b[0m' % \ (define, filename, lno) # we've already warned once, no need to do it twice @@ -576,7 +576,7 @@ def consume_ifdef(lno, lines, warn_on_ifdefs = False): ' TORRENT_USE_ASSERTS' in l or ' TORRENT_USE_INVARIANT_CHECKS' in l or ' TORRENT_ASIO_DEBUGGING' in l) or - l == '#ifndef TORRENT_NO_DEPRECATE' + l == '#if TORRENT_ABI_VERSION == 1' ): while lno < len(lines): l = lines[lno].strip() @@ -649,10 +649,6 @@ for filename in files: lno = consume_block(lno, lines) continue - if 'TORRENT_CFG' in l: - blanks += 1 - if verbose: print 'xx %s' % l - continue if 'TORRENT_DEPRECATED' in l: if ('class ' in l or 'struct ' in l) and not ';' in l: lno = consume_block(lno - 1, lines) diff --git a/docs/gen_settings_doc.py b/docs/gen_settings_doc.py index 2aee4b275..5329cf0aa 100755 --- a/docs/gen_settings_doc.py +++ b/docs/gen_settings_doc.py @@ -56,7 +56,7 @@ for l in f: if 'enum string_types' in l: mode = 'string' if 'enum bool_types' in l: mode = 'bool' if 'enum int_types' in l: mode = 'int' - if '#ifndef TORRENT_NO_DEPRECATE' in l: mode += 'skip' + if '#if TORRENT_ABI_VERSION == 1' in l: mode += 'skip' if '#endif' in l: mode = mode[0:-4] if mode == '': continue diff --git a/docs/gen_stats_doc.py b/docs/gen_stats_doc.py index 0925c0b61..5bba99812 100755 --- a/docs/gen_stats_doc.py +++ b/docs/gen_stats_doc.py @@ -89,7 +89,7 @@ for l in f: if '#endif' in l: mode = '' continue - if 'TORRENT_NO_DEPRECATE' in l: + if 'TORRENT_ABI_VERSION == 1' in l: mode = 'ignore' continue diff --git a/include/libtorrent/Makefile.am b/include/libtorrent/Makefile.am index b8c3ee994..f75f6178d 100644 --- a/include/libtorrent/Makefile.am +++ b/include/libtorrent/Makefile.am @@ -21,7 +21,6 @@ nobase_include_HEADERS = \ broadcast_socket.hpp \ bt_peer_connection.hpp \ buffer.hpp \ - build_config.hpp \ chained_buffer.hpp \ choker.hpp \ close_reason.hpp \ diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index ac1737e47..30ac9fd11 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -56,6 +56,8 @@ namespace libtorrent { struct torrent_plugin; struct torrent_handle; +TORRENT_VERSION_NAMESPACE_2 + // The add_torrent_params is a parameter pack for adding torrents to a // session. The key fields when adding a torrent are: // @@ -95,7 +97,7 @@ namespace libtorrent { // These are all deprecated. use torrent_flags_t instead (in // libtorrent/torrent_flags.hpp) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 using flags_t = torrent_flags_t; @@ -123,7 +125,7 @@ namespace libtorrent { DECL_FLAG(merge_resume_http_seeds); DECL_FLAG(default_flags); #undef DECL_FLAG -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #include "libtorrent/aux_/disable_warnings_pop.hpp" @@ -334,7 +336,7 @@ namespace libtorrent { std::time_t last_download = 0; std::time_t last_upload = 0; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // ``url`` can be set to a magnet link, in order to download the .torrent @@ -369,17 +371,11 @@ namespace libtorrent { // communicated forward into libtorrent via this field. If this is set, a // fastresume_rejected_alert will be posted. error_code internal_resume_data_error; -#else - // hidden - // to maintain ABI compatibility - std::string deprecated5; - std::string deprecated1; - std::string deprecated2; - aux::noexcept_movable> deprecated3; - error_code deprecated4; -#endif +#endif // TORRENT_ABI_VERSION }; + +TORRENT_VERSION_NAMESPACE_2_END } #endif diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 54cb2d669..a36f83c24 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -90,7 +90,7 @@ namespace libtorrent { alert& operator=(alert const&) = delete; alert(alert&& rhs) noexcept = default; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // only here for backwards compatibility enum TORRENT_DEPRECATED_ENUM severity_t { debug, info, warning, critical, fatal, none }; #endif @@ -128,7 +128,7 @@ namespace libtorrent { // Enables alerts for when a torrent or the session changes state. static constexpr alert_category_t status_notification = 6_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // Alerts for when blocks are requested and completed. Also when // pieces are completed. static constexpr alert_category_t TORRENT_DEPRECATED_MEMBER progress_notification = 7_bit; @@ -151,7 +151,7 @@ namespace libtorrent { // the lasts stats alert. static constexpr alert_category_t stats_notification = 11_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // Alerts on RSS related events, like feeds being updated, feed error // conditions and successful RSS feed updates. Enabling this category // will make you receive rss_alert alerts. @@ -267,7 +267,7 @@ namespace libtorrent { // returns a bitmask specifying which categories this alert belong to. virtual alert_category_t category() const noexcept = 0; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -286,7 +286,7 @@ namespace libtorrent { #include "libtorrent/aux_/disable_warnings_pop.hpp" -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION private: time_point const m_timestamp; diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index ec2208788..de082a2bc 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -59,7 +59,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_pop.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #define PROGRESS_NOTIFICATION | alert::progress_notification #else #define PROGRESS_NOTIFICATION @@ -68,7 +68,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED_EXPORT char const* operation_name(int op); #endif @@ -82,6 +82,20 @@ namespace libtorrent { alert_priority_critical }; + // struct to hold information about a single DHT routing table bucket + struct TORRENT_EXPORT dht_routing_bucket + { + // the total number of nodes and replacement nodes + // in the routing table + int num_nodes; + int num_replacements; + + // number of seconds since last activity + int last_active; + }; + +TORRENT_VERSION_NAMESPACE_2 + // This is a base class for alerts that are associated with a // specific torrent. It contains a handle to the torrent. struct TORRENT_EXPORT torrent_alert : alert @@ -90,7 +104,7 @@ namespace libtorrent { torrent_alert(aux::stack_allocator& alloc, torrent_handle const& h); torrent_alert(torrent_alert&&) noexcept = default; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 static const int TORRENT_DEPRECATED_MEMBER alert_type = 0; #endif @@ -107,7 +121,7 @@ namespace libtorrent { std::reference_wrapper m_alloc; private: aux::allocation_slot m_name_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: std::string TORRENT_DEPRECATED_MEMBER name; #endif @@ -122,7 +136,7 @@ namespace libtorrent { tcp::endpoint const& i, peer_id const& pi); peer_alert(peer_alert&& rhs) noexcept = default; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 static const int TORRENT_DEPRECATED_MEMBER alert_type = 1; #endif @@ -134,7 +148,7 @@ namespace libtorrent { // the peer ID, if known. peer_id pid; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // The peer's IP address and port. aux::noexcept_movable TORRENT_DEPRECATED_MEMBER ip; #endif @@ -149,7 +163,7 @@ namespace libtorrent { tracker_alert(aux::stack_allocator& alloc, torrent_handle const& h , tcp::endpoint const& ep, string_view u); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 static const int TORRENT_DEPRECATED_MEMBER alert_type = 2; #endif @@ -163,7 +177,7 @@ namespace libtorrent { private: aux::allocation_slot m_url_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // The tracker URL std::string TORRENT_DEPRECATED_MEMBER url; @@ -184,7 +198,7 @@ namespace libtorrent { #define TORRENT_DEFINE_ALERT_PRIO(name, seq, prio) \ TORRENT_DEFINE_ALERT_IMPL(name, seq, prio) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // The ``torrent_added_alert`` is posted once every time a torrent is successfully // added. It doesn't contain any members of its own, but inherits the torrent handle // from its base class. @@ -252,7 +266,7 @@ namespace libtorrent { piece_index_t const piece; int const size; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 error_code TORRENT_DEPRECATED_MEMBER ec; #endif }; @@ -303,7 +317,7 @@ namespace libtorrent { file_index_t const index; private: aux::allocation_slot m_name_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #if defined __clang__ #pragma clang diagnostic push @@ -488,7 +502,7 @@ namespace libtorrent { private: aux::allocation_slot m_msg_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: int const TORRENT_DEPRECATED_MEMBER status_code; std::string TORRENT_DEPRECATED_MEMBER msg; @@ -515,7 +529,7 @@ namespace libtorrent { private: aux::allocation_slot m_msg_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // contains the warning message from the tracker. std::string TORRENT_DEPRECATED_MEMBER msg; @@ -570,7 +584,7 @@ namespace libtorrent { private: aux::allocation_slot m_msg_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // contains a message describing the error. std::string TORRENT_DEPRECATED_MEMBER msg; @@ -720,7 +734,7 @@ namespace libtorrent { // tells you what error caused this alert. error_code const error; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int const TORRENT_DEPRECATED_MEMBER operation; std::string TORRENT_DEPRECATED_MEMBER msg; #endif @@ -769,7 +783,7 @@ namespace libtorrent { // the reason the peer disconnected (if specified) close_reason_t const reason; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int const TORRENT_DEPRECATED_MEMBER operation; std::string TORRENT_DEPRECATED_MEMBER msg; #endif @@ -957,7 +971,7 @@ namespace libtorrent { int const block_index; piece_index_t const piece_index; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 char const* TORRENT_DEPRECATED_MEMBER peer_speedmsg; #endif }; @@ -1001,7 +1015,7 @@ namespace libtorrent { private: aux::allocation_slot m_path_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: std::string TORRENT_DEPRECATED_MEMBER path; #endif @@ -1030,7 +1044,7 @@ namespace libtorrent { operation_t op; private: aux::allocation_slot m_file_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: char const* TORRENT_DEPRECATED_MEMBER operation; // If the error happened for a specific file, ``file`` is its path. @@ -1081,7 +1095,7 @@ namespace libtorrent { // the info hash of the torrent whose files failed to be deleted sha1_hash info_hash; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -1105,7 +1119,7 @@ namespace libtorrent { // save the state to disk, you may pass it on to write_resume_data(). add_torrent_params params; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // points to the resume data. std::shared_ptr TORRENT_DEPRECATED_MEMBER resume_data; #endif @@ -1128,7 +1142,7 @@ namespace libtorrent { // the error code from the resume_data failure error_code const error; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -1201,7 +1215,7 @@ namespace libtorrent { private: aux::allocation_slot m_url_idx; aux::allocation_slot m_msg_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // the HTTP seed that failed std::string TORRENT_DEPRECATED_MEMBER url; @@ -1238,7 +1252,7 @@ namespace libtorrent { private: aux::allocation_slot m_file_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: char const* TORRENT_DEPRECATED_MEMBER operation; // the path to the file that was accessed when the error occurred. @@ -1366,7 +1380,7 @@ namespace libtorrent { // listen on it. struct TORRENT_EXPORT listen_failed_alert final : alert { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum socket_type_t : std::uint8_t { tcp TORRENT_DEPRECATED_ENUM, @@ -1422,9 +1436,9 @@ namespace libtorrent { private: std::reference_wrapper m_alloc; aux::allocation_slot m_interface_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: - enum op_t + enum TORRENT_DEPRECATED_ENUM op_t { parse_addr TORRENT_DEPRECATED_ENUM, open TORRENT_DEPRECATED_ENUM, @@ -1452,7 +1466,7 @@ namespace libtorrent { // successfully was opened for listening. struct TORRENT_EXPORT listen_succeeded_alert final : alert { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum socket_type_t : std::uint8_t { tcp TORRENT_DEPRECATED_ENUM, @@ -1493,7 +1507,7 @@ namespace libtorrent { // the type of listen socket this alert refers to. libtorrent::socket_type_t const socket_type; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the endpoint libtorrent ended up listening on. The address // refers to the local interface and the port is the listen port. aux::noexcept_movable TORRENT_DEPRECATED_MEMBER endpoint; @@ -1531,7 +1545,7 @@ namespace libtorrent { // tells you what failed. error_code const error; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // is 0 for NAT-PMP and 1 for UPnP. int const TORRENT_DEPRECATED_MEMBER map_type; @@ -1565,7 +1579,7 @@ namespace libtorrent { portmap_transport const map_transport; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum TORRENT_DEPRECATED_ENUM protocol_t { tcp, @@ -1606,7 +1620,7 @@ namespace libtorrent { std::reference_wrapper m_alloc; aux::allocation_slot m_log_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: int const TORRENT_DEPRECATED_MEMBER map_type; std::string TORRENT_DEPRECATED_MEMBER msg; @@ -1640,7 +1654,7 @@ namespace libtorrent { private: aux::allocation_slot m_path_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // If the error happened in a disk operation. a 0-terminated string of // the name of that operation. ``operation`` is nullptr otherwise. @@ -1743,7 +1757,7 @@ namespace libtorrent { download_payload, download_protocol, upload_ip_protocol, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 upload_dht_protocol TORRENT_DEPRECATED_ENUM, upload_tracker_protocol TORRENT_DEPRECATED_ENUM, #else @@ -1751,7 +1765,7 @@ namespace libtorrent { deprecated2, #endif download_ip_protocol, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 download_dht_protocol TORRENT_DEPRECATED_ENUM, download_tracker_protocol TORRENT_DEPRECATED_ENUM, #else @@ -1848,7 +1862,7 @@ namespace libtorrent { private: aux::allocation_slot m_tracker_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // The tracker ID returned by the tracker std::string TORRENT_DEPRECATED_MEMBER trackerid; @@ -1887,7 +1901,7 @@ namespace libtorrent { private: aux::allocation_slot m_file_idx; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: // the filename (or object) the error occurred on. std::string TORRENT_DEPRECATED_MEMBER error_file; @@ -1909,7 +1923,7 @@ namespace libtorrent { static constexpr alert_category_t static_category = alert::status_notification; std::string message() const override; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 error_code const TORRENT_DEPRECATED_MEMBER error; #endif }; @@ -1950,7 +1964,7 @@ namespace libtorrent { // is the IP address and port the connection came from. aux::noexcept_movable endpoint; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // is the IP address and port the connection came from. aux::noexcept_movable TORRENT_DEPRECATED_MEMBER ip; #endif @@ -2002,7 +2016,7 @@ namespace libtorrent { std::vector status; }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef _MSC_VER #pragma warning(push, 1) // warning C4996: X: was declared deprecated @@ -2029,7 +2043,7 @@ namespace libtorrent { #ifdef _MSC_VER #pragma warning(pop) #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // The session_stats_alert is posted when the user requests session statistics by // calling post_session_stats() on the session object. Its category is @@ -2045,7 +2059,7 @@ namespace libtorrent { { session_stats_alert(aux::stack_allocator& alloc, counters const& cnt); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -2056,7 +2070,7 @@ namespace libtorrent { #endif #endif TORRENT_DEFINE_ALERT_PRIO(session_stats_alert, 70, alert_priority_critical) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -2079,14 +2093,16 @@ namespace libtorrent { // For more information, see the session-statistics_ section. span counters() const; -#ifdef TORRENT_NO_DEPRECATE - private: -#endif - // TODO: allocate this on the alert_stack in the future +#if TORRENT_ABI_VERSION == 1 std::array const TORRENT_DEPRECATED_MEMBER values; +#else + private: + std::reference_wrapper m_alloc; + aux::allocation_slot m_counters_idx; +#endif }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // hidden // When a torrent changes its info-hash, this alert is posted. This only // happens in very specific cases. For instance, when a torrent is @@ -2125,7 +2141,7 @@ namespace libtorrent { #ifdef _MSC_VER #pragma warning(pop) #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // posted when something fails in the DHT. This is not necessarily a fatal // error, but it could prevent proper operation @@ -2146,7 +2162,7 @@ namespace libtorrent { // the operation that failed operation_t op; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum op_t { unknown TORRENT_DEPRECATED_ENUM, @@ -2289,7 +2305,7 @@ namespace libtorrent { // the endpoint we're sending this query to aux::noexcept_movable endpoint; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the endpoint we're sending this query to aux::noexcept_movable TORRENT_DEPRECATED_MEMBER ip; #endif @@ -2313,7 +2329,7 @@ namespace libtorrent { // returns the log message char const* log_message() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // returns the log message TORRENT_DEPRECATED char const* msg() const; @@ -2342,7 +2358,7 @@ namespace libtorrent { // returns the log message char const* log_message() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // returns the log message TORRENT_DEPRECATED char const* msg() const; @@ -2389,7 +2405,7 @@ namespace libtorrent { // returns the log message char const* log_message() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // returns the log message TORRENT_DEPRECATED char const* msg() const; @@ -2463,18 +2479,6 @@ namespace libtorrent { sha1_hash target; }; - // struct to hold information about a single DHT routing table bucket - struct TORRENT_EXPORT dht_routing_bucket - { - // the total number of nodes and replacement nodes - // in the routing table - int num_nodes; - int num_replacements; - - // number of seconds since last activity - int last_active; - }; - // contains current DHT state. Posted in response to session::post_dht_stats(). struct TORRENT_EXPORT dht_stats_alert final : alert { @@ -2579,7 +2583,7 @@ namespace libtorrent { std::reference_wrapper m_alloc; aux::allocation_slot m_msg_idx; std::size_t const m_size; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: direction_t TORRENT_DEPRECATED_MEMBER dir; #endif @@ -2601,7 +2605,7 @@ namespace libtorrent { int num_peers() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED void peers(std::vector& v) const; #endif @@ -2640,7 +2644,7 @@ namespace libtorrent { std::reference_wrapper m_alloc; aux::allocation_slot m_response_idx; int const m_response_size; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 public: aux::noexcept_movable TORRENT_DEPRECATED_MEMBER addr; #endif @@ -2831,6 +2835,8 @@ namespace libtorrent { piece_index_t const piece_index; }; +TORRENT_VERSION_NAMESPACE_2_END + #undef TORRENT_DEFINE_ALERT_IMPL #undef TORRENT_DEFINE_ALERT #undef TORRENT_DEFINE_ALERT_PRIO diff --git a/include/libtorrent/announce_entry.hpp b/include/libtorrent/announce_entry.hpp index da9fce2be..94c914f53 100644 --- a/include/libtorrent/announce_entry.hpp +++ b/include/libtorrent/announce_entry.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_ANNOUNCE_ENTRY_HPP_INCLUDED #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/time.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/string_view.hpp" @@ -51,7 +52,11 @@ namespace libtorrent { struct TORRENT_EXPORT announce_endpoint { friend class torrent; +#if TORRENT_ABI_VERSION == 1 friend struct announce_entry; +#else + friend struct v1_2::announce_entry; +#endif // internal explicit announce_endpoint(aux::listen_socket_handle const& s); @@ -135,6 +140,8 @@ namespace libtorrent { bool is_working() const { return fails == 0; } }; +TORRENT_VERSION_NAMESPACE_2 + // this class holds information about one bittorrent tracker, as it // relates to a specific torrent. struct TORRENT_EXPORT announce_entry @@ -184,7 +191,7 @@ namespace libtorrent { // from this tracker. bool verified:1; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // all of these will be set to false or 0 // use the corresponding members in announce_endpoint @@ -195,14 +202,6 @@ namespace libtorrent { // internal bool TORRENT_DEPRECATED_MEMBER triggered_manually:1; bool TORRENT_DEPRECATED_MEMBER updating:1; -#else - // hidden - std::uint8_t deprecated_fails:7; - bool deprecated_send_stats:1; - bool deprecated_start_sent:1; - bool deprecated_complete_sent:1; - bool deprecated_triggered_manually:1; - bool deprecated_updating:1; #endif // reset announce counters and clears the started sent flag. @@ -210,7 +209,7 @@ namespace libtorrent { // the tracker. void reset(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2, use announce_endpoint::can_announce // returns true if we can announce to this tracker now. // The current time is passed in as ``now``. The ``is_seed`` @@ -232,6 +231,8 @@ namespace libtorrent { void trim(); }; +TORRENT_VERSION_NAMESPACE_2_END + } #endif diff --git a/include/libtorrent/aux_/escape_string.hpp b/include/libtorrent/aux_/escape_string.hpp index 5007df460..29f352d2b 100644 --- a/include/libtorrent/aux_/escape_string.hpp +++ b/include/libtorrent/aux_/escape_string.hpp @@ -66,7 +66,7 @@ namespace libtorrent { TORRENT_EXTRA_EXPORT string_view trim(string_view); TORRENT_EXTRA_EXPORT string_view::size_type find(string_view haystack, string_view needle, string_view::size_type pos); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // convert a file://-URL to a proper path TORRENT_EXTRA_EXPORT std::string resolve_file_url(std::string const& url); diff --git a/include/libtorrent/aux_/proxy_settings.hpp b/include/libtorrent/aux_/proxy_settings.hpp index 124ccaf32..e9f7477dd 100644 --- a/include/libtorrent/aux_/proxy_settings.hpp +++ b/include/libtorrent/aux_/proxy_settings.hpp @@ -67,7 +67,7 @@ namespace aux { std::string username; std::string password; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the type of proxy to use. Assign one of these to the // proxy_settings::type field. enum proxy_type diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index a369d64cc..2be68889a 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -82,7 +82,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/portmap.hpp" #include "libtorrent/aux_/lsd.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/session_settings.hpp" #endif @@ -344,7 +344,7 @@ namespace aux { void incoming_connection(std::shared_ptr const& s); std::weak_ptr find_torrent(sha1_hash const& info_hash) const override; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 TORRENT_DEPRECATED @@ -353,6 +353,10 @@ namespace aux { TORRENT_DEPRECATED std::weak_ptr find_torrent(std::string const& uuid) const; + + TORRENT_DEPRECATED + void insert_uuid_torrent(std::string uuid, std::shared_ptr const& t) override + { m_uuids.insert(std::make_pair(uuid, t)); } #endif #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS std::vector> find_collection( @@ -363,12 +367,7 @@ namespace aux { void insert_torrent(sha1_hash const& ih, std::shared_ptr const& t , std::string uuid) override; -#ifndef TORRENT_NO_DEPRECATE - //deprecated in 1.2 - TORRENT_DEPRECATED - void insert_uuid_torrent(std::string uuid, std::shared_ptr const& t) override - { m_uuids.insert(std::make_pair(uuid, t)); } -#endif + std::shared_ptr delay_load_torrent(sha1_hash const& info_hash , peer_connection* pc) override; void set_queue_position(torrent* t, queue_position_t p) override; @@ -425,7 +424,7 @@ namespace aux { void dht_direct_request(udp::endpoint const& ep, entry& e , void* userdata = nullptr); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED entry dht_state() const; TORRENT_DEPRECATED @@ -506,7 +505,7 @@ namespace aux { add_torrent_impl(add_torrent_params& p, error_code& ec); void async_add_torrent(add_torrent_params* params); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void on_async_load_torrent(add_torrent_params* params, error_code ec); #endif @@ -527,7 +526,7 @@ namespace aux { void pop_alerts(std::vector* alerts); alert* wait_for_alert(time_duration max_wait); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED void pop_alerts(); TORRENT_DEPRECATED alert const* pop_alert(); TORRENT_DEPRECATED std::size_t set_alert_queue_size_limit(std::size_t queue_size_limit_); @@ -580,7 +579,7 @@ namespace aux { m_optimistic_unchoke_time_scaler = 0; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 session_status status() const; peer_id deprecated_get_peer_id() const; #endif @@ -714,7 +713,7 @@ namespace aux { // the settings for the client aux::session_settings m_settings; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void update_ssl_listen(); void update_dht_upload_rate_limit(); void update_local_download_rate(); @@ -807,7 +806,7 @@ namespace aux { // handles delayed alerts mutable alert_manager m_alerts; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the alert pointers stored in m_alerts mutable aux::vector m_alert_pointers; @@ -869,7 +868,7 @@ namespace aux { torrent_map m_obfuscated_torrents; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 std::map> m_uuids; #endif @@ -1141,7 +1140,7 @@ namespace aux { std::shared_ptr m_upnp; std::shared_ptr m_lsd; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct work_thread_t { work_thread_t() @@ -1256,7 +1255,7 @@ namespace aux { std::array>, 4> m_ses_extensions; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 user_load_function_t m_user_load_torrent; #endif diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index b84880dae..edd4948ad 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_SESSION_INTERFACE_HPP_INCLUDED #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/address.hpp" #include "libtorrent/io_service.hpp" #include "libtorrent/time.hpp" @@ -64,9 +65,6 @@ namespace libtorrent { class peer_connection; class torrent; -#ifndef TORRENT_NO_DEPRECATE - struct pe_settings; -#endif struct peer_class_set; struct bandwidth_channel; struct bandwidth_manager; @@ -78,12 +76,7 @@ namespace libtorrent { struct tracker_request; struct request_callback; struct utp_socket_manager; - struct block_info; struct external_ip; - struct torrent_handle; - struct ip_filter; - class port_filter; - struct settings_pack; struct torrent_peer_allocator_interface; struct counters; struct resolver_interface; @@ -193,7 +186,7 @@ namespace aux { , peer_connection* pc) = 0; virtual void insert_torrent(sha1_hash const& ih, std::shared_ptr const& t , std::string uuid) = 0; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 virtual void insert_uuid_torrent(std::string uuid, std::shared_ptr const& t) = 0; #endif diff --git a/include/libtorrent/aux_/storage_utils.hpp b/include/libtorrent/aux_/storage_utils.hpp index c6d5d2a1e..d9d4c994a 100644 --- a/include/libtorrent/aux_/storage_utils.hpp +++ b/include/libtorrent/aux_/storage_utils.hpp @@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/span.hpp" #include "libtorrent/aux_/typed_span.hpp" #include "libtorrent/units.hpp" @@ -45,11 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - class file_storage; struct part_file; - struct storage_error; struct stat_cache; - struct add_torrent_params; // TODO: 3 remove this typedef, and use span for disk write // operations diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index 7f9d21fbc..bb4f88206 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -103,7 +103,7 @@ namespace libtorrent { TORRENT_EXPORT boost::system::error_category& bdecode_category(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline boost::system::error_category& get_bdecode_category() { return bdecode_category(); } @@ -252,7 +252,7 @@ struct bdecode_token // There are 5 different types of nodes, see type_t. struct TORRENT_EXPORT bdecode_node { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED_EXPORT friend int bdecode(char const* start, char const* end, bdecode_node& ret , error_code& ec, int* error_pos, int depth_limit , int token_limit); diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 3cfede6b1..919e29b2e 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -79,7 +79,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 using invalid_encoding = system_error; #endif diff --git a/include/libtorrent/bitfield.hpp b/include/libtorrent/bitfield.hpp index bccfda3dd..9003cf557 100644 --- a/include/libtorrent/bitfield.hpp +++ b/include/libtorrent/bitfield.hpp @@ -136,7 +136,7 @@ namespace libtorrent { char const* data() const { return m_buf ? reinterpret_cast(&m_buf[1]) : nullptr; } char* data() { return m_buf ? reinterpret_cast(&m_buf[1]) : nullptr; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED char const* bytes() const { return data(); } #endif diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index ff381ef4f..45fee2e59 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -471,7 +471,7 @@ namespace aux { void clear(tailqueue& jobs); void update_stats_counters(counters& c) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void get_stats(cache_status* ret) const; #endif void set_settings(aux::session_settings const& sett); diff --git a/include/libtorrent/build_config.hpp b/include/libtorrent/build_config.hpp deleted file mode 100644 index b024c9ffb..000000000 --- a/include/libtorrent/build_config.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - -Copyright (c) 2010-2018, Arvid Norberg -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef TORRENT_BUILD_CONFIG_HPP_INCLUDED -#define TORRENT_BUILD_CONFIG_HPP_INCLUDED - -#include "libtorrent/config.hpp" -#include -#include - -// TODO: 2 instead of using a dummy function to cause link errors when -// incompatible build configurations are used, make the namespace name -// depend on the configuration, and have a using declaration in the headers -// to pull it into libtorrent. -#if TORRENT_USE_IPV6 -#define TORRENT_CFG_IPV6 ipv6_ -#else -#define TORRENT_CFG_IPV6 noipv6_ -#endif - -#ifdef TORRENT_NO_DEPRECATE -#define TORRENT_CFG_DEPR nodeprecate_ -#else -#define TORRENT_CFG_DEPR deprecated_ -#endif - -#if defined TORRENT_EXPORT_EXTRA -#if TORRENT_USE_ASSERTS -#define TORRENT_CFG_ASSERTS asserts_ -#else -#define TORRENT_CFG_ASSERTS noasserts_ -#endif -#else -#define TORRENT_CFG_ASSERTS -#endif - -#define TORRENT_CFG \ - BOOST_PP_CAT(TORRENT_CFG_IPV6, \ - BOOST_PP_CAT(TORRENT_CFG_DEPR, \ - TORRENT_CFG_ASSERTS)) - -#define TORRENT_CFG_STRING BOOST_PP_STRINGIZE(TORRENT_CFG) - -#endif - diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 5d7e85c04..392a234e1 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -38,20 +38,17 @@ POSSIBILITY OF SUCH DAMAGE. #define _FILE_OFFSET_BITS 64 #include -#include #include "libtorrent/aux_/disable_warnings_pop.hpp" +// TODO: don't include that here. Make each header that use the export macros +// include it instead. and move it to aux_ #include "libtorrent/export.hpp" #ifdef __linux__ #include // for LINUX_VERSION_CODE and KERNEL_VERSION #endif // __linux -#if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LINK -#define BOOST_ASIO_SEPARATE_COMPILATION -#endif - #if defined __MINGW64__ || defined __MINGW32__ // GCC warns on format codes that are incompatible with glibc, which the windows // format codes are. So we need to disable those for mingw targets @@ -249,6 +246,10 @@ POSSIBILITY OF SUCH DAMAGE. # define TORRENT_USE_GETIPFORWARDTABLE 1 #endif +#ifndef NOMINMAX +#define NOMINMAX +#endif + # if !defined TORRENT_USE_LIBCRYPTO && !defined TORRENT_USE_LIBGCRYPT // unless some other crypto library has been specified, default to the native // windows CryptoAPI @@ -614,6 +615,14 @@ constexpr std::size_t TORRENT_WRITE_HANDLER_MAX_SIZE = 342; #endif #endif // TORRENT_HAS_ARM_CRC32 +#if TORRENT_USE_IPV6 +#define TORRENT_IPV6_NAMESPACE inline namespace v6 { +#define TORRENT_IPV6_NAMESPACE_END } +#else +#define TORRENT_IPV6_NAMESPACE +#define TORRENT_IPV6_NAMESPACE_END +#endif + namespace libtorrent {} // create alias diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index b0fb9c94b..ad1cd9411 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -106,7 +106,7 @@ namespace libtorrent { // files, to keep the impact down for clients that don't support // them. static constexpr create_flags_t optimize_alignment = 0_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // same as optimize_alignment, for backwards compatibility static constexpr create_flags_t TORRENT_DEPRECATED_MEMBER optimize = 0_bit; #endif @@ -420,7 +420,7 @@ namespace detail { // all wstring APIs are deprecated since 0.16.11 // instead, use the wchar -> utf8 conversion functions // and pass in utf8 strings -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED_EXPORT void add_files(file_storage& fs, std::wstring const& wfile @@ -463,7 +463,7 @@ namespace detail { { set_piece_hashes_deprecated(t, p, detail::nop, ec); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION } diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index 20c438b8f..23ec7779d 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/fwd.hpp" #include "libtorrent/units.hpp" #include "libtorrent/disk_buffer_holder.hpp" #include "libtorrent/aux_/vector.hpp" @@ -50,17 +51,9 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct storage_interface; - struct peer_request; struct disk_observer; - struct add_torrent_params; - struct cache_status; struct disk_buffer_holder; struct counters; - struct settings_pack; - struct storage_params; - struct storage_error; - class file_storage; struct storage_holder; @@ -96,7 +89,7 @@ namespace libtorrent { // logic constexpr file_open_mode_t random_access = 5_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // prevent the file from being opened by another process // while it's still being held open by this handle constexpr file_open_mode_t TORRENT_DEPRECATED locked = 6_bit; @@ -123,7 +116,7 @@ namespace libtorrent { time_point last_use; }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 using pool_file_status = open_file_state; #endif diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 94839e556..321c3034d 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISK_IO_JOB_HPP #define TORRENT_DISK_IO_JOB_HPP +#include "libtorrent/fwd.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/tailqueue.hpp" #include "libtorrent/peer_request.hpp" @@ -55,10 +56,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct storage_interface; struct cached_piece_entry; - class torrent_info; - struct add_torrent_params; enum class job_action_t : std::uint8_t { diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 4ef0b457e..1fd03dae7 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_DISK_IO_THREAD #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/debug.hpp" #include "libtorrent/storage.hpp" #include "libtorrent/allocator.hpp" @@ -56,8 +57,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - class alert; - struct add_torrent_params; struct counters; class alert_manager; @@ -104,7 +103,7 @@ namespace aux { // initializes all counters to 0 cache_status() : pieces() -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , blocks_written(0) , writes(0) , blocks_read(0) @@ -142,14 +141,14 @@ namespace aux { , num_writing_threads(0) #endif { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::memset(num_fence_jobs, 0, sizeof(num_fence_jobs)); #endif } std::vector pieces; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the total number of 16 KiB blocks written to disk // since this session was started. int blocks_written; diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 43fceb007..a4cec458c 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -78,7 +78,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct lazy_entry; // backwards compatibility using type_error = system_error; @@ -190,7 +190,7 @@ namespace aux { // copies the structure of the right hand side into this // entry. -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 entry& operator=(lazy_entry const&); #endif entry& operator=(bdecode_node const&); diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index a0992e6a4..4eeecf206 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -420,7 +420,7 @@ namespace libtorrent { // invalid action field in udp tracker response invalid_tracker_action, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // expected string in bencoded string expected_string = 190, // expected colon in bencoded string @@ -489,7 +489,7 @@ namespace libtorrent { using system_error = boost::system::system_error; #ifndef BOOST_NO_EXCEPTIONS -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline boost::system::error_category& get_libtorrent_category() { return libtorrent_category(); } @@ -523,7 +523,7 @@ namespace libtorrent { // kind of operation failed. operation_t operation; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // Returns a string literal representing the file operation // that failed. If there were no failure, it returns // an empty string. diff --git a/include/libtorrent/export.hpp b/include/libtorrent/export.hpp index 478e684cc..31f0e35ba 100644 --- a/include/libtorrent/export.hpp +++ b/include/libtorrent/export.hpp @@ -35,6 +35,22 @@ POSSIBILITY OF SUCH DAMAGE. #include +#if !defined TORRENT_ABI_VERSION + #ifdef TORRENT_NO_DEPRECATE + #define TORRENT_ABI_VERSION 2 + #else + #define TORRENT_ABI_VERSION 1 + #endif +#endif + +#if TORRENT_ABI_VERSION >= 2 +#define TORRENT_VERSION_NAMESPACE_2 inline namespace v1_2 { +#define TORRENT_VERSION_NAMESPACE_2_END } +#else +#define TORRENT_VERSION_NAMESPACE_2 +#define TORRENT_VERSION_NAMESPACE_2_END +#endif + // backwards compatibility with older versions of boost #if !defined BOOST_SYMBOL_EXPORT && !defined BOOST_SYMBOL_IMPORT # if defined _MSC_VER || defined __MINGW32__ @@ -74,7 +90,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif // only export this type if deprecated functions are enabled -#ifdef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION >= 2 #define TORRENT_DEPRECATED_EXPORT TORRENT_EXTRA_EXPORT #else #define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index f09eec071..6ee533561 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -166,6 +166,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/span.hpp" #include "libtorrent/sha1_hash.hpp" #include "libtorrent/string_view.hpp" @@ -174,18 +175,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct peer_plugin; - struct peer_request; - class entry; - struct bdecode_node; - struct bitfield; - class alert; - struct torrent_plugin; - struct add_torrent_params; - struct torrent_handle; - struct session_handle; - struct peer_connection_handle; - // these are flags that can be returned by implemented_features() // indicating which callbacks this plugin is interested in using feature_flags_t = flags::bitfield_flag; diff --git a/include/libtorrent/file_pool.hpp b/include/libtorrent/file_pool.hpp index 92c202d51..32d6fe342 100644 --- a/include/libtorrent/file_pool.hpp +++ b/include/libtorrent/file_pool.hpp @@ -90,15 +90,6 @@ namespace libtorrent { // any file to stay open for too long, allowing the disk cache to accrue. void close_oldest(); -#if TORRENT_USE_ASSERTS - bool assert_idle_files(storage_index_t st) const; - - // remember that this storage has had - // its files deleted. We may not open any - // files from it again - void mark_deleted(file_storage const& fs); -#endif - private: file_handle remove_oldest(std::unique_lock&); @@ -117,11 +108,9 @@ namespace libtorrent { // maps storage pointer, file index pairs to the // LRU entry for the file std::map, lru_file_entry> m_files; -#if TORRENT_USE_ASSERTS - std::vector> m_deleted_storages; -#endif mutable std::mutex m_mutex; }; + } #endif diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 215cb6c09..7634deab0 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // information about a file in a file_storage struct TORRENT_DEPRECATED_EXPORT file_entry { @@ -103,7 +103,7 @@ namespace libtorrent { // where the data for this file was found. bool symlink_attribute:1; }; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // internal struct TORRENT_DEPRECATED_EXPORT internal_file_entry @@ -217,7 +217,7 @@ namespace libtorrent { // not. bool is_valid() const { return m_piece_length > 0; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 static constexpr file_flags_t TORRENT_DEPRECATED_MEMBER pad_file = 0_bit; static constexpr file_flags_t TORRENT_DEPRECATED_MEMBER attribute_hidden = 1_bit; static constexpr file_flags_t TORRENT_DEPRECATED_MEMBER attribute_executable = 2_bit; @@ -278,7 +278,7 @@ namespace libtorrent { // that filenames are expected to be UTF-8 encoded. void rename_file(file_index_t index, std::string const& new_filename); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED void add_file_borrow(char const* filename, int filename_len , std::string const& path, std::int64_t file_size @@ -300,7 +300,7 @@ namespace libtorrent { void set_name(std::wstring const& n); void rename_file_deprecated(file_index_t index, std::wstring const& new_filename); -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // returns a list of file_slice objects representing the portions of // files the specified piece index, byte offset and size range overlaps. @@ -323,7 +323,7 @@ namespace libtorrent { // integer. peer_request map_file(file_index_t file, std::int64_t offset, int size) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // all functions depending on internal_file_entry // were deprecated in 1.0. Use the variants that take an // index instead @@ -361,7 +361,7 @@ namespace libtorrent { reverse_iterator rend_deprecated() const { return m_files.rend(); } iterator file_at_offset_deprecated(std::int64_t offset) const; file_entry at_deprecated(int index) const; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // returns the number of files in the file_storage int num_files() const @@ -511,7 +511,7 @@ namespace libtorrent { char const* file_name_ptr(file_index_t index) const; int file_name_len(file_index_t index) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // these were deprecated in 1.0. Use the versions that take an index instead TORRENT_DEPRECATED sha1_hash hash(internal_file_entry const& fe) const; diff --git a/include/libtorrent/fingerprint.hpp b/include/libtorrent/fingerprint.hpp index cb95417df..20a380400 100644 --- a/include/libtorrent/fingerprint.hpp +++ b/include/libtorrent/fingerprint.hpp @@ -82,7 +82,7 @@ namespace libtorrent { { fingerprint(const char* id_string, int major, int minor, int revision, int tag); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // generates the actual string put in the peer-id, and return it. std::string to_string() const; #endif diff --git a/include/libtorrent/flags.hpp b/include/libtorrent/flags.hpp index 679b8704f..8c5811808 100644 --- a/include/libtorrent/flags.hpp +++ b/include/libtorrent/flags.hpp @@ -64,7 +64,7 @@ struct bitfield_flag constexpr bitfield_flag() noexcept : m_val(0) {} explicit constexpr bitfield_flag(UnderlyingType const val) noexcept : m_val(val) {} constexpr bitfield_flag(bit_t const bit) noexcept : m_val(static_cast(UnderlyingType{1} << static_cast(bit))) {} -#ifdef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION >= 2 explicit constexpr operator UnderlyingType() const noexcept { return m_val; } #else constexpr operator UnderlyingType() const noexcept { return m_val; } diff --git a/include/libtorrent/fwd.hpp b/include/libtorrent/fwd.hpp index 269c1d0ae..157edc635 100644 --- a/include/libtorrent/fwd.hpp +++ b/include/libtorrent/fwd.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2017-2018, Arvid Norberg +Copyright (c) 2017, Arvid Norberg All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,15 +33,21 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_FWD_HPP #define TORRENT_FWD_HPP +#include "libtorrent/config.hpp" + namespace libtorrent { // include/libtorrent/add_torrent_params.hpp +TORRENT_VERSION_NAMESPACE_2 struct add_torrent_params; +TORRENT_VERSION_NAMESPACE_2_END // include/libtorrent/alert.hpp class alert; // include/libtorrent/alert_types.hpp +struct dht_routing_bucket; +TORRENT_VERSION_NAMESPACE_2 struct torrent_alert; struct peer_alert; struct tracker_alert; @@ -121,7 +127,6 @@ struct torrent_log_alert; struct peer_log_alert; struct lsd_error_alert; struct dht_lookup; -struct dht_routing_bucket; struct dht_stats_alert; struct incoming_request_alert; struct dht_log_alert; @@ -134,10 +139,13 @@ struct dht_live_nodes_alert; struct session_stats_header_alert; struct dht_sample_infohashes_alert; struct block_uploaded_alert; +TORRENT_VERSION_NAMESPACE_2_END // include/libtorrent/announce_entry.hpp struct announce_endpoint; +TORRENT_VERSION_NAMESPACE_2 struct announce_entry; +TORRENT_VERSION_NAMESPACE_2_END // include/libtorrent/bdecode.hpp struct bdecode_node; @@ -180,9 +188,29 @@ class hasher; class hasher512; // include/libtorrent/ip_filter.hpp +TORRENT_IPV6_NAMESPACE struct ip_filter; +TORRENT_IPV6_NAMESPACE_END class port_filter; +// include/libtorrent/kademlia/dht_settings.hpp +namespace dht { +struct dht_settings; +} + +// include/libtorrent/kademlia/dht_state.hpp +namespace dht { +struct dht_state; +} + +// include/libtorrent/kademlia/dht_storage.hpp +namespace dht { +struct dht_storage_counters; +} +namespace dht { +struct dht_storage_interface; +} + // include/libtorrent/peer_class.hpp struct peer_class_info; @@ -194,7 +222,9 @@ struct peer_connection_handle; struct bt_peer_connection_handle; // include/libtorrent/peer_info.hpp +TORRENT_VERSION_NAMESPACE_2 struct peer_info; +TORRENT_VERSION_NAMESPACE_2_END // include/libtorrent/peer_request.hpp struct peer_request; @@ -226,8 +256,10 @@ struct storage_interface; struct storage_params; // include/libtorrent/torrent_handle.hpp +TORRENT_IPV6_NAMESPACE struct block_info; struct partial_piece_info; +TORRENT_IPV6_NAMESPACE_END struct torrent_handle; // include/libtorrent/torrent_info.hpp @@ -235,28 +267,18 @@ struct web_seed_entry; class torrent_info; // include/libtorrent/torrent_status.hpp +TORRENT_VERSION_NAMESPACE_2 struct torrent_status; +TORRENT_VERSION_NAMESPACE_2_END -namespace dht { - -// include/libtorrent/kademlia/dht_settings.hpp -struct dht_settings; - -// include/libtorrent/kademlia/dht_state.hpp -struct dht_state; - -// include/libtorrent/kademlia/dht_storage.hpp -struct dht_storage_counters; -struct dht_storage_interface; - -} - -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // include/libtorrent/alert_types.hpp +TORRENT_VERSION_NAMESPACE_2 struct torrent_added_alert; struct mmap_cache_alert; struct torrent_update_alert; +TORRENT_VERSION_NAMESPACE_2_END // include/libtorrent/file_storage.hpp struct file_entry; @@ -269,7 +291,7 @@ struct lazy_entry; // include/libtorrent/session_settings.hpp struct pe_settings; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION } diff --git a/include/libtorrent/gzip.hpp b/include/libtorrent/gzip.hpp index bbebfd4cb..cc92ee35a 100644 --- a/include/libtorrent/gzip.hpp +++ b/include/libtorrent/gzip.hpp @@ -50,7 +50,7 @@ namespace libtorrent { // get the ``error_category`` for zip errors TORRENT_EXPORT boost::system::error_category& gzip_category(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline boost::system::error_category& get_gzip_category() { return gzip_category(); } diff --git a/include/libtorrent/hex.hpp b/include/libtorrent/hex.hpp index dcdd33eeb..a852649af 100644 --- a/include/libtorrent/hex.hpp +++ b/include/libtorrent/hex.hpp @@ -65,7 +65,7 @@ namespace libtorrent { } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 TORRENT_DEPRECATED inline void to_hex(char const* in, int len, char* out) diff --git a/include/libtorrent/i2p_stream.hpp b/include/libtorrent/i2p_stream.hpp index 2e7aab540..be086d78b 100644 --- a/include/libtorrent/i2p_stream.hpp +++ b/include/libtorrent/i2p_stream.hpp @@ -73,7 +73,7 @@ namespace libtorrent { // returns the error category for I2P errors TORRENT_EXPORT boost::system::error_category& i2p_category(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline boost::system::error_category& get_i2p_category() { return i2p_category(); } diff --git a/include/libtorrent/identify_client.hpp b/include/libtorrent/identify_client.hpp index f1f133ff7..fec750ddd 100644 --- a/include/libtorrent/identify_client.hpp +++ b/include/libtorrent/identify_client.hpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/aux_/disable_warnings_push.hpp" #include #include "libtorrent/aux_/disable_warnings_pop.hpp" @@ -64,7 +64,7 @@ namespace aux { TORRENT_DEPRECATED_EXPORT std::string identify_client(const peer_id& p); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic push @@ -96,7 +96,7 @@ namespace aux { #pragma warning(pop) #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION } diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index c0af59277..e821e3257 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -256,6 +256,8 @@ namespace detail { } +TORRENT_IPV6_NAMESPACE + // The ``ip_filter`` class is a set of rules that uniquely categorizes all // ip addresses as allowed or disallowed. The default constructor creates // a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for @@ -320,6 +322,8 @@ private: #endif }; +TORRENT_IPV6_NAMESPACE_END + // the port filter maps non-overlapping port ranges to flags. This // is primarily used to indicate whether a range of ports should // be connected to or not. The default is to have the full port diff --git a/include/libtorrent/kademlia/dht_settings.hpp b/include/libtorrent/kademlia/dht_settings.hpp index 691c94a83..60ccfc158 100644 --- a/include/libtorrent/kademlia/dht_settings.hpp +++ b/include/libtorrent/kademlia/dht_settings.hpp @@ -158,7 +158,7 @@ namespace dht { // to clamp it in order to allow UDP packets go through int max_infohashes_sample_count = 20; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the listen port for the dht. This is a UDP port. zero means use the // same as the tcp interface int service_port = 0; diff --git a/include/libtorrent/kademlia/dht_storage.hpp b/include/libtorrent/kademlia/dht_storage.hpp index 26985e54d..9276cb699 100644 --- a/include/libtorrent/kademlia/dht_storage.hpp +++ b/include/libtorrent/kademlia/dht_storage.hpp @@ -78,7 +78,7 @@ namespace libtorrent { namespace dht { // struct TORRENT_EXPORT dht_storage_interface { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // This function returns the number of torrents tracked by // the DHT at the moment. It's used to fill session_status. // It's deprecated. diff --git a/include/libtorrent/kademlia/dht_tracker.hpp b/include/libtorrent/kademlia/dht_tracker.hpp index de0f8aa3e..36788e100 100644 --- a/include/libtorrent/kademlia/dht_tracker.hpp +++ b/include/libtorrent/kademlia/dht_tracker.hpp @@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct counters; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct session_status; #endif } @@ -133,7 +133,7 @@ namespace libtorrent { namespace dht { void direct_request(udp::endpoint const& ep, entry& e , std::function f); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void dht_status(session_status& s); #endif void dht_status(std::vector& table diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index fd5325e68..a57ea3f88 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -47,14 +47,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include // for udp::endpoint #include #include namespace libtorrent { - struct counters; - struct dht_routing_bucket; } namespace libtorrent { namespace dht { @@ -112,7 +111,7 @@ public: void unreachable(udp::endpoint const& ep); void incoming(aux::listen_socket_handle const& s, msg const& m); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int num_torrents() const { return int(m_storage.num_torrents()); } int num_peers() const { return int(m_storage.num_peers()); } #endif @@ -129,7 +128,7 @@ public: std::int64_t num_global_nodes() const { return m_table.num_global_nodes(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int data_size() const { return int(m_storage.num_torrents()); } #endif @@ -193,7 +192,7 @@ public: std::tuple get_stats_counters() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void status(libtorrent::session_status& s); #endif diff --git a/include/libtorrent/kademlia/routing_table.hpp b/include/libtorrent/kademlia/routing_table.hpp index f57fdd820..56cf3caf6 100644 --- a/include/libtorrent/kademlia/routing_table.hpp +++ b/include/libtorrent/kademlia/routing_table.hpp @@ -40,20 +40,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include #include #include #include -namespace libtorrent { - -#ifndef TORRENT_NO_DEPRECATE - struct session_status; -#endif - struct dht_routing_bucket; -} - namespace libtorrent { namespace dht { struct dht_settings; @@ -148,7 +141,7 @@ public: routing_table(routing_table const&) = delete; routing_table& operator=(routing_table const&) = delete; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void status(session_status& s) const; #endif diff --git a/include/libtorrent/kademlia/traversal_algorithm.hpp b/include/libtorrent/kademlia/traversal_algorithm.hpp index c7acadaef..5eb78fe76 100644 --- a/include/libtorrent/kademlia/traversal_algorithm.hpp +++ b/include/libtorrent/kademlia/traversal_algorithm.hpp @@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include #include @@ -46,8 +47,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -struct dht_lookup; - namespace dht { class node; diff --git a/include/libtorrent/lazy_entry.hpp b/include/libtorrent/lazy_entry.hpp index 78859a5cf..9d4ad3490 100644 --- a/include/libtorrent/lazy_entry.hpp +++ b/include/libtorrent/lazy_entry.hpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_LAZY_ENTRY_HPP_INCLUDED #define TORRENT_LAZY_ENTRY_HPP_INCLUDED -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include #include @@ -408,6 +408,6 @@ namespace libtorrent { } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #endif diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index fa54730b9..96307a6db 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -52,7 +52,7 @@ namespace libtorrent { TORRENT_EXPORT std::string make_magnet_uri(torrent_handle const& handle); TORRENT_EXPORT std::string make_magnet_uri(torrent_info const& info); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifndef BOOST_NO_EXCEPTIONS // deprecated in 0.14 TORRENT_DEPRECATED_EXPORT @@ -73,7 +73,7 @@ namespace libtorrent { TORRENT_DEPRECATED_EXPORT torrent_handle add_magnet_uri(session& ses, std::string const& uri , add_torrent_params p, error_code& ec); -#endif +#endif // TORRENT_ABI_VERSION // This function parses out information from the magnet link and populates the diff --git a/include/libtorrent/operations.hpp b/include/libtorrent/operations.hpp index 082468d20..808ae0e88 100644 --- a/include/libtorrent/operations.hpp +++ b/include/libtorrent/operations.hpp @@ -140,7 +140,7 @@ namespace libtorrent { // to its name. See peer_connection for the constants TORRENT_EXPORT char const* operation_name(operation_t op); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 enum deprecated_operation_t : std::uint8_t { // the error was unexpected and it is unknown which operation caused it diff --git a/include/libtorrent/peer_connection_handle.hpp b/include/libtorrent/peer_connection_handle.hpp index f5ab27fc0..f34bd0f0b 100644 --- a/include/libtorrent/peer_connection_handle.hpp +++ b/include/libtorrent/peer_connection_handle.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_PEER_CONNECTION_HANDLE_HPP_INCLUDED #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/operations.hpp" #include "libtorrent/alert_types.hpp" @@ -43,10 +44,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { class bt_peer_connection; -struct torrent_handle; -struct peer_plugin; -struct peer_info; -struct crypto_plugin; struct TORRENT_EXPORT peer_connection_handle { diff --git a/include/libtorrent/peer_connection_interface.hpp b/include/libtorrent/peer_connection_interface.hpp index fb21417bd..dda4f049b 100644 --- a/include/libtorrent/peer_connection_interface.hpp +++ b/include/libtorrent/peer_connection_interface.hpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PEER_CONNECTION_INTERFACE_HPP #define TORRENT_PEER_CONNECTION_INTERFACE_HPP +#include "libtorrent/fwd.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/alert_types.hpp" @@ -42,7 +43,6 @@ namespace libtorrent { struct torrent_peer; class stat; - struct peer_info; // TODO: make this interface smaller! struct TORRENT_EXTRA_EXPORT peer_connection_interface diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index 31c2fcc0e..9a121170d 100644 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -58,6 +58,8 @@ namespace libtorrent { // direction using bandwidth_state_flags_t = flags::bitfield_flag; +TORRENT_VERSION_NAMESPACE_2 + // holds information and statistics about one peer // that libtorrent is connected to struct TORRENT_EXPORT peer_info @@ -122,7 +124,7 @@ namespace libtorrent { // being connected). static constexpr peer_flags_t connecting = 7_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // The connection is currently queued for a connection // attempt. This may happen if there is a limit set on // the number of half-open TCP connections. @@ -313,12 +315,10 @@ namespace libtorrent { // the kind of connection this peer uses. See connection_type_t. int connection_type; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // an estimate of the rate this peer is downloading at, in // bytes per second. int remote_dl_rate; -#else - int deprecated_remote_dl_rate; #endif // the number of bytes this peer has pending in the disk-io thread. @@ -397,7 +397,7 @@ namespace libtorrent { bandwidth_state_flags_t read_state; bandwidth_state_flags_t write_state; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 static constexpr bandwidth_state_flags_t bw_torrent = bw_limit; static constexpr bandwidth_state_flags_t bw_global = bw_limit; @@ -414,10 +414,11 @@ namespace libtorrent { // have got this amount of free download. std::int64_t load_balancing; #endif - }; -#ifndef TORRENT_NO_DEPRECATE +TORRENT_VERSION_NAMESPACE_2_END + +#if TORRENT_ABI_VERSION == 1 // internal struct TORRENT_EXTRA_EXPORT peer_list_entry { diff --git a/include/libtorrent/peer_list.hpp b/include/libtorrent/peer_list.hpp index 1928b0e79..b4e4be78a 100644 --- a/include/libtorrent/peer_list.hpp +++ b/include/libtorrent/peer_list.hpp @@ -34,6 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_POLICY_HPP_INCLUDED #include + +#include "libtorrent/fwd.hpp" #include "libtorrent/string_util.hpp" // for allocate_string_copy #include "libtorrent/request_blocks.hpp" // for source_rank @@ -53,8 +55,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct ip_filter; - class port_filter; struct torrent_peer_allocator_interface; // this object is used to communicate torrent state and diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 04646de4c..61e56e41e 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -131,7 +131,7 @@ namespace libtorrent { on_disk_queue_counter, on_disk_counter, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_evicted_counter, #endif diff --git a/include/libtorrent/read_resume_data.hpp b/include/libtorrent/read_resume_data.hpp index b3cd64573..6d2d9f136 100644 --- a/include/libtorrent/read_resume_data.hpp +++ b/include/libtorrent/read_resume_data.hpp @@ -33,15 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_READ_RESUME_DATA_HPP_INCLUDE #define TORRENT_READ_RESUME_DATA_HPP_INCLUDE +#include "libtorrent/fwd.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/export.hpp" #include "libtorrent/span.hpp" namespace libtorrent { - struct add_torrent_params; - struct bdecode_node; - // these functions are used to parse resume data and populate the appropriate // fields in an add_torrent_params object. This object can then be used to add // the actual torrent_info object to and pass to session::add_torrent() or diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index a9bbf7ebc..67f036b25 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" -#include "libtorrent/build_config.hpp" #include "libtorrent/io_service.hpp" #include "libtorrent/settings_pack.hpp" #include "libtorrent/session_handle.hpp" @@ -44,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/dht_state.hpp" #include "libtorrent/kademlia/dht_storage.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/fingerprint.hpp" #include // for snprintf #endif @@ -78,7 +77,7 @@ namespace libtorrent { // upload rates by allowing large send buffers. TORRENT_EXPORT settings_pack min_memory_usage(); TORRENT_EXPORT settings_pack high_performance_seed(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline void min_memory_usage(settings_pack& set) { set = min_memory_usage(); } @@ -87,16 +86,10 @@ namespace libtorrent { { set = high_performance_seed(); } #endif -#ifndef TORRENT_CFG -#error TORRENT_CFG is not defined! -#endif - - void TORRENT_EXPORT TORRENT_CFG(); - namespace aux { - struct session_impl; - } + struct session_impl; +} struct disk_interface; struct counters; @@ -187,7 +180,6 @@ namespace aux { // will take effect before the session starts up. explicit session(session_params params = session_params()) { - TORRENT_CFG(); start(std::move(params), nullptr); } @@ -206,7 +198,6 @@ namespace aux { // destruct the session_proxy object. session(session_params params, io_service& ios) { - TORRENT_CFG(); start(std::move(params), &ios); } @@ -224,7 +215,6 @@ namespace aux { session(settings_pack pack , session_flags_t const flags = start_default_features | add_default_plugins) { - TORRENT_CFG(); start(flags, std::move(pack), nullptr); } @@ -253,11 +243,10 @@ namespace aux { , io_service& ios , session_flags_t const flags = start_default_features | add_default_plugins) { - TORRENT_CFG(); start(flags, std::move(pack), &ios); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -275,7 +264,6 @@ namespace aux { , session_flags_t const flags = start_default_features | add_default_plugins , alert_category_t const alert_mask = alert::error_notification) { - TORRENT_CFG(); settings_pack pack; pack.set_int(settings_pack::alert_mask, int(alert_mask)); pack.set_str(settings_pack::peer_fingerprint, print.to_string()); @@ -297,7 +285,6 @@ namespace aux { , session_flags_t const flags = start_default_features | add_default_plugins , alert_category_t const alert_mask = alert::error_notification) { - TORRENT_CFG(); TORRENT_ASSERT(listen_port_range.first > 0); TORRENT_ASSERT(listen_port_range.first <= listen_port_range.second); @@ -329,7 +316,7 @@ namespace aux { #ifdef _MSC_VER #pragma warning(pop) #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // The destructor of session will notify all trackers that our torrents // have been shut down. If some trackers are down, they will time out. diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index cd713c62e..e06e50abd 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_SESSION_HANDLE_HPP_INCLUDED #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/torrent_handle.hpp" #include "libtorrent/add_torrent_params.hpp" @@ -50,22 +51,16 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/dht_storage.hpp" #include "libtorrent/kademlia/dht_settings.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/session_settings.hpp" #include #endif namespace libtorrent { - struct plugin; - struct torrent_plugin; class torrent; - struct ip_filter; - class port_filter; - class alert; - struct settings_pack; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct session_status; using user_load_function_t = std::function&, error_code&)>; @@ -95,7 +90,7 @@ namespace libtorrent { // joining the DHT if provided at next session startup. static constexpr save_state_flags_t save_dht_state = 2_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // save pe_settings static constexpr save_state_flags_t TORRENT_DEPRECATED_MEMBER save_encryption_settings = 3_bit; static constexpr save_state_flags_t TORRENT_DEPRECATED_MEMBER save_as_map = 4_bit; @@ -223,7 +218,7 @@ namespace libtorrent { void async_add_torrent(add_torrent_params params); #ifndef BOOST_NO_EXCEPTIONS -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 0.14 TORRENT_DEPRECATED torrent_handle add_torrent( @@ -246,7 +241,7 @@ namespace libtorrent { , bool paused = false , storage_constructor_type sc = default_storage_constructor , void* userdata = nullptr); -#endif +#endif // TORRENT_ABI_VERSION #endif // Pausing the session has the same effect as pausing every torrent in @@ -259,7 +254,7 @@ namespace libtorrent { void resume(); bool is_paused() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // *the feature of dynamically loading/unloading torrents is deprecated // and discouraged* // @@ -310,7 +305,7 @@ namespace libtorrent { void get_torrent_status(std::vector* ret , std::function const& pred , status_flags_t flags = {}) const; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION enum { disk_cache_no_pieces = 1 }; @@ -319,7 +314,7 @@ namespace libtorrent { // will not be set. This may significantly reduce the cost of this call. void get_cache_info(cache_status* ret, torrent_handle h = torrent_handle(), int flags = 0) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``start_dht`` starts the dht node and makes the trackerless service // available to torrents. // @@ -362,7 +357,7 @@ namespace libtorrent { // the routing table. void add_dht_node(std::pair const& node); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated, use settings_pack::dht_bootstrap_nodes instead // // ``add_dht_router`` adds the given endpoint to a list of DHT router @@ -466,7 +461,7 @@ namespace libtorrent { // posted, regardless of the alert mask. void dht_direct_request(udp::endpoint const& ep, entry const& e, void* userdata = nullptr); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 0.15 // use save_state and load_state instead TORRENT_DEPRECATED @@ -516,7 +511,7 @@ namespace libtorrent { torrent_handle const&, void*)> ext); void add_extension(std::shared_ptr ext); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // GeoIP support has been removed from libtorrent internals. If you // still need to resolve peers, please do so on the client side, using // libgeoip directly. This was removed in libtorrent 1.1 @@ -556,7 +551,7 @@ namespace libtorrent { TORRENT_DEPRECATED void load_state(lazy_entry const& ses_state , save_state_flags_t flags = save_state_flags_t::all()); -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // Sets a filter that will be used to reject and accept incoming as well // as outgoing connections based on their originating ip address. The @@ -575,7 +570,7 @@ namespace libtorrent { // anti-virus software by connecting to SMTP, FTP ports. void set_port_filter(port_filter const& f); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.1, use settings_pack::peer_fingerprint instead TORRENT_DEPRECATED void set_peer_id(peer_id const& pid); @@ -585,7 +580,7 @@ namespace libtorrent { peer_id id() const; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // sets the key sent to trackers. If it's not set, it is initialized // by libtorrent. The key may be used by the tracker to identify the @@ -713,7 +708,7 @@ namespace libtorrent { peer_class_info get_peer_class(peer_class_t cid) const; void set_peer_class(peer_class_t cid, peer_class_info const& pci); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if the listen port failed in some way you can retry to listen on // another port- range with this function. If the listener succeeded and // is currently listening, a call to this function will shut down the @@ -780,7 +775,7 @@ namespace libtorrent { // shifting. void remove_torrent(const torrent_handle& h, remove_flags_t options = {}); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in libtorrent 1.1. use settings_pack instead TORRENT_DEPRECATED void set_pe_settings(pe_settings const& settings); @@ -794,7 +789,7 @@ namespace libtorrent { void apply_settings(settings_pack s); settings_pack get_settings() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``set_i2p_proxy`` sets the i2p_ proxy, and tries to open a persistent // connection to it. The only used fields in the proxy settings structs // are ``hostname`` and ``port``. @@ -954,7 +949,7 @@ namespace libtorrent { void set_alert_notify(std::function const& fun); dropped_alerts_t dropped_alerts(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/aux_/disable_warnings_push.hpp" TORRENT_DEPRECATED diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index db248f452..271af3fa5 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SESSION_SETTINGS_HPP_INCLUDED #define TORRENT_SESSION_SETTINGS_HPP_INCLUDED -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/config.hpp" #include "libtorrent/settings_pack.hpp" @@ -109,5 +109,5 @@ namespace libtorrent { }; } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #endif diff --git a/include/libtorrent/session_status.hpp b/include/libtorrent/session_status.hpp index 26493aa2b..c862677d7 100644 --- a/include/libtorrent/session_status.hpp +++ b/include/libtorrent/session_status.hpp @@ -36,14 +36,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // for dht_lookup and dht_routing_bucket #include "libtorrent/alert_types.hpp" #endif namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // holds counters and gauges for the uTP sockets // deprecated in 1.1 in favor of session_stats counters, which is a more // flexible, extensible and performant mechanism for stats. @@ -224,7 +224,7 @@ namespace libtorrent { int num_torrents; int num_paused_torrents; }; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION } diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 5c146a1e1..8443d6142 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -135,7 +135,7 @@ namespace libtorrent { // omitted. announce_ip, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``mmap_cache`` may be set to a filename where the disk cache will // be mmapped to. This could be useful, for instance, to map the disk // cache from regular rotating hard drives onto an SSD drive. Doing @@ -251,7 +251,7 @@ namespace libtorrent { // in a swarm has the same IP address. allow_multiple_connections_per_ip = bool_type_base, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if set to true, upload, download and unchoke limits are ignored for // peers on the local network. This option is *DEPRECATED*, please use // set_peer_class_filter() instead. @@ -265,7 +265,7 @@ namespace libtorrent { // but it might be necessary for collecting statistics in some cases. send_redundant_have, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if this is true, outgoing bitfields will never be fuil. If the // client is seed, a few bits will be set to 0, and later filled in // with have messages. This is to prevent certain ISPs from stopping @@ -301,7 +301,7 @@ namespace libtorrent { // reading blocks back from the disk multiple times for popular // pieces. use_read_cache, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 use_write_cache TORRENT_DEPRECATED_ENUM, // this will make the disk cache never flush a write piece if it would @@ -374,7 +374,7 @@ namespace libtorrent { // out. This is the traditional definition of super seeding. strict_super_seeding, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if this is set to true, the memory allocated for the disk cache // will be locked in physical RAM, never to be swapped out. Every time // a disk buffer is allocated and freed, there will be the extra @@ -397,7 +397,7 @@ namespace libtorrent { // to connect to i2p peers. allow_i2p_mixed, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``low_prio_disk`` determines if the disk I/O should use a normal or // low priority policy. This defaults to true, which means that it's // low priority by default. Other processes doing disk I/O will @@ -418,7 +418,7 @@ namespace libtorrent { // place. volatile_read_cache, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``guided_read_cache`` enables the disk cache to adjust the size of // a cache line generated by peers to depend on the upload rate you // are sending to that peer. The intention is to optimize the RAM @@ -478,7 +478,7 @@ namespace libtorrent { enable_outgoing_tcp, enable_incoming_tcp, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``ignore_resume_timestamps`` determines if the storage, when // loading resume data files, should verify that the file modification // time with the timestamps in the resume data. This defaults to @@ -523,7 +523,7 @@ namespace libtorrent { // libtorrent API. report_web_seed_downloads, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // set to true if uTP connections should be rate limited This option // is *DEPRECATED*, please use set_peer_class_filter() instead. rate_limit_utp TORRENT_DEPRECATED_ENUM, @@ -531,7 +531,7 @@ namespace libtorrent { deprecated2, #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if this is true, the ``&ip=`` argument in tracker requests (unless // otherwise specified) will be set to the intermediate IP address if // the user is double NATed. If the user is not double NATed, this @@ -574,7 +574,7 @@ namespace libtorrent { // is one). If no IP filter is set, this setting is irrelevant. apply_ip_filter_to_trackers, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``use_disk_read_ahead`` defaults to true and will attempt to // optimize disk reads by giving the operating system heads up of disk // read requests as they are queued in the disk job queue. @@ -583,7 +583,7 @@ namespace libtorrent { deprecated19, #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``lock_files`` determines whether or not to lock files which // libtorrent is downloading to or seeding from. This is implemented // using ``fcntl(F_SETLK)`` on unix systems and by not passing in @@ -595,7 +595,7 @@ namespace libtorrent { deprecated26, #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``contiguous_recv_buffer`` determines whether or not libtorrent // should receive data from peers into a contiguous intermediate // buffer, to then copy blocks into disk buffers from, or to make many @@ -647,7 +647,7 @@ namespace libtorrent { // failure is preferred, set this to false. listen_system_port_fallback, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``use_disk_cache_pool`` enables using a pool allocator for disk // cache blocks. Enabling it makes the cache perform better at high // throughput. It also makes the cache less likely and slower at @@ -986,7 +986,7 @@ namespace libtorrent { // On 32 bit builds, the effective cache size will be limited to 3/4 of // 2 GiB to avoid exceeding the virtual address space limit. cache_size, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 cache_buffer_chunk_size, #else deprecated25, @@ -1089,7 +1089,7 @@ namespace libtorrent { active_lsd_limit, active_limit, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``active_loaded_limit`` is the number of torrents that are allowed // to be *loaded* at any given time. Note that a torrent can be active // even though it's not loaded. If an unloaded torrents finds a peer @@ -1177,7 +1177,7 @@ namespace libtorrent { // allowed to grow to. max_peer_recv_buffer_size, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``file_checks_delay_per_block`` is the number of milliseconds to // sleep in between disk read operations when checking torrents. This // defaults to 0, but can be set to higher numbers to slow down the @@ -1237,7 +1237,7 @@ namespace libtorrent { // to match the expiration time for tokens. udp_tracker_token_expiry, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``default_cache_min_age`` is the minimum number of seconds any read // cache line is kept in the cache. This defaults to one second but // may be greater if ``guided_read_cache`` is enabled. Having a lower @@ -1313,7 +1313,7 @@ namespace libtorrent { // to local peers, see peer-classes_. upload_rate_limit, download_rate_limit, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 local_upload_rate_limit TORRENT_DEPRECATED_ENUM, local_download_rate_limit TORRENT_DEPRECATED_ENUM, #else @@ -1321,7 +1321,7 @@ namespace libtorrent { deprecated4, #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``dht_upload_rate_limit`` sets the rate limit on the DHT. This is // specified in bytes per second and defaults to 4000. For busy boxes // with lots of torrents that requires more DHT traffic, this should @@ -1336,7 +1336,7 @@ namespace libtorrent { // what ``choking_algorithm`` is set to. unchoke_slots_limit, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``half_open_limit`` sets the maximum number of half-open // connections libtorrent will have when connecting to peers. A // half-open connection is one where connect() has been called, but @@ -1404,7 +1404,7 @@ namespace libtorrent { utp_fin_resends, utp_num_resends, utp_connect_timeout, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 utp_delayed_ack TORRENT_DEPRECATED_ENUM, #else deprecated6, @@ -1455,7 +1455,7 @@ namespace libtorrent { // received by the metadata extension, i.e. magnet links. max_metadata_size, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // DEPRECATED: use aio_threads instead // ``hashing_threads`` is the number of threads to use for piece hash @@ -1499,7 +1499,7 @@ namespace libtorrent { // SSL encryption as well. network_threads, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ``ssl_listen`` sets the listen port for SSL connections. If this is // set to 0, no SSL listen port is opened. Otherwise a socket is // opened on this port. This setting is only taken into account when @@ -1690,7 +1690,7 @@ namespace libtorrent { enum io_buffer_mode_t { enable_os_cache = 0, -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 disable_os_cache_for_aligned_files TORRENT_DEPRECATED_ENUM = 2, #else deprecated = 1, diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index e6dfcf874..2f1dacc23 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -108,7 +108,7 @@ namespace aux { if (s == nullptr) clear(); else std::memcpy(m_number.data(), s, size()); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED explicit digest32(std::string const& s) { diff --git a/include/libtorrent/socks5_stream.hpp b/include/libtorrent/socks5_stream.hpp index 0f2b76da2..f3e696b87 100644 --- a/include/libtorrent/socks5_stream.hpp +++ b/include/libtorrent/socks5_stream.hpp @@ -72,7 +72,7 @@ namespace socks_error { // returns the error_category for SOCKS5 errors TORRENT_EXPORT boost::system::error_category& socks_category(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline boost::system::error_category& get_socks_category() { return socks_category(); } diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index f80d61cb6..80c0834ee 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/fwd.hpp" #include "libtorrent/aux_/disk_job_fence.hpp" #include "libtorrent/aux_/storage_piece_set.hpp" #include "libtorrent/storage_defs.hpp" @@ -127,9 +128,7 @@ POSSIBILITY OF SUCH DAMAGE. // } namespace libtorrent { - struct file_pool; namespace aux { struct session_settings; } - struct add_torrent_params; // The storage interface is a pure virtual class that can be implemented to // customize how and where data for a torrent is stored. The default storage diff --git a/include/libtorrent/storage_defs.hpp b/include/libtorrent/storage_defs.hpp index f28910db0..c9b0cfdf1 100644 --- a/include/libtorrent/storage_defs.hpp +++ b/include/libtorrent/storage_defs.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_STORAGE_DEFS_HPP_INCLUDE #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/units.hpp" #include "libtorrent/aux_/vector.hpp" #include "libtorrent/sha1_hash.hpp" @@ -44,9 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct TORRENT_EXPORT storage_interface; - class file_storage; - struct file_pool; - class torrent_info; using storage_index_t = aux::strong_typedef; @@ -93,7 +91,7 @@ namespace libtorrent { dont_replace }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 enum deprecated_move_flags_t { diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 608504f28..ab5ac7f88 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for numeric_limits #include // for unique_ptr +#include "libtorrent/fwd.hpp" #include "libtorrent/optional.hpp" #include "libtorrent/torrent_handle.hpp" #include "libtorrent/entry.hpp" @@ -100,14 +101,7 @@ namespace ssl { namespace libtorrent { class http_parser; - - struct storage_interface; - struct torrent_plugin; - template struct typed_bitfield; - struct announce_entry; struct tracker_request; - struct add_torrent_params; - struct storage_interface; class bt_peer_connection; peer_id generate_peer_id(aux::session_settings const& sett); @@ -353,7 +347,10 @@ namespace libtorrent { update_gauge(); } +#if TORRENT_ABI_VERSION == 1 + // deprecated in 1.2 void start_download_url(); +#endif // returns which stats gauge this torrent currently // has incremented. @@ -554,11 +551,11 @@ namespace libtorrent { bool delete_files(remove_flags_t options); void peers_erased(std::vector const& peers); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #if !TORRENT_NO_FPU void file_progress_float(aux::vector& fp); #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void piece_availability(aux::vector& avail) const; @@ -590,7 +587,7 @@ namespace libtorrent { void file_progress(aux::vector& fp, int flags = 0); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void use_interface(std::string net_interface); #endif @@ -598,9 +595,9 @@ namespace libtorrent { bool connect_to_peer(torrent_peer* peerinfo, bool ignore_limit = false); int priority() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void set_priority(int prio); -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // -------------------------------------------- // BANDWIDTH MANAGEMENT @@ -697,7 +694,7 @@ namespace libtorrent { peer_iterator begin() { return m_connections.begin(); } peer_iterator end() { return m_connections.end(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void get_full_peer_list(std::vector* v) const; #endif void get_peer_info(std::vector* v); @@ -729,7 +726,7 @@ namespace libtorrent { void update_scrape_state(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if no password and username is set // this will return an empty string, otherwise // it will concatenate the login and password @@ -756,7 +753,7 @@ namespace libtorrent { void dht_announce(); #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // sets the username and password that will be sent to // the tracker void set_tracker_login(std::string const& name, std::string const& pw); @@ -986,7 +983,7 @@ namespace libtorrent { std::shared_ptr get_torrent_copy(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 std::string const& uuid() const { return m_uuid; } void set_uuid(std::string const& s) { m_uuid = s; } @@ -1058,7 +1055,7 @@ namespace libtorrent { // a return value of false indicates an error bool set_metadata(span metadata); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void on_torrent_download(error_code const& ec, http_parser const& parser , span data); #endif @@ -1273,7 +1270,7 @@ namespace libtorrent { std::vector m_time_critical_pieces; std::string m_trackerid; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.1 std::string m_username; std::string m_password; @@ -1281,7 +1278,7 @@ namespace libtorrent { std::string m_save_path; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // if we don't have the metadata, this is a url to @@ -1661,7 +1658,7 @@ namespace libtorrent { // is optional and may be 0xffffff std::uint32_t m_downloaded:24; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the timestamp of the last scrape request to one of the trackers in // this torrent specified in session_time. This is signed because it must // be able to represent time before the session started diff --git a/include/libtorrent/torrent_flags.hpp b/include/libtorrent/torrent_flags.hpp index a2a4f2459..7dc7c85e1 100644 --- a/include/libtorrent/torrent_flags.hpp +++ b/include/libtorrent/torrent_flags.hpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_TORRENT_FLAGS_HPP #define TORRENT_TORRENT_FLAGS_HPP +#include "libtorrent/config.hpp" #include "libtorrent/flags.hpp" namespace libtorrent { @@ -41,7 +42,7 @@ using torrent_flags_t = flags::bitfield_flag #include "libtorrent/aux_/disable_warnings_push.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // for deprecated force_reannounce #include #endif #include "libtorrent/aux_/disable_warnings_pop.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/address.hpp" #include "libtorrent/socket.hpp" // tcp::endpoint #include "libtorrent/span.hpp" @@ -62,23 +63,12 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace aux { - struct session_impl; - } - class entry; - struct open_file_state; - struct announce_entry; - class torrent_info; - struct torrent_plugin; - struct peer_info; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 struct peer_list_entry; #endif - struct torrent_status; - struct torrent_handle; - struct storage_interface; class torrent; #ifndef BOOST_NO_EXCEPTIONS @@ -92,6 +82,8 @@ namespace aux { using resume_data_flags_t = flags::bitfield_flag; using queue_position_t = aux::strong_typedef; +TORRENT_IPV6_NAMESPACE + // holds the state of a block in a piece. Who we requested // it from and how far along we are at downloading it. struct TORRENT_EXPORT block_info @@ -168,7 +160,7 @@ namespace aux { // or outstanding writes struct TORRENT_EXPORT partial_piece_info { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/aux_/disable_warnings_push.hpp" partial_piece_info() = default; partial_piece_info(partial_piece_info&&) noexcept = default; @@ -203,7 +195,7 @@ namespace aux { // get_download_queue() is called, it will be invalidated. block_info* blocks; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the speed classes. These may be used by the piece picker to // coalesce requests of similar download rates enum state_t { none, slow, medium, fast }; @@ -221,13 +213,11 @@ namespace aux { // any of ``fast``, ``medium`` or ``slow`` as soon as a peer want to // download from it. state_t TORRENT_DEPRECATED_MEMBER piece_state; -#else - // hidden - enum deprecated_state_t { none, slow, medium, fast }; - deprecated_state_t deprecated_piece_state; #endif }; +TORRENT_IPV6_NAMESPACE_END + // for std::hash (and to support using this type in unordered_map etc.) TORRENT_EXPORT std::size_t hash_value(torrent_handle const& h); @@ -310,7 +300,7 @@ namespace aux { // otherwise. bool have_piece(piece_index_t piece) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // internal TORRENT_DEPRECATED void get_full_peer_list(std::vector& v) const; @@ -397,7 +387,7 @@ namespace aux { void reset_piece_deadline(piece_index_t index) const; void clear_piece_deadlines() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // This sets the bandwidth priority of this torrent. The priority of a // torrent determines how much bandwidth its peers are assigned when // distributing upload and download rate quotas. A high number gives more @@ -539,7 +529,7 @@ namespace aux { // affect the torrent, and false will be returned. bool set_metadata(span metadata) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED bool set_metadata(char const* metadata, int size) const { return set_metadata({metadata, size_t(size)}); } @@ -850,7 +840,7 @@ namespace aux { // info-hash. std::shared_ptr torrent_file() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ================ start deprecation ============ @@ -984,7 +974,7 @@ namespace aux { void prioritize_pieces(std::vector> const& pieces) const; std::vector get_piece_priorities() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED void prioritize_pieces(std::vector const& pieces) const; TORRENT_DEPRECATED @@ -1020,7 +1010,7 @@ namespace aux { void prioritize_files(std::vector const& files) const; std::vector get_file_priorities() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED void prioritize_files(std::vector const& files) const; TORRENT_DEPRECATED @@ -1044,7 +1034,7 @@ namespace aux { void force_reannounce(int seconds = 0, int tracker_index = -1) const; void force_dht_announce() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // forces a reannounce in the specified amount of time. // This overrides the default announce interval, and no // announce will take place until the given time has @@ -1135,7 +1125,7 @@ namespace aux { void set_max_connections(int max_connections) const; int max_connections() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // sets a username and password that will be sent along in the HTTP-request // of the tracker announce. Set this if the tracker requires authorization. TORRENT_DEPRECATED @@ -1190,7 +1180,7 @@ namespace aux { , move_flags_t flags = move_flags_t::always_replace_files ) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 TORRENT_DEPRECATED void move_storage(std::string const& save_path, int flags) const; @@ -1201,7 +1191,7 @@ namespace aux { // file_rename_failed_alert is posted. void rename_file(file_index_t index, std::string const& new_name) const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // all wstring APIs are deprecated since 0.16.11 // instead, use the wchar -> utf8 conversion functions // and pass in utf8 strings @@ -1214,7 +1204,7 @@ namespace aux { // The torrent needs to be a seed for this to take effect. TORRENT_DEPRECATED void super_seeding(bool on) const; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // ``info_hash()`` returns the info-hash of the torrent. If this handle // is to a torrent that hasn't loaded yet (for instance by being added) diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index c0256732c..6d048227f 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/bdecode.hpp" #include "libtorrent/time.hpp" #include "libtorrent/assert.hpp" @@ -58,8 +59,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { class peer_connection; - class entry; - struct announce_entry; struct lazy_entry; // internal, exposed for the unit test @@ -171,7 +170,7 @@ namespace libtorrent { torrent_info(span buffer, error_code& ec, from_span_t); torrent_info(std::string const& filename, error_code& ec); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifndef BOOST_NO_EXCEPTIONS TORRENT_DEPRECATED torrent_info(char const* buffer, int size, int) @@ -196,7 +195,7 @@ namespace libtorrent { torrent_info(std::wstring const& filename, error_code& ec); TORRENT_DEPRECATED explicit torrent_info(std::wstring const& filename); -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // frees all storage associated with this torrent_info object ~torrent_info(); @@ -243,13 +242,13 @@ namespace libtorrent { copy_on_write(); m_files.rename_file(index, new_filename); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // all wstring APIs are deprecated since 0.16.11 // instead, use the wchar -> utf8 conversion functions // and pass in utf8 strings TORRENT_DEPRECATED void rename_file(file_index_t index, std::wstring const& new_filename); -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // Remaps the file storage to a new file layout. This can be used to, for // instance, download all data in a torrent to a single file, or to a @@ -281,7 +280,7 @@ namespace libtorrent { std::vector similar_torrents() const; std::vector collections() const; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 0.16. Use web_seeds() instead TORRENT_DEPRECATED std::vector url_seeds() const; @@ -291,7 +290,7 @@ namespace libtorrent { // deprecated in 1.1 TORRENT_DEPRECATED bool parse_info_section(lazy_entry const& e, error_code& ec); -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // ``web_seeds()`` returns all url seeds and http seeds in the torrent. // Each entry is a ``web_seed_entry`` and may refer to either a url seed @@ -348,7 +347,7 @@ namespace libtorrent { // returns the info-hash of the torrent const sha1_hash& info_hash() const { return m_info_hash; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.0. Use the variants that take an index instead // internal_file_entry is no longer exposed in the API using file_iterator = file_storage::iterator; @@ -377,7 +376,7 @@ namespace libtorrent { TORRENT_DEPRECATED file_entry file_at(int index) const { return m_files.at_deprecated(index); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // If you need index-access to files you can use the ``num_files()`` along // with the ``file_path()``, ``file_size()``-family of functions to access @@ -408,7 +407,7 @@ namespace libtorrent { return m_files.map_file(file, offset, size); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ------- start deprecation ------- // deprecated in 1.2 void load(char const*, int, error_code&) {} diff --git a/include/libtorrent/torrent_status.hpp b/include/libtorrent/torrent_status.hpp index a4acb0914..d877ed1ff 100644 --- a/include/libtorrent/torrent_status.hpp +++ b/include/libtorrent/torrent_status.hpp @@ -48,18 +48,20 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #endif +TORRENT_VERSION_NAMESPACE_2 + // holds a snapshot of the status of a torrent, as queried by // torrent_handle::status(). struct TORRENT_EXPORT torrent_status { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -83,7 +85,7 @@ namespace libtorrent { // the different overall states a torrent can be in enum state_t { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // The torrent is in the queue for being checked. But there // currently is another torrent that are being checked. // This torrent will wait for its turn. @@ -128,11 +130,8 @@ namespace libtorrent { checking_resume_data }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string error; -#else - // internal - std::string _dummy_string_; #endif // may be set to an error code describing why the torrent was paused, in @@ -152,7 +151,7 @@ namespace libtorrent { // the error occurred setting up the SSL context static constexpr file_index_t error_file_ssl_ctx{-3}; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the error occurred while loading the .torrent file via the user // supplied load function static constexpr file_index_t TORRENT_DEPRECATED error_file_metadata{-4}; @@ -191,13 +190,10 @@ namespace libtorrent { // the time until the torrent will announce itself to the tracker. time_duration next_announce = seconds(0); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the time the tracker want us to wait until we announce ourself // again the next time. time_duration announce_interval; -#else - // hidden - time_duration deprecated_announce_interval_; #endif // the URL of the last working tracker. If no tracker request has @@ -411,7 +407,7 @@ namespace libtorrent { int up_bandwidth_queue = 0; int down_bandwidth_queue = 0; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // use last_upload, last_download or // seeding_duration, finished_duration and active_duration @@ -436,12 +432,6 @@ namespace libtorrent { int TORRENT_DEPRECATED_MEMBER active_time = 0; int TORRENT_DEPRECATED_MEMBER finished_time = 0; int TORRENT_DEPRECATED_MEMBER seeding_time = 0; -#else - int deprecated_time_since_upload = 0; - int deprecated_time_since_download = 0; - int deprecated_active_time = 0; - int deprecated_finished_time = 0; - int deprecated_seeding_time = 0; #endif // A rank of how important it is to seed the torrent, it is used to @@ -450,22 +440,17 @@ namespace libtorrent { // see queuing_. Higher value means more important to seed int seed_rank = 0; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // the number of seconds since this torrent acquired scrape data. // If it has never done that, this value is -1. int TORRENT_DEPRECATED_MEMBER last_scrape = 0; -#else - int deprecated_last_scrape = 0; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // the priority of this torrent int TORRENT_DEPRECATED_MEMBER priority = 0; -#else - // hidden - int deprecated_priority = 0; #endif // the main state the torrent is in. See torrent_status::state_t. @@ -476,7 +461,7 @@ namespace libtorrent { // was saved. bool need_save_resume = false; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // true if the session global IP filter applies // to this torrent. This defaults to true. bool TORRENT_DEPRECATED_MEMBER ip_filter_applies = false; @@ -512,15 +497,6 @@ namespace libtorrent { // true when the torrent is in sequential download mode. In this mode // pieces are downloaded in order rather than rarest first. bool TORRENT_DEPRECATED_MEMBER sequential_download = false; -#else - // hidden - bool deprecated_ip_filter_applies = false; - bool deprecated_upload_mode = false; - bool deprecated_share_mode = false; - bool deprecated_super_seeding = false; - bool deprecated_paused = false; - bool deprecated_auto_managed = false; - bool deprecated_sequential_download = false; #endif // true if all pieces have been downloaded. @@ -542,14 +518,11 @@ namespace libtorrent { // torrent. bool has_incoming = false; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // true if the torrent is in seed_mode. If the torrent was started in // seed mode, it will leave seed mode once all pieces have been checked // or as soon as one piece fails the hash check. bool TORRENT_DEPRECATED_MEMBER seed_mode = false; -#else - // hidden - bool deprecated_seed_mode = false; #endif // this is true if this torrent's storage is currently being moved from @@ -557,14 +530,11 @@ namespace libtorrent { // if a large file ends up being copied from one drive to another. bool moving_storage = false; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // true if this torrent is loaded into RAM. A torrent can be started // and still not loaded into RAM, in case it has not had any peers interested in it // yet. Torrents are loaded on demand. bool TORRENT_DEPRECATED_MEMBER is_loaded = false; -#else - // hidden - bool deprecated_is_loaded; #endif // these are set to true if this torrent is allowed to announce to the @@ -575,14 +545,11 @@ namespace libtorrent { bool announcing_to_lsd = false; bool announcing_to_dht = false; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // this reflects whether the ``stop_when_ready`` flag is currently enabled // on this torrent. For more information, see // torrent_handle::stop_when_ready(). bool TORRENT_DEPRECATED_MEMBER stop_when_ready = false; -#else - // hidden - bool deprecated_stop_when_ready = false; #endif // the info-hash for this torrent @@ -599,6 +566,8 @@ namespace libtorrent { // information, see ``torrent_handle::flags()``. torrent_flags_t flags{}; }; + +TORRENT_VERSION_NAMESPACE_2_END } namespace std diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index ba4001afa..2d98ecda3 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -57,6 +57,7 @@ namespace ssl { #endif #include "libtorrent/socket.hpp" +#include "libtorrent/fwd.hpp" #include "libtorrent/address.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/peer.hpp" // peer_entry @@ -72,14 +73,12 @@ namespace ssl { namespace libtorrent { - struct request_callback; class tracker_manager; struct timeout_handler; class udp_tracker_connection; class http_tracker_connection; struct resolver_interface; struct counters; - struct ip_filter; #if TORRENT_USE_I2P class i2p_connection; #endif @@ -123,7 +122,7 @@ namespace libtorrent { std::string url; std::string trackerid; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string auth; #endif diff --git a/include/libtorrent/union_endpoint.hpp b/include/libtorrent/union_endpoint.hpp index 9dbe40661..7488faabd 100644 --- a/include/libtorrent/union_endpoint.hpp +++ b/include/libtorrent/union_endpoint.hpp @@ -38,6 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { +TORRENT_IPV6_NAMESPACE + struct union_address { union_address() { *this = address(); } @@ -124,6 +126,7 @@ namespace libtorrent { union_address addr; std::uint16_t port; }; +TORRENT_IPV6_NAMESPACE_END } #endif diff --git a/include/libtorrent/units.hpp b/include/libtorrent/units.hpp index 594e44917..b9bbf4a28 100644 --- a/include/libtorrent/units.hpp +++ b/include/libtorrent/units.hpp @@ -55,7 +55,7 @@ namespace libtorrent { namespace aux { constexpr strong_typedef(strong_typedef const& rhs) noexcept = default; constexpr strong_typedef(strong_typedef&& rhs) noexcept = default; strong_typedef() noexcept = default; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr strong_typedef(UnderlyingType val) : m_val(val) {} constexpr operator UnderlyingType() const { return m_val; } #else diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index 37f4e2317..b52d83156 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -95,7 +95,7 @@ namespace libtorrent { // the boost.system error category for UPnP errors TORRENT_EXPORT boost::system::error_category& upnp_category(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_DEPRECATED inline boost::system::error_category& get_upnp_category() { return upnp_category(); } diff --git a/include/libtorrent/write_resume_data.hpp b/include/libtorrent/write_resume_data.hpp index 2d1c4ead1..c04bd3777 100644 --- a/include/libtorrent/write_resume_data.hpp +++ b/include/libtorrent/write_resume_data.hpp @@ -33,15 +33,14 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_WRITE_RESUME_DATA_HPP_INCLUDE #define TORRENT_WRITE_RESUME_DATA_HPP_INCLUDE -#include "libtorrent/error_code.hpp" +#include + +#include "libtorrent/fwd.hpp" #include "libtorrent/export.hpp" #include "libtorrent/bencode.hpp" namespace libtorrent { - struct add_torrent_params; - class entry; - // this function turns the resume data in an ``add_torrent_params`` object // into a bencoded structure TORRENT_EXPORT entry write_resume_data(add_torrent_params const& atp); diff --git a/simulation/setup_dht.hpp b/simulation/setup_dht.hpp index edbfaed9e..4f5c1c46d 100644 --- a/simulation/setup_dht.hpp +++ b/simulation/setup_dht.hpp @@ -37,18 +37,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/kademlia/dht_settings.hpp" // for dht_settings #include "libtorrent/performance_counters.hpp" // for counters - +#include "libtorrent/alert_types.hpp" // for dht_routing_bucket namespace sim { struct simulation; } -namespace libtorrent -{ - struct dht_routing_bucket; -} - struct dht_node; void print_routing_table(std::vector const& rt); diff --git a/simulation/setup_swarm.hpp b/simulation/setup_swarm.hpp index 495b0bb5e..6c83b7b9e 100644 --- a/simulation/setup_swarm.hpp +++ b/simulation/setup_swarm.hpp @@ -32,22 +32,12 @@ POSSIBILITY OF SUCH DAMAGE. #include "simulator/simulator.hpp" #include "libtorrent/address.hpp" +#include "libtorrent/fwd.hpp" #include #ifndef TORRENT_SETUP_SWARM_HPP_INCLUDED #define TORRENT_SETUP_SWARM_HPP_INCLUDED -namespace libtorrent -{ - class alert; - class session; - struct add_torrent_params; - struct settings_pack; - struct torrent_handle; - struct torrent_status; -} - - enum class swarm_test { download, upload }; void setup_swarm(int num_nodes diff --git a/simulation/test_auto_manage.cpp b/simulation/test_auto_manage.cpp index 5abdd5721..fbd1b6ba8 100644 --- a/simulation/test_auto_manage.cpp +++ b/simulation/test_auto_manage.cpp @@ -100,7 +100,7 @@ TORRENT_TEST(dont_count_slow_torrents) // add torrents for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, false); + lt::add_torrent_params params = ::create_torrent(i, false); params.flags |= lt::torrent_flags::auto_managed; params.flags |= lt::torrent_flags::paused; ses.async_add_torrent(params); @@ -159,7 +159,7 @@ TORRENT_TEST(count_slow_torrents) // add torrents for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, false); + lt::add_torrent_params params = ::create_torrent(i, false); params.flags |= torrent_flags::auto_managed; params.flags |= torrent_flags::paused; ses.async_add_torrent(params); @@ -210,7 +210,7 @@ TORRENT_TEST(force_stopped_download) // add torrents for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, false); + lt::add_torrent_params params = ::create_torrent(i, false); // torrents are paused and not auto-managed params.flags &= ~torrent_flags::auto_managed; params.flags |= torrent_flags::paused; @@ -258,7 +258,7 @@ TORRENT_TEST(force_started) // add torrents for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, false); + lt::add_torrent_params params = ::create_torrent(i, false); // torrents are started and not auto-managed params.flags &= ~torrent_flags::auto_managed; params.flags &= ~torrent_flags::paused; @@ -308,7 +308,7 @@ TORRENT_TEST(seed_limit) // add 5 seeds for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, true); + lt::add_torrent_params params = ::create_torrent(i, true); // torrents are paused and auto-managed params.flags |= torrent_flags::auto_managed; params.flags |= torrent_flags::paused; @@ -397,7 +397,7 @@ TORRENT_TEST(download_limit) // add 5 seeds for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, false); + lt::add_torrent_params params = ::create_torrent(i, false); // torrents are paused and auto-managed params.flags |= torrent_flags::auto_managed; params.flags |= torrent_flags::paused; @@ -493,7 +493,7 @@ TORRENT_TEST(checking_announce) // add 5 seeds for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, true); + lt::add_torrent_params params = ::create_torrent(i, true); // torrents are paused and auto-managed params.flags |= torrent_flags::auto_managed; params.flags |= torrent_flags::paused; @@ -546,7 +546,7 @@ TORRENT_TEST(paused_checking) // add 5 seeds for (int i = 0; i < num_torrents; ++i) { - lt::add_torrent_params params = create_torrent(i, true); + lt::add_torrent_params params = ::create_torrent(i, true); // torrents are paused and auto-managed params.flags &= ~torrent_flags::auto_managed; params.flags |= torrent_flags::paused; @@ -593,7 +593,7 @@ TORRENT_TEST(stop_when_ready) [](lt::session& ses) { // add torrents - lt::add_torrent_params params = create_torrent(0, true); + lt::add_torrent_params params = ::create_torrent(0, true); // torrents are started and auto-managed params.flags |= torrent_flags::auto_managed; params.flags |= torrent_flags::stop_when_ready; @@ -661,7 +661,7 @@ TORRENT_TEST(resume_reject_when_paused) [](lt::session& ses) { // add torrents - lt::add_torrent_params params = create_torrent(0, true); + lt::add_torrent_params params = ::create_torrent(0, true); // the torrent is not auto managed and paused. Once the resume data // check completes, it will stay paused but the state_changed_alert @@ -734,7 +734,7 @@ TORRENT_TEST(no_resume_when_paused) [](lt::session& ses) { // add torrents - lt::add_torrent_params params = create_torrent(0, true); + lt::add_torrent_params params = ::create_torrent(0, true); // the torrent is not auto managed and paused. params.flags &= ~torrent_flags::auto_managed; @@ -802,7 +802,7 @@ TORRENT_TEST(no_resume_when_started) [](lt::session& ses) { // add torrents - lt::add_torrent_params params = create_torrent(0, true); + lt::add_torrent_params params = ::create_torrent(0, true); ses.async_add_torrent(params); }, @@ -850,7 +850,7 @@ TORRENT_TEST(pause_completed_torrents) [](lt::session& ses) { // add torrent - lt::add_torrent_params params = create_torrent(0, true); + lt::add_torrent_params params = ::create_torrent(0, true); params.flags |= torrent_flags::auto_managed; params.flags |= torrent_flags::paused; ses.async_add_torrent(params); diff --git a/simulation/test_error_handling.cpp b/simulation/test_error_handling.cpp index 1538479f4..83123564a 100644 --- a/simulation/test_error_handling.cpp +++ b/simulation/test_error_handling.cpp @@ -119,7 +119,7 @@ void run_test(HandleAlerts const& on_alert, Test const& test) print_alerts(*ses[1]); // the first peer is a downloader, the second peer is a seed - lt::add_torrent_params params = create_torrent(1); + lt::add_torrent_params params = ::create_torrent(1); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; diff --git a/simulation/test_ip_filter.cpp b/simulation/test_ip_filter.cpp index 6ba70191c..c4c2e6554 100644 --- a/simulation/test_ip_filter.cpp +++ b/simulation/test_ip_filter.cpp @@ -119,7 +119,7 @@ TORRENT_TEST(apply_ip_filter) { add_ip_filter(ses); - lt::add_torrent_params params = create_torrent(0, false); + lt::add_torrent_params params = ::create_torrent(0, false); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; ses.async_add_torrent(params); @@ -148,7 +148,7 @@ TORRENT_TEST(update_ip_filter) run_test( [](lt::session& ses) { - lt::add_torrent_params params = create_torrent(0, false); + lt::add_torrent_params params = ::create_torrent(0, false); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; ses.async_add_torrent(params); @@ -181,7 +181,7 @@ TORRENT_TEST(apply_ip_filter_to_torrent) { add_ip_filter(ses); - lt::add_torrent_params params = create_torrent(0, false); + lt::add_torrent_params params = ::create_torrent(0, false); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; @@ -216,7 +216,7 @@ TORRENT_TEST(ip_filter_trackers) { add_ip_filter(ses); - lt::add_torrent_params params = create_torrent(0, false); + lt::add_torrent_params params = ::create_torrent(0, false); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; params.trackers = { diff --git a/simulation/test_optimistic_unchoke.cpp b/simulation/test_optimistic_unchoke.cpp index 2261b5b93..9b37383be 100644 --- a/simulation/test_optimistic_unchoke.cpp +++ b/simulation/test_optimistic_unchoke.cpp @@ -71,7 +71,7 @@ TORRENT_TEST(optimistic_unchoke) io_service ios(sim, addr("50.1.0.0")); lt::time_point start_time(lt::clock_type::now()); - lt::add_torrent_params atp = create_torrent(0); + lt::add_torrent_params atp = ::create_torrent(0); atp.flags &= ~torrent_flags::auto_managed; atp.flags &= ~torrent_flags::paused; diff --git a/simulation/test_pause.cpp b/simulation/test_pause.cpp index c8989c7a2..ac1017936 100644 --- a/simulation/test_pause.cpp +++ b/simulation/test_pause.cpp @@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE. using namespace sim; using namespace lt; - using sim::asio::ip::address_v4; // this is the general template for these tests. create the session with custom @@ -76,7 +75,7 @@ void run_test(Setup const& setup, Torrent const& torrent std::array test_peers = {{ &p1, &p2, &p3 }}; // add torrent - lt::add_torrent_params params = create_torrent(0, false); + lt::add_torrent_params params = ::create_torrent(0, false); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; ses->async_add_torrent(std::move(params)); diff --git a/simulation/test_socks5.cpp b/simulation/test_socks5.cpp index 22b4d9572..a467cd2a1 100644 --- a/simulation/test_socks5.cpp +++ b/simulation/test_socks5.cpp @@ -81,7 +81,7 @@ void run_test(Setup const& setup on_alert(ses, a); }); - lt::add_torrent_params params = create_torrent(1); + lt::add_torrent_params params = ::create_torrent(1); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; params.save_path = save_path(0); diff --git a/simulation/test_swarm.cpp b/simulation/test_swarm.cpp index 31b56dad8..6e0bd2b42 100644 --- a/simulation/test_swarm.cpp +++ b/simulation/test_swarm.cpp @@ -657,7 +657,7 @@ TORRENT_TEST(redundant_have) ); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(lazy_bitfields) { test_settings([](lt::settings_pack& pack) { diff --git a/simulation/test_transfer.cpp b/simulation/test_transfer.cpp index bb569994a..4f82610b8 100644 --- a/simulation/test_transfer.cpp +++ b/simulation/test_transfer.cpp @@ -130,7 +130,7 @@ void run_test( print_alerts(*ses[1], [](lt::session&, lt::alert const*){}, 1); // the first peer is a downloader, the second peer is a seed - lt::add_torrent_params params = create_torrent(1); + lt::add_torrent_params params = ::create_torrent(1); params.flags &= ~lt::torrent_flags::auto_managed; params.flags &= ~lt::torrent_flags::paused; diff --git a/src/add_torrent_params.cpp b/src/add_torrent_params.cpp index 5953fd339..87478dea1 100644 --- a/src/add_torrent_params.cpp +++ b/src/add_torrent_params.cpp @@ -40,7 +40,7 @@ namespace libtorrent { add_torrent_params::add_torrent_params(add_torrent_params const&) = default; add_torrent_params& add_torrent_params::operator=(add_torrent_params const&) = default; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #define DECL_FLAG(name) \ constexpr torrent_flags_t add_torrent_params::flag_##name @@ -65,7 +65,7 @@ namespace libtorrent { DECL_FLAG(merge_resume_http_seeds); DECL_FLAG(default_flags); #undef DECL_FLAG -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION static_assert(std::is_nothrow_move_constructible::value , "should be nothrow move constructible"); diff --git a/src/alert.cpp b/src/alert.cpp index 5c2ebc599..af5518f80 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hex.hpp" // to_hex #include "libtorrent/session_stats.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/write_resume_data.hpp" #endif @@ -62,7 +62,7 @@ namespace libtorrent { constexpr alert_category_t alert::tracker_notification; constexpr alert_category_t alert::debug_notification; constexpr alert_category_t alert::status_notification; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr alert_category_t alert::progress_notification; #endif constexpr alert_category_t alert::ip_block_notification; @@ -83,7 +83,7 @@ namespace libtorrent { constexpr alert_category_t alert::block_progress_notification; constexpr alert_category_t alert::all_categories; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr alert_category_t alert::rss_notification; #endif @@ -114,7 +114,7 @@ namespace libtorrent { m_name_idx = alloc.copy_string(""); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 name = m_alloc.get().ptr(m_name_idx); #endif } @@ -137,7 +137,7 @@ namespace libtorrent { : torrent_alert(alloc, h) , endpoint(i) , pid(pi) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , ip(i) #endif {} @@ -153,7 +153,7 @@ namespace libtorrent { : torrent_alert(alloc, h) , local_endpoint(ep) , m_url_idx(alloc.copy_string(u)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , url(u) #endif {} @@ -184,7 +184,7 @@ namespace libtorrent { , error(e) , piece(p) , size(0) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , ec(e) #endif {} @@ -228,7 +228,7 @@ namespace libtorrent { : torrent_alert(alloc, h) , index(idx) , m_name_idx(alloc.copy_string(n)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , name(n) #endif {} @@ -324,7 +324,7 @@ namespace libtorrent { , times_in_row(times) , error(e) , m_msg_idx(alloc.copy_string(m)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , status_code(e && e.category() == http_category() ? e.value() : -1) , msg(m) #endif @@ -352,7 +352,7 @@ namespace libtorrent { , string_view u, string_view m) : tracker_alert(alloc, h, ep, u) , m_msg_idx(alloc.copy_string(m)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , msg(m) #endif { @@ -393,7 +393,7 @@ namespace libtorrent { : tracker_alert(alloc, h, ep, u) , error(e) , m_msg_idx() -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , msg(convert_from_native(e.message())) #endif { @@ -406,7 +406,7 @@ namespace libtorrent { : tracker_alert(alloc, h, ep, u) , error(errors::tracker_failure) , m_msg_idx(alloc.copy_string(m)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , msg(m) #endif { @@ -633,7 +633,7 @@ namespace libtorrent { : peer_alert(alloc, h, ep, peer_id) , block_index(block_num) , piece_index(piece_num) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , peer_speedmsg("") #endif { @@ -670,7 +670,7 @@ namespace libtorrent { , torrent_handle const& h, string_view p) : torrent_alert(alloc, h) , m_path_idx(alloc.copy_string(p)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , path(p) #endif {} @@ -693,7 +693,7 @@ namespace libtorrent { , error(e) , op(op_) , m_file_idx(alloc.copy_string(f)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(operation_name(op_)) , file(f) #endif @@ -727,7 +727,7 @@ namespace libtorrent { : torrent_alert(alloc, h) , error(e) , info_hash(ih) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , msg(convert_from_native(error.message())) #endif { @@ -744,7 +744,7 @@ namespace libtorrent { , torrent_handle const& h) : torrent_alert(alloc, h) , params(std::move(p)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , resume_data(std::make_shared(write_resume_data(params))) #endif { @@ -759,7 +759,7 @@ namespace libtorrent { , torrent_handle const& h, error_code const& e) : torrent_alert(alloc, h) , error(e) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , msg(convert_from_native(error.message())) #endif { @@ -836,7 +836,7 @@ namespace { "SSL/uTP" }; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int to_op_t(operation_t op) { @@ -904,7 +904,8 @@ namespace { #pragma warning(pop) #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION + } // anonymous namespace listen_failed_alert::listen_failed_alert( @@ -922,7 +923,7 @@ namespace { , port(listen_port) , m_alloc(alloc) , m_interface_idx(alloc.copy_string(iface)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(to_op_t(op_)) , endpoint(listen_addr, std::uint16_t(listen_port)) , sock_type(static_cast(sock_type_idx(t))) @@ -1046,7 +1047,7 @@ namespace { : address(listen_addr) , port(listen_port) , socket_type(t) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , endpoint(listen_addr, std::uint16_t(listen_port)) , sock_type(static_cast(sock_type_idx(t))) #endif @@ -1083,7 +1084,7 @@ namespace { : mapping(i) , map_transport(t) , error(e) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , map_type(static_cast(t)) , msg(convert_from_native(error.message())) #endif @@ -1104,7 +1105,7 @@ namespace { , external_port(port) , map_protocol(proto) , map_transport(t) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , protocol(static_cast(proto)) , map_type(static_cast(t)) #endif @@ -1124,7 +1125,7 @@ namespace { : map_transport(t) , m_alloc(alloc) , m_log_idx(alloc.copy_string(m)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , map_type(static_cast(t)) , msg(m) #endif @@ -1154,7 +1155,7 @@ namespace { , error(ec) , op(op_) , m_path_idx(alloc.copy_string(f)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(operation_name(op_)) , file(f) , msg(convert_from_native(error.message())) @@ -1241,7 +1242,7 @@ namespace { arr[stats_alert::upload_ip_protocol] = s[stat::upload_ip_protocol].counter(); arr[stats_alert::download_ip_protocol] = s[stat::download_ip_protocol].counter(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 arr[stats_alert::upload_dht_protocol] = 0; arr[stats_alert::upload_tracker_protocol] = 0; arr[stats_alert::download_dht_protocol] = 0; @@ -1267,7 +1268,7 @@ namespace { { char msg[200]; std::snprintf(msg, sizeof(msg), "%s: [%d] %d %d %d %d %d %d" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 " %d %d %d %d" #endif , torrent_alert::message().c_str() @@ -1278,7 +1279,7 @@ namespace { , transferred[3] , transferred[4] , transferred[5] -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , transferred[6] , transferred[7] , transferred[8] @@ -1332,7 +1333,7 @@ namespace { , const std::string& id) : tracker_alert(alloc, h, ep, u) , m_tracker_idx(alloc.copy_string(id)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , trackerid(id) #endif {} @@ -1362,7 +1363,7 @@ namespace { : torrent_alert(alloc, h) , error(e) , m_file_idx(alloc.copy_string(f)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , error_file(f) #endif {} @@ -1388,7 +1389,7 @@ namespace { return m_alloc.get().ptr(m_file_idx); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_added_alert::torrent_added_alert(aux::stack_allocator& alloc , torrent_handle const& h) : torrent_alert(alloc, h) @@ -1425,7 +1426,7 @@ namespace { , tcp::endpoint const& i) : socket_type(t) , endpoint(i) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , ip(i) #endif {} @@ -1466,7 +1467,7 @@ namespace { char const* torrent_name = info_hash; if (params.ti) torrent_name = params.ti->name().c_str(); else if (!params.name.empty()) torrent_name = params.name.c_str(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 else if (!params.url.empty()) torrent_name = params.url.c_str(); #endif else aux::to_hex(params.info_hash, info_hash); @@ -1496,7 +1497,7 @@ namespace { return msg; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 mmap_cache_alert::mmap_cache_alert(aux::stack_allocator& , error_code const& ec): error(ec) {} @@ -1561,7 +1562,7 @@ namespace { return names[idx]; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 char const* operation_name(int const op) { return operation_name(static_cast(op)); @@ -1574,7 +1575,7 @@ namespace { : peer_alert(alloc, h, ep, peer_id) , op(op_) , error(e) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(static_cast(op_)) , msg(convert_from_native(error.message())) #endif @@ -1590,7 +1591,7 @@ namespace { return buf; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_update_alert::torrent_update_alert(aux::stack_allocator& alloc, torrent_handle h , sha1_hash const& old_hash, sha1_hash const& new_hash) : torrent_alert(alloc, h) @@ -1617,7 +1618,7 @@ namespace { , op(op_) , error(e) , reason(r) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(static_cast(op)) , msg(convert_from_native(error.message())) #endif @@ -1640,7 +1641,7 @@ namespace { , error_code const& ec) : error(ec) , op(op_) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(op_ == operation_t::hostname_lookup ? op_t::hostname_lookup : op_t::unknown) #endif @@ -1755,7 +1756,7 @@ namespace { : info_hash(ih) , obfuscated_info_hash(obfih) , endpoint(std::move(ep)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , ip(endpoint) #endif {} @@ -1791,7 +1792,7 @@ namespace { return m_alloc.get().ptr(m_str_idx); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 char const* log_alert::msg() const { return log_message(); @@ -1814,7 +1815,7 @@ namespace { return m_alloc.get().ptr(m_str_idx); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 char const* torrent_log_alert::msg() const { return log_message(); @@ -1842,7 +1843,7 @@ namespace { return m_alloc.get().ptr(m_str_idx); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 char const* peer_log_alert::msg() const { return log_message(); @@ -1867,30 +1868,54 @@ namespace { return "Local Service Discovery error: " + convert_from_native(error.message()); } +#if TORRENT_ABI_VERSION == 1 namespace { - aux::array counters_to_array(counters const& cnt) - { - aux::array arr; + aux::array counters_to_array(counters const& cnt) + { + aux::array arr; - for (int i = 0; i < counters::num_counters; ++i) - arr[i] = cnt[i]; + for (int i = 0; i < counters::num_counters; ++i) + arr[i] = cnt[i]; - return arr; - } + return arr; } +} +#else +namespace { + template + T* align_pointer(U* ptr) + { + return reinterpret_cast((reinterpret_cast(ptr) + alignof(T) - 1) + & ~(alignof(T) - 1)); + } +} +#endif +#if TORRENT_ABI_VERSION == 1 session_stats_alert::session_stats_alert(aux::stack_allocator&, struct counters const& cnt) : values(counters_to_array(cnt)) {} +#else + session_stats_alert::session_stats_alert(aux::stack_allocator& alloc, struct counters const& cnt) + : m_alloc(alloc) + , m_counters_idx(alloc.allocate(sizeof(std::int64_t) + * counters::num_counters + sizeof(std::int64_t) - 1)) + { + std::int64_t* ptr = align_pointer(alloc.ptr(m_counters_idx)); + for (int i = 0; i < counters::num_counters; ++i, ++ptr) + *ptr = cnt[i]; + } +#endif std::string session_stats_alert::message() const { char msg[50]; - std::snprintf(msg, sizeof(msg), "session stats (%d values): " , int(values.size())); + auto cnt = counters(); + std::snprintf(msg, sizeof(msg), "session stats (%d values): " , int(cnt.size())); std::string ret = msg; bool first = true; - for (auto v : values) + for (auto v : cnt) { std::snprintf(msg, sizeof(msg), first ? "%" PRId64 : ", %" PRId64, v); first = false; @@ -1901,7 +1926,12 @@ namespace { span session_stats_alert::counters() const { +#if TORRENT_ABI_VERSION == 1 return values; +#else + return { align_pointer(m_alloc.get().ptr(m_counters_idx)) + , counters::num_counters }; +#endif } dht_stats_alert::dht_stats_alert(aux::stack_allocator& @@ -1927,7 +1957,7 @@ namespace { , error(e) , m_url_idx(alloc.copy_string(u)) , m_msg_idx() -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , url(u) , msg(convert_from_native(e.message())) #endif @@ -1938,7 +1968,7 @@ namespace { : torrent_alert(alloc, h) , m_url_idx(alloc.copy_string(u)) , m_msg_idx(alloc.copy_string(m)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , url(u) , msg(m) #endif @@ -1968,7 +1998,7 @@ namespace { , error(ec) , op(op_) , m_file_idx(alloc.copy_string(f)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , operation(operation_name(op_)) , file(f) , msg(convert_from_native(error.message())) @@ -2040,7 +2070,7 @@ namespace { , m_alloc(alloc) , m_msg_idx(alloc.copy_buffer(buf)) , m_size(buf.size()) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , dir(d) #endif {} @@ -2117,7 +2147,7 @@ namespace { return m_v4_num_peers + m_v6_num_peers; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void dht_get_peers_reply_alert::peers(std::vector &v) const { std::vector p(peers()); @@ -2149,7 +2179,7 @@ namespace { , m_alloc(alloc) , m_response_idx(alloc.copy_buffer(response.data_section())) , m_response_size(int(response.data_section().size())) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , addr(addr_) #endif {} @@ -2162,7 +2192,7 @@ namespace { , m_alloc(alloc) , m_response_idx() , m_response_size(0) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , addr(addr_) #endif {} @@ -2594,7 +2624,7 @@ namespace { constexpr alert_category_t session_stats_header_alert::static_category; constexpr alert_category_t dht_sample_infohashes_alert::static_category; constexpr alert_category_t block_uploaded_alert::static_category; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr alert_category_t mmap_cache_alert::static_category; constexpr alert_category_t torrent_added_alert::static_category; constexpr alert_category_t torrent_update_alert::static_category; diff --git a/src/announce_entry.cpp b/src/announce_entry.cpp index 8dde2df9a..772e52160 100644 --- a/src/announce_entry.cpp +++ b/src/announce_entry.cpp @@ -61,7 +61,7 @@ namespace libtorrent { : url(u.to_string()) , source(0) , verified(false) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , fails(0) , send_stats(false) , start_sent(false) @@ -74,7 +74,7 @@ namespace libtorrent { announce_entry::announce_entry() : source(0) , verified(false) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , fails(0) , send_stats(false) , start_sent(false) @@ -130,7 +130,7 @@ namespace libtorrent { aep.reset(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 bool announce_entry::can_announce(time_point now, bool is_seed) const { return std::any_of(endpoints.begin(), endpoints.end() diff --git a/src/block_cache.cpp b/src/block_cache.cpp index b467c0e8f..53fc73de0 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -1469,7 +1469,7 @@ void block_cache::update_stats_counters(counters& c) const c.set_value(counters::arc_volatile_size, m_lru[cached_piece_entry::volatile_read_lru].size()); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void block_cache::get_stats(cache_status* ret) const { ret->write_cache_size = m_write_cache_size; diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 4d0241894..f7f5c8335 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -52,7 +52,7 @@ using namespace std::placeholders; namespace libtorrent { constexpr create_flags_t create_torrent::optimize_alignment; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr create_flags_t create_torrent::optimize; #endif constexpr create_flags_t create_torrent::merkle; @@ -202,7 +202,7 @@ namespace { } // anonymous namespace -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void add_files(file_storage& fs, std::wstring const& wfile , std::function p, create_flags_t const flags) @@ -233,7 +233,7 @@ namespace { std::string utf8 = wchar_utf8(p); set_piece_hashes(t, utf8, f, ec); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void add_files(file_storage& fs, std::string const& file , std::function p, create_flags_t const flags) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 5870da0bc..eff018b4b 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -2554,7 +2554,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit; { std::unique_lock l(m_cache_mutex); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 ret->total_used_buffers = m_disk_cache.in_use(); ret->blocks_read_hit = int(m_stats_counters[counters::num_blocks_cache_hits]); @@ -2636,7 +2636,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit; l.unlock(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::unique_lock jl(m_job_mutex); ret->queued_jobs = m_generic_io_jobs.m_queued_jobs.size() + m_hash_io_jobs.m_queued_jobs.size(); jl.unlock(); diff --git a/src/entry.cpp b/src/entry.cpp index 0e2491b9a..f50511b13 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/config.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/lazy_entry.hpp" #endif #include "libtorrent/bdecode.hpp" @@ -397,7 +397,7 @@ namespace { return *this; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // convert a lazy_entry into an old skool entry entry& entry::operator=(lazy_entry const& e) { diff --git a/src/error_code.cpp b/src/error_code.cpp index 5884ec607..2d20b5f70 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -243,7 +243,7 @@ namespace libtorrent { "udp tracker response packet has invalid size", "invalid transaction id in udp tracker response", "invalid action field in udp tracker response", -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 "", "", "", diff --git a/src/escape_string.cpp b/src/escape_string.cpp index a6faeec93..304585581 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -256,7 +256,7 @@ namespace libtorrent { return msg; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string resolve_file_url(std::string const& url) { TORRENT_ASSERT(url.substr(0, 7) == "file://"); diff --git a/src/file_pool.cpp b/src/file_pool.cpp index b49431d20..a66568aa2 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -112,14 +112,6 @@ namespace libtorrent { std::unique_lock l(m_mutex); -#if TORRENT_USE_ASSERTS - // we're not allowed to open a file - // from a deleted storage! - TORRENT_ASSERT(std::find(m_deleted_storages.begin(), m_deleted_storages.end() - , std::make_pair(fs.name(), static_cast(&fs))) - == m_deleted_storages.end()); -#endif - TORRENT_ASSERT(is_complete(p)); TORRENT_ASSERT((m & open_mode::rw_mask) == open_mode::read_only || (m & open_mode::rw_mask) == open_mode::read_write); @@ -281,29 +273,6 @@ namespace libtorrent { // the files are closed here while the lock is not held } -#if TORRENT_USE_ASSERTS - void file_pool::mark_deleted(file_storage const& fs) - { - std::unique_lock l(m_mutex); - m_deleted_storages.push_back(std::make_pair(fs.name() - , static_cast(&fs))); - if(m_deleted_storages.size() > 100) - m_deleted_storages.erase(m_deleted_storages.begin()); - } - - bool file_pool::assert_idle_files(storage_index_t const st) const - { - std::unique_lock l(m_mutex); - - for (auto const& i : m_files) - { - if (i.first.first == st && !i.second.file_ptr.unique()) - return false; - } - return true; - } -#endif - void file_pool::resize(int size) { // these are destructed _after_ the mutex is released diff --git a/src/file_storage.cpp b/src/file_storage.cpp index b0ad0e68f..a587b1cba 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -59,7 +59,7 @@ namespace libtorrent { constexpr file_flags_t file_storage::flag_executable; constexpr file_flags_t file_storage::flag_symlink; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr file_flags_t file_storage::pad_file; constexpr file_flags_t file_storage::attribute_hidden; constexpr file_flags_t file_storage::attribute_executable; @@ -192,7 +192,7 @@ namespace { } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 file_entry::file_entry(): offset(0), size(0) , mtime(0), pad_file(false), hidden_attribute(false) , executable_attribute(false) @@ -200,7 +200,7 @@ namespace { {} file_entry::~file_entry() = default; -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION internal_file_entry::internal_file_entry() : offset(0) @@ -346,7 +346,7 @@ namespace { } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void file_storage::add_file_borrow(char const* filename, int filename_len , std::string const& path, std::int64_t file_size, file_flags_t file_flags @@ -390,7 +390,7 @@ namespace { { rename_file_deprecated(index, new_filename); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void file_storage::rename_file(file_index_t const index , std::string const& new_filename) @@ -399,7 +399,7 @@ namespace { update_path_index(m_files[index], new_filename); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 file_storage::iterator file_storage::file_at_offset_deprecated(std::int64_t offset) const { // find the file iterator and file offset @@ -497,7 +497,7 @@ namespace { return ret; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 file_entry file_storage::at(int index) const { return at_deprecated(index); @@ -521,7 +521,7 @@ namespace { ret.filehash = hash(index); return ret; } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION peer_request file_storage::map_file(file_index_t const file_index , std::int64_t const file_offset, int const size) const @@ -849,7 +849,7 @@ namespace { return fe.path_index == -2; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 sha1_hash file_storage::hash(internal_file_entry const& fe) const { int index = int(&fe - &m_files[0]); @@ -906,7 +906,7 @@ namespace { file_entry file_storage::at(file_storage::iterator i) const { return at_deprecated(int(i - m_files.begin())); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void file_storage::reorder_file(int const index, int const dst) { diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp index 60e7daec7..293427a2e 100644 --- a/src/fingerprint.cpp +++ b/src/fingerprint.cpp @@ -89,13 +89,13 @@ namespace libtorrent { name[1] = id_string[1]; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string fingerprint::to_string() const { return generate_fingerprint(std::string(name, 2), major_version, minor_version , revision_version, tag_version); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION } diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 0fad224c2..2161249f6 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -225,7 +225,7 @@ namespace libtorrent { , (tracker_req().event == tracker_request::stopped ? resolver_interface::cache_only : resolver_flags{}) | resolver_interface::abort_on_shutdown -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 , tracker_req().auth #else , "" diff --git a/src/identify_client.cpp b/src/identify_client.cpp index df7932653..65605ae28 100644 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -345,7 +345,7 @@ namespace { namespace libtorrent { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 boost::optional client_fingerprint(peer_id const& p) { diff --git a/src/kademlia/dht_storage.cpp b/src/kademlia/dht_storage.cpp index 8f734eef4..c42cdcd07 100644 --- a/src/kademlia/dht_storage.cpp +++ b/src/kademlia/dht_storage.cpp @@ -199,7 +199,7 @@ namespace { dht_default_storage(dht_default_storage const&) = delete; dht_default_storage& operator=(dht_default_storage const&) = delete; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 size_t num_torrents() const override { return m_map.size(); } size_t num_peers() const override { diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index 434131956..97ebfbd7e 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -206,7 +206,7 @@ namespace libtorrent { namespace dht { m_host_resolver.cancel(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void dht_tracker::dht_status(session_status& s) { s.dht_torrents += int(m_storage.num_torrents()); diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 89d3e00aa..37d848a2e 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -737,7 +737,7 @@ std::tuple node::get_stats_counters() const return std::make_tuple(nodes, replacements, m_rpc.num_allocated_observers()); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // TODO: 2 use the non deprecated function instead of this one void node::status(session_status& s) { diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 038a6636d..5ae448886 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -145,7 +145,7 @@ void routing_table::status(std::vector& s) const } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // TODO: 2 use the non deprecated function instead of this one void routing_table::status(session_status& s) const { @@ -167,7 +167,7 @@ void routing_table::status(session_status& s) const dht_routing_bucket b; b.num_nodes = int(i.live_nodes.size()); b.num_replacements = int(i.replacements.size()); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 b.last_active = 0; #endif s.dht_routing_table.push_back(b); diff --git a/src/lazy_bdecode.cpp b/src/lazy_bdecode.cpp index 75a80ef7f..aef84cbff 100644 --- a/src/lazy_bdecode.cpp +++ b/src/lazy_bdecode.cpp @@ -30,9 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TORRENT_NO_DEPRECATE - #include "libtorrent/config.hpp" + +#if TORRENT_ABI_VERSION == 1 + #include "libtorrent/lazy_entry.hpp" #include "libtorrent/bdecode.hpp" // for error codes #include "libtorrent/string_util.hpp" // for is_digit @@ -81,7 +82,7 @@ namespace { } // anonymous namespace -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int lazy_bdecode(char const* start, char const* end , lazy_entry& ret, int depth_limit, int item_limit) { @@ -674,4 +675,4 @@ namespace { } } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION diff --git a/src/magnet_uri.cpp b/src/magnet_uri.cpp index 64fa19e4b..a264d9f97 100644 --- a/src/magnet_uri.cpp +++ b/src/magnet_uri.cpp @@ -105,7 +105,7 @@ namespace libtorrent { return ret; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 namespace { torrent_handle add_magnet_uri_deprecated(session& ses, std::string const& uri @@ -165,7 +165,7 @@ namespace libtorrent { return ret; } #endif // BOOST_NO_EXCEPTIONS -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION add_torrent_params parse_magnet_uri(string_view uri, error_code& ec) { diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index fa35eceed..01ad78e58 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4483,7 +4483,7 @@ namespace libtorrent { p.total_download = statistics().total_payload_download(); p.total_upload = statistics().total_payload_upload(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 p.upload_limit = -1; p.download_limit = -1; p.load_balancing = 0; @@ -4550,7 +4550,7 @@ namespace libtorrent { p.num_hashfails = 0; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 p.remote_dl_rate = 0; #endif p.send_buffer_size = m_send_buffer.capacity(); diff --git a/src/peer_info.cpp b/src/peer_info.cpp index a207817ca..71fbda042 100644 --- a/src/peer_info.cpp +++ b/src/peer_info.cpp @@ -43,7 +43,7 @@ namespace libtorrent { constexpr peer_flags_t peer_info::local_connection; constexpr peer_flags_t peer_info::handshake; constexpr peer_flags_t peer_info::connecting; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr peer_flags_t peer_info::queued; #endif constexpr peer_flags_t peer_info::on_parole; @@ -71,7 +71,7 @@ namespace libtorrent { constexpr bandwidth_state_flags_t peer_info::bw_network; constexpr bandwidth_state_flags_t peer_info::bw_disk; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr bandwidth_state_flags_t peer_info::bw_torrent; constexpr bandwidth_state_flags_t peer_info::bw_global; #endif diff --git a/src/read_resume_data.cpp b/src/read_resume_data.cpp index e3c709348..b67068b00 100644 --- a/src/read_resume_data.cpp +++ b/src/read_resume_data.cpp @@ -144,7 +144,7 @@ namespace { ret.save_path = rd.dict_find_string_value("save_path").to_string(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 ret.url = rd.dict_find_string_value("url").to_string(); ret.uuid = rd.dict_find_string_value("uuid").to_string(); diff --git a/src/session.cpp b/src/session.cpp index c88b2ee90..7f162df26 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -90,7 +90,7 @@ namespace { settings_pack min_memory_usage() { settings_pack set; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // receive data directly into disk buffers // this yields more system calls to read() and // kqueue(), but saves RAM. @@ -288,16 +288,6 @@ namespace { return set; } -#ifndef TORRENT_CFG -#error TORRENT_CFG is not defined! -#endif - - // this is a dummy function that's exported and named based - // on the configuration. The session.hpp file will reference - // it and if the library and the client are built with different - // configurations this will give a link error - void TORRENT_CFG() {} - session_params read_session_params(bdecode_node const& e, save_state_flags_t const flags) { session_params params; diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 314c9c9e9..692fbadab 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_class.hpp" #include "libtorrent/peer_class_type_filter.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/read_resume_data.hpp" #endif @@ -55,7 +55,7 @@ namespace libtorrent { constexpr save_state_flags_t session_handle::save_settings; constexpr save_state_flags_t session_handle::save_dht_settings; constexpr save_state_flags_t session_handle::save_dht_state; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr save_state_flags_t session_handle::save_encryption_settings; constexpr save_state_flags_t session_handle::save_as_map TORRENT_DEPRECATED_ENUM; constexpr save_state_flags_t session_handle::save_proxy TORRENT_DEPRECATED_ENUM; @@ -185,7 +185,7 @@ namespace libtorrent { return ret; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::get_torrent_status(std::vector* ret , std::function const& pred , status_flags_t const flags) const @@ -232,7 +232,7 @@ namespace libtorrent { return sync_call_ret>(&session_impl::get_torrents); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 namespace { void handle_backwards_compatible_resume_data(add_torrent_params& atp) @@ -357,14 +357,14 @@ namespace { } // anonymous namespace -#endif +#endif // TORRENT_ABI_VERSION #ifndef BOOST_NO_EXCEPTIONS torrent_handle session_handle::add_torrent(add_torrent_params const& params) { TORRENT_ASSERT_PRECOND(!params.save_path.empty()); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 add_torrent_params p = params; handle_backwards_compatible_resume_data(p); #else @@ -383,7 +383,7 @@ namespace { TORRENT_ASSERT_PRECOND(!params.save_path.empty()); ec.clear(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 add_torrent_params p = params; handle_backwards_compatible_resume_data(p); #else @@ -403,7 +403,7 @@ namespace { auto* p = new add_torrent_params(std::move(params)); p->save_path = complete(p->save_path); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 handle_backwards_compatible_resume_data(*p); #endif @@ -411,7 +411,7 @@ namespace { } #ifndef BOOST_NO_EXCEPTIONS -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // if the torrent already exists, this will throw duplicate_torrent torrent_handle session_handle::add_torrent( torrent_info const& ti @@ -464,7 +464,7 @@ namespace { } return add_torrent(p); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #endif // BOOST_NO_EXCEPTIONS void session_handle::pause() @@ -482,7 +482,7 @@ namespace { return sync_call_ret(&session_impl::is_paused); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::set_load_function(user_load_function_t fun) { async_call(&session_impl::set_load_function, fun); @@ -515,7 +515,7 @@ namespace { sync_call(&session_impl::get_cache_info, h, ret, flags); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::start_dht() { settings_pack p; @@ -529,7 +529,7 @@ namespace { p.set_bool(settings_pack::enable_dht, false); apply_settings(std::move(p)); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void session_handle::set_dht_settings(dht::dht_settings const& settings) { @@ -576,7 +576,7 @@ namespace { #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::add_dht_router(std::pair const& node) { #ifndef TORRENT_DISABLE_DHT @@ -585,7 +585,7 @@ namespace { TORRENT_UNUSED(node); #endif } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void session_handle::dht_get_item(sha1_hash const& target) { @@ -686,7 +686,7 @@ namespace { #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 entry session_handle::dht_state() const { #ifndef TORRENT_DISABLE_DHT @@ -704,7 +704,7 @@ namespace { TORRENT_UNUSED(startup_state); #endif } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void session_handle::add_extension(std::function(torrent_handle const&, void*)> ext) { @@ -724,7 +724,7 @@ namespace { #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::load_asnum_db(char const*) {} void session_handle::load_country_db(char const*) {} @@ -780,7 +780,7 @@ namespace { #endif sync_call(&session_impl::load_state, &e, flags); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void session_handle::set_ip_filter(ip_filter const& f) { @@ -798,7 +798,7 @@ namespace { async_call(&session_impl::set_port_filter, f); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::set_peer_id(peer_id const& id) { settings_pack p; @@ -875,7 +875,7 @@ namespace { async_call(&session_impl::set_peer_class, cid, pci); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::use_interfaces(char const* interfaces) { settings_pack p; @@ -914,7 +914,7 @@ namespace { async_call(&session_impl::remove_torrent, h, options); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::set_pe_settings(pe_settings const& r) { settings_pack p; @@ -960,7 +960,7 @@ namespace { return sync_call_ret(&session_impl::get_settings); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::set_i2p_proxy(proxy_settings const& s) { settings_pack pack; @@ -1120,7 +1120,7 @@ namespace { return sync_call_ret(&session_impl::max_connections); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // the alerts are const, they may not be deleted by the client void session_handle::pop_alerts(std::vector* alerts) @@ -1151,7 +1151,7 @@ namespace { return s->alerts().dropped_alerts(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_handle::set_severity_level(alert::severity_t s) { alert_category_t m = {}; @@ -1231,7 +1231,7 @@ namespace { p.set_bool(settings_pack::enable_natpmp, false); apply_settings(std::move(p)); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION port_mapping_t session_handle::add_port_mapping(portmap_protocol const t , int external_port, int local_port) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 356e989fd..200d3088c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -76,7 +76,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/lsd.hpp" #include "libtorrent/instantiate_connection.hpp" #include "libtorrent/peer_info.hpp" -#include "libtorrent/build_config.hpp" #include "libtorrent/random.hpp" #include "libtorrent/magnet_uri.hpp" #include "libtorrent/aux_/session_settings.hpp" @@ -518,10 +517,8 @@ namespace aux { #ifndef TORRENT_DISABLE_LOGGING - session_log("config: %s version: %s revision: %s" - , TORRENT_CFG_STRING - , LIBTORRENT_VERSION - , LIBTORRENT_REVISION); + session_log("version: %s revision: %s" + , LIBTORRENT_VERSION, LIBTORRENT_REVISION); #endif // TORRENT_DISABLE_LOGGING @@ -666,7 +663,7 @@ namespace aux { } #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 bool need_update_proxy = false; if (flags & session_handle::save_proxy) { @@ -724,7 +721,7 @@ namespace aux { #ifndef TORRENT_DISABLE_DHT need_update_dht = false; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 need_update_proxy = false; #endif } @@ -733,7 +730,7 @@ namespace aux { #ifndef TORRENT_DISABLE_DHT if (need_update_dht) start_dht(); #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (need_update_proxy) update_proxy(); #endif @@ -1269,7 +1266,7 @@ namespace aux { void session_impl::apply_settings_pack_impl(settings_pack const& pack) { bool const reopen_listen_port = -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 (pack.has_val(settings_pack::ssl_listen) && pack.get_int(settings_pack::ssl_listen) != m_settings.get_int(settings_pack::ssl_listen)) @@ -2958,7 +2955,7 @@ namespace aux { } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 peer_id session_impl::deprecated_get_peer_id() const { return generate_peer_id(m_settings); @@ -4348,7 +4345,7 @@ namespace aux { , std::string uuid) { m_torrents.insert(std::make_pair(ih, t)); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 if (!uuid.empty()) m_uuids.insert(std::make_pair(uuid, t)); #else @@ -4431,7 +4428,7 @@ namespace aux { } #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 std::weak_ptr session_impl::find_torrent(std::string const& uuid) const { @@ -4634,7 +4631,7 @@ namespace aux { { std::unique_ptr holder(params); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (!params->ti && string_begins_no_case("file://", params->url.c_str())) { if (!m_torrent_load_thread) @@ -4661,7 +4658,7 @@ namespace aux { add_torrent(std::move(*params), ec); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_impl::on_async_load_torrent(add_torrent_params* params, error_code ec) { std::unique_ptr holder(params); @@ -4723,7 +4720,7 @@ namespace aux { } #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (m_alerts.should_post()) m_alerts.emplace_alert(handle); #endif @@ -4787,7 +4784,7 @@ namespace aux { #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 if (!params.uuid.empty() || !params.url.empty()) m_uuids.insert(std::make_pair(params.uuid.empty() @@ -4832,7 +4829,7 @@ namespace aux { using ptr_t = std::shared_ptr; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (string_begins_no_case("magnet:", params.url.c_str())) { parse_magnet_uri(params.url, params, ec); @@ -4880,7 +4877,7 @@ namespace aux { // figure out the info hash of the torrent and make sure params.info_hash // is set correctly if (params.ti) params.info_hash = params.ti->info_hash(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 else if (!params.url.empty()) { @@ -4901,7 +4898,7 @@ namespace aux { // is the torrent already active? std::shared_ptr torrent_ptr = find_torrent(params.info_hash).lock(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 if (!torrent_ptr && !params.uuid.empty()) torrent_ptr = find_torrent(params.uuid).lock(); // if we still can't find the torrent, look for it by url @@ -4919,7 +4916,7 @@ namespace aux { { if (!(params.flags & torrent_flags::duplicate_is_error)) { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 //deprecated in 1.2 if (!params.uuid.empty() && torrent_ptr->uuid().empty()) torrent_ptr->set_uuid(params.uuid); @@ -5102,7 +5099,7 @@ namespace aux { void session_impl::remove_torrent_impl(std::shared_ptr tptr , remove_flags_t const options) { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // remove from uuid list if (!tptr->uuid().empty()) @@ -5114,7 +5111,7 @@ namespace aux { auto i = m_torrents.find(tptr->torrent_file().info_hash()); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // this torrent might be filed under the URL-hash if (i == m_torrents.end() && !tptr->url().empty()) @@ -5171,7 +5168,7 @@ namespace aux { TORRENT_ASSERT(m_torrents.find(i_hash) == m_torrents.end()); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_impl::update_ssl_listen() { @@ -5208,7 +5205,7 @@ namespace aux { m_settings.set_str(settings_pack::listen_interfaces , print_listen_interfaces(current_ifaces)); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void session_impl::update_listen_interfaces() { @@ -5500,7 +5497,7 @@ namespace aux { } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 session_status session_impl::status() const { // INVARIANT_CHECK; @@ -5624,7 +5621,7 @@ namespace aux { return s; } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void session_impl::get_cache_info(torrent_handle h, cache_status* ret, int flags) const { @@ -5750,7 +5747,7 @@ namespace aux { m_dht_storage_constructor = std::move(sc); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 entry session_impl::dht_state() const { return m_dht ? dht::save_dht_state(m_dht->state()) : entry(); @@ -6041,7 +6038,7 @@ namespace aux { #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 int session_impl::max_connections() const { return m_settings.get_int(settings_pack::connections_limit); @@ -6233,7 +6230,7 @@ namespace aux { || m_settings.get_int(settings_pack::unchoke_slots_limit) < 0; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_impl::update_dht_upload_rate_limit() { #ifndef TORRENT_DISABLE_DHT @@ -6425,7 +6422,7 @@ namespace aux { #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_impl::update_local_download_rate() { if (m_settings.get_int(settings_pack::local_download_rate_limit) < 0) @@ -6534,7 +6531,7 @@ namespace aux { m_alerts.get_all(*alerts); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void session_impl::update_rate_limit_utp() { if (m_settings.get_bool(settings_pack::rate_limit_utp)) @@ -6598,7 +6595,7 @@ namespace aux { return m_alerts.wait_for_alert(max_wait); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::size_t session_impl::set_alert_queue_size_limit(std::size_t queue_size_limit_) { m_settings.set_int(settings_pack::alert_queue_size, int(queue_size_limit_)); diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 2f642dc7b..054f20641 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -235,10 +235,10 @@ namespace { METRIC(ses, num_have_pieces) METRIC(ses, num_total_pieces_added) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // this counts the number of times a torrent has been - // evicted (only applies when `dynamic loading of torrent files`_ - // is enabled). + // evicted (only applies when dynamic-loading-of-torrent-files + // is enabled, which is deprecated). METRIC(ses, torrent_evicted_counter) #endif diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 90124d800..26e29a920 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -93,7 +93,7 @@ namespace libtorrent { #define SET(name, default_value, fun) { #name, fun, default_value } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #define DEPRECATED_SET(name, default_value, fun) { #name, fun, default_value } #else #define DEPRECATED_SET(name, default_value, fun) { "", nullptr, 0 } diff --git a/src/storage.cpp b/src/storage.cpp index 1f9b245e7..0ecd952e4 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -431,17 +431,6 @@ namespace libtorrent { void default_storage::delete_files(remove_flags_t const options, storage_error& ec) { -#if TORRENT_USE_ASSERTS - // this is a fence job, we expect no other - // threads to hold any references to any files - // in this file storage. Assert that that's the - // case - if (!m_pool.assert_idle_files(storage_index())) - { - TORRENT_ASSERT_FAIL(); - } -#endif - // make sure we don't have the files open m_pool.release(storage_index()); diff --git a/src/torrent.cpp b/src/torrent.cpp index 556e433e0..b838d6ab0 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -187,7 +187,7 @@ bool is_downloading_state(int const st) , m_inactivity_timer(ses.get_io_service()) , m_trackerid(p.trackerid) , m_save_path(complete(p.save_path)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 , m_url(p.url) , m_uuid(p.uuid) @@ -369,7 +369,7 @@ bool is_downloading_state(int const st) if (!p.name.empty()) m_name.reset(new std::string(p.name)); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 if (!m_url.empty() && m_uuid.empty()) m_uuid = m_url; #endif @@ -395,7 +395,7 @@ bool is_downloading_state(int const st) if (m_completed_time != 0 && m_completed_time < m_added_time) m_completed_time = m_added_time; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (!m_name && !m_url.empty()) m_name.reset(new std::string(m_url)); #endif @@ -409,7 +409,7 @@ bool is_downloading_state(int const st) void torrent::inc_stats_counter(int c, int value) { m_ses.stats_counters().inc_stats_counter(c, value); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 void torrent::on_torrent_download(error_code const& ec , http_parser const& parser, span data) try @@ -522,7 +522,7 @@ bool is_downloading_state(int const st) } catch (...) { handle_exception(); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION int torrent::current_stats_state() const { @@ -537,7 +537,7 @@ bool is_downloading_state(int const st) return counters::num_queued_download_torrents; } if (state() == torrent_status::checking_files -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 || state() == torrent_status::queued_for_checking #endif ) @@ -622,7 +622,7 @@ bool is_downloading_state(int const st) // constructed, as it relies on get_shared_from_this() if (m_add_torrent_params) { -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (m_add_torrent_params->internal_resume_data_error && m_ses.alerts().should_post()) { @@ -681,7 +681,7 @@ bool is_downloading_state(int const st) update_want_tick(); update_state_list(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 if (!m_torrent_file->is_valid() && !m_url.empty()) { @@ -707,7 +707,7 @@ bool is_downloading_state(int const st) #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 void torrent::start_download_url() { @@ -770,7 +770,7 @@ bool is_downloading_state(int const st) if (!m_announce_to_dht) return false; if (m_paused) return false; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // if we don't have the metadata, and we're waiting // for a web server to serve it to us, no need to announce @@ -2469,7 +2469,7 @@ bool is_downloading_state(int const st) } catch (...) { handle_exception(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent::use_interface(std::string net_interfaces) { std::shared_ptr p = std::make_shared(); @@ -2558,7 +2558,7 @@ bool is_downloading_state(int const st) if (m_paused) debug_log("DHT: torrent paused, no DHT announce"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 if (!m_torrent_file->is_valid() && !m_url.empty()) debug_log("DHT: no info-hash, waiting for \"%s\"", m_url.c_str()); @@ -2906,7 +2906,7 @@ bool is_downloading_state(int const st) } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 req.auth = tracker_login(); #endif req.key = tracker_key(); @@ -2971,7 +2971,7 @@ bool is_downloading_state(int const st) void torrent::scrape_tracker(int idx, bool const user_triggered) { TORRENT_ASSERT(is_single_thread()); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 m_last_scrape = aux::time_now32(); #endif @@ -2989,7 +2989,7 @@ bool is_downloading_state(int const st) req.kind |= tracker_request::scrape_request; req.url = m_trackers[idx].url; req.private_torrent = m_torrent_file->priv(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 req.auth = tracker_login(); #endif req.key = tracker_key(); @@ -3153,7 +3153,7 @@ bool is_downloading_state(int const st) } update_tracker_timer(now); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (resp.complete >= 0 && resp.incomplete >= 0) m_last_scrape = aux::time_now32(); #endif @@ -3384,9 +3384,8 @@ bool is_downloading_state(int const st) update_tracker_timer(aux::time_now32()); } -#ifndef TORRENT_NO_DEPRECATE - void torrent::set_tracker_login( - std::string const& name +#if TORRENT_ABI_VERSION == 1 + void torrent::set_tracker_login(std::string const& name , std::string const& pw) { m_username = name; @@ -4566,7 +4565,7 @@ bool is_downloading_state(int const st) } catch (...) { handle_exception(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 std::string torrent::tracker_login() const { if (m_username.empty() && m_password.empty()) return ""; @@ -6133,7 +6132,7 @@ bool is_downloading_state(int const st) ret.save_path = m_save_path; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 ret.url = m_url; ret.uuid = m_uuid; @@ -6354,7 +6353,7 @@ bool is_downloading_state(int const st) } } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent::get_full_peer_list(std::vector* v) const { v->clear(); @@ -6420,10 +6419,8 @@ bool is_downloading_state(int const st) pi.finished = int(i->finished); pi.writing = int(i->writing); pi.requested = int(i->requested); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pi.piece_state = partial_piece_info::none; -#else - pi.deprecated_piece_state = partial_piece_info::none; #endif TORRENT_ASSERT(counter * blocks_per_piece + pi.blocks_in_piece <= int(blk.size())); pi.blocks = &blk[std::size_t(counter * blocks_per_piece)]; @@ -7781,11 +7778,11 @@ bool is_downloading_state(int const st) { case counters::num_error_torrents: TORRENT_ASSERT(has_error()); break; case counters::num_checking_torrents: -#ifdef TORRENT_NO_DEPRECATE - TORRENT_ASSERT(state() == torrent_status::checking_files); -#else +#if TORRENT_ABI_VERSION == 1 TORRENT_ASSERT(state() == torrent_status::checking_files || state() == torrent_status::queued_for_checking); +#else + TORRENT_ASSERT(state() == torrent_status::checking_files); #endif break; case counters::num_seeding_torrents: TORRENT_ASSERT(is_seed()); break; @@ -8209,7 +8206,7 @@ bool is_downloading_state(int const st) update_want_peers(); update_state_list(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 // if we haven't downloaded the metadata from m_url, try again if (!m_url.empty() && !m_torrent_file->is_valid()) @@ -8229,7 +8226,7 @@ bool is_downloading_state(int const st) if (file == torrent_status::error_file_ssl_ctx) return "SSL Context"; if (file == torrent_status::error_file_exception) return "exception"; if (file == torrent_status::error_file_partfile) return "partfile"; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (file == torrent_status::error_file_url) return m_url; if (file == torrent_status::error_file_metadata) return "metadata (from user load function)"; #endif @@ -8912,7 +8909,7 @@ bool is_downloading_state(int const st) #endif return; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 if (!m_torrent_file->is_valid() && !m_url.empty()) { @@ -10303,7 +10300,7 @@ bool is_downloading_state(int const st) #endif } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #if !TORRENT_NO_FPU void torrent::file_progress_float(aux::vector& fp) { @@ -10328,7 +10325,7 @@ bool is_downloading_state(int const st) } } #endif -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void torrent::file_progress(aux::vector& fp, int const flags) { @@ -10600,7 +10597,7 @@ bool is_downloading_state(int const st) st->handle = get_handle(); st->info_hash = info_hash(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->is_loaded = true; #endif @@ -10617,7 +10614,7 @@ bool is_downloading_state(int const st) st->errc = m_error; st->error_file = m_error_file; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (m_error) st->error = convert_from_native(m_error.message()) + ": " + resolve_filename(m_error_file); st->seed_mode = m_seed_mode; @@ -10627,24 +10624,24 @@ bool is_downloading_state(int const st) st->announcing_to_trackers = m_announce_to_trackers; st->announcing_to_lsd = m_announce_to_lsd; st->announcing_to_dht = m_announce_to_dht; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->stop_when_ready = m_stop_when_ready; #endif st->added_time = m_added_time; st->completed_time = m_completed_time; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->last_scrape = static_cast(total_seconds(aux::time_now32() - m_last_scrape)); #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->share_mode = m_share_mode; st->upload_mode = m_upload_mode; #endif st->up_bandwidth_queue = 0; st->down_bandwidth_queue = 0; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->priority = priority(); #endif @@ -10659,7 +10656,7 @@ bool is_downloading_state(int const st) st->all_time_download = m_total_downloaded; // activity time -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->finished_time = int(total_seconds(finished_time())); st->active_time = int(total_seconds(active_time())); st->seeding_time = int(total_seconds(seeding_time())); @@ -10683,14 +10680,14 @@ bool is_downloading_state(int const st) st->num_complete = (m_complete == 0xffffff) ? -1 : m_complete; st->num_incomplete = (m_incomplete == 0xffffff) ? -1 : m_incomplete; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->paused = is_torrent_paused(); st->auto_managed = m_auto_managed; st->sequential_download = m_sequential_download; #endif st->is_seeding = is_seed(); st->is_finished = is_finished(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->super_seeding = m_super_seeding; #endif st->has_metadata = valid_metadata(); @@ -10726,7 +10723,7 @@ bool is_downloading_state(int const st) if (st->next_announce.count() < 0) st->next_announce = seconds(0); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->announce_interval = seconds(0); #endif @@ -10762,7 +10759,7 @@ bool is_downloading_state(int const st) st->queue_position = queue_position(); st->need_save_resume = need_save_resume_data(); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 st->ip_filter_applies = m_apply_ip_filter; #endif @@ -10864,13 +10861,13 @@ bool is_downloading_state(int const st) return priority; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent::set_priority(int const prio) { // priority 1 is default - if (prio == 1 && m_peer_class == 0) return; + if (prio == 1 && m_peer_class == peer_class_t{}) return; - if (m_peer_class == 0) + if (m_peer_class == peer_class_t{}) setup_peer_class(); struct peer_class* tpc = m_ses.peer_classes().at(m_peer_class); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 0867b422a..60c58ba43 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_flags.hpp" #include "libtorrent/pex_flags.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/peer_info.hpp" // for peer_list_entry #endif @@ -233,15 +233,13 @@ namespace libtorrent { async_call(&torrent::move_storage, save_path, flags); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent_handle::move_storage( std::string const& save_path, int const flags) const { async_call(&torrent::move_storage, save_path, static_cast(flags)); } -#endif -#ifndef TORRENT_NO_DEPRECATE void torrent_handle::move_storage( std::wstring const& save_path, int flags) const { @@ -252,7 +250,7 @@ namespace libtorrent { { async_call(&torrent::rename_file, index, wchar_utf8(new_name)); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void torrent_handle::rename_file(file_index_t index, std::string const& new_name) const { @@ -302,26 +300,26 @@ namespace libtorrent { async_call(&torrent::set_flags, torrent_flags_t{}, flags); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent_handle::stop_when_ready(bool b) const - { - async_call(&torrent::stop_when_ready, b); - } - - void torrent_handle::apply_ip_filter(bool b) const - { - async_call(&torrent::set_apply_ip_filter, b); - } - - void torrent_handle::set_share_mode(bool b) const - { - async_call(&torrent::set_share_mode, b); - } + { async_call(&torrent::stop_when_ready, b); } void torrent_handle::set_upload_mode(bool b) const - { - async_call(&torrent::set_upload_mode, b); - } + { async_call(&torrent::set_upload_mode, b); } + + void torrent_handle::set_share_mode(bool b) const + { async_call(&torrent::set_share_mode, b); } + + void torrent_handle::apply_ip_filter(bool b) const + { async_call(&torrent::set_apply_ip_filter, b); } + + void torrent_handle::auto_managed(bool m) const + { async_call(&torrent::auto_managed, m); } + + void torrent_handle::set_pinned(bool) const {} + + void torrent_handle::set_sequential_download(bool sd) const + { async_call(&torrent::set_sequential_download, sd); } #endif void torrent_handle::flush_cache() const @@ -379,13 +377,6 @@ namespace libtorrent { async_call(&torrent::resume); } -#ifndef TORRENT_NO_DEPRECATE - void torrent_handle::auto_managed(bool m) const - { - async_call(&torrent::auto_managed, m); - } -#endif - queue_position_t torrent_handle::queue_position() const { return sync_call_ret(no_pos @@ -424,7 +415,7 @@ namespace libtorrent { async_call(&torrent::clear_error); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent_handle::set_priority(int const p) const { async_call(&torrent::set_priority, p); @@ -435,8 +426,6 @@ namespace libtorrent { { async_call(&torrent::set_tracker_login, name, password); } - - void torrent_handle::set_pinned(bool) const {} #endif void torrent_handle::file_progress(std::vector& progress, int flags) const @@ -452,13 +441,6 @@ namespace libtorrent { return st; } -#ifndef TORRENT_NO_DEPRECATE - void torrent_handle::set_sequential_download(bool sd) const - { - async_call(&torrent::set_sequential_download, sd); - } -#endif - void torrent_handle::piece_availability(std::vector& avail) const { auto availr = std::ref(static_cast&>(avail)); @@ -495,7 +477,7 @@ namespace libtorrent { return ret; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent_handle::prioritize_pieces(std::vector const& pieces) const { aux::vector p; @@ -550,7 +532,7 @@ namespace libtorrent { return ret; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // ============ start deprecation =============== @@ -595,39 +577,25 @@ namespace libtorrent { #endif bool torrent_handle::is_seed() const - { - return sync_call_ret(false, &torrent::is_seed); - } + { return sync_call_ret(false, &torrent::is_seed); } bool torrent_handle::is_finished() const - { - return sync_call_ret(false, &torrent::is_finished); - } + { return sync_call_ret(false, &torrent::is_finished); } bool torrent_handle::is_paused() const - { - return sync_call_ret(false, &torrent::is_torrent_paused); - } + { return sync_call_ret(false, &torrent::is_torrent_paused); } bool torrent_handle::is_sequential_download() const - { - return sync_call_ret(false, &torrent::is_sequential_download); - } + { return sync_call_ret(false, &torrent::is_sequential_download); } bool torrent_handle::is_auto_managed() const - { - return sync_call_ret(false, &torrent::is_auto_managed); - } + { return sync_call_ret(false, &torrent::is_auto_managed); } bool torrent_handle::has_metadata() const - { - return sync_call_ret(false, &torrent::valid_metadata); - } + { return sync_call_ret(false, &torrent::valid_metadata); } bool torrent_handle::super_seeding() const - { - return sync_call_ret(false, &torrent::super_seeding); - } + { return sync_call_ret(false, &torrent::super_seeding); } // ============ end deprecation =============== #endif @@ -714,7 +682,7 @@ namespace libtorrent { std::shared_ptr(), &torrent::get_torrent_copy); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // this function should either be removed, or return // reference counted handle to the torrent_info which // forces the torrent to stay loaded while the client holds it @@ -758,7 +726,7 @@ namespace libtorrent { async_call(&torrent::add_peer, adr, source, flags); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent_handle::force_reannounce( boost::posix_time::time_duration duration) const { @@ -802,7 +770,7 @@ namespace libtorrent { async_call(&torrent::scrape_tracker, idx, true); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 void torrent_handle::super_seeding(bool on) const { async_call(&torrent::set_super_seeding, on); diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index cd68bc192..d043c6d12 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -55,7 +55,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hex.hpp" // to_hex #include "libtorrent/aux_/numeric_cast.hpp" -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/lazy_entry.hpp" #endif @@ -699,7 +699,7 @@ namespace { m_files.set_piece_length(m_orig_files->piece_length()); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec) { std::pair buf = torrent_file.data_section(); @@ -791,7 +791,7 @@ namespace { INVARIANT_CHECK; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_info::torrent_info(std::wstring const& filename) { std::vector buf; @@ -814,7 +814,7 @@ namespace { copy_on_write(); m_files.rename_file_deprecated(index, new_filename); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION #endif torrent_info::torrent_info(bdecode_node const& torrent_file @@ -847,7 +847,7 @@ namespace { INVARIANT_CHECK; } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 torrent_info::torrent_info(std::wstring const& filename , error_code& ec) { @@ -861,7 +861,7 @@ namespace { INVARIANT_CHECK; } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION // constructor used for creating new torrents // will not contain any hashes, comments, creation date @@ -1450,7 +1450,7 @@ namespace { { return lhs.tier < rhs.tier; }); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 namespace { struct filter_web_seed_type @@ -1486,7 +1486,7 @@ namespace { return parse_info_section(e, ec); } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION void torrent_info::add_url_seed(std::string const& url , std::string const& ext_auth diff --git a/src/torrent_status.cpp b/src/torrent_status.cpp index 8d10db3ac..6e465736a 100644 --- a/src/torrent_status.cpp +++ b/src/torrent_status.cpp @@ -39,7 +39,7 @@ namespace libtorrent { file_index_t constexpr torrent_status::error_file_exception; file_index_t constexpr torrent_status::error_file_partfile; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 file_index_t constexpr torrent_status::error_file_url; file_index_t constexpr torrent_status::error_file_metadata; #endif diff --git a/src/write_resume_data.cpp b/src/write_resume_data.cpp index b728f19ab..b27a3d066 100644 --- a/src/write_resume_data.cpp +++ b/src/write_resume_data.cpp @@ -80,7 +80,7 @@ namespace libtorrent { ret["save_path"] = atp.save_path; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // deprecated in 1.2 if (!atp.url.empty()) ret["url"] = atp.url; if (!atp.uuid.empty()) ret["uuid"] = atp.uuid; diff --git a/test/settings.cpp b/test/settings.cpp index 35bf7f1a3..27c983b67 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -41,7 +41,7 @@ lt::settings_pack settings() auto const mask = alert::all_categories & ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification @@ -58,7 +58,7 @@ lt::settings_pack settings() pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); pack.set_int(settings_pack::allowed_enc_level, settings_pack::pe_both); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif @@ -72,7 +72,7 @@ lt::settings_pack settings() pack.set_int(settings_pack::aio_threads, 0); #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_int(settings_pack::half_open_limit, 1); #endif diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 44ab84a2c..5761a1597 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -773,7 +773,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3 auto const mask = alert::all_categories & ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index 672800f2b..200156518 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -37,14 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/session.hpp" #include "libtorrent/units.hpp" - -namespace libtorrent -{ - class alert; - struct add_torrent_params; - class file_storage; - class session; -} +#include "libtorrent/fwd.hpp" EXPORT int print_failures(); EXPORT unsigned char random_byte(); diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 8b5a73415..e17990d97 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -77,7 +77,7 @@ void test_swarm(test_flags_t const flags) auto const mask = ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/test/test_alert_types.cpp b/test/test_alert_types.cpp index 44b1b083b..b97ffbc52 100644 --- a/test/test_alert_types.cpp +++ b/test/test_alert_types.cpp @@ -47,7 +47,7 @@ TORRENT_TEST(alerts_types) // are abstract int count_alert_types = 3; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_EQUAL(torrent_alert::alert_type, 0); TEST_EQUAL(peer_alert::alert_type, 1); TEST_EQUAL(tracker_alert::alert_type, 2); @@ -60,13 +60,13 @@ TORRENT_TEST(alerts_types) TEST_EQUAL(count_alert_types, seq); \ count_alert_types++; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_ALERT_TYPE(torrent_added_alert, 3, 0, alert::status_notification); #else ++count_alert_types; #endif -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #define PROGRESS_NOTIFICATION alert::progress_notification | #else #define PROGRESS_NOTIFICATION @@ -137,13 +137,13 @@ TORRENT_TEST(alerts_types) TEST_ALERT_TYPE(incoming_connection_alert, 66, 0, alert::peer_notification); TEST_ALERT_TYPE(add_torrent_alert, 67, 2, alert::status_notification); TEST_ALERT_TYPE(state_update_alert, 68, 1, alert::status_notification); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_ALERT_TYPE(mmap_cache_alert, 69, 0, alert::error_notification); #else count_alert_types++; #endif TEST_ALERT_TYPE(session_stats_alert, 70, 2, alert::stats_notification); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_ALERT_TYPE(torrent_update_alert, 71, 2, alert::status_notification); #else count_alert_types++; diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 6b3ce3c67..b2986d9b0 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -75,7 +75,7 @@ void test_swarm() pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif diff --git a/test/test_bencoding.cpp b/test/test_bencoding.cpp index b82f9f721..362a487a1 100644 --- a/test/test_bencoding.cpp +++ b/test/test_bencoding.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 #include "libtorrent/lazy_entry.hpp" #endif @@ -146,7 +146,7 @@ TORRENT_TEST(implicit_construct) TEST_EQUAL(e.list().back().type(), entry::list_t); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(lazy_entry) { { @@ -644,4 +644,4 @@ TORRENT_TEST(lazy_entry) } } } -#endif // TORRENT_NO_DEPRECATE +#endif // TORRENT_ABI_VERSION diff --git a/test/test_checking.cpp b/test/test_checking.cpp index 461115699..c0a3a1577 100644 --- a/test/test_checking.cpp +++ b/test/test_checking.cpp @@ -51,7 +51,7 @@ namespace bool is_checking(int const state) { return state == lt::torrent_status::checking_files -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 || state == lt::torrent_status::queued_for_checking #endif || state == lt::torrent_status::checking_resume_data; diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 1567c5d16..1429502da 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -433,7 +433,7 @@ std::shared_ptr setup_peer(tcp::socket& s, sha1_hash& ih sett.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); sett.set_bool(settings_pack::enable_outgoing_utp, false); sett.set_bool(settings_pack::enable_incoming_utp, false); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 sett.set_bool(settings_pack::rate_limit_utp, true); #endif ses.reset(new lt::session(sett, lt::session::add_default_plugins)); diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp index 0103d6aae..e7f439eb1 100644 --- a/test/test_lsd.cpp +++ b/test/test_lsd.cpp @@ -60,7 +60,7 @@ void test_lsd() pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48100"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif diff --git a/test/test_magnet.cpp b/test/test_magnet.cpp index e0cd02642..6945a6bf9 100644 --- a/test/test_magnet.cpp +++ b/test/test_magnet.cpp @@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace lt; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 namespace { void test_remove_url(std::string url) { diff --git a/test/test_pex.cpp b/test/test_pex.cpp index bb39b9c16..4104670d6 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -61,7 +61,7 @@ void test_pex() auto const mask = ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); @@ -79,7 +79,7 @@ void test_pex() pack.set_bool(settings_pack::enable_dht, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_natpmp, false); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif diff --git a/test/test_priority.cpp b/test/test_priority.cpp index 9d1b9261b..18852c568 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -109,7 +109,7 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false) pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); pack.set_int(settings_pack::alert_mask, mask); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif @@ -290,7 +290,7 @@ done: std::cout << "re-adding" << std::endl; add_torrent_params p; TORRENT_UNUSED(test_deprecated); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (test_deprecated) { p.resume_data = resume_data; @@ -399,7 +399,7 @@ TORRENT_TEST(priority) cleanup(); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(priority_deprecated) { using namespace lt; diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index a6326b5ac..843491320 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -103,7 +103,7 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags) auto const alert_mask = ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/test/test_read_piece.cpp b/test/test_read_piece.cpp index d19291ed4..d8c3bb8d4 100644 --- a/test/test_read_piece.cpp +++ b/test/test_read_piece.cpp @@ -93,7 +93,7 @@ void test_read_piece(int flags) auto const mask = ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/test/test_resume.cpp b/test/test_resume.cpp index ce2d251a4..9ceb1a5c6 100644 --- a/test/test_resume.cpp +++ b/test/test_resume.cpp @@ -158,7 +158,7 @@ torrent_handle test_resume_flags(lt::session& ses add_torrent_params p; std::vector rd = generate_resume_data(ti.get(), resume_file_prio); TORRENT_UNUSED(test_deprecated); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (test_deprecated) { p.resume_data.swap(rd); @@ -207,7 +207,7 @@ void default_tests(torrent_status const& s) // allow some slack in the time stamps since they are reported as // relative times. If the computer is busy while running the unit test // or running under valgrind it may take several seconds -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_CHECK(s.active_time >= 1339); TEST_CHECK(s.active_time < 1339 + 10); @@ -259,7 +259,7 @@ void test_piece_priorities(bool test_deprecated = false) std::vector resume_data = write_resume_data_buf(ra->params); TORRENT_UNUSED(test_deprecated); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (test_deprecated) { p.resume_data = resume_data; @@ -287,7 +287,7 @@ void test_piece_priorities(bool test_deprecated = false) } // anonymous namespace -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(piece_priorities_deprecated) { test_piece_priorities(true); @@ -432,7 +432,7 @@ TORRENT_TEST(piece_slots_seed_suggest_cache) // TODO: generally save -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(file_priorities_default_deprecated) { lt::session ses(settings()); @@ -866,7 +866,7 @@ void test_zero_file_prio(bool test_deprecated = false) std::vector resume_data; bencode(back_inserter(resume_data), rd); TORRENT_UNUSED(test_deprecated); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (test_deprecated) { p.resume_data = resume_data; @@ -889,7 +889,7 @@ void test_zero_file_prio(bool test_deprecated = false) } // anonymous namespace -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(zero_file_prio_deprecated) { test_zero_file_prio(true); @@ -954,7 +954,7 @@ namespace test_mode { constexpr test_mode_t pieces_have = 1_bit; constexpr test_mode_t piece_prio = 2_bit; constexpr test_mode_t all_files_zero = 3_bit; -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 constexpr test_mode_t deprecated = 4_bit; #endif } @@ -1009,7 +1009,7 @@ void test_seed_mode(test_mode_t const flags) std::vector resume_data; bencode(back_inserter(resume_data), rd); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (flags & test_mode::deprecated) { p.resume_data = resume_data; @@ -1041,7 +1041,7 @@ void test_seed_mode(test_mode_t const flags) } // anonymous namespace -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(seed_mode_file_prio_deprecated) { test_seed_mode(test_mode::file_prio | test_mode::deprecated); diff --git a/test/test_session.cpp b/test/test_session.cpp index e771eac93..63bcc2eb3 100644 --- a/test/test_session.cpp +++ b/test/test_session.cpp @@ -251,7 +251,7 @@ TORRENT_TEST(get_cache_info) s.get_cache_info(&ret); TEST_CHECK(ret.pieces.empty()); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_EQUAL(ret.blocks_written, 0); TEST_EQUAL(ret.writes, 0); TEST_EQUAL(ret.blocks_read, 0); diff --git a/test/test_settings_pack.cpp b/test/test_settings_pack.cpp index 4a9672eb3..9a6728c07 100644 --- a/test/test_settings_pack.cpp +++ b/test/test_settings_pack.cpp @@ -120,12 +120,12 @@ TORRENT_TEST(test_name) TEST_EQUAL(setting_by_name(#n), settings_pack:: n) \ TEST_EQUAL(name_for_setting(settings_pack:: n), std::string(#n)) -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_NAME(contiguous_recv_buffer); #endif TEST_NAME(choking_algorithm); TEST_NAME(seeding_piece_quota); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_NAME(half_open_limit); TEST_NAME(mmap_cache); #endif diff --git a/test/test_storage.cpp b/test/test_storage.cpp index c6d09be86..df15d7995 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -739,7 +739,7 @@ void test_fastresume(bool const test_deprecated) add_torrent_params p; TORRENT_UNUSED(test_deprecated); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (test_deprecated) { p.resume_data = resume_data; @@ -777,7 +777,7 @@ TORRENT_TEST(fastresume) test_fastresume(false); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(fastresume_deprecated) { test_fastresume(true); @@ -925,7 +925,7 @@ void test_rename_file_fastresume(bool test_deprecated) std::vector resume_data; bencode(std::back_inserter(resume_data), resume_ent); TORRENT_UNUSED(test_deprecated); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 if (test_deprecated) { p.resume_data = resume_data; @@ -976,7 +976,7 @@ TORRENT_TEST(rename_file_fastresume) test_rename_file_fastresume(false); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(rename_file_fastresume_deprecated) { test_rename_file_fastresume(true); diff --git a/test/test_string.cpp b/test/test_string.cpp index af1ca7ad7..73fc47d00 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -338,7 +338,7 @@ TORRENT_TEST(path) convert_path_to_posix(path); TEST_EQUAL(path, "a/b/c"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 // resolve_file_url #ifdef TORRENT_WINDOWS diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 7c1fa9547..83c7c1409 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -426,7 +426,7 @@ TORRENT_TEST(rename_file) TEST_EQUAL(info->files().file_path(file_index_t(0)), "tmp1"); } -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(async_load_deprecated) { settings_pack pack = settings(); @@ -455,7 +455,7 @@ TORRENT_TEST(async_load_deprecated) TORRENT_TEST(torrent_status) { TEST_EQUAL(static_cast(torrent_status::error_file_none), -1); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_EQUAL(static_cast(torrent_status::error_file_url), -2); TEST_EQUAL(static_cast(torrent_status::error_file_metadata), -4); #endif diff --git a/test/test_torrent_info.cpp b/test/test_torrent_info.cpp index e0ca12081..ae9a54736 100644 --- a/test/test_torrent_info.cpp +++ b/test/test_torrent_info.cpp @@ -746,7 +746,7 @@ TORRENT_TEST(parse_torrents) { TEST_EQUAL(ti->web_seeds().size(), 1); TEST_EQUAL(ti->web_seeds()[0].url, "http://test.com/file"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_EQUAL(ti->http_seeds().size(), 0); TEST_EQUAL(ti->url_seeds().size(), 1); TEST_EQUAL(ti->url_seeds()[0], "http://test.com/file"); @@ -756,7 +756,7 @@ TORRENT_TEST(parse_torrents) { TEST_EQUAL(ti->web_seeds().size(), 1); TEST_EQUAL(ti->web_seeds()[0].url, "http://test.com/file/"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_EQUAL(ti->http_seeds().size(), 0); TEST_EQUAL(ti->url_seeds().size(), 1); TEST_EQUAL(ti->url_seeds()[0], "http://test.com/file/"); @@ -767,7 +767,7 @@ TORRENT_TEST(parse_torrents) { TEST_EQUAL(ti->web_seeds().size(), 1); TEST_EQUAL(ti->web_seeds()[0].url, "http://test.com/test%20file/foo%20bar/"); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TEST_EQUAL(ti->http_seeds().size(), 0); TEST_EQUAL(ti->url_seeds().size(), 1); TEST_EQUAL(ti->url_seeds()[0], "http://test.com/test%20file/foo%20bar/"); diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index f39a2624e..22b2c1dfd 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -162,7 +162,7 @@ void test_transfer(int proxy_type, settings_pack const& sett pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_dht, false); -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif @@ -390,7 +390,7 @@ void cleanup() } // anonymous namespace -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(no_contiguous_buffers) { using namespace lt; diff --git a/test/test_utp.cpp b/test/test_utp.cpp index 75b524142..ddabdbd1f 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -64,7 +64,7 @@ void test_transfer() auto const mask = ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/test/test_web_seed_redirect.cpp b/test/test_web_seed_redirect.cpp index b13d5d993..defb811cb 100644 --- a/test/test_web_seed_redirect.cpp +++ b/test/test_web_seed_redirect.cpp @@ -90,7 +90,7 @@ TORRENT_TEST(web_seed_redirect) { auto const mask = ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/test/web_seed_suite.cpp b/test/web_seed_suite.cpp index 79f834b75..d45ef4192 100644 --- a/test/web_seed_suite.cpp +++ b/test/web_seed_suite.cpp @@ -394,7 +394,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed auto const mask = alert::all_categories & ~( alert::performance_warning -#ifndef TORRENT_NO_DEPRECATE +#if TORRENT_ABI_VERSION == 1 | alert::progress_notification #endif | alert::stats_notification); diff --git a/tools/gen_fwd.py b/tools/gen_fwd.py index 671ad8c53..d6ec6a093 100644 --- a/tools/gen_fwd.py +++ b/tools/gen_fwd.py @@ -38,6 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_FWD_HPP #define TORRENT_FWD_HPP +#include "libtorrent/config.hpp" + namespace libtorrent { ''' @@ -50,56 +52,78 @@ namespace lt = libtorrent; #endif // TORRENT_FWD_HPP ''' -classes = os.popen('git grep TORRENT_EXPORT').read().split('\n') +classes = os.popen('git grep "\(TORRENT_EXPORT\|TORRENT_DEPRECATED_EXPORT\|^TORRENT_[A-Z0-9]\+_NAMESPACE\)"').read().split('\n') -deprecated_classes = os.popen('git grep TORRENT_DEPRECATED_EXPORT').read().split('\n') - -def filter_classes(classes, keyword): +def print_classes(out, classes, keyword): current_file = '' ret = '' dht_ret = '' - for c in classes: - line = c.split(':', 1) - if not line[0].endswith('.hpp'): continue - # ignore the forward header itself, that's the one we're generating - if line[0].endswith('/fwd.hpp'): continue - # don't provide forward declarations of internal types - if '/aux_/' in line[0]: continue - this_file = line[0].strip() - decl = ':'.join(line[1:]).strip().split(' ') - if decl[0].strip() not in ['struct', 'class']: continue - # TODO: support TORRENT_DEPRECATED_EXPORT - if decl[1].strip() != keyword: continue + # [(file, decl), ...] + classes = [(l.split(':')[0].strip(), ':'.join(l.split(':')[1:]).strip()) for l in classes] + + # we only care about header files + # ignore the forward header itself, that's the one we're generating + # also ignore any header in the aux_ directory, those are private + classes = [l for l in classes if l[0].endswith('.hpp') and not l[0].endswith('/fwd.hpp') and '/aux_/' not in l[0]] + + namespaces = ['TORRENT_VERSION_NAMESPACE_2', 'TORRENT_IPV6_NAMESPACE', + 'TORRENT_VERSION_NAMESPACE_2_END', 'TORRENT_IPV6_NAMESPACE_END'] + + # only include classes with the right kind of export + classes = [l for l in classes if l[1] in namespaces or (l[1].split(' ')[0] in ['class', 'struct'] and l[1].split(' ')[1] == keyword)] + + # collapse empty namespaces + classes2 = [] + skip = 0 + for i in xrange(len(classes)): + if skip > 0: + skip -= 1 + continue + if classes[i][1] in namespaces \ + and len(classes) > i+1 \ + and classes[i+1][1] == ('%s_END' % classes[i][1]): + skip = 1 + else: + classes2.append(classes[i]) + + classes = classes2 + + idx = -1 + for line in classes: + idx += 1 + this_file = line[0] + decl = line[1].split(' ') content = '' if this_file != current_file: - content += '\n// ' + this_file + '\n' + out.write('\n// ' + this_file + '\n') current_file = this_file; - decl = decl[0] + ' ' + decl[2] - if not decl.endswith(';'): decl += ';' - content += decl + '\n' - if 'kademlia' in this_file: - dht_ret += content + if len(decl) > 2 and decl[0] in ['struct', 'class']: + decl = decl[0] + ' ' + decl[2] + if not decl.endswith(';'): decl += ';' + content = decl + '\n' else: - ret += content + content = line[1] + '\n' - if dht_ret == '': - return ret - else: - return ret + '\nnamespace dht {\n' + dht_ret + '\n}\n' + if 'kademlia' in this_file: + out.write('namespace dht {\n') + out.write(content) + out.write('}\n') + else: + out.write(content) os.remove('include/libtorrent/fwd.hpp') with open('include/libtorrent/fwd.hpp', 'w+') as f: f.write(file_header) - f.write(filter_classes(classes, 'TORRENT_EXPORT')); + print_classes(f, classes, 'TORRENT_EXPORT'); - f.write('\n#ifndef TORRENT_NO_DEPRECATE\n') + f.write('\n#if TORRENT_ABI_VERSION == 1\n') - f.write(filter_classes(deprecated_classes, 'TORRENT_DEPRECATED_EXPORT')); + print_classes(f, classes, 'TORRENT_DEPRECATED_EXPORT'); - f.write('\n#endif // TORRENT_NO_DEPRECATE') + f.write('\n#endif // TORRENT_ABI_VERSION') f.write(file_footer)