added url seed related functions to torrent_handle

This commit is contained in:
Arvid Norberg 2007-08-17 16:40:55 +00:00
parent 3d3df51d45
commit c70223ff38
4 changed files with 36 additions and 8 deletions

View File

@ -1090,8 +1090,8 @@ The input range is assumed to be valid within the torrent. ``file_offset``
must refer to a valid file, i.e. it cannot be >= ``num_files()``.
url_seeds()
-----------
url_seeds() add_url_seed()
--------------------------
::
@ -1266,6 +1266,8 @@ Its declaration looks like this::
void replace_trackers(std::vector<announce_entry> const&);
void add_url_seed(std::string const& url);
void remove_url_seed(std::string const& url);
std::set<std::string> url_seeds() const;
void set_ratio(float ratio) const;
void set_max_uploads(int max_uploads) const;
@ -1601,17 +1603,22 @@ replace it. If you want an immediate effect, you have to call
`force_reannounce()`_.
add_url_seed()
--------------
add_url_seed() remove_url_seed() url_seeds()
--------------------------------------------
::
void add_url_seed(std::string const& url);
void remove_url_seed(std::string const& url);
std::set<std::string> url_seeds() const;
``add_url_seed()`` adds another url to the torrent's list of url seeds. If the
given url already exists in that list, the call has no effect. The torrent
will connect to the server and try to download pieces from it, unless it's
paused, queued, checking or seeding.
paused, queued, checking or seeding. ``remove_url_seed()`` removes the given
url if it exists already. ``url_seeds()`` return a set of the url seeds
currently in this torrent. Note that urls that fails may be removed
automatically from the list.
See `HTTP seeding`_ for more information.

View File

@ -249,6 +249,8 @@ namespace libtorrent
void remove_url_seed(std::string const& url)
{ m_web_seeds.erase(url); }
std::set<std::string> url_seeds() const
{ return m_web_seeds; }
bool free_upload_slots() const
{ return m_num_uploads < m_max_uploads; }

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_TORRENT_HANDLE_HPP_INCLUDED
#include <vector>
#include <set>
#ifdef _MSC_VER
#pragma warning(push, 1)
@ -273,7 +274,9 @@ namespace libtorrent
std::vector<announce_entry> const& trackers() const;
void replace_trackers(std::vector<announce_entry> const&) const;
void add_url_seed(std::string const& url);
void add_url_seed(std::string const& url) const;
void remove_url_seed(std::string const& url) const;
std::set<std::string> url_seeds() const;
bool has_metadata() const;
const torrent_info& get_torrent_info() const;

View File

@ -453,14 +453,30 @@ namespace libtorrent
, m_chk, m_info_hash, bind(&torrent::trackers, _1));
}
void torrent_handle::add_url_seed(std::string const& url)
void torrent_handle::add_url_seed(std::string const& url) const
{
INVARIANT_CHECK;
return call_member<void>(m_ses, m_chk, m_info_hash
call_member<void>(m_ses, m_chk, m_info_hash
, bind(&torrent::add_url_seed, _1, url));
}
void torrent_handle::remove_url_seed(std::string const& url) const
{
INVARIANT_CHECK;
call_member<void>(m_ses, m_chk, m_info_hash
, bind(&torrent::remove_url_seed, _1, url));
}
std::set<std::string> torrent_handle::url_seeds() const
{
INVARIANT_CHECK;
return call_member<std::set<std::string> >(m_ses, m_chk, m_info_hash
, bind(&torrent::url_seeds, _1));
}
void torrent_handle::replace_trackers(
std::vector<announce_entry> const& urls) const
{