add a few missing alerts to the python bindings

This commit is contained in:
arvidn 2019-04-27 09:48:23 +02:00 committed by Arvid Norberg
parent b21eebbad7
commit 0cf2924230
2 changed files with 42 additions and 4 deletions

View File

@ -1,3 +1,4 @@
* add dht_pkt_alert and alerts_dropped_alert to python bindings
* fix python bindins for block_uploaded_alert * fix python bindins for block_uploaded_alert
* optimize resolving duplicate filenames in loading torrent files * optimize resolving duplicate filenames in loading torrent files
* fix python binding of dht_settings * fix python binding of dht_settings

View File

@ -200,6 +200,9 @@ namespace boost
POLY(state_changed_alert) POLY(state_changed_alert)
POLY(state_update_alert) POLY(state_update_alert)
POLY(i2p_alert) POLY(i2p_alert)
POLY(dht_immutable_item_alert)
POLY(dht_mutable_item_alert)
POLY(dht_put_alert)
POLY(dht_reply_alert) POLY(dht_reply_alert)
POLY(dht_announce_alert) POLY(dht_announce_alert)
POLY(dht_get_peers_alert) POLY(dht_get_peers_alert)
@ -221,12 +224,18 @@ namespace boost
POLY(dht_outgoing_get_peers_alert) POLY(dht_outgoing_get_peers_alert)
POLY(lsd_error_alert) POLY(lsd_error_alert)
POLY(dht_stats_alert) POLY(dht_stats_alert)
POLY(dht_immutable_item_alert) POLY(incoming_request_alert)
POLY(dht_mutable_item_alert) POLY(dht_log_alert)
POLY(dht_put_alert) POLY(dht_pkt_alert)
POLY(session_stats_alert)
POLY(dht_get_peers_reply_alert) POLY(dht_get_peers_reply_alert)
POLY(dht_direct_response_alert)
POLY(session_error_alert)
POLY(dht_live_nodes_alert)
POLY(session_stats_header_alert)
POLY(dht_sample_infohashes_alert)
POLY(block_uploaded_alert) POLY(block_uploaded_alert)
POLY(alerts_dropped_alert)
POLY(session_stats_alert)
#if TORRENT_ABI_VERSION == 1 #if TORRENT_ABI_VERSION == 1
POLY(anonymous_mode_alert) POLY(anonymous_mode_alert)
@ -247,6 +256,19 @@ namespace boost
struct dummy3 {}; struct dummy3 {};
bytes get_pkt_buf(dht_pkt_alert const& alert)
{
return {alert.pkt_buf().data(), static_cast<std::size_t>(alert.pkt_buf().size())};
}
list get_dropped_alerts(alerts_dropped_alert const& alert)
{
list ret;
for (int i = 0; i < int(alert.dropped_alerts.size()); ++i)
ret.append(bool(alert.dropped_alerts[i]));
return ret;
}
void bind_alert() void bind_alert()
{ {
using boost::noncopyable; using boost::noncopyable;
@ -942,6 +964,16 @@ void bind_alert()
.add_property("routing_table", &dht_stats_routing_table) .add_property("routing_table", &dht_stats_routing_table)
; ;
class_<dht_log_alert, bases<alert>, noncopyable>("dht_log_alert", no_init)
.def_readonly("module", &dht_log_alert::module)
.def("log_message", &dht_log_alert::log_message)
;
class_<dht_pkt_alert, bases<alert>, noncopyable>(
"dht_pkt_alert", no_init)
.add_property("pkt_buf", &get_pkt_buf)
;
class_<dht_immutable_item_alert, bases<alert>, noncopyable>( class_<dht_immutable_item_alert, bases<alert>, noncopyable>(
"dht_immutable_item_alert", no_init) "dht_immutable_item_alert", no_init)
.def_readonly("target", &dht_immutable_item_alert::target) .def_readonly("target", &dht_immutable_item_alert::target)
@ -992,6 +1024,11 @@ void bind_alert()
.add_property("piece_index", make_getter((&block_uploaded_alert::piece_index), by_value())) .add_property("piece_index", make_getter((&block_uploaded_alert::piece_index), by_value()))
; ;
class_<alerts_dropped_alert, bases<alert>, noncopyable>(
"alerts_dropped_alert", no_init)
.add_property("dropped_alerts", &get_dropped_alerts)
;
} }
#ifdef _MSC_VER #ifdef _MSC_VER