introduced TORRENT_NO_DEPRECATE, to disable deprecated functions. Made example not use deprecated functions. Documented magnet uri related functions.

This commit is contained in:
Arvid Norberg
2008-08-03 15:14:08 +00:00
parent 18b14e56df
commit cbf8e6f3b1
16 changed files with 351 additions and 180 deletions

View File

@@ -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<std::string> display_name = url_has_argument(uri, "dn");
if (display_name) name = unescape_string(display_name->c_str());
boost::optional<std::string> tracker_string = url_has_argument(uri, "tr");
if (tracker_string) tracker = unescape_string(tracker_string->c_str());
boost::optional<std::string> 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);
}
}

View File

@@ -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()
{

View File

@@ -332,11 +332,13 @@ namespace libtorrent
TORRENT_FORWARD(set_tracker_login(name, password));
}
#ifndef TORRENT_NO_DEPRECATE
void torrent_handle::file_progress(std::vector<float>& progress) const
{
INVARIANT_CHECK;
TORRENT_FORWARD(file_progress(progress));
}
#endif
void torrent_handle::file_progress(std::vector<size_type>& 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<announce_entry> 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
{

View File

@@ -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
}