fixes bug where priorities where lost when force-rechecking.
[libtorrent.git] / bindings / python / src / alert.cpp
blobfe34c6c273d29357bdcb851b2939e81aa93585c4
1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #include <libtorrent/alert.hpp>
6 #include <libtorrent/alert_types.hpp>
7 #include <boost/python.hpp>
9 using namespace boost::python;
10 using namespace libtorrent;
12 extern char const* alert_doc;
13 extern char const* alert_msg_doc;
14 extern char const* alert_severity_doc;
15 extern char const* torrent_alert_doc;
16 extern char const* tracker_alert_doc;
17 extern char const* tracker_error_alert_doc;
18 extern char const* tracker_warning_alert_doc;
19 extern char const* tracker_reply_alert_doc;
20 extern char const* tracker_announce_alert_doc;
21 extern char const* hash_failed_alert_doc;
22 extern char const* peer_ban_alert_doc;
23 extern char const* peer_error_alert_doc;
24 extern char const* invalid_request_alert_doc;
25 extern char const* peer_request_doc;
26 extern char const* torrent_finished_alert_doc;
27 extern char const* piece_finished_alert_doc;
28 extern char const* block_finished_alert_doc;
29 extern char const* block_downloading_alert_doc;
30 extern char const* storage_moved_alert_doc;
31 extern char const* torrent_deleted_alert_doc;
32 extern char const* torrent_paused_alert_doc;
33 extern char const* torrent_checked_alert_doc;
34 extern char const* url_seed_alert_doc;
35 extern char const* file_error_alert_doc;
36 extern char const* metadata_failed_alert_doc;
37 extern char const* metadata_received_alert_doc;
38 extern char const* listen_failed_alert_doc;
39 extern char const* listen_succeeded_alert_doc;
40 extern char const* portmap_error_alert_doc;
41 extern char const* portmap_alert_doc;
42 extern char const* fastresume_rejected_alert_doc;
43 extern char const* peer_blocked_alert_doc;
44 extern char const* scrape_reply_alert_doc;
45 extern char const* scrape_failed_alert_doc;
46 extern char const* udp_error_alert_doc;
47 extern char const* external_ip_alert_doc;
48 extern char const* save_resume_data_alert_doc;
50 void bind_alert()
52 using boost::noncopyable;
55 scope alert_scope = class_<alert, noncopyable>("alert", alert_doc, no_init)
56 .def("message", &alert::message, alert_msg_doc)
57 .def("what", &alert::what)
58 .def("category", &alert::category)
59 .def("severity", &alert::severity, alert_severity_doc)
60 .def("__str__", &alert::message, alert_msg_doc)
63 enum_<alert::severity_t>("severity_levels")
64 .value("debug", alert::debug)
65 .value("info", alert::info)
66 .value("warning", alert::warning)
67 .value("critical", alert::critical)
68 .value("fatal", alert::fatal)
69 .value("none", alert::none)
72 enum_<alert::category_t>("category_t")
73 .value("error_notification", alert::error_notification)
74 .value("peer_notification", alert::peer_notification)
75 .value("port_mapping_notification", alert::port_mapping_notification)
76 .value("storage_notification", alert::storage_notification)
77 .value("tracker_notification", alert::tracker_notification)
78 .value("debug_notification", alert::debug_notification)
79 .value("status_notification", alert::status_notification)
80 .value("progress_notification", alert::progress_notification)
81 .value("ip_block_notification", alert::ip_block_notification)
82 .value("all_categories", alert::all_categories)
86 class_<torrent_alert, bases<alert>, noncopyable>(
87 "torrent_alert", torrent_alert_doc, no_init
89 .def_readonly("handle", &torrent_alert::handle)
92 class_<tracker_alert, bases<torrent_alert>, noncopyable>(
93 "tracker_alert", tracker_alert_doc, no_init
95 .def_readonly("url", &tracker_alert::url)
98 class_<peer_alert, bases<torrent_alert>, noncopyable>(
99 "peer_alert", no_init
101 .def_readonly("ip", &peer_alert::ip)
102 .def_readonly("pid", &peer_alert::pid)
104 class_<tracker_error_alert, bases<tracker_alert>, noncopyable>(
105 "tracker_error_alert", tracker_error_alert_doc, no_init
107 .def_readonly("times_in_row", &tracker_error_alert::times_in_row)
108 .def_readonly("status_code", &tracker_error_alert::status_code)
111 class_<tracker_warning_alert, bases<tracker_alert>, noncopyable>(
112 "tracker_warning_alert", tracker_warning_alert_doc, no_init
115 class_<tracker_reply_alert, bases<tracker_alert>, noncopyable>(
116 "tracker_reply_alert", tracker_reply_alert_doc, no_init
118 .def_readonly("num_peers", &tracker_reply_alert::num_peers)
121 class_<tracker_announce_alert, bases<tracker_alert>, noncopyable>(
122 "tracker_announce_alert", tracker_announce_alert_doc, no_init
125 class_<hash_failed_alert, bases<torrent_alert>, noncopyable>(
126 "hash_failed_alert", hash_failed_alert_doc, no_init
128 .def_readonly("piece_index", &hash_failed_alert::piece_index)
131 class_<peer_ban_alert, bases<peer_alert>, noncopyable>(
132 "peer_ban_alert", peer_ban_alert_doc, no_init
135 class_<peer_error_alert, bases<peer_alert>, noncopyable>(
136 "peer_error_alert", peer_error_alert_doc, no_init
139 class_<invalid_request_alert, bases<peer_alert>, noncopyable>(
140 "invalid_request_alert", invalid_request_alert_doc, no_init
142 .def_readonly("request", &invalid_request_alert::request)
145 class_<peer_request>("peer_request", peer_request_doc)
146 .def_readonly("piece", &peer_request::piece)
147 .def_readonly("start", &peer_request::start)
148 .def_readonly("length", &peer_request::length)
149 .def(self == self)
152 class_<torrent_finished_alert, bases<torrent_alert>, noncopyable>(
153 "torrent_finished_alert", torrent_finished_alert_doc, no_init
156 class_<piece_finished_alert, bases<torrent_alert>, noncopyable>(
157 "piece_finished_alert", piece_finished_alert_doc, no_init
159 .def_readonly("piece_index", &piece_finished_alert::piece_index)
162 class_<block_finished_alert, bases<peer_alert>, noncopyable>(
163 "block_finished_alert", block_finished_alert_doc, no_init
165 .def_readonly("block_index", &block_finished_alert::block_index)
166 .def_readonly("piece_index", &block_finished_alert::piece_index)
169 class_<block_downloading_alert, bases<peer_alert>, noncopyable>(
170 "block_downloading_alert", block_downloading_alert_doc, no_init
172 .def_readonly("peer_speedmsg", &block_downloading_alert::peer_speedmsg)
173 .def_readonly("block_index", &block_downloading_alert::block_index)
174 .def_readonly("piece_index", &block_downloading_alert::piece_index)
177 class_<storage_moved_alert, bases<torrent_alert>, noncopyable>(
178 "storage_moved_alert", storage_moved_alert_doc, no_init
181 class_<torrent_deleted_alert, bases<torrent_alert>, noncopyable>(
182 "torrent_deleted_alert", torrent_deleted_alert_doc, no_init
185 class_<torrent_paused_alert, bases<torrent_alert>, noncopyable>(
186 "torrent_paused_alert", torrent_paused_alert_doc, no_init
189 class_<torrent_checked_alert, bases<torrent_alert>, noncopyable>(
190 "torrent_checked_alert", torrent_checked_alert_doc, no_init
193 class_<url_seed_alert, bases<torrent_alert>, noncopyable>(
194 "url_seed_alert", url_seed_alert_doc, no_init
196 .def_readonly("url", &url_seed_alert::url)
199 class_<file_error_alert, bases<torrent_alert>, noncopyable>(
200 "file_error_alert", file_error_alert_doc, no_init
202 .def_readonly("file", &file_error_alert::file)
205 class_<metadata_failed_alert, bases<torrent_alert>, noncopyable>(
206 "metadata_failed_alert", metadata_failed_alert_doc, no_init
209 class_<metadata_received_alert, bases<torrent_alert>, noncopyable>(
210 "metadata_received_alert", metadata_received_alert_doc, no_init
213 class_<listen_failed_alert, bases<alert>, noncopyable>(
214 "listen_failed_alert", listen_failed_alert_doc, no_init
217 class_<listen_succeeded_alert, bases<alert>, noncopyable>(
218 "listen_succeeded_alert", listen_succeeded_alert_doc, no_init
220 .def_readonly("endpoint", &listen_succeeded_alert::endpoint)
223 class_<portmap_error_alert, bases<alert>, noncopyable>(
224 "portmap_error_alert", portmap_error_alert_doc, no_init
226 .def_readonly("mapping", &portmap_error_alert::mapping)
227 .def_readonly("type", &portmap_error_alert::type)
230 class_<portmap_alert, bases<alert>, noncopyable>(
231 "portmap_alert", portmap_alert_doc, no_init
233 .def_readonly("mapping", &portmap_alert::mapping)
234 .def_readonly("external_port", &portmap_alert::external_port)
235 .def_readonly("type", &portmap_alert::type)
238 class_<fastresume_rejected_alert, bases<torrent_alert>, noncopyable>(
239 "fastresume_rejected_alert", fastresume_rejected_alert_doc, no_init
242 class_<peer_blocked_alert, bases<alert>, noncopyable>(
243 "peer_blocked_alert", peer_blocked_alert_doc, no_init
245 .def_readonly("ip", &peer_blocked_alert::ip)
248 class_<scrape_reply_alert, bases<tracker_alert>, noncopyable>(
249 "scrape_reply_alert", scrape_reply_alert_doc, no_init
251 .def_readonly("incomplete", &scrape_reply_alert::incomplete)
252 .def_readonly("complete", &scrape_reply_alert::complete)
255 class_<scrape_failed_alert, bases<tracker_alert>, noncopyable>(
256 "scrape_failed_alert", scrape_failed_alert_doc, no_init
259 class_<udp_error_alert, bases<alert>, noncopyable>(
260 "udp_error_alert", udp_error_alert_doc, no_init
262 .def_readonly("endpoint", &udp_error_alert::endpoint)
265 class_<external_ip_alert, bases<alert>, noncopyable>(
266 "external_ip_alert", external_ip_alert_doc, no_init
268 .def_readonly("external_address", &external_ip_alert::external_address)
271 class_<save_resume_data_alert, bases<torrent_alert>, noncopyable>(
272 "save_resume_data_alert", save_resume_data_alert_doc, no_init
274 .def_readonly("resume_data", &save_resume_data_alert::resume_data)
277 class_<file_renamed_alert, bases<torrent_alert>, noncopyable>(
278 "file_renamed_alert", no_init
280 .def_readonly("name", &file_renamed_alert::name)
283 class_<file_rename_failed_alert, bases<torrent_alert>, noncopyable>(
284 "file_rename_failed_alert", no_init
286 .def_readonly("index", &file_rename_failed_alert::index)
289 class_<torrent_resumed_alert, bases<torrent_alert>, noncopyable>(
290 "torrent_resumed_alert", no_init
293 class_<state_changed_alert, bases<torrent_alert>, noncopyable>(
294 "state_changed_alert", no_init
296 .def_readonly("state", &state_changed_alert::state)
299 class_<dht_reply_alert, bases<tracker_alert>, noncopyable>(
300 "dht_reply_alert", no_init
302 .def_readonly("num_peers", &dht_reply_alert::num_peers)
305 class_<peer_unsnubbed_alert, bases<peer_alert>, noncopyable>(
306 "peer_unsnubbed_alert", no_init
309 class_<peer_snubbed_alert, bases<peer_alert>, noncopyable>(
310 "peer_snubbed_alert", no_init
313 class_<peer_connect_alert, bases<peer_alert>, noncopyable>(
314 "peer_connect_alert", no_init
317 class_<peer_disconnected_alert, bases<peer_alert>, noncopyable>(
318 "peer_disconnected_alert", no_init
321 class_<request_dropped_alert, bases<peer_alert>, noncopyable>(
322 "request_dropped_alert", no_init
324 .def_readonly("block_index", &request_dropped_alert::block_index)
325 .def_readonly("piece_index", &request_dropped_alert::piece_index)
328 class_<block_timeout_alert, bases<peer_alert>, noncopyable>(
329 "block_timeout_alert", no_init
331 .def_readonly("block_index", &block_timeout_alert::block_index)
332 .def_readonly("piece_index", &block_timeout_alert::piece_index)
335 class_<unwanted_block_alert, bases<peer_alert>, noncopyable>(
336 "unwanted_block_alert", no_init
338 .def_readonly("block_index", &unwanted_block_alert::block_index)
339 .def_readonly("piece_index", &unwanted_block_alert::piece_index)
342 class_<torrent_delete_failed_alert, bases<torrent_alert>, noncopyable>(
343 "torrent_delete_failed_alert", no_init
346 class_<save_resume_data_failed_alert, bases<torrent_alert>, noncopyable>(
347 "save_resume_data_failed_alert", no_init