From ee38106465b3cf93e387d67cc610c0f85d863aaa Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 3 Mar 2020 10:01:50 +0100 Subject: [PATCH] restore in-class flag types, for backwards compatibility with libtorrent-1.1 --- include/libtorrent/alert.hpp | 2 ++ include/libtorrent/create_torrent.hpp | 5 ++++- include/libtorrent/extensions.hpp | 12 ++++++++---- include/libtorrent/file_storage.hpp | 1 + include/libtorrent/peer_info.hpp | 5 +++++ include/libtorrent/session_handle.hpp | 5 +++++ include/libtorrent/torrent_handle.hpp | 9 +++++++++ 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 98ccbcde9..5fe9e8c79 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -94,6 +94,8 @@ namespace libtorrent { #if TORRENT_ABI_VERSION == 1 // only here for backwards compatibility enum TORRENT_DEPRECATED_ENUM severity_t { debug, info, warning, critical, fatal, none }; + + using category_t = alert_category_t; #endif // Enables alerts that report an error. This includes: diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 923e75dee..527250816 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -101,6 +101,9 @@ namespace libtorrent { // .torrent file using bencode(). struct TORRENT_EXPORT create_torrent { +#if TORRENT_ABI_VERSION == 1 + using flags_t = create_flags_t; +#endif // This will insert pad files to align the files to piece boundaries, for // optimized disk-I/O. This will minimize the number of bytes of pad- // files, to keep the impact down for clients that don't support @@ -160,7 +163,7 @@ namespace libtorrent { // have any affect. // // The ``flags`` arguments specifies options for the torrent creation. It can - // be any combination of the flags defined by create_torrent::flags_t. + // be any combination of the flags defined by create_flags_t. // // ``alignment`` is used when pad files are enabled. This is the size // eligible files are aligned to. The default is -1, which means the diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index cea5f8c96..1e52b8458 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -188,6 +188,10 @@ namespace libtorrent { // hidden virtual ~plugin() {} +#if TORRENT_ABI_VERSION == 1 + using feature_flags_t = libtorrent::feature_flags_t; +#endif + // include this bit if your plugin needs to alter the order of the // optimistic unchoke of peers. i.e. have the on_optimistic_unchoke() // callback be called. @@ -277,6 +281,10 @@ namespace libtorrent { // hidden virtual ~torrent_plugin() {} +#if TORRENT_ABI_VERSION == 1 + using flags_t = libtorrent::add_peer_flags_t; +#endif + // This function is called each time a new peer is connected to the torrent. You // may choose to ignore this by just returning a default constructed // ``shared_ptr`` (in which case you don't need to override this member @@ -332,10 +340,6 @@ namespace libtorrent { // enum members virtual void on_state(torrent_status::state_t) {} - // called every time policy::add_peer is called - // src is a bitmask of which sources this peer - // has been seen from. flags is a bitmask of: - // this is the first time we see this peer static constexpr add_peer_flags_t first_time = 1_bit; diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index c2b0cb202..70f73c897 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -229,6 +229,7 @@ namespace libtorrent { bool is_valid() const { return m_piece_length > 0; } #if TORRENT_ABI_VERSION == 1 + using flags_t = file_flags_t; 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; diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index 0ce2c8c67..b5327a142 100644 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -90,6 +90,11 @@ TORRENT_VERSION_NAMESPACE_2 // the time until all blocks in the request queue will be downloaded time_duration download_queue_time; +#if TORRENT_ABI_VERSION == 1 + using peer_flags_t = libtorrent::peer_flags_t; + using peer_source_flags = libtorrent::peer_source_flags_t; +#endif + // **we** are interested in pieces from this peer. static constexpr peer_flags_t interesting = 0_bit; diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 2003c9687..52b7be801 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -83,6 +83,11 @@ namespace libtorrent { session_handle& operator=(session_handle const&) = default; session_handle& operator=(session_handle&&) noexcept = default; +#if TORRENT_ABI_VERSION == 1 + using save_state_flags_t = libtorrent::save_state_flags_t; + using session_flags_t = libtorrent::session_flags_t; +#endif + // returns true if this handle refers to a valid session object. If the // session has been destroyed, all session_handle objects will expire and // not be valid. diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index acc642282..b3070023a 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -254,6 +254,15 @@ namespace aux { torrent_handle& operator=(torrent_handle const&) = default; torrent_handle& operator=(torrent_handle&&) noexcept = default; + +#if TORRENT_ABI_VERSION == 1 + using flags_t = add_piece_flags_t; + using status_flags_t = libtorrent::status_flags_t; + using pause_flags_t = libtorrent::pause_flags_t; + using save_resume_flags_t = libtorrent::resume_data_flags_t; + using reannounce_flags_t = libtorrent::reannounce_flags_t; +#endif + // instruct libtorrent to overwrite any data that may already have been // downloaded with the data of the new piece being added. static constexpr add_piece_flags_t overwrite_existing = 0_bit;