2003-10-26 18:35:23 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 2003, Arvid Norberg
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TORRENT_TORRENT_HANDLE_HPP_INCLUDED
|
|
|
|
#define TORRENT_TORRENT_HANDLE_HPP_INCLUDED
|
|
|
|
|
|
|
|
#include <vector>
|
2007-08-17 18:40:55 +02:00
|
|
|
#include <set>
|
2004-01-25 19:18:36 +01:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push, 1)
|
|
|
|
#endif
|
|
|
|
|
2007-04-10 11:11:32 +02:00
|
|
|
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
2003-10-26 18:35:23 +01:00
|
|
|
|
2004-01-25 19:18:36 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2003-10-26 18:35:23 +01:00
|
|
|
#include "libtorrent/peer_id.hpp"
|
|
|
|
#include "libtorrent/peer_info.hpp"
|
2003-11-02 22:06:50 +01:00
|
|
|
#include "libtorrent/piece_picker.hpp"
|
2003-11-28 18:29:27 +01:00
|
|
|
#include "libtorrent/torrent_info.hpp"
|
2007-04-05 00:27:36 +02:00
|
|
|
#include "libtorrent/time.hpp"
|
2005-11-01 19:30:39 +01:00
|
|
|
#include "libtorrent/config.hpp"
|
2007-10-08 22:01:36 +02:00
|
|
|
#include "libtorrent/storage.hpp"
|
2003-10-26 18:35:23 +01:00
|
|
|
|
|
|
|
namespace libtorrent
|
|
|
|
{
|
2007-06-10 22:46:09 +02:00
|
|
|
namespace fs = boost::filesystem;
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
namespace aux
|
2003-10-26 18:35:23 +01:00
|
|
|
{
|
|
|
|
struct session_impl;
|
2003-10-31 05:02:51 +01:00
|
|
|
struct checker_impl;
|
2003-10-26 18:35:23 +01:00
|
|
|
}
|
|
|
|
|
2007-11-08 02:45:35 +01:00
|
|
|
struct torrent_plugin;
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
struct TORRENT_EXPORT duplicate_torrent: std::exception
|
2003-11-02 22:06:50 +01:00
|
|
|
{
|
2003-11-05 00:27:06 +01:00
|
|
|
virtual const char* what() const throw()
|
|
|
|
{ return "torrent already exists in session"; }
|
2003-11-02 22:06:50 +01:00
|
|
|
};
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
struct TORRENT_EXPORT invalid_handle: std::exception
|
2003-11-28 18:29:27 +01:00
|
|
|
{
|
|
|
|
virtual const char* what() const throw()
|
|
|
|
{ return "invalid torrent handle used"; }
|
|
|
|
};
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
struct TORRENT_EXPORT torrent_status
|
2003-10-26 18:35:23 +01:00
|
|
|
{
|
2003-12-22 08:14:35 +01:00
|
|
|
torrent_status()
|
|
|
|
: state(queued_for_checking)
|
2004-03-22 15:56:32 +01:00
|
|
|
, paused(false)
|
2003-12-22 08:14:35 +01:00
|
|
|
, progress(0.f)
|
|
|
|
, total_download(0)
|
|
|
|
, total_upload(0)
|
|
|
|
, total_payload_download(0)
|
|
|
|
, total_payload_upload(0)
|
2006-04-25 23:04:48 +02:00
|
|
|
, total_failed_bytes(0)
|
|
|
|
, total_redundant_bytes(0)
|
2003-12-22 08:14:35 +01:00
|
|
|
, download_rate(0)
|
|
|
|
, upload_rate(0)
|
2004-11-30 12:17:32 +01:00
|
|
|
, download_payload_rate(0)
|
|
|
|
, upload_payload_rate(0)
|
2007-11-20 23:46:27 +01:00
|
|
|
, num_seeds(0)
|
2004-01-15 02:01:09 +01:00
|
|
|
, num_peers(0)
|
2005-02-23 21:38:29 +01:00
|
|
|
, num_complete(-1)
|
|
|
|
, num_incomplete(-1)
|
2007-11-20 23:46:27 +01:00
|
|
|
, list_seeds(0)
|
|
|
|
, list_peers(0)
|
2006-04-25 23:04:48 +02:00
|
|
|
, num_pieces(0)
|
2003-12-22 08:14:35 +01:00
|
|
|
, total_done(0)
|
2005-05-30 19:43:03 +02:00
|
|
|
, total_wanted_done(0)
|
|
|
|
, total_wanted(0)
|
2004-08-05 15:56:26 +02:00
|
|
|
, distributed_copies(0.f)
|
2004-08-11 19:22:58 +02:00
|
|
|
, block_size(0)
|
2007-07-17 08:39:39 +02:00
|
|
|
, num_uploads(0)
|
|
|
|
, num_connections(0)
|
|
|
|
, uploads_limit(0)
|
|
|
|
, connections_limit(0)
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode(storage_mode_sparse)
|
2008-01-17 18:40:46 +01:00
|
|
|
, up_bandwidth_queue(0)
|
|
|
|
, down_bandwidth_queue(0)
|
2008-04-16 08:31:05 +02:00
|
|
|
, all_time_upload(0)
|
|
|
|
, all_time_download(0)
|
|
|
|
, active_time(0)
|
|
|
|
, seeding_time(0)
|
2008-05-06 20:03:41 +02:00
|
|
|
, seed_rank(0)
|
2008-05-19 06:06:25 +02:00
|
|
|
, last_scrape(0)
|
2008-06-05 20:19:03 +02:00
|
|
|
, has_incoming(false)
|
2003-12-22 08:14:35 +01:00
|
|
|
{}
|
|
|
|
|
2003-10-26 18:35:23 +01:00
|
|
|
enum state_t
|
|
|
|
{
|
2003-10-31 05:02:51 +01:00
|
|
|
queued_for_checking,
|
2003-10-26 18:35:23 +01:00
|
|
|
checking_files,
|
2007-11-24 05:19:21 +01:00
|
|
|
downloading_metadata,
|
2003-10-26 18:35:23 +01:00
|
|
|
downloading,
|
2005-05-30 19:43:03 +02:00
|
|
|
finished,
|
2005-10-17 15:45:53 +02:00
|
|
|
seeding,
|
|
|
|
allocating
|
2003-10-26 18:35:23 +01:00
|
|
|
};
|
2003-10-31 05:02:51 +01:00
|
|
|
|
|
|
|
state_t state;
|
2004-03-21 03:03:37 +01:00
|
|
|
bool paused;
|
2003-10-31 05:02:51 +01:00
|
|
|
float progress;
|
2008-05-20 09:57:44 +02:00
|
|
|
std::string error;
|
|
|
|
|
2003-11-05 00:27:06 +01:00
|
|
|
boost::posix_time::time_duration next_announce;
|
2004-01-17 21:04:19 +01:00
|
|
|
boost::posix_time::time_duration announce_interval;
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
std::string current_tracker;
|
2003-11-20 20:58:29 +01:00
|
|
|
|
|
|
|
// transferred this session!
|
2003-12-22 08:14:35 +01:00
|
|
|
// total, payload plus protocol
|
2004-01-15 17:45:34 +01:00
|
|
|
size_type total_download;
|
|
|
|
size_type total_upload;
|
2003-12-22 08:14:35 +01:00
|
|
|
|
|
|
|
// payload only
|
2004-01-15 17:45:34 +01:00
|
|
|
size_type total_payload_download;
|
|
|
|
size_type total_payload_upload;
|
2003-12-22 08:14:35 +01:00
|
|
|
|
2004-04-18 14:28:02 +02:00
|
|
|
// the amount of payload bytes that
|
|
|
|
// has failed their hash test
|
|
|
|
size_type total_failed_bytes;
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
// the number of payload bytes that
|
|
|
|
// has been received redundantly.
|
|
|
|
size_type total_redundant_bytes;
|
|
|
|
|
2003-12-22 08:14:35 +01:00
|
|
|
// current transfer rate
|
|
|
|
// payload plus protocol
|
2003-12-07 06:53:04 +01:00
|
|
|
float download_rate;
|
|
|
|
float upload_rate;
|
2003-12-22 08:14:35 +01:00
|
|
|
|
2004-04-18 14:28:02 +02:00
|
|
|
// the rate of payload that is
|
|
|
|
// sent and received
|
|
|
|
float download_payload_rate;
|
|
|
|
float upload_payload_rate;
|
|
|
|
|
2007-11-20 23:46:27 +01:00
|
|
|
// the number of peers this torrent is connected to
|
|
|
|
// that are seeding.
|
|
|
|
int num_seeds;
|
|
|
|
|
2004-01-15 02:01:09 +01:00
|
|
|
// the number of peers this torrent
|
2007-11-20 23:46:27 +01:00
|
|
|
// is connected to (including seeds).
|
2004-01-15 02:01:09 +01:00
|
|
|
int num_peers;
|
|
|
|
|
2005-02-23 21:38:29 +01:00
|
|
|
// if the tracker sends scrape info in its
|
|
|
|
// announce reply, these fields will be
|
|
|
|
// set to the total number of peers that
|
|
|
|
// have the whole file and the total number
|
|
|
|
// of peers that are still downloading
|
|
|
|
int num_complete;
|
|
|
|
int num_incomplete;
|
|
|
|
|
2007-11-20 23:46:27 +01:00
|
|
|
// this is the number of seeds whose IP we know
|
|
|
|
// but are not necessarily connected to
|
|
|
|
int list_seeds;
|
|
|
|
|
|
|
|
// this is the number of peers whose IP we know
|
|
|
|
// (including seeds), but are not necessarily
|
|
|
|
// connected to
|
|
|
|
int list_peers;
|
2008-03-29 19:47:24 +01:00
|
|
|
|
|
|
|
// the number of peers in our peerlist that
|
|
|
|
// we potentially could connect to
|
|
|
|
int connect_candidates;
|
2007-11-20 23:46:27 +01:00
|
|
|
|
2008-06-07 04:58:28 +02:00
|
|
|
bitfield pieces;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
// this is the number of pieces the client has
|
|
|
|
// downloaded. it is equal to:
|
|
|
|
// std::accumulate(pieces->begin(), pieces->end());
|
|
|
|
int num_pieces;
|
2003-11-20 20:58:29 +01:00
|
|
|
|
|
|
|
// the number of bytes of the file we have
|
2005-05-30 19:43:03 +02:00
|
|
|
// including pieces that may have been filtered
|
|
|
|
// after we downloaded them
|
2004-01-15 17:45:34 +01:00
|
|
|
size_type total_done;
|
2004-08-05 15:56:26 +02:00
|
|
|
|
2005-05-30 19:43:03 +02:00
|
|
|
// the number of bytes we have of those that we
|
|
|
|
// want. i.e. not counting bytes from pieces that
|
|
|
|
// are filtered as not wanted.
|
|
|
|
size_type total_wanted_done;
|
|
|
|
|
|
|
|
// the total number of bytes we want to download
|
|
|
|
// this may be smaller than the total torrent size
|
|
|
|
// in case any pieces are filtered as not wanted
|
|
|
|
size_type total_wanted;
|
|
|
|
|
2004-08-05 15:56:26 +02:00
|
|
|
// the number of distributed copies of the file.
|
|
|
|
// note that one copy may be spread out among many peers.
|
|
|
|
//
|
2007-03-20 02:59:00 +01:00
|
|
|
// the integer part tells how many copies
|
2004-08-05 15:56:26 +02:00
|
|
|
// there are of the rarest piece(s)
|
|
|
|
//
|
|
|
|
// the fractional part tells the fraction of pieces that
|
|
|
|
// have more copies than the rarest piece(s).
|
|
|
|
float distributed_copies;
|
2004-08-11 19:22:58 +02:00
|
|
|
|
|
|
|
// the block size that is used in this torrent. i.e.
|
|
|
|
// the number of bytes each piece request asks for
|
|
|
|
// and each bit in the download queue bitfield represents
|
|
|
|
int block_size;
|
2007-07-17 08:39:39 +02:00
|
|
|
|
|
|
|
int num_uploads;
|
|
|
|
int num_connections;
|
|
|
|
int uploads_limit;
|
|
|
|
int connections_limit;
|
2007-07-23 06:36:56 +02:00
|
|
|
|
|
|
|
// true if the torrent is saved in compact mode
|
|
|
|
// false if it is saved in full allocation mode
|
2007-10-08 22:01:36 +02:00
|
|
|
storage_mode_t storage_mode;
|
2008-01-17 18:40:46 +01:00
|
|
|
|
|
|
|
int up_bandwidth_queue;
|
|
|
|
int down_bandwidth_queue;
|
2008-04-16 08:31:05 +02:00
|
|
|
|
|
|
|
// number of bytes downloaded since torrent was started
|
|
|
|
// saved and restored from resume data
|
|
|
|
size_type all_time_upload;
|
|
|
|
size_type all_time_download;
|
|
|
|
|
|
|
|
// the number of seconds of being active
|
|
|
|
// and as being a seed, saved and restored
|
|
|
|
// from resume data
|
|
|
|
int active_time;
|
|
|
|
int seeding_time;
|
2008-04-24 05:28:48 +02:00
|
|
|
|
2008-05-06 20:03:41 +02:00
|
|
|
// higher value means more important to seed
|
|
|
|
int seed_rank;
|
2008-05-19 06:06:25 +02:00
|
|
|
|
|
|
|
// number of seconds since last scrape, or -1 if
|
|
|
|
// there hasn't been a scrape
|
|
|
|
int last_scrape;
|
2008-06-05 20:19:03 +02:00
|
|
|
|
|
|
|
// true if there are incoming connections to this
|
|
|
|
// torrent
|
|
|
|
bool has_incoming;
|
2003-10-31 05:02:51 +01:00
|
|
|
};
|
2003-10-26 18:35:23 +01:00
|
|
|
|
2007-06-10 22:46:09 +02:00
|
|
|
struct TORRENT_EXPORT block_info
|
|
|
|
{
|
|
|
|
enum block_state_t
|
|
|
|
{ none, requested, writing, finished };
|
|
|
|
|
|
|
|
tcp::endpoint peer;
|
2007-07-08 22:45:42 +02:00
|
|
|
// number of bytes downloaded in this block
|
|
|
|
unsigned bytes_progress:16;
|
|
|
|
// the total number of bytes in this block
|
|
|
|
unsigned block_size:16;
|
|
|
|
// the state this block is in (see block_state_t)
|
2007-06-10 22:46:09 +02:00
|
|
|
unsigned state:2;
|
2007-07-08 22:45:42 +02:00
|
|
|
// the number of peers that has requested this block
|
|
|
|
// typically 0 or 1. If > 1, this block is in
|
|
|
|
// end game mode
|
2007-07-06 19:15:35 +02:00
|
|
|
unsigned num_peers:14;
|
2007-06-10 22:46:09 +02:00
|
|
|
};
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
struct TORRENT_EXPORT partial_piece_info
|
2003-11-02 22:06:50 +01:00
|
|
|
{
|
2007-05-09 02:49:13 +02:00
|
|
|
enum { max_blocks_per_piece = 256 };
|
2003-11-02 22:06:50 +01:00
|
|
|
int piece_index;
|
|
|
|
int blocks_in_piece;
|
2007-08-01 08:14:16 +02:00
|
|
|
// the number of blocks in the finished state
|
|
|
|
int finished;
|
|
|
|
// the number of blocks in the writing state
|
|
|
|
int writing;
|
|
|
|
// the number of blocks in the requested state
|
|
|
|
int requested;
|
2007-06-10 22:46:09 +02:00
|
|
|
block_info blocks[max_blocks_per_piece];
|
2007-04-27 02:27:37 +02:00
|
|
|
enum state_t { none, slow, medium, fast };
|
|
|
|
state_t piece_state;
|
2003-11-02 22:06:50 +01:00
|
|
|
};
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
struct TORRENT_EXPORT torrent_handle
|
2003-10-31 05:02:51 +01:00
|
|
|
{
|
2004-02-29 17:39:52 +01:00
|
|
|
friend class invariant_access;
|
2006-10-20 00:23:40 +02:00
|
|
|
friend struct aux::session_impl;
|
2003-12-22 08:14:35 +01:00
|
|
|
friend class torrent;
|
|
|
|
|
2008-04-09 22:09:36 +02:00
|
|
|
torrent_handle() {}
|
2003-10-31 05:02:51 +01:00
|
|
|
|
2008-04-13 08:32:48 +02:00
|
|
|
void get_full_peer_list(std::vector<peer_list_entry>& v) const;
|
2003-12-07 06:53:04 +01:00
|
|
|
void get_peer_info(std::vector<peer_info>& v) const;
|
|
|
|
torrent_status status() const;
|
|
|
|
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
2006-06-11 15:48:39 +02:00
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2006-06-11 15:48:39 +02:00
|
|
|
// 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.
|
2008-07-12 15:38:22 +02:00
|
|
|
void file_progress(std::vector<float>& progress) const TORRENT_DEPRECATED;
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2008-07-12 15:38:22 +02:00
|
|
|
void file_progress(std::vector<size_type>& progress) const;
|
2003-11-28 18:29:27 +01:00
|
|
|
|
2008-07-12 19:00:52 +02:00
|
|
|
void clear_error() const;
|
|
|
|
|
2004-09-12 12:12:16 +02:00
|
|
|
std::vector<announce_entry> const& trackers() const;
|
2005-10-19 15:58:41 +02:00
|
|
|
void replace_trackers(std::vector<announce_entry> const&) const;
|
2004-09-12 12:12:16 +02:00
|
|
|
|
2007-08-17 18:40:55 +02:00
|
|
|
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;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
2007-11-08 02:45:35 +01:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
|
|
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> const& ext
|
|
|
|
, void* userdata = 0);
|
|
|
|
#endif
|
|
|
|
|
2004-09-10 02:47:30 +02:00
|
|
|
bool has_metadata() const;
|
2003-12-07 06:53:04 +01:00
|
|
|
const torrent_info& get_torrent_info() const;
|
|
|
|
bool is_valid() const;
|
2003-11-02 22:06:50 +01:00
|
|
|
|
2004-09-08 01:16:11 +02:00
|
|
|
bool is_seed() const;
|
2008-04-13 04:15:56 +02:00
|
|
|
bool is_finished() const;
|
2004-03-21 03:03:37 +01:00
|
|
|
bool is_paused() const;
|
2005-10-19 15:58:41 +02:00
|
|
|
void pause() const;
|
|
|
|
void resume() const;
|
2008-06-07 18:24:56 +02:00
|
|
|
void force_recheck() const;
|
2008-04-13 20:54:36 +02:00
|
|
|
void save_resume_data() const;
|
2007-05-02 21:47:38 +02:00
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
bool is_auto_managed() const;
|
|
|
|
void auto_managed(bool m) const;
|
|
|
|
|
2008-05-29 05:37:19 +02:00
|
|
|
int queue_position() const;
|
|
|
|
void queue_position_up() const;
|
|
|
|
void queue_position_down() const;
|
|
|
|
void queue_position_top() const;
|
|
|
|
void queue_position_bottom() const;
|
|
|
|
|
2007-05-02 21:47:38 +02:00
|
|
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
2007-01-29 08:39:33 +01:00
|
|
|
void resolve_countries(bool r);
|
|
|
|
bool resolve_countries() const;
|
2007-05-02 21:47:38 +02:00
|
|
|
#endif
|
2004-03-21 03:03:37 +01:00
|
|
|
|
2007-03-20 02:59:00 +01:00
|
|
|
// all these are deprecated, use piece
|
|
|
|
// priority functions instead
|
|
|
|
|
|
|
|
// ================ start deprecation ============
|
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2008-04-24 05:28:48 +02:00
|
|
|
// deprecated in 0.13
|
2005-05-25 12:01:01 +02:00
|
|
|
// marks the piece with the given index as filtered
|
|
|
|
// it will not be downloaded
|
2007-08-10 18:57:37 +02:00
|
|
|
void filter_piece(int index, bool filter) const TORRENT_DEPRECATED;
|
|
|
|
void filter_pieces(std::vector<bool> const& pieces) const TORRENT_DEPRECATED;
|
|
|
|
bool is_piece_filtered(int index) const TORRENT_DEPRECATED;
|
|
|
|
std::vector<bool> filtered_pieces() const TORRENT_DEPRECATED;
|
2005-07-04 01:33:47 +02:00
|
|
|
// marks the file with the given index as filtered
|
|
|
|
// it will not be downloaded
|
2007-08-10 18:57:37 +02:00
|
|
|
void filter_files(std::vector<bool> const& files) const TORRENT_DEPRECATED;
|
2005-07-02 10:48:37 +02:00
|
|
|
|
2007-03-20 02:59:00 +01:00
|
|
|
// ================ end deprecation ============
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2007-03-20 02:59:00 +01:00
|
|
|
|
2007-05-30 08:52:59 +02:00
|
|
|
void piece_availability(std::vector<int>& avail) const;
|
|
|
|
|
2007-03-20 02:59:00 +01:00
|
|
|
// priority must be within the range [0, 7]
|
|
|
|
void piece_priority(int index, int priority) const;
|
|
|
|
int piece_priority(int index) const;
|
|
|
|
|
|
|
|
void prioritize_pieces(std::vector<int> const& pieces) const;
|
|
|
|
std::vector<int> piece_priorities() const;
|
|
|
|
|
2008-07-20 18:00:08 +02:00
|
|
|
// priority must be within the range [0, 7]
|
|
|
|
void file_priority(int index, int priority) const;
|
|
|
|
int file_priority(int index) const;
|
2007-03-20 02:59:00 +01:00
|
|
|
|
2008-07-20 18:00:08 +02:00
|
|
|
void prioritize_files(std::vector<int> const& files) const;
|
|
|
|
std::vector<int> file_priorities() const;
|
2007-03-20 02:59:00 +01:00
|
|
|
|
2004-02-26 01:27:06 +01:00
|
|
|
// set the interface to bind outgoing connections
|
|
|
|
// to.
|
2005-10-19 15:58:41 +02:00
|
|
|
void use_interface(const char* net_interface) const;
|
2004-02-26 01:27:06 +01:00
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2008-04-24 05:28:48 +02:00
|
|
|
// deprecated in 0.14
|
2008-04-13 20:54:36 +02:00
|
|
|
// use save_resume_data() instead. It is async. and
|
|
|
|
// will return the resume data in an alert
|
|
|
|
entry write_resume_data() const TORRENT_DEPRECATED;
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2004-02-25 00:55:42 +01:00
|
|
|
|
2004-01-08 18:03:04 +01:00
|
|
|
// forces this torrent to reannounce
|
|
|
|
// (make a rerequest from the tracker)
|
|
|
|
void force_reannounce() const;
|
2003-10-30 00:28:09 +01:00
|
|
|
|
2005-05-03 15:13:57 +02:00
|
|
|
// forces a reannounce in the specified amount of time.
|
|
|
|
// This overrides the default announce interval, and no
|
|
|
|
// announce will take place until the given time has
|
|
|
|
// timed out.
|
2007-04-07 05:05:59 +02:00
|
|
|
void force_reannounce(boost::posix_time::time_duration) const;
|
2005-05-03 15:13:57 +02:00
|
|
|
|
2007-11-20 23:46:27 +01:00
|
|
|
// performs a scrape request
|
|
|
|
void scrape_tracker() const;
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
// returns the name of this torrent, in case it doesn't
|
|
|
|
// have metadata it returns the name assigned to it
|
|
|
|
// when it was added.
|
|
|
|
std::string name() const;
|
|
|
|
|
2004-02-26 13:59:01 +01:00
|
|
|
// TODO: add a feature where the user can tell the torrent
|
2003-11-28 18:29:27 +01:00
|
|
|
// to finish all pieces currently in the pipeline, and then
|
|
|
|
// abort the torrent.
|
2003-10-26 18:35:23 +01:00
|
|
|
|
2005-10-19 15:58:41 +02:00
|
|
|
void set_upload_limit(int limit) const;
|
2007-04-10 11:25:17 +02:00
|
|
|
int upload_limit() const;
|
2005-10-19 15:58:41 +02:00
|
|
|
void set_download_limit(int limit) const;
|
2007-04-10 11:25:17 +02:00
|
|
|
int download_limit() const;
|
|
|
|
|
2008-01-31 18:52:29 +01:00
|
|
|
void set_sequential_download(bool sd) const;
|
2008-06-17 10:30:04 +02:00
|
|
|
bool is_sequential_download() const;
|
2004-02-01 01:50:18 +01:00
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
void set_peer_upload_limit(tcp::endpoint ip, int limit) const;
|
|
|
|
void set_peer_download_limit(tcp::endpoint ip, int limit) const;
|
|
|
|
|
2004-01-08 18:03:04 +01:00
|
|
|
// manually connect a peer
|
2007-04-10 23:23:13 +02:00
|
|
|
void connect_peer(tcp::endpoint const& adr, int source = 0) const;
|
2004-01-08 18:03:04 +01:00
|
|
|
|
2004-01-12 04:05:10 +01:00
|
|
|
// valid ratios are 0 (infinite ratio) or [ 1.0 , inf )
|
|
|
|
// the ratio is uploaded / downloaded. less than 1 is not allowed
|
2005-10-19 15:58:41 +02:00
|
|
|
void set_ratio(float up_down_ratio) const;
|
2004-01-12 04:05:10 +01:00
|
|
|
|
2007-06-10 22:46:09 +02:00
|
|
|
fs::path save_path() const;
|
2003-12-07 06:53:04 +01:00
|
|
|
|
2003-12-14 06:56:12 +01:00
|
|
|
// -1 means unlimited unchokes
|
2005-10-19 15:58:41 +02:00
|
|
|
void set_max_uploads(int max_uploads) const;
|
2003-12-14 06:56:12 +01:00
|
|
|
|
2004-01-21 01:59:38 +01:00
|
|
|
// -1 means unlimited connections
|
2005-10-19 15:58:41 +02:00
|
|
|
void set_max_connections(int max_connections) const;
|
2004-01-21 01:59:38 +01:00
|
|
|
|
2005-10-19 15:58:41 +02:00
|
|
|
void set_tracker_login(std::string const& name
|
|
|
|
, std::string const& password) const;
|
2004-02-22 23:40:45 +01:00
|
|
|
|
2004-07-18 02:39:58 +02:00
|
|
|
// post condition: save_path() == save_path if true is returned
|
2007-06-10 22:46:09 +02:00
|
|
|
void move_storage(fs::path const& save_path) const;
|
2008-05-28 10:44:40 +02:00
|
|
|
void rename_file(int index, fs::path const& new_name) const;
|
2004-07-18 02:39:58 +02:00
|
|
|
|
2008-04-09 22:09:36 +02:00
|
|
|
sha1_hash info_hash() const;
|
2003-12-07 06:53:04 +01:00
|
|
|
|
|
|
|
bool operator==(const torrent_handle& h) const
|
2008-04-09 22:09:36 +02:00
|
|
|
{ return m_torrent.lock() == h.m_torrent.lock(); }
|
2003-12-07 06:53:04 +01:00
|
|
|
|
|
|
|
bool operator!=(const torrent_handle& h) const
|
2008-04-09 22:09:36 +02:00
|
|
|
{ return m_torrent.lock() != h.m_torrent.lock(); }
|
2003-12-07 06:53:04 +01:00
|
|
|
|
|
|
|
bool operator<(const torrent_handle& h) const
|
2008-04-09 22:09:36 +02:00
|
|
|
{ return m_torrent.lock() < h.m_torrent.lock(); }
|
2003-12-07 06:53:04 +01:00
|
|
|
|
2003-11-28 18:29:27 +01:00
|
|
|
private:
|
2003-11-08 03:16:26 +01:00
|
|
|
|
2008-04-09 22:09:36 +02:00
|
|
|
torrent_handle(boost::weak_ptr<torrent> const& t)
|
|
|
|
: m_torrent(t)
|
|
|
|
{}
|
2004-02-29 17:39:52 +01:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
void check_invariant() const;
|
|
|
|
#endif
|
2003-10-26 18:35:23 +01:00
|
|
|
|
2008-04-09 22:09:36 +02:00
|
|
|
boost::weak_ptr<torrent> m_torrent;
|
2003-10-26 18:35:23 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TORRENT_TORRENT_HANDLE_HPP_INCLUDED
|
2007-05-10 00:54:26 +02:00
|
|
|
|