Skip to content

Commit

Permalink
deprecate torrent_alert::torrent_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jan 30, 2025
1 parent 979d478 commit f93da4e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2.1.0 not released

* deprecate torrent_alert::torrent_name()
* requires OpenSSL minimum version 1.1.0 with SNI support
* try harder to bind TCP and UDP sockets to the same port
* made disk_interface's status_t type a flags type
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ void bind_alert()
class_<torrent_alert, bases<alert>, noncopyable>(
"torrent_alert", no_init)
.add_property("handle", make_getter(&torrent_alert::handle, by_value()))
#if TORRENT_ABI_VERSION < 4
.add_property("torrent_name", &torrent_alert::torrent_name)
#endif
;

class_<tracker_alert, bases<torrent_alert>, noncopyable>(
Expand Down
8 changes: 8 additions & 0 deletions docs/upgrade_to_1.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ libtorrent session plugins no longer have all callbacks called unconditionally.
The plugin has to register which callbacks it's interested in receiving by returning a bitmask from ``feature_flags_t implemented_features()``.
The return value is documented in the plugin class.

torrent_alert deprecation
=========================

torrent_alert::torrent_name() was deprecated. When ABI version < 4 (controlled
by the ``deprecated-functions`` feature in the Jamfile), the ABI of
torrent_alert is changed. The name of the torrent is no longer allocated and
copied into every alert deriving from torrent_alert.

RSS functions removed
=====================

Expand Down
10 changes: 7 additions & 3 deletions include/libtorrent/alert_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace libtorrent {
int last_active;
};

TORRENT_VERSION_NAMESPACE_3
TORRENT_VERSION_NAMESPACE_4

// This is a base class for alerts that are associated with a
// specific torrent. It contains a handle to the torrent.
Expand All @@ -127,12 +127,16 @@ TORRENT_VERSION_NAMESPACE_3
// alert is associated with.
torrent_handle handle;

char const* torrent_name() const;
#if TORRENT_ABI_VERSION < 4
TORRENT_DEPRECATED char const* torrent_name() const;
#endif

protected:
std::reference_wrapper<aux::stack_allocator const> m_alloc;
private:
#if TORRENT_ABI_VERSION < 4
aux::allocation_slot m_name_idx;
#endif
#if TORRENT_ABI_VERSION == 1
public:
TORRENT_DEPRECATED std::string name;
Expand Down Expand Up @@ -2952,7 +2956,7 @@ TORRENT_VERSION_NAMESPACE_3
operation_t op;
};

TORRENT_VERSION_NAMESPACE_3_END
TORRENT_VERSION_NAMESPACE_4_END

// this alert may be posted when the initial checking of resume data and files
// on disk (just existence, not piece hashes) completes. If a file belonging
Expand Down
8 changes: 4 additions & 4 deletions include/libtorrent/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct alert;

// include/libtorrent/alert_types.hpp
struct dht_routing_bucket;
TORRENT_VERSION_NAMESPACE_3
TORRENT_VERSION_NAMESPACE_4
struct torrent_alert;
struct peer_alert;
struct tracker_alert;
Expand Down Expand Up @@ -119,7 +119,7 @@ struct block_uploaded_alert;
struct alerts_dropped_alert;
struct socks5_alert;
struct file_prio_alert;
TORRENT_VERSION_NAMESPACE_3_END
TORRENT_VERSION_NAMESPACE_4_END
struct oversized_file_alert;
struct torrent_conflict_alert;
struct peer_info_alert;
Expand Down Expand Up @@ -276,12 +276,12 @@ struct web_seed_entry;
#if TORRENT_ABI_VERSION <= 2

// include/libtorrent/alert_types.hpp
TORRENT_VERSION_NAMESPACE_3
TORRENT_VERSION_NAMESPACE_4
struct torrent_added_alert;
struct stats_alert;
struct anonymous_mode_alert;
struct mmap_cache_alert;
TORRENT_VERSION_NAMESPACE_3_END
TORRENT_VERSION_NAMESPACE_4_END

// include/libtorrent/file_storage.hpp
struct file_entry;
Expand Down
4 changes: 4 additions & 0 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace libtorrent {
: handle(h)
, m_alloc(alloc)
{
#if TORRENT_ABI_VERSION < 4
auto t = h.native_handle();
if (t)
{
Expand All @@ -78,16 +79,19 @@ namespace libtorrent {
{
m_name_idx = alloc.copy_string("");
}
#endif

#if TORRENT_ABI_VERSION == 1
name = m_alloc.get().ptr(m_name_idx);
#endif
}

#if TORRENT_ABI_VERSION < 4
char const* torrent_alert::torrent_name() const
{
return m_alloc.get().ptr(m_name_idx);
}
#endif

std::string torrent_alert::message() const
{
Expand Down

0 comments on commit f93da4e

Please sign in to comment.