diff --git a/ChangeLog b/ChangeLog index c980aca44..cf5d633b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -87,6 +87,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * exposed alert error_codes to python * fixed bug in announce_entry::next_announce_in and min_announce_in * fixed sign issue in set_alert_mask signature * fixed unaligned disk access for unbuffered I/O in windows diff --git a/bindings/python/Jamfile b/bindings/python/Jamfile index 290524001..00b873239 100755 --- a/bindings/python/Jamfile +++ b/bindings/python/Jamfile @@ -54,6 +54,7 @@ python-extension libtorrent src/peer_info.cpp src/ip_filter.cpp src/magnet_uri.cpp + src/error_code.cpp : src /torrent//torrent/static system:boost_python diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 1a98da050..57d84dad1 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -116,6 +116,7 @@ void bind_alert() .def_readonly("msg", &tracker_error_alert::msg) .def_readonly("times_in_row", &tracker_error_alert::times_in_row) .def_readonly("status_code", &tracker_error_alert::status_code) + .def_readonly("error", &tracker_error_alert::error) ; class_, noncopyable>( @@ -140,7 +141,9 @@ void bind_alert() "peer_ban_alert", no_init); class_, noncopyable>( - "peer_error_alert", no_init); + "peer_error_alert", no_init) + .def_readonly("error", &peer_error_alert::error) + ; class_, noncopyable>( "invalid_request_alert", no_init) @@ -205,6 +208,7 @@ void bind_alert() class_, noncopyable>( "file_error_alert", no_init) .def_readonly("file", &file_error_alert::file) + .def_readonly("error", &file_error_alert::error) #ifndef TORRENT_NO_DEPRECATE .def_readonly("msg", &file_error_alert::msg) #endif @@ -231,6 +235,7 @@ void bind_alert() "portmap_error_alert", no_init) .def_readonly("mapping", &portmap_error_alert::mapping) .def_readonly("map_type", &portmap_error_alert::map_type) + .def_readonly("error", &portmap_error_alert::error) #ifndef TORRENT_NO_DEPRECATE .def_readonly("type", &portmap_error_alert::map_type) .def_readonly("msg", &portmap_error_alert::msg) @@ -258,6 +263,7 @@ void bind_alert() class_, noncopyable>( "fastresume_rejected_alert", no_init) + .def_readonly("error", &fastresume_rejected_alert::error) #ifndef TORRENT_NO_DEPRECATE .def_readonly("msg", &fastresume_rejected_alert::msg) #endif @@ -275,7 +281,8 @@ void bind_alert() ; class_, noncopyable>( - "scrape_failed_alert", no_init); + "scrape_failed_alert", no_init) + ; class_, noncopyable>( "udp_error_alert", no_init) @@ -352,6 +359,7 @@ void bind_alert() class_, noncopyable>( "peer_disconnected_alert", no_init) + .def_readonly("error", &peer_disconnected_alert::error) #ifndef TORRENT_NO_DEPRECATE .def_readonly("msg", &peer_disconnected_alert::msg) #endif @@ -380,6 +388,7 @@ void bind_alert() #ifndef TORRENT_NO_DEPRECATE .def_readonly("msg", &torrent_delete_failed_alert::msg) #endif + .def_readonly("error", &torrent_delete_failed_alert::error) ; class_, noncopyable>( @@ -387,6 +396,7 @@ void bind_alert() #ifndef TORRENT_NO_DEPRECATE .def_readonly("msg", &save_resume_data_failed_alert::msg) #endif + .def_readonly("error", &save_resume_data_failed_alert::error) ; class_, noncopyable>( diff --git a/bindings/python/src/error_code.cpp b/bindings/python/src/error_code.cpp new file mode 100644 index 000000000..987d92973 --- /dev/null +++ b/bindings/python/src/error_code.cpp @@ -0,0 +1,48 @@ +/* + +Copyright (c) 2011, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include + +using namespace boost::python; +using namespace libtorrent; + +void bind_error_code() +{ + class_("error_code") + .def(init<>()) + .def("message", &error_code::message) + .def("value", &error_code::value) + .def("clear", &error_code::clear) + ; +} + diff --git a/bindings/python/src/module.cpp b/bindings/python/src/module.cpp index d0b221e95..2fb1bd1e4 100644 --- a/bindings/python/src/module.cpp +++ b/bindings/python/src/module.cpp @@ -24,12 +24,14 @@ void bind_ip_filter(); void bind_magnet_uri(); void bind_converters(); void bind_create_torrent(); +void bind_error_code(); BOOST_PYTHON_MODULE(libtorrent) { Py_Initialize(); PyEval_InitThreads(); + bind_error_code(); bind_utility(); bind_fingerprint(); bind_big_number();