From 9fedc8617265843e0e4a51f60a3d36c304b110f1 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 4 Aug 2008 23:32:18 +0000 Subject: [PATCH] lt sync 2588 --- deluge/common.py | 24 +++++++---------- deluge/core/torrent.py | 3 +-- .../bindings/python/src/torrent_status.cpp | 1 - libtorrent/include/libtorrent/alert.hpp | 2 ++ libtorrent/include/libtorrent/magnet_uri.hpp | 8 +++++- libtorrent/include/libtorrent/session.hpp | 4 +++ .../include/libtorrent/session_settings.hpp | 6 +++++ .../include/libtorrent/torrent_handle.hpp | 7 ++++- .../include/libtorrent/torrent_info.hpp | 2 ++ libtorrent/src/magnet_uri.cpp | 26 +++++++++++++++++++ libtorrent/src/session.cpp | 4 +++ libtorrent/src/torrent.cpp | 25 ++++-------------- libtorrent/src/torrent_handle.cpp | 8 ++++-- libtorrent/src/torrent_info.cpp | 4 +++ 14 files changed, 83 insertions(+), 41 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index a404707b8..ace19ad02 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -42,22 +42,18 @@ import xdg, xdg.BaseDirectory LT_TORRENT_STATE = { "Queued": 0, "Checking": 1, - "Connecting": 2, - "Downloading Metadata": 3, - "Downloading": 4, - "Finished": 5, - "Seeding": 6, - "Allocating": 7, - "Paused": 8, + "Downloading Metadata": 2, + "Downloading": 3, + "Finished": 4, + "Seeding": 5, + "Allocating": 6, 0: "Queued", 1: "Checking", - 2: "Connecting", - 3: "Downloading Metadata", - 4: "Downloading", - 5: "Finished", - 6: "Seeding", - 7: "Allocating", - 8: "Paused" + 2: "Downloading Metadata", + 3: "Downloading", + 4: "Finished", + 5: "Seeding", + 6: "Allocating", } TORRENT_STATE = [ diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 02ffe2602..173397404 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -251,8 +251,7 @@ class Torrent: if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]: self.state = "Checking" return - elif ltstate == LTSTATE["Connecting"] or ltstate == LTSTATE["Downloading"] or\ - ltstate == LTSTATE["Downloading Metadata"]: + elif ltstate == LTSTATE["Downloading"] or ltstate == LTSTATE["Downloading Metadata"]: self.state = "Downloading" elif ltstate == LTSTATE["Finished"] or ltstate == LTSTATE["Seeding"]: self.state = "Seeding" diff --git a/libtorrent/bindings/python/src/torrent_status.cpp b/libtorrent/bindings/python/src/torrent_status.cpp index 186d0f2f5..81e2bf3a6 100755 --- a/libtorrent/bindings/python/src/torrent_status.cpp +++ b/libtorrent/bindings/python/src/torrent_status.cpp @@ -80,7 +80,6 @@ void bind_torrent_status() enum_("states") .value("queued_for_checking", torrent_status::queued_for_checking) .value("checking_files", torrent_status::checking_files) - .value("connecting_to_tracker", torrent_status::connecting_to_tracker) .value("downloading", torrent_status::downloading) .value("finished", torrent_status::finished) .value("seeding", torrent_status::seeding) diff --git a/libtorrent/include/libtorrent/alert.hpp b/libtorrent/include/libtorrent/alert.hpp index 49b1129b4..f3df27742 100644 --- a/libtorrent/include/libtorrent/alert.hpp +++ b/libtorrent/include/libtorrent/alert.hpp @@ -96,7 +96,9 @@ namespace libtorrent { virtual std::string message() const = 0; virtual int category() const = 0; +#ifndef TORRENT_NO_DEPRECATE severity_t severity() const TORRENT_DEPRECATED { return warning; } +#endif virtual std::auto_ptr clone() const = 0; diff --git a/libtorrent/include/libtorrent/magnet_uri.hpp b/libtorrent/include/libtorrent/magnet_uri.hpp index 2e947efa0..a77880d16 100644 --- a/libtorrent/include/libtorrent/magnet_uri.hpp +++ b/libtorrent/include/libtorrent/magnet_uri.hpp @@ -47,12 +47,18 @@ namespace libtorrent std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle); +#ifndef TORRENT_NO_DEPRECATE + // deprecated in 0.14 torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri , fs::path const& save_path , storage_mode_t storage_mode = storage_mode_sparse , bool paused = false , storage_constructor_type sc = default_storage_constructor - , void* userdata = 0); + , void* userdata = 0) TORRENT_DEPRECATED; +#endif + + torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri + , add_torrent_params p); } #endif diff --git a/libtorrent/include/libtorrent/session.hpp b/libtorrent/include/libtorrent/session.hpp index 6b628bdbf..a3fa9e5cd 100644 --- a/libtorrent/include/libtorrent/session.hpp +++ b/libtorrent/include/libtorrent/session.hpp @@ -179,6 +179,7 @@ namespace libtorrent // all torrent_handles must be destructed before the session is destructed! torrent_handle add_torrent(add_torrent_params const& params); +#ifndef TORRENT_NO_DEPRECATE // deprecated in 0.14 torrent_handle add_torrent( torrent_info const& ti @@ -209,6 +210,7 @@ namespace libtorrent , bool paused = false , storage_constructor_type sc = default_storage_constructor , void* userdata = 0) TORRENT_DEPRECATED; +#endif session_proxy abort() { return session_proxy(m_impl); } @@ -317,7 +319,9 @@ namespace libtorrent void set_max_half_open_connections(int limit); std::auto_ptr pop_alert(); +#ifndef TORRENT_NO_DEPRECATE void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED; +#endif void set_alert_mask(int m); alert const* wait_for_alert(time_duration max_wait); diff --git a/libtorrent/include/libtorrent/session_settings.hpp b/libtorrent/include/libtorrent/session_settings.hpp index fb98ad98b..9aafbb921 100644 --- a/libtorrent/include/libtorrent/session_settings.hpp +++ b/libtorrent/include/libtorrent/session_settings.hpp @@ -140,6 +140,7 @@ namespace libtorrent , auto_scrape_interval(1800) , auto_scrape_min_interval(300) , max_peerlist_size(8000) + , min_announce_interval(5 * 60) {} // this is the user agent that will be sent to the tracker @@ -430,6 +431,11 @@ namespace libtorrent // per torrent. This is the peers we know // about, not necessarily connected to. int max_peerlist_size; + + // any announce intervals reported from a tracker + // that is lower than this, will be clamped to this + // value. It's specified in seconds + int min_announce_interval; }; #ifndef TORRENT_DISABLE_DHT diff --git a/libtorrent/include/libtorrent/torrent_handle.hpp b/libtorrent/include/libtorrent/torrent_handle.hpp index b19b2a2a9..97d8edb37 100644 --- a/libtorrent/include/libtorrent/torrent_handle.hpp +++ b/libtorrent/include/libtorrent/torrent_handle.hpp @@ -126,7 +126,6 @@ namespace libtorrent { queued_for_checking, checking_files, - connecting_to_tracker, downloading_metadata, downloading, finished, @@ -319,10 +318,12 @@ namespace libtorrent torrent_status status() const; void get_download_queue(std::vector& queue) const; +#ifndef TORRENT_NO_DEPRECATE // fills the specified vector with the download progress [0, 1] // of each file in the torrent. The files are ordered as in // the torrent_info. void file_progress(std::vector& progress) const TORRENT_DEPRECATED; +#endif void file_progress(std::vector& progress) const; void clear_error() const; @@ -370,6 +371,7 @@ namespace libtorrent // ================ start deprecation ============ +#ifndef TORRENT_NO_DEPRECATE // deprecated in 0.13 // marks the piece with the given index as filtered // it will not be downloaded @@ -382,6 +384,7 @@ namespace libtorrent void filter_files(std::vector const& files) const TORRENT_DEPRECATED; // ================ end deprecation ============ +#endif void piece_availability(std::vector& avail) const; @@ -403,10 +406,12 @@ namespace libtorrent // to. void use_interface(const char* net_interface) const; +#ifndef TORRENT_NO_DEPRECATE // deprecated in 0.14 // use save_resume_data() instead. It is async. and // will return the resume data in an alert entry write_resume_data() const TORRENT_DEPRECATED; +#endif // forces this torrent to reannounce // (make a rerequest from the tracker) diff --git a/libtorrent/include/libtorrent/torrent_info.hpp b/libtorrent/include/libtorrent/torrent_info.hpp index 6c87b475a..a027e3460 100644 --- a/libtorrent/include/libtorrent/torrent_info.hpp +++ b/libtorrent/include/libtorrent/torrent_info.hpp @@ -125,11 +125,13 @@ namespace libtorrent peer_request map_file(int file, size_type offset, int size) const { return m_files.map_file(file, offset, size); } +#ifndef TORRENT_NO_DEPRECATE // ------- start deprecation ------- // these functions will be removed in a future version torrent_info(entry const& torrent_file) TORRENT_DEPRECATED; void print(std::ostream& os) const TORRENT_DEPRECATED; // ------- end deprecation ------- +#endif bool is_valid() const { return m_files.is_valid(); } diff --git a/libtorrent/src/magnet_uri.cpp b/libtorrent/src/magnet_uri.cpp index bd582476a..af54de9e0 100644 --- a/libtorrent/src/magnet_uri.cpp +++ b/libtorrent/src/magnet_uri.cpp @@ -69,6 +69,7 @@ namespace libtorrent return ret.str(); } +#ifndef TORRENT_NO_DEPRECATE torrent_handle add_magnet_uri(session& ses, std::string const& uri , fs::path const& save_path , storage_mode_t storage_mode @@ -95,6 +96,31 @@ namespace libtorrent , name.empty() ? 0 : name.c_str(), save_path, entry() , storage_mode, paused, sc, userdata); } +#endif + + torrent_handle add_magnet_uri(session& ses, std::string const& uri + , add_torrent_params p) + { + std::string name; + std::string tracker; + + boost::optional display_name = url_has_argument(uri, "dn"); + if (display_name) name = unescape_string(display_name->c_str()); + boost::optional tracker_string = url_has_argument(uri, "tr"); + if (tracker_string) tracker = unescape_string(tracker_string->c_str()); + + boost::optional btih = url_has_argument(uri, "xt"); + if (!btih) return torrent_handle(); + + if (btih->compare(0, 9, "urn:btih:") != 0) return torrent_handle(); + + sha1_hash info_hash(base32decode(btih->substr(9))); + + if (!tracker.empty()) p.tracker_url = tracker.c_str(); + p.info_hash = info_hash; + if (!name.empty()) p.name = name.c_str(); + return ses.add_torrent(p); + } } diff --git a/libtorrent/src/session.cpp b/libtorrent/src/session.cpp index 5e0ad1205..3c65d02b5 100755 --- a/libtorrent/src/session.cpp +++ b/libtorrent/src/session.cpp @@ -244,6 +244,7 @@ namespace libtorrent return m_impl->add_torrent(params); } +#ifndef TORRENT_NO_DEPRECATE // if the torrent already exists, this will throw duplicate_torrent torrent_handle session::add_torrent( torrent_info const& ti @@ -311,6 +312,7 @@ namespace libtorrent p.userdata = userdata; return m_impl->add_torrent(p); } +#endif void session::remove_torrent(const torrent_handle& h, int options) { @@ -518,6 +520,7 @@ namespace libtorrent m_impl->set_alert_mask(m); } +#ifndef TORRENT_NO_DEPRECATE void session::set_severity_level(alert::severity_t s) { int m = 0; @@ -535,6 +538,7 @@ namespace libtorrent m_impl->set_alert_mask(m); } +#endif void session::start_lsd() { diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 66a0b0797..a7eb485e3 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -962,9 +962,9 @@ namespace libtorrent m_complete_sent = true; m_failed_trackers = 0; - // announce intervals less than 5 minutes - // are insane. - if (interval < 60 * 5) interval = 60 * 5; + + if (interval < m_ses.settings().min_announce_interval) + interval = m_ses.settings().min_announce_interval; m_last_working_tracker = prioritize_tracker(m_currently_trying_tracker); @@ -1016,17 +1016,6 @@ namespace libtorrent } else { - if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked) - { -#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - debug_log("blocked ip from tracker: " + i->ip); -#endif - if (m_ses.m_alerts.should_post()) - m_ses.m_alerts.post_alert(peer_blocked_alert(a.address())); - - continue; - } - m_policy.peer_from_tracker(a, i->pid, peer_info::tracker, 0); } } @@ -3272,7 +3261,7 @@ namespace libtorrent TORRENT_ASSERT(m_torrent_file->is_valid()); INVARIANT_CHECK; - set_state(torrent_status::connecting_to_tracker); + set_state(torrent_status::downloading); if (!is_seed()) { @@ -4368,11 +4357,7 @@ namespace libtorrent if (!valid_metadata()) { - if (m_got_tracker_response == false && m_connections.empty()) - st.state = torrent_status::connecting_to_tracker; - else - st.state = torrent_status::downloading_metadata; - + st.state = torrent_status::downloading_metadata; st.progress = m_progress; st.block_size = 0; return st; diff --git a/libtorrent/src/torrent_handle.cpp b/libtorrent/src/torrent_handle.cpp index e9f179e32..b1ee00296 100755 --- a/libtorrent/src/torrent_handle.cpp +++ b/libtorrent/src/torrent_handle.cpp @@ -332,11 +332,13 @@ namespace libtorrent TORRENT_FORWARD(set_tracker_login(name, password)); } +#ifndef TORRENT_NO_DEPRECATE void torrent_handle::file_progress(std::vector& progress) const { INVARIANT_CHECK; TORRENT_FORWARD(file_progress(progress)); } +#endif void torrent_handle::file_progress(std::vector& progress) const { @@ -426,6 +428,7 @@ namespace libtorrent return ret; } +#ifndef TORRENT_NO_DEPRECATE // ============ start deprecation =============== void torrent_handle::filter_piece(int index, bool filter) const @@ -461,7 +464,7 @@ namespace libtorrent } // ============ end deprecation =============== - +#endif std::vector const& torrent_handle::trackers() const { @@ -525,6 +528,7 @@ namespace libtorrent return !m_torrent.expired(); } +#ifndef TORRENT_NO_DEPRECATE entry torrent_handle::write_resume_data() const { INVARIANT_CHECK; @@ -535,7 +539,7 @@ namespace libtorrent return ret; } - +#endif fs::path torrent_handle::save_path() const { diff --git a/libtorrent/src/torrent_info.cpp b/libtorrent/src/torrent_info.cpp index 03dc235d6..0c3e0fe5d 100755 --- a/libtorrent/src/torrent_info.cpp +++ b/libtorrent/src/torrent_info.cpp @@ -227,6 +227,7 @@ namespace libtorrent return 0; } +#ifndef TORRENT_NO_DEPRECATE // standard constructor that parses a torrent file torrent_info::torrent_info(entry const& torrent_file) : m_creation_date(pt::ptime(pt::not_a_date_time)) @@ -249,6 +250,7 @@ namespace libtorrent parse_torrent_file(e, error); #endif } +#endif torrent_info::torrent_info(lazy_entry const& torrent_file) : m_creation_date(pt::ptime(pt::not_a_date_time)) @@ -583,6 +585,7 @@ namespace libtorrent , bind(&announce_entry::tier, _1), bind(&announce_entry::tier, _2))); } +#ifndef TORRENT_NO_DEPRECATE // ------- start deprecation ------- void torrent_info::print(std::ostream& os) const @@ -606,6 +609,7 @@ namespace libtorrent } // ------- end deprecation ------- +#endif }