*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-09-10 00:47:30 +00:00
parent 29cb9e8969
commit b2150236b0
10 changed files with 201 additions and 47 deletions

View File

@ -59,61 +59,63 @@
<li><a class="reference" href="#info-hash" id="id52" name="id52">info_hash()</a></li>
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id53" name="id53">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#write-resume-data" id="id54" name="id54">write_resume_data()</a></li>
<li><a class="reference" href="#id11" id="id55" name="id55">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id56" name="id56">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id57" name="id57">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id58" name="id58">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id59" name="id59">is_valid()</a></li>
<li><a class="reference" href="#metadata" id="id55" name="id55">metadata()</a></li>
<li><a class="reference" href="#id11" id="id56" name="id56">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id57" name="id57">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id58" name="id58">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id59" name="id59">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id60" name="id60">is_valid()</a></li>
</ul>
</li>
<li><a class="reference" href="#torrent-status" id="id60" name="id60">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id61" name="id61">peer_info</a></li>
<li><a class="reference" href="#address" id="id62" name="id62">address</a></li>
<li><a class="reference" href="#http-settings" id="id63" name="id63">http_settings</a></li>
<li><a class="reference" href="#big-number" id="id64" name="id64">big_number</a></li>
<li><a class="reference" href="#hasher" id="id65" name="id65">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id66" name="id66">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id67" name="id67">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id68" name="id68">identify_client()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id69" name="id69">bdecode() bencode()</a></li>
<li><a class="reference" href="#torrent-status" id="id61" name="id61">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id62" name="id62">peer_info</a></li>
<li><a class="reference" href="#address" id="id63" name="id63">address</a></li>
<li><a class="reference" href="#http-settings" id="id64" name="id64">http_settings</a></li>
<li><a class="reference" href="#big-number" id="id65" name="id65">big_number</a></li>
<li><a class="reference" href="#hasher" id="id66" name="id66">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id67" name="id67">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id68" name="id68">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id69" name="id69">identify_client()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id70" name="id70">bdecode() bencode()</a></li>
</ul>
</li>
<li><a class="reference" href="#alerts" id="id70" name="id70">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id71" name="id71">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id72" name="id72">file_error_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id73" name="id73">tracker_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id74" name="id74">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id75" name="id75">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id76" name="id76">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id77" name="id77">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id78" name="id78">torrent_finished_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id79" name="id79">dispatcher</a></li>
<li><a class="reference" href="#alerts" id="id71" name="id71">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id72" name="id72">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id73" name="id73">file_error_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id74" name="id74">tracker_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id75" name="id75">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id76" name="id76">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id77" name="id77">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id78" name="id78">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id79" name="id79">torrent_finished_alert</a></li>
<li><a class="reference" href="#metadata-received-alert" id="id80" name="id80">metadata_received_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id81" name="id81">dispatcher</a></li>
</ul>
</li>
<li><a class="reference" href="#exceptions" id="id80" name="id80">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id81" name="id81">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id82" name="id82">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id83" name="id83">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id84" name="id84">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id85" name="id85">invalid_torrent_file</a></li>
<li><a class="reference" href="#exceptions" id="id82" name="id82">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id83" name="id83">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id84" name="id84">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id85" name="id85">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id86" name="id86">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id87" name="id87">invalid_torrent_file</a></li>
</ul>
</li>
<li><a class="reference" href="#examples" id="id86" name="id86">examples</a><ul>
<li><a class="reference" href="#dump-torrent" id="id87" name="id87">dump_torrent</a></li>
<li><a class="reference" href="#simple-client" id="id88" name="id88">simple client</a></li>
<li><a class="reference" href="#examples" id="id88" name="id88">examples</a><ul>
<li><a class="reference" href="#dump-torrent" id="id89" name="id89">dump_torrent</a></li>
<li><a class="reference" href="#simple-client" id="id90" name="id90">simple client</a></li>
</ul>
</li>
<li><a class="reference" href="#fast-resume" id="id89" name="id89">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id90" name="id90">file format</a></li>
<li><a class="reference" href="#fast-resume" id="id91" name="id91">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id92" name="id92">file format</a></li>
</ul>
</li>
<li><a class="reference" href="#extensions" id="id91" name="id91">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id92" name="id92">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id93" name="id93">metadata from peers</a></li>
<li><a class="reference" href="#extensions" id="id93" name="id93">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id94" name="id94">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id95" name="id95">metadata from peers</a></li>
</ul>
</li>
<li><a class="reference" href="#filename-checks" id="id94" name="id94">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id95" name="id95">aknowledgements</a></li>
<li><a class="reference" href="#filename-checks" id="id96" name="id96">filename checks</a></li>
<li><a class="reference" href="#aknowledgements" id="id97" name="id97">aknowledgements</a></li>
</ul>
</div>
<div class="section" id="introduction">
@ -805,6 +807,7 @@ struct torrent_handle
bool is_valid();
entry write_resume_data();
std::vector&lt;char&gt; const&amp; metadata() const;
void force_reannounce();
void connect_peer(address const&amp; adr) const;
@ -822,6 +825,8 @@ struct torrent_handle
bool is_paused() const;
bool is_seed() const;
bool has_metadata() const;
boost::filsystem::path save_path() const;
bool move_storage(boost::filesystem::path const&amp; save_path);
@ -935,6 +940,16 @@ bool is_seed() const;
</pre>
</blockquote>
<p>Returns true if the torrent is in seed mode (i.e. if it has finished downloading).</p>
<p>has_metadata()</p>
<blockquote>
<pre class="literal-block">
bool has_metadata() const;
</pre>
</blockquote>
<p>Returns true if this torrent has metadata (either it was started from a .torrent file or the
metadata has been downloaded). The only scenario where this can return false is when the torrent
was started torrent-less (i.e. with just an info-hash and tracker ip). Note that if the torrent
doesn't have metadata, the member <a class="reference" href="#get-torrent-info">get_torrent_info()</a> will throw.</p>
</div>
<div class="section" id="set-tracker-login">
<h2><a name="set-tracker-login">set_tracker_login()</a></h2>
@ -995,6 +1010,17 @@ It may throw <a class="reference" href="#invalid-handle">invalid_handle</a> if t
is still downloading! The recommended practice is to first pause the torrent, then generate the
fast resume data, and then close it down.</p>
</div>
<div class="section" id="metadata">
<h2><a name="metadata">metadata()</a></h2>
<blockquote>
<pre class="literal-block">
std::vector&lt;char&gt; const&amp; metadata() const;
</pre>
</blockquote>
<p><tt class="literal"><span class="pre">metadata()</span></tt> will return a reference to a buffer containing the exact info part of the
.torrent file. This buffer will be valid as long as the torrent is still running. When hashed,
it will produce the same hash as the info-hash.</p>
</div>
<div class="section" id="id11">
<h2><a name="id11">status()</a></h2>
<blockquote>
@ -1064,7 +1090,10 @@ torrent_info const&amp; get_torrent_info();
</blockquote>
<p>Returns a const reference to the <a class="reference" href="#torrent-info">torrent_info</a> object associated with this torrent.
This reference is valid as long as the <a class="reference" href="#torrent-handle">torrent_handle</a> is valid, no longer. If the
<a class="reference" href="#torrent-handle">torrent_handle</a> is invalid, <a class="reference" href="#invalid-handle">invalid_handle</a> exception will be thrown.</p>
<a class="reference" href="#torrent-handle">torrent_handle</a> is invalid or if it doesn't have any metadata, <a class="reference" href="#invalid-handle">invalid_handle</a>
exception will be thrown. The torrent may be in a state without metadata only if
it was started without a .torrent file, i.e. by using the libtorrent extension of
just supplying a tracker and info-hash.</p>
</div>
<div class="section" id="is-valid">
<h2><a name="is-valid">is_valid()</a></h2>
@ -1786,6 +1815,25 @@ struct torrent_finished_alert: alert
torrent_handle handle;
};
</pre>
</div>
<div class="section" id="metadata-received-alert">
<h2><a name="metadata-received-alert">metadata_received_alert</a></h2>
<p>This alert is generated when the metadata has been completely received and the torrent
can start downloading. It is not generated on torrents that are started with metadata, bu
only those that needs to download it from peers (when utilizing the libtorrent extension).
It is generated at severity level <tt class="literal"><span class="pre">info</span></tt>.</p>
<pre class="literal-block">
struct metadata_received_alert: alert
{
metadata_received_alert(
const torrent_handle&amp; h
, const std::string&amp; msg);
virtual std::auto_ptr&lt;alert&gt; clone() const;
torrent_handle handle;
};
</pre>
<!-- chat_message_alert
- - - - - - - - - - - - - - - - - -

View File

@ -750,6 +750,7 @@ Its declaration looks like this::
bool is_valid();
entry write_resume_data();
std::vector<char> const& metadata() const;
void force_reannounce();
void connect_peer(address const& adr) const;
@ -767,6 +768,8 @@ Its declaration looks like this::
bool is_paused() const;
bool is_seed() const;
bool has_metadata() const;
boost::filsystem::path save_path() const;
bool move_storage(boost::filesystem::path const& save_path);
@ -889,6 +892,16 @@ is_seed()
Returns true if the torrent is in seed mode (i.e. if it has finished downloading).
has_metadata()
::
bool has_metadata() const;
Returns true if this torrent has metadata (either it was started from a .torrent file or the
metadata has been downloaded). The only scenario where this can return false is when the torrent
was started torrent-less (i.e. with just an info-hash and tracker ip). Note that if the torrent
doesn't have metadata, the member `get_torrent_info()`_ will throw.
set_tracker_login()
-------------------
@ -956,6 +969,18 @@ is still downloading! The recommended practice is to first pause the torrent, th
fast resume data, and then close it down.
metadata()
-------------------
::
std::vector<char> const& metadata() const;
``metadata()`` will return a reference to a buffer containing the exact info part of the
.torrent file. This buffer will be valid as long as the torrent is still running. When hashed,
it will produce the same hash as the info-hash.
status()
--------
@ -1030,7 +1055,10 @@ get_torrent_info()
Returns a const reference to the torrent_info_ object associated with this torrent.
This reference is valid as long as the torrent_handle_ is valid, no longer. If the
torrent_handle_ is invalid, invalid_handle_ exception will be thrown.
torrent_handle_ is invalid or if it doesn't have any metadata, invalid_handle_
exception will be thrown. The torrent may be in a state without metadata only if
it was started without a .torrent file, i.e. by using the libtorrent extension of
just supplying a tracker and info-hash.
is_valid()
@ -1822,6 +1850,28 @@ torrent in question. This alert is generated as severity level ``info``.
torrent_handle handle;
};
metadata_received_alert
-----------------------
This alert is generated when the metadata has been completely received and the torrent
can start downloading. It is not generated on torrents that are started with metadata, bu
only those that needs to download it from peers (when utilizing the libtorrent extension).
It is generated at severity level ``info``.
::
struct metadata_received_alert: alert
{
metadata_received_alert(
const torrent_handle& h
, const std::string& msg);
virtual std::auto_ptr<alert> clone() const;
torrent_handle handle;
};
.. chat_message_alert
------------------

View File

@ -175,6 +175,21 @@ namespace libtorrent
torrent_handle handle;
};
struct metadata_received_alert: alert
{
metadata_received_alert(
const torrent_handle& h
, const std::string& msg)
: alert(alert::info, msg)
, handle(h)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new metadata_received_alert(*this)); }
torrent_handle handle;
};
struct listen_failed_alert: alert
{
listen_failed_alert(

View File

@ -93,6 +93,10 @@ namespace libtorrent
struct invalid_encoding: std::exception
{
invalid_encoding()
{
int i = 0;
}
virtual const char* what() const throw() { return "invalid bencoding"; }
};

View File

@ -36,6 +36,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cassert>
#include <boost/cstdint.hpp>
#include "libtorrent/peer_id.hpp"
// from sha1.cpp
struct SHA1_CTX
{

View File

@ -183,6 +183,7 @@ namespace libtorrent
torrent_status status() const;
void get_download_queue(std::vector<partial_piece_info>& queue) const;
bool has_metadata() const;
const torrent_info& get_torrent_info() const;
bool is_valid() const;
@ -195,10 +196,16 @@ namespace libtorrent
// to.
void use_interface(const char* net_interface);
// TODO: there must be a way to get resume data and
// shut down the torrent in one atomic operation
entry write_resume_data() const;
// kind of similar to get_torrent_info() but this
// is low level, returning the exact info-part of
// the .torrent file. This when hashed, this buffer
// will produce the same hash as the info hash.
// the reference is valid only as long as the torrent
// is running.
std::vector<char> const& metadata() const;
// forces this torrent to reannounce
// (make a rerequest from the tracker)
void force_reannounce() const;

View File

@ -86,7 +86,10 @@ namespace libtorrent
public:
torrent_info(const entry& torrent_file);
torrent_info(int piece_size, const char* name, sha1_hash const& info_hash = sha1_hash(0));
torrent_info(
int piece_size
, const char* name
, sha1_hash const& info_hash = sha1_hash(0));
entry create_torrent() const;
entry create_info_metadata() const;

View File

@ -111,7 +111,7 @@ namespace libtorrent
, access_mask
, FILE_SHARE_READ
, 0
, OPEN_ALWAYS
, (flags & read_flag)?OPEN_EXISTING:OPEN_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, 0);

View File

@ -1009,8 +1009,16 @@ namespace libtorrent
detail::piece_checker_data d;
d.abort = false;
// TODO: this check should be moved to the checker thread
// not really a high priority, since no files would usually
// be available if the metadata wasn't available.
check_files(d, m);
if (m_ses.m_alerts.should_post(alert::info))
{
m_ses.m_alerts.post_alert(metadata_received_alert(
get_handle(), "metadata successfully received from swarm"));
}
// all peer connections have to initialize themselves now that the metadata
// is available
for (std::map<address, peer_connection*>::iterator i = m_connections.begin();

View File

@ -230,6 +230,14 @@ namespace libtorrent
, boost::bind(&torrent::move_storage, _1, save_path));
}
bool torrent_handle::has_metadata() const
{
INVARIANT_CHECK;
return call_member<bool>(m_ses, m_chk, m_info_hash
, boost::bind(&torrent::valid_metadata, _1));
}
bool torrent_handle::is_seed() const
{
INVARIANT_CHECK;
@ -309,6 +317,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
if (!has_metadata()) throw invalid_handle();
return call_member<torrent_info const&>(m_ses, m_chk, m_info_hash
, boost::bind(&torrent::torrent_file, _1));
}
@ -461,6 +470,14 @@ namespace libtorrent
, boost::bind(&torrent::save_path, _1));
}
std::vector<char> const& torrent_handle::metadata() const
{
INVARIANT_CHECK;
return call_member<std::vector<char> const&>(m_ses, m_chk, m_info_hash
, boost::bind(&torrent::metadata, _1));
}
void torrent_handle::connect_peer(const address& adr) const
{
INVARIANT_CHECK;