forked from premiere/premiere-libtorrent
deprecate torrent_added_alert in favor of add_torrent_alert
This commit is contained in:
parent
9ea9075b2a
commit
910ccc528f
|
@ -1,3 +1,4 @@
|
|||
* deprecate torrent_added_alert (in favor of add_torrent_alert)
|
||||
* fix python binding for parse_magnet_uri
|
||||
* fix minor robustness issue in DHT bootstrap logic
|
||||
* fix issue where torrent_status::num_seeds could be negative
|
||||
|
|
|
@ -243,9 +243,11 @@ void bind_alert()
|
|||
.def("tracker_url", &tracker_alert::tracker_url)
|
||||
;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
class_<torrent_added_alert, bases<torrent_alert>, noncopyable>(
|
||||
"torrent_added_alert", no_init)
|
||||
;
|
||||
#endif
|
||||
|
||||
class_<torrent_removed_alert, bases<torrent_alert>, noncopyable>(
|
||||
"torrent_removed_alert", no_init)
|
||||
|
|
|
@ -195,11 +195,14 @@ namespace libtorrent
|
|||
#define TORRENT_DEFINE_ALERT_PRIO(name, seq) \
|
||||
TORRENT_DEFINE_ALERT_IMPL(name, seq, 1)
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
// 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.
|
||||
// It's posted when the ``status_notification`` bit is set in the alert_mask.
|
||||
struct TORRENT_EXPORT torrent_added_alert TORRENT_FINAL : torrent_alert
|
||||
// deprecated in 1.1.3
|
||||
// use add_torrent_alert instead
|
||||
struct TORRENT_DEPRECATED_EXPORT torrent_added_alert TORRENT_FINAL : torrent_alert
|
||||
{
|
||||
// internal
|
||||
torrent_added_alert(aux::stack_allocator& alloc, torrent_handle const& h);
|
||||
|
@ -208,6 +211,7 @@ namespace libtorrent
|
|||
static const int static_category = alert::status_notification;
|
||||
virtual std::string message() const TORRENT_OVERRIDE;
|
||||
};
|
||||
#endif
|
||||
|
||||
// The ``torrent_removed_alert`` is posted whenever a torrent is removed. Since
|
||||
// the torrent handle in its base class will always be invalid (since the torrent
|
||||
|
|
|
@ -195,7 +195,7 @@ void test_stop_start_download(swarm_test type, bool graceful)
|
|||
// on alert
|
||||
, [&](lt::alert const* a, lt::session& ses) {
|
||||
|
||||
if (lt::alert_cast<lt::torrent_added_alert>(a))
|
||||
if (lt::alert_cast<lt::add_torrent_alert>(a))
|
||||
add_extra_peers(ses);
|
||||
|
||||
if (auto tp = lt::alert_cast<lt::torrent_paused_alert>(a))
|
||||
|
|
|
@ -54,7 +54,7 @@ TORRENT_TEST(status_timers)
|
|||
, [](lt::add_torrent_params& params) {}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session& ses) {
|
||||
if (auto ta = alert_cast<torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<add_torrent_alert>(a))
|
||||
{
|
||||
TEST_CHECK(!handle.is_valid());
|
||||
start_time = lt::clock_type::now();
|
||||
|
|
|
@ -110,7 +110,7 @@ void run_test(
|
|||
|
||||
// only monitor alerts for session 0 (the downloader)
|
||||
print_alerts(*ses[0], [=](lt::session& ses, lt::alert const* a) {
|
||||
if (auto ta = alert_cast<lt::torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<lt::add_torrent_alert>(a))
|
||||
{
|
||||
ta->handle.connect_peer(lt::tcp::endpoint(
|
||||
(flags & connect_socks) ? proxy : peer1, 6881));
|
||||
|
|
|
@ -1202,6 +1202,7 @@ namespace libtorrent {
|
|||
return m_alloc.ptr(m_file_idx);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
torrent_added_alert::torrent_added_alert(aux::stack_allocator& alloc
|
||||
, torrent_handle const& h)
|
||||
: torrent_alert(alloc, h)
|
||||
|
@ -1211,6 +1212,7 @@ namespace libtorrent {
|
|||
{
|
||||
return torrent_alert::message() + " added";
|
||||
}
|
||||
#endif
|
||||
|
||||
torrent_removed_alert::torrent_removed_alert(aux::stack_allocator& alloc
|
||||
, torrent_handle const& h, sha1_hash const& ih)
|
||||
|
|
|
@ -4856,8 +4856,10 @@ retry:
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (m_alerts.should_post<torrent_added_alert>())
|
||||
m_alerts.emplace_alert<torrent_added_alert>(handle);
|
||||
#endif
|
||||
|
||||
// if this was an existing torrent, we can't start it again, or add
|
||||
// another set of plugins etc. we're done
|
||||
|
|
|
@ -54,7 +54,7 @@ TORRENT_TEST(limit)
|
|||
// try add 600 torrent_add_alert to make sure we honor the limit of 500
|
||||
// alerts.
|
||||
for (int i = 0; i < 600; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -71,7 +71,7 @@ TORRENT_TEST(limit)
|
|||
mgr.set_alert_queue_size_limit(200);
|
||||
|
||||
for (int i = 0; i < 600; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -89,7 +89,7 @@ TORRENT_TEST(priority_limit)
|
|||
|
||||
// this should only add 100 because of the limit
|
||||
for (int i = 0; i < 200; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
// the limit is twice as high for priority alerts
|
||||
for (int i = 0; i < 200; ++i)
|
||||
|
@ -119,7 +119,7 @@ TORRENT_TEST(dispatch_function)
|
|||
TEST_EQUAL(mgr.pending(), false);
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -130,7 +130,7 @@ TORRENT_TEST(dispatch_function)
|
|||
TEST_EQUAL(cnt, 20);
|
||||
|
||||
for (int i = 0; i < 200; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), false);
|
||||
TEST_EQUAL(cnt, 220);
|
||||
|
@ -151,7 +151,7 @@ TORRENT_TEST(notify_function)
|
|||
TEST_EQUAL(mgr.pending(), false);
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -165,7 +165,7 @@ TORRENT_TEST(notify_function)
|
|||
// subsequent posted alerts will not cause an edge (because there are
|
||||
// already alerts queued)
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
TEST_EQUAL(cnt, 1);
|
||||
|
@ -179,7 +179,7 @@ TORRENT_TEST(notify_function)
|
|||
TEST_EQUAL(mgr.pending(), false);
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
TEST_EQUAL(cnt, 2);
|
||||
|
@ -211,14 +211,14 @@ TORRENT_TEST(extensions)
|
|||
mgr.add_extension(boost::make_shared<test_plugin>(2));
|
||||
|
||||
for (int i = 0; i < 53; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(plugin_alerts[0], 53);
|
||||
TEST_EQUAL(plugin_alerts[1], 53);
|
||||
TEST_EQUAL(plugin_alerts[2], 53);
|
||||
|
||||
for (int i = 0; i < 17; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(plugin_alerts[0], 70);
|
||||
TEST_EQUAL(plugin_alerts[1], 70);
|
||||
|
@ -229,7 +229,7 @@ TORRENT_TEST(extensions)
|
|||
void post_torrent_added(alert_manager* mgr)
|
||||
{
|
||||
test_sleep(10);
|
||||
mgr->emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr->emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
}
|
||||
|
||||
TORRENT_TEST(wait_for_alert)
|
||||
|
@ -247,7 +247,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
TEST_CHECK(end - start > milliseconds(900));
|
||||
TEST_CHECK(end - start < milliseconds(1100));
|
||||
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
start = clock_type::now();
|
||||
a = mgr.wait_for_alert(seconds(1));
|
||||
|
@ -255,7 +255,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
|
||||
fprintf(stderr, "delay: %d ms\n", int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start < milliseconds(1));
|
||||
TEST_CHECK(a->type() == torrent_added_alert::alert_type);
|
||||
TEST_CHECK(a->type() == add_torrent_alert::alert_type);
|
||||
|
||||
std::vector<alert*> alerts;
|
||||
int num_resume = 0;
|
||||
|
@ -269,7 +269,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
|
||||
fprintf(stderr, "delay: %d ms\n", int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start < milliseconds(500));
|
||||
TEST_CHECK(a->type() == torrent_added_alert::alert_type);
|
||||
TEST_CHECK(a->type() == add_torrent_alert::alert_type);
|
||||
|
||||
posting_thread.join();
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ TORRENT_TEST(queued_resume)
|
|||
TEST_EQUAL(mgr.num_queued_resume(), 0);
|
||||
|
||||
for (int i = 0; i < 17; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.num_queued_resume(), 0);
|
||||
|
||||
|
@ -312,12 +312,12 @@ TORRENT_TEST(alert_mask)
|
|||
{
|
||||
alert_manager mgr(100, 0xffffffff);
|
||||
|
||||
TEST_CHECK(mgr.should_post<torrent_added_alert>());
|
||||
TEST_CHECK(mgr.should_post<add_torrent_alert>());
|
||||
TEST_CHECK(mgr.should_post<torrent_paused_alert>());
|
||||
|
||||
mgr.set_alert_mask(0);
|
||||
|
||||
TEST_CHECK(!mgr.should_post<torrent_added_alert>());
|
||||
TEST_CHECK(!mgr.should_post<add_torrent_alert>());
|
||||
TEST_CHECK(!mgr.should_post<torrent_paused_alert>());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue