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/torrent_handle.hpp>
6 #include <boost/python.hpp>
7 #include <libtorrent/bitfield.hpp>
9 using namespace boost::python
;
10 using namespace libtorrent
;
12 object
pieces(torrent_status
const& s
)
16 for (bitfield::const_iterator
i(s
.pieces
.begin()), e(s
.pieces
.end()); i
!= e
; ++i
)
22 void bind_torrent_status()
24 scope status
= class_
<torrent_status
>("torrent_status")
25 .def_readonly("state", &torrent_status::state
)
26 .def_readonly("paused", &torrent_status::paused
)
27 .def_readonly("progress", &torrent_status::progress
)
31 &torrent_status::next_announce
, return_value_policy
<return_by_value
>()
37 &torrent_status::announce_interval
, return_value_policy
<return_by_value
>()
40 .def_readonly("current_tracker", &torrent_status::current_tracker
)
41 .def_readonly("total_download", &torrent_status::total_download
)
42 .def_readonly("total_upload", &torrent_status::total_upload
)
43 .def_readonly("total_payload_download", &torrent_status::total_payload_download
)
44 .def_readonly("total_payload_upload", &torrent_status::total_payload_upload
)
45 .def_readonly("total_failed_bytes", &torrent_status::total_failed_bytes
)
46 .def_readonly("total_redundant_bytes", &torrent_status::total_redundant_bytes
)
47 .def_readonly("download_rate", &torrent_status::download_rate
)
48 .def_readonly("upload_rate", &torrent_status::upload_rate
)
49 .def_readonly("download_payload_rate", &torrent_status::download_payload_rate
)
50 .def_readonly("upload_payload_rate", &torrent_status::upload_payload_rate
)
51 .def_readonly("num_seeds", &torrent_status::num_seeds
)
52 .def_readonly("num_peers", &torrent_status::num_peers
)
53 .def_readonly("num_complete", &torrent_status::num_complete
)
54 .def_readonly("num_incomplete", &torrent_status::num_incomplete
)
55 .def_readonly("list_seeds", &torrent_status::list_seeds
)
56 .def_readonly("list_peers", &torrent_status::list_peers
)
57 .add_property("pieces", pieces
)
58 .def_readonly("num_pieces", &torrent_status::num_pieces
)
59 .def_readonly("total_done", &torrent_status::total_done
)
60 .def_readonly("total_wanted_done", &torrent_status::total_wanted_done
)
61 .def_readonly("total_wanted", &torrent_status::total_wanted
)
62 .def_readonly("distributed_copies", &torrent_status::distributed_copies
)
63 .def_readonly("block_size", &torrent_status::block_size
)
64 .def_readonly("num_uploads", &torrent_status::num_uploads
)
65 .def_readonly("num_connections", &torrent_status::num_connections
)
66 .def_readonly("uploads_limit", &torrent_status::uploads_limit
)
67 .def_readonly("connections_limit", &torrent_status::connections_limit
)
68 .def_readonly("storage_mode", &torrent_status::storage_mode
)
69 .def_readonly("up_bandwidth_queue", &torrent_status::up_bandwidth_queue
)
70 .def_readonly("down_bandwidth_queue", &torrent_status::down_bandwidth_queue
)
71 .def_readonly("all_time_upload", &torrent_status::all_time_upload
)
72 .def_readonly("all_time_download", &torrent_status::all_time_download
)
73 .def_readonly("active_time", &torrent_status::active_time
)
74 .def_readonly("seeding_time", &torrent_status::seeding_time
)
75 .def_readonly("seed_rank", &torrent_status::seed_rank
)
76 .def_readonly("last_scrape", &torrent_status::last_scrape
)
77 .def_readonly("error", &torrent_status::error
)
80 enum_
<torrent_status::state_t
>("states")
81 .value("queued_for_checking", torrent_status::queued_for_checking
)
82 .value("checking_files", torrent_status::checking_files
)
83 .value("downloading", torrent_status::downloading
)
84 .value("finished", torrent_status::finished
)
85 .value("seeding", torrent_status::seeding
)
86 .value("allocating", torrent_status::allocating
)