added url to tracker alerts. introduced a base class for all tracker alerts

This commit is contained in:
Arvid Norberg
2008-04-23 01:54:21 +00:00
parent 05c1a64c76
commit 7a432786e7
9 changed files with 168 additions and 109 deletions

View File

@@ -56,39 +56,55 @@ namespace libtorrent
struct TORRENT_EXPORT tracker_alert: torrent_alert
{
tracker_alert(torrent_handle const& h
, std::string const& url_
, alert::severity_t s
, std::string const& msg)
: torrent_alert(h, s, msg)
, url(url_)
{}
std::string url;
};
struct TORRENT_EXPORT tracker_error_alert: tracker_alert
{
tracker_error_alert(torrent_handle const& h
, int times
, int status
, std::string const& url
, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
: tracker_alert(h, url, alert::warning, msg)
, times_in_row(times)
, status_code(status)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_alert(*this)); }
{ return std::auto_ptr<alert>(new tracker_error_alert(*this)); }
int times_in_row;
int status_code;
};
struct TORRENT_EXPORT tracker_warning_alert: torrent_alert
struct TORRENT_EXPORT tracker_warning_alert: tracker_alert
{
tracker_warning_alert(torrent_handle const& h
, std::string const& url
, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
: tracker_alert(h, url, alert::warning, msg)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
};
struct TORRENT_EXPORT scrape_reply_alert: torrent_alert
struct TORRENT_EXPORT scrape_reply_alert: tracker_alert
{
scrape_reply_alert(torrent_handle const& h
, int incomplete_
, int complete_
, std::string const& url
, std::string const& msg)
: torrent_alert(h, alert::info, msg)
: tracker_alert(h, url, alert::info, msg)
, incomplete(incomplete_)
, complete(complete_)
{}
@@ -100,23 +116,25 @@ namespace libtorrent
{ return std::auto_ptr<alert>(new scrape_reply_alert(*this)); }
};
struct TORRENT_EXPORT scrape_failed_alert: torrent_alert
struct TORRENT_EXPORT scrape_failed_alert: tracker_alert
{
scrape_failed_alert(torrent_handle const& h
, std::string const& url
, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
: tracker_alert(h, url, alert::warning, msg)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new scrape_failed_alert(*this)); }
};
struct TORRENT_EXPORT tracker_reply_alert: torrent_alert
struct TORRENT_EXPORT tracker_reply_alert: tracker_alert
{
tracker_reply_alert(torrent_handle const& h
, int np
, std::string const& url
, std::string const& msg)
: torrent_alert(h, alert::info, msg)
: tracker_alert(h, url, alert::info, msg)
, num_peers(np)
{}
@@ -126,10 +144,12 @@ namespace libtorrent
{ return std::auto_ptr<alert>(new tracker_reply_alert(*this)); }
};
struct TORRENT_EXPORT tracker_announce_alert: torrent_alert
struct TORRENT_EXPORT tracker_announce_alert: tracker_alert
{
tracker_announce_alert(torrent_handle const& h, std::string const& msg)
: torrent_alert(h, alert::info, msg)
tracker_announce_alert(torrent_handle const& h
, std::string const& url
, std::string const& msg)
: tracker_alert(h, url, alert::info, msg)
{}
virtual std::auto_ptr<alert> clone() const

View File

@@ -318,7 +318,8 @@ namespace libtorrent
tracker_request const& r);
virtual void tracker_request_error(tracker_request const& r
, int response_code, const std::string& str);
virtual void tracker_warning(std::string const& msg);
virtual void tracker_warning(tracker_request const& req
, std::string const& msg);
virtual void tracker_scrape_response(tracker_request const& req
, int complete, int incomplete, int downloaded);

View File

@@ -118,20 +118,21 @@ namespace libtorrent
friend class tracker_manager;
request_callback(): m_manager(0) {}
virtual ~request_callback() {}
virtual void tracker_warning(std::string const& msg) = 0;
virtual void tracker_warning(tracker_request const& req
, std::string const& msg) = 0;
virtual void tracker_scrape_response(tracker_request const& req
, int complete, int incomplete, int downloads) {}
virtual void tracker_response(
tracker_request const&
tracker_request const& req
, std::vector<peer_entry>& peers
, int interval
, int complete
, int incomplete
, address const& external_ip) = 0;
virtual void tracker_request_timed_out(
tracker_request const&) = 0;
tracker_request const& req) = 0;
virtual void tracker_request_error(
tracker_request const&
tracker_request const& req
, int response_code
, const std::string& description) = 0;