Changeset 4118
- Timestamp:
- 10/28/08 22:20:46 (2 months ago)
- Files:
-
- 10 modified
-
branches/1.0.0_RC/libtorrent/bindings/python/src/alert.cpp (modified) (23 diffs)
-
branches/1.0.0_RC/libtorrent/bindings/python/src/extensions.cpp (modified) (3 diffs)
-
branches/1.0.0_RC/libtorrent/bindings/python/src/ip_filter.cpp (modified) (2 diffs)
-
branches/1.0.0_RC/libtorrent/bindings/python/src/session.cpp (modified) (8 diffs)
-
branches/1.0.0_RC/libtorrent/bindings/python/src/torrent_handle.cpp (modified) (6 diffs)
-
branches/1.0.0_RC/libtorrent/bindings/python/src/torrent_info.cpp (modified) (4 diffs)
-
trunk/libtorrent/bindings/python/src/alert.cpp (modified) (23 diffs)
-
trunk/libtorrent/bindings/python/src/session.cpp (modified) (8 diffs)
-
trunk/libtorrent/bindings/python/src/torrent_handle.cpp (modified) (6 diffs)
-
trunk/libtorrent/bindings/python/src/torrent_info.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0.0_RC/libtorrent/bindings/python/src/alert.cpp
r3930 r4118 57 57 .def("what", &alert::what) 58 58 .def("category", &alert::category) 59 #ifndef TORRENT_NO_DEPRECATE 59 60 .def("severity", &alert::severity, alert_severity_doc) 61 #endif 60 62 .def("__str__", &alert::message, alert_msg_doc) 61 63 ; … … 68 70 .value("fatal", alert::fatal) 69 71 .value("none", alert::none) 70 ; 72 ; 71 73 72 74 enum_<alert::category_t>("category_t") … … 80 82 .value("progress_notification", alert::progress_notification) 81 83 .value("ip_block_notification", alert::ip_block_notification) 84 .value("performance_warning", alert::performance_warning) 82 85 .value("all_categories", alert::all_categories) 83 ; 86 ; 87 84 88 } 85 89 … … 154 158 "torrent_finished_alert", torrent_finished_alert_doc, no_init 155 159 ); 156 160 157 161 class_<piece_finished_alert, bases<torrent_alert>, noncopyable>( 158 162 "piece_finished_alert", piece_finished_alert_doc, no_init … … 160 164 .def_readonly("piece_index", &piece_finished_alert::piece_index) 161 165 ; 162 166 163 167 class_<block_finished_alert, bases<peer_alert>, noncopyable>( 164 168 "block_finished_alert", block_finished_alert_doc, no_init … … 167 171 .def_readonly("piece_index", &block_finished_alert::piece_index) 168 172 ; 169 173 170 174 class_<block_downloading_alert, bases<peer_alert>, noncopyable>( 171 175 "block_downloading_alert", block_downloading_alert_doc, no_init … … 175 179 .def_readonly("piece_index", &block_downloading_alert::piece_index) 176 180 ; 177 181 178 182 class_<storage_moved_alert, bases<torrent_alert>, noncopyable>( 179 183 "storage_moved_alert", storage_moved_alert_doc, no_init … … 183 187 "torrent_deleted_alert", torrent_deleted_alert_doc, no_init 184 188 ); 185 189 186 190 class_<torrent_paused_alert, bases<torrent_alert>, noncopyable>( 187 191 "torrent_paused_alert", torrent_paused_alert_doc, no_init … … 191 195 "torrent_checked_alert", torrent_checked_alert_doc, no_init 192 196 ); 193 197 194 198 class_<url_seed_alert, bases<torrent_alert>, noncopyable>( 195 199 "url_seed_alert", url_seed_alert_doc, no_init … … 197 201 .def_readonly("url", &url_seed_alert::url) 198 202 ; 199 203 200 204 class_<file_error_alert, bases<torrent_alert>, noncopyable>( 201 205 "file_error_alert", file_error_alert_doc, no_init … … 203 207 .def_readonly("file", &file_error_alert::file) 204 208 ; 205 209 206 210 class_<metadata_failed_alert, bases<torrent_alert>, noncopyable>( 207 211 "metadata_failed_alert", metadata_failed_alert_doc, no_init … … 215 219 "listen_failed_alert", listen_failed_alert_doc, no_init 216 220 ); 217 221 218 222 class_<listen_succeeded_alert, bases<alert>, noncopyable>( 219 223 "listen_succeeded_alert", listen_succeeded_alert_doc, no_init … … 221 225 .def_readonly("endpoint", &listen_succeeded_alert::endpoint) 222 226 ; 223 227 224 228 class_<portmap_error_alert, bases<alert>, noncopyable>( 225 229 "portmap_error_alert", portmap_error_alert_doc, no_init … … 228 232 .def_readonly("type", &portmap_error_alert::type) 229 233 ; 230 234 231 235 class_<portmap_alert, bases<alert>, noncopyable>( 232 236 "portmap_alert", portmap_alert_doc, no_init … … 236 240 .def_readonly("type", &portmap_alert::type) 237 241 ; 238 242 239 243 class_<fastresume_rejected_alert, bases<torrent_alert>, noncopyable>( 240 244 "fastresume_rejected_alert", fastresume_rejected_alert_doc, no_init 241 245 ); 242 246 243 247 class_<peer_blocked_alert, bases<alert>, noncopyable>( 244 248 "peer_blocked_alert", peer_blocked_alert_doc, no_init … … 246 250 .def_readonly("ip", &peer_blocked_alert::ip) 247 251 ; 248 252 249 253 class_<scrape_reply_alert, bases<tracker_alert>, noncopyable>( 250 254 "scrape_reply_alert", scrape_reply_alert_doc, no_init … … 253 257 .def_readonly("complete", &scrape_reply_alert::complete) 254 258 ; 255 259 256 260 class_<scrape_failed_alert, bases<tracker_alert>, noncopyable>( 257 261 "scrape_failed_alert", scrape_failed_alert_doc, no_init 258 262 ); 259 263 260 264 class_<udp_error_alert, bases<alert>, noncopyable>( 261 265 "udp_error_alert", udp_error_alert_doc, no_init … … 263 267 .def_readonly("endpoint", &udp_error_alert::endpoint) 264 268 ; 265 269 266 270 class_<external_ip_alert, bases<alert>, noncopyable>( 267 271 "external_ip_alert", external_ip_alert_doc, no_init … … 289 293 .def_readonly("msg", &file_rename_failed_alert::msg) 290 294 ; 291 292 class_<torrent_resumed_alert, bases<torrent_alert>, noncopyable>( 293 "torrent_resumed_alert", no_init 295 296 class_<torrent_resumed_alert, bases<torrent_alert>, noncopyable>( 297 "torrent_resumed_alert", no_init 294 298 ); 295 299 296 300 class_<state_changed_alert, bases<torrent_alert>, noncopyable>( 297 301 "state_changed_alert", no_init … … 305 309 .def_readonly("num_peers", &dht_reply_alert::num_peers) 306 310 ; 307 311 308 312 class_<peer_unsnubbed_alert, bases<peer_alert>, noncopyable>( 309 313 "peer_unsnubbed_alert", no_init 310 314 ); 311 315 312 316 class_<peer_snubbed_alert, bases<peer_alert>, noncopyable>( 313 317 "peer_snubbed_alert", no_init 314 318 ); 315 319 316 320 class_<peer_connect_alert, bases<peer_alert>, noncopyable>( 317 321 "peer_connect_alert", no_init 318 322 ); 319 323 320 324 class_<peer_disconnected_alert, bases<peer_alert>, noncopyable>( 321 325 "peer_disconnected_alert", no_init 322 326 ); 323 327 324 328 class_<request_dropped_alert, bases<peer_alert>, noncopyable>( 325 329 "request_dropped_alert", no_init … … 328 332 .def_readonly("piece_index", &request_dropped_alert::piece_index) 329 333 ; 330 334 331 335 class_<block_timeout_alert, bases<peer_alert>, noncopyable>( 332 336 "block_timeout_alert", no_init … … 335 339 .def_readonly("piece_index", &block_timeout_alert::piece_index) 336 340 ; 337 341 338 342 class_<unwanted_block_alert, bases<peer_alert>, noncopyable>( 339 343 "unwanted_block_alert", no_init … … 342 346 .def_readonly("piece_index", &unwanted_block_alert::piece_index) 343 347 ; 344 348 345 349 class_<torrent_delete_failed_alert, bases<torrent_alert>, noncopyable>( 346 350 "torrent_delete_failed_alert", no_init 347 351 ); 348 352 349 353 class_<save_resume_data_failed_alert, bases<torrent_alert>, noncopyable>( 350 354 "save_resume_data_failed_alert", no_init 351 355 ); 352 356 357 class_<performance_alert, bases<torrent_alert>, noncopyable>( 358 "performance_alert", no_init 359 ) 360 .def_readonly("warning_code", &performance_alert::warning_code) 361 ; 362 enum_<performance_alert::performance_warning_t>("performance_warning_t") 363 .value("outstanding_disk_buffer_limit_reached", performance_alert::outstanding_disk_buffer_limit_reached) 364 .value("outstanding_request_limit_reached", performance_alert::outstanding_request_limit_reached) 365 ; 366 367 368 353 369 } -
branches/1.0.0_RC/libtorrent/bindings/python/src/extensions.cpp
r3871 r4118 10 10 #include <libtorrent/extensions/metadata_transfer.hpp> 11 11 #include <libtorrent/extensions/ut_metadata.hpp> 12 #include <libtorrent/extensions/smart_ban.hpp> 12 13 #include <boost/python.hpp> 13 14 #include "gil.hpp" … … 124 125 } 125 126 127 boost::shared_ptr<torrent_plugin> create_smart_ban_plugin_wrapper(torrent* t) { 128 return create_smart_ban_plugin(t, NULL); 129 } 130 126 131 void bind_extensions() 127 132 { … … 161 166 def("create_metadata_plugin", create_metadata_plugin_wrapper); 162 167 def("create_ut_metadata_plugin", create_ut_metadata_plugin_wrapper); 168 def("create_smart_ban_plugin", create_smart_ban_plugin_wrapper); 163 169 } 164 170 -
branches/1.0.0_RC/libtorrent/bindings/python/src/ip_filter.cpp
r3032 r4118 14 14 void add_rule(ip_filter& filter, std::string start, std::string end, int flags) 15 15 { 16 return filter.add_rule(address_v4::from_string(start), address_v4::from_string(end), flags); 16 return filter.add_rule(address::from_string(start), address::from_string(end), flags); 17 } 18 19 int _access(ip_filter& filter, std::string addr) 20 { 21 return filter.access(address::from_string(addr)); 17 22 } 18 23 } … … 21 26 { 22 27 class_<ip_filter>("ip_filter") 23 .def("add_rule", &add_rule)24 .def("access", allow_threads(&ip_filter::access))25 .def _readonly("export_filter", allow_threads(&ip_filter::export_filter))28 .def("add_rule", add_rule) 29 .def("access", _access) 30 .def("export_filter", allow_threads(&ip_filter::export_filter)) 26 31 ; 27 32 } -
branches/1.0.0_RC/libtorrent/bindings/python/src/session.cpp
r3908 r4118 50 50 extern char const* session_set_settings_doc; 51 51 extern char const* session_set_pe_settings_doc; 52 extern char const* session_get_pe_settings_doc; 52 extern char const* session_get_pe_settings_doc; 53 53 extern char const* session_set_severity_level_doc; 54 54 extern char const* session_pop_alert_doc; … … 105 105 s.add_extension(invoke_extension_factory(e)); 106 106 } 107 108 #ifndef TORRENT_NO_DEPRECATE 109 torrent_handle add_torrent_depr(session& s, torrent_info const& ti 110 , boost::filesystem::path const& save, entry const& resume 111 , storage_mode_t storage_mode, bool paused) 112 { 113 allow_threading_guard guard; 114 return s.add_torrent(ti, save, resume, storage_mode, paused, default_storage_constructor); 115 } 116 #endif 107 117 108 118 torrent_handle add_torrent(session& s, dict params) … … 137 147 p.resume_data = &resume_buf; 138 148 } 139 p.storage_mode = extract<storage_mode_t>(params["storage_mode"]); 140 p.paused = params["paused"]; 141 p.auto_managed = params["auto_managed"]; 142 p.duplicate_is_error = params["duplicate_is_error"]; 149 if (params.has_key("storage_mode")) 150 p.storage_mode = extract<storage_mode_t>(params["storage_mode"]); 151 if (params.has_key("paused")) 152 p.paused = params["paused"]; 153 if (params.has_key("auto_managed")) 154 p.auto_managed = params["auto_managed"]; 155 if (params.has_key("duplicate_is_error")) 156 p.duplicate_is_error = params["duplicate_is_error"]; 143 157 144 158 return s.add_torrent(p); … … 170 184 return ret; 171 185 } 172 186 173 187 #ifndef TORRENT_DISABLE_GEO_IP 174 188 bool load_asnum_db(session& s, std::string file) … … 260 274 .value("start_default_features", session::start_default_features) 261 275 ; 262 276 263 277 class_<session, boost::noncopyable>("session", session_doc, no_init) 264 278 .def( … … 289 303 #endif 290 304 .def("add_torrent", &add_torrent, session_add_torrent_doc) 305 #ifndef TORRENT_NO_DEPRECATE 306 .def( 307 "add_torrent", &add_torrent_depr 308 , ( 309 arg("resume_data") = entry(), arg("storage_mode") = storage_mode_sparse, 310 arg("paused") = false 311 ) 312 , session_add_torrent_doc 313 ) 314 #endif 291 315 .def("remove_torrent", allow_threads(&session::remove_torrent), arg("option") = session::none 316 292 317 , session_remove_torrent_doc) 293 318 .def( … … 337 362 .def("load_state", allow_threads(&session::load_state)) 338 363 .def("state", allow_threads(&session::state)) 364 #ifndef TORRENT_NO_DEPRECATE 339 365 .def( 340 366 "set_severity_level", allow_threads(&session::set_severity_level) 341 367 , session_set_severity_level_doc 342 368 ) 369 #endif 343 370 .def("set_alert_mask", allow_threads(&session::set_alert_mask)) 344 371 .def("pop_alert", allow_threads(&session::pop_alert), session_pop_alert_doc) … … 363 390 register_ptr_to_python<std::auto_ptr<alert> >(); 364 391 } 365 366 -
branches/1.0.0_RC/libtorrent/bindings/python/src/torrent_handle.cpp
r3942 r4118 153 153 list ret; 154 154 std::vector<int> priorities = handle.file_priorities(); 155 155 156 156 for (std::vector<int>::iterator i = priorities.begin(); i != priorities.end(); ++i) 157 157 ret.append(*i); 158 158 159 159 return ret; 160 160 } … … 254 254 void (torrent_handle::*piece_priority1)(int, int) const = &torrent_handle::piece_priority; 255 255 256 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES 256 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES 257 257 bool (torrent_handle::*resolve_countries0)() const = &torrent_handle::resolve_countries; 258 258 void (torrent_handle::*resolve_countries1)(bool) = &torrent_handle::resolve_countries; … … 282 282 .def("resume", _(&torrent_handle::resume)) 283 283 .def("clear_error", _(&torrent_handle::clear_error)) 284 284 285 285 .def("is_auto_managed", _(&torrent_handle::is_auto_managed)) 286 286 .def("auto_managed", _(&torrent_handle::auto_managed)) … … 290 290 .def("queue_position_top", _(&torrent_handle::queue_position_top)) 291 291 .def("queue_position_bottom", _(&torrent_handle::queue_position_bottom)) 292 293 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES 292 293 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES 294 294 .def("resolve_countries", _(resolve_countries0)) 295 295 .def("resolve_countries", _(resolve_countries1)) 296 296 #endif 297 297 // deprecated 298 #ifndef TORRENT_NO_DEPRECATE 298 299 .def("filter_piece", _(&torrent_handle::filter_piece)) 299 300 .def("is_piece_filtered", _(&torrent_handle::is_piece_filtered)) 300 301 .def("write_resume_data", _(&torrent_handle::write_resume_data)) 302 #endif 301 303 .def("piece_availability", piece_availability) 302 304 .def("piece_priority", _(piece_priority0)) … … 307 309 .def("file_priorities", file_priorities) 308 310 .def("use_interface", &torrent_handle::use_interface) 309 .def("write_resume_data", _(&torrent_handle::write_resume_data))310 311 .def("save_resume_data", _(&torrent_handle::save_resume_data)) 311 312 .def("force_reannounce", _(force_reannounce0)) … … 332 333 ; 333 334 } 334 -
branches/1.0.0_RC/libtorrent/bindings/python/src/torrent_info.cpp
r4030 r4118 68 68 return result; 69 69 } 70 71 torrent_info construct0(std::string path) { 72 return torrent_info(fs::path(path)); 73 } 70 74 } // namespace unnamed 71 75 … … 75 79 76 80 class_<torrent_info, boost::intrusive_ptr<torrent_info> >("torrent_info", no_init) 81 #ifndef TORRENT_NO_DEPRECATE 77 82 .def(init<entry const&>()) 83 #endif 78 84 .def(init<sha1_hash const&>()) 79 85 .def(init<char const*, int>()) 80 86 .def(init<boost::filesystem::path>()) 87 81 88 .def("add_tracker", &torrent_info::add_tracker, (arg("url"), arg("tier")=0)) 82 89 .def("add_url_seed", &torrent_info::add_url_seed) … … 88 95 .def("piece_length", &torrent_info::piece_length) 89 96 .def("num_pieces", &torrent_info::num_pieces) 97 #ifndef TORRENT_NO_DEPRECATE 90 98 .def("info_hash", &torrent_info::info_hash, copy) 91 99 #endif 92 100 .def("hash_for_piece", &torrent_info::hash_for_piece) 93 101 .def("piece_size", &torrent_info::piece_size) … … 124 132 ; 125 133 } 126 127 -
trunk/libtorrent/bindings/python/src/alert.cpp
r3905 r4118 57 57 .def("what", &alert::what) 58 58 .def("category", &alert::category) 59 #ifndef TORRENT_NO_DEPRECATE 59 60 .def("severity", &alert::severity, alert_severity_doc) 61 #endif 60 62 .def("__str__", &alert::message, alert_msg_doc) 61 63 ; … … 68 70 .value("fatal", alert::fatal) 69 71 .value("none", alert::none) 70 ; 72 ; 71 73 72 74 enum_<alert::category_t>("category_t") … … 80 82 .value("progress_notification", alert::progress_notification) 81 83 .value("ip_block_notification", alert::ip_block_notification) 84 .value("performance_warning", alert::performance_warning) 82 85 .value("all_categories", alert::all_categories) 83 ; 86 ; 87 84 88 } 85 89 … … 154 158 "torrent_finished_alert", torrent_finished_alert_doc, no_init 155 159 ); 156 160 157 161 class_<piece_finished_alert, bases<torrent_alert>, noncopyable>( 158 162 "piece_finished_alert", piece_finished_alert_doc, no_init … … 160 164 .def_readonly("piece_index", &piece_finished_alert::piece_index) 161 165 ; 162 166 163 167 class_<block_finished_alert, bases<peer_alert>, noncopyable>( 164 168 "block_finished_alert", block_finished_alert_doc, no_init … … 167 171 .def_readonly("piece_index", &block_finished_alert::piece_index) 168 172 ; 169 173 170 174 class_<block_downloading_alert, bases<peer_alert>, noncopyable>( 171 175 "block_downloading_alert", block_downloading_alert_doc, no_init … … 175 179 .def_readonly("piece_index", &block_downloading_alert::piece_index) 176 180 ; 177 181 178 182 class_<storage_moved_alert, bases<torrent_alert>, noncopyable>( 179 183 "storage_moved_alert", storage_moved_alert_doc, no_init … … 183 187 "torrent_deleted_alert", torrent_deleted_alert_doc, no_init 184 188 ); 185 189 186 190 class_<torrent_paused_alert, bases<torrent_alert>, noncopyable>( 187 191 "torrent_paused_alert", torrent_paused_alert_doc, no_init … … 191 195 "torrent_checked_alert", torrent_checked_alert_doc, no_init 192 196 ); 193 197 194 198 class_<url_seed_alert, bases<torrent_alert>, noncopyable>( 195 199 "url_seed_alert", url_seed_alert_doc, no_init … … 197 201 .def_readonly("url", &url_seed_alert::url) 198 202 ; 199 203 200 204 class_<file_error_alert, bases<torrent_alert>, noncopyable>( 201 205 "file_error_alert", file_error_alert_doc, no_init … … 203 207 .def_readonly("file", &file_error_alert::file) 204 208 ;
