premiere-libtorrent/include/libtorrent/alert_types.hpp

501 lines
13 KiB
C++
Raw Normal View History

2004-01-18 20:12:18 +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_ALERT_TYPES_HPP_INCLUDED
#define TORRENT_ALERT_TYPES_HPP_INCLUDED
#include "libtorrent/alert.hpp"
#include "libtorrent/torrent_handle.hpp"
2004-03-08 13:36:03 +01:00
#include "libtorrent/socket.hpp"
#include "libtorrent/peer_connection.hpp"
#include "libtorrent/config.hpp"
2007-09-10 08:12:41 +02:00
#include "libtorrent/assert.hpp"
2004-01-18 20:12:18 +01:00
namespace libtorrent
{
struct TORRENT_EXPORT torrent_alert: alert
{
torrent_alert(torrent_handle const& h, alert::severity_t s
, std::string const& msg)
: alert(s, msg)
, handle(h)
{}
torrent_handle handle;
};
struct TORRENT_EXPORT tracker_alert: torrent_alert
2004-01-18 20:12:18 +01:00
{
2005-06-06 12:33:44 +02:00
tracker_alert(torrent_handle const& h
2004-09-12 12:12:16 +02:00
, int times
, int status
2005-06-06 12:33:44 +02:00
, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
2004-09-12 12:12:16 +02:00
, times_in_row(times)
, status_code(status)
2005-08-11 01:32:39 +02:00
{}
2004-01-18 20:12:18 +01:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_alert(*this)); }
2004-09-12 12:12:16 +02:00
int times_in_row;
int status_code;
2004-01-18 20:12:18 +01:00
};
struct TORRENT_EXPORT tracker_warning_alert: torrent_alert
2005-08-11 01:32:39 +02:00
{
tracker_warning_alert(torrent_handle const& h
, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
2005-08-11 01:32:39 +02:00
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
};
2007-11-20 23:46:27 +01:00
struct TORRENT_EXPORT scrape_reply_alert: torrent_alert
{
scrape_reply_alert(torrent_handle const& h
, int incomplete_
, int complete_
, std::string const& msg)
: torrent_alert(h, alert::info, msg)
, incomplete(incomplete_)
, complete(complete_)
{}
int incomplete;
int complete;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new scrape_reply_alert(*this)); }
};
struct TORRENT_EXPORT scrape_failed_alert: torrent_alert
{
scrape_failed_alert(torrent_handle const& h
, std::string const& msg)
: torrent_alert(h, 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
2005-03-10 10:59:12 +01:00
{
2005-06-06 12:33:44 +02:00
tracker_reply_alert(torrent_handle const& h
, int np
2005-06-06 12:33:44 +02:00
, std::string const& msg)
: torrent_alert(h, alert::info, msg)
, num_peers(np)
2005-08-11 01:32:39 +02:00
{}
2005-03-10 10:59:12 +01:00
int num_peers;
2005-03-10 10:59:12 +01:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_reply_alert(*this)); }
};
2005-06-06 12:33:44 +02:00
struct TORRENT_EXPORT tracker_announce_alert: torrent_alert
2005-06-06 12:33:44 +02:00
{
tracker_announce_alert(torrent_handle const& h, std::string const& msg)
: torrent_alert(h, alert::info, msg)
2005-08-11 01:32:39 +02:00
{}
2005-06-06 12:33:44 +02:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_announce_alert(*this)); }
};
2005-03-10 10:59:12 +01:00
struct TORRENT_EXPORT hash_failed_alert: torrent_alert
2004-01-18 20:12:18 +01:00
{
hash_failed_alert(
2005-06-06 12:33:44 +02:00
torrent_handle const& h
2004-01-18 20:12:18 +01:00
, int index
2005-06-06 12:33:44 +02:00
, std::string const& msg)
: torrent_alert(h, alert::info, msg)
2004-01-18 20:12:18 +01:00
, piece_index(index)
{ TORRENT_ASSERT(index >= 0);}
2004-01-18 20:12:18 +01:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
int piece_index;
};
struct TORRENT_EXPORT peer_ban_alert: torrent_alert
2004-03-21 03:03:37 +01:00
{
peer_ban_alert(tcp::endpoint const& pip, torrent_handle h, std::string const& msg)
: torrent_alert(h, alert::info, msg)
2004-03-21 03:03:37 +01:00
, ip(pip)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new peer_ban_alert(*this)); }
tcp::endpoint ip;
2004-03-21 03:03:37 +01:00
};
struct TORRENT_EXPORT peer_error_alert: alert
2004-01-18 20:12:18 +01:00
{
peer_error_alert(tcp::endpoint const& pip, peer_id const& pid_, std::string const& msg)
2004-01-18 20:12:18 +01:00
: alert(alert::debug, msg)
2004-01-31 11:20:19 +01:00
, ip(pip)
, pid(pid_)
2004-01-18 20:12:18 +01:00
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new peer_error_alert(*this)); }
tcp::endpoint ip;
peer_id pid;
2004-01-18 20:12:18 +01:00
};
struct TORRENT_EXPORT invalid_request_alert: torrent_alert
2004-01-18 20:12:18 +01:00
{
invalid_request_alert(
2004-03-28 19:45:37 +02:00
peer_request const& r
, torrent_handle const& h
, tcp::endpoint const& sender
, peer_id const& pid_
2004-03-28 19:45:37 +02:00
, std::string const& msg)
: torrent_alert(h, alert::debug, msg)
2004-01-31 11:20:19 +01:00
, ip(sender)
2004-01-18 20:12:18 +01:00
, request(r)
, pid(pid_)
2004-01-18 20:12:18 +01:00
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
tcp::endpoint ip;
2004-01-18 20:12:18 +01:00
peer_request request;
peer_id pid;
2004-01-18 20:12:18 +01:00
};
struct TORRENT_EXPORT torrent_finished_alert: torrent_alert
2004-01-18 20:12:18 +01:00
{
torrent_finished_alert(
const torrent_handle& h
, const std::string& msg)
: torrent_alert(h, alert::warning, msg)
2004-01-18 20:12:18 +01:00
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new torrent_finished_alert(*this)); }
};
struct TORRENT_EXPORT piece_finished_alert: torrent_alert
{
piece_finished_alert(
const torrent_handle& h
, int piece_num
, const std::string& msg)
: torrent_alert(h, alert::debug, msg)
, piece_index(piece_num)
{ TORRENT_ASSERT(piece_index >= 0);}
int piece_index;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new piece_finished_alert(*this)); }
};
struct TORRENT_EXPORT block_finished_alert: torrent_alert
{
block_finished_alert(
const torrent_handle& h
, int block_num
, int piece_num
, const std::string& msg)
: torrent_alert(h, alert::debug, msg)
, block_index(block_num)
, piece_index(piece_num)
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
int block_index;
int piece_index;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new block_finished_alert(*this)); }
};
struct TORRENT_EXPORT block_downloading_alert: torrent_alert
{
block_downloading_alert(
const torrent_handle& h
2007-09-06 20:30:46 +02:00
, char const* speedmsg
, int block_num
, int piece_num
, const std::string& msg)
: torrent_alert(h, alert::debug, msg)
, peer_speedmsg(speedmsg)
, block_index(block_num)
, piece_index(piece_num)
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
std::string peer_speedmsg;
int block_index;
int piece_index;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new block_downloading_alert(*this)); }
};
struct TORRENT_EXPORT storage_moved_alert: torrent_alert
{
storage_moved_alert(torrent_handle const& h, std::string const& path)
: torrent_alert(h, alert::warning, path)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new storage_moved_alert(*this)); }
};
struct TORRENT_EXPORT torrent_deleted_alert: torrent_alert
{
torrent_deleted_alert(torrent_handle const& h, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new torrent_deleted_alert(*this)); }
};
struct TORRENT_EXPORT save_resume_data_alert: torrent_alert
{
save_resume_data_alert(boost::shared_ptr<entry> const& rd
, torrent_handle const& h, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
, resume_data(rd)
{}
boost::shared_ptr<entry> resume_data;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new save_resume_data_alert(*this)); }
};
struct TORRENT_EXPORT torrent_paused_alert: torrent_alert
{
torrent_paused_alert(torrent_handle const& h, std::string const& msg)
: torrent_alert(h, alert::warning, msg)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new torrent_paused_alert(*this)); }
};
2007-08-16 21:41:28 +02:00
struct TORRENT_EXPORT torrent_checked_alert: torrent_alert
{
torrent_checked_alert(torrent_handle const& h, std::string const& msg)
: torrent_alert(h, alert::info, msg)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new torrent_checked_alert(*this)); }
};
struct TORRENT_EXPORT url_seed_alert: torrent_alert
{
url_seed_alert(
torrent_handle const& h
, const std::string& url_
, const std::string& msg)
: torrent_alert(h, alert::warning, msg)
, url(url_)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new url_seed_alert(*this)); }
std::string url;
};
struct TORRENT_EXPORT file_error_alert: torrent_alert
2004-01-26 02:08:59 +01:00
{
file_error_alert(
2008-04-13 00:08:07 +02:00
std::string const& f
, const torrent_handle& h
2004-01-26 02:08:59 +01:00
, const std::string& msg)
: torrent_alert(h, alert::fatal, msg)
2008-04-13 00:08:07 +02:00
, file(f)
2004-01-26 02:08:59 +01:00
{}
2008-04-13 00:08:07 +02:00
std::string file;
2004-01-26 02:08:59 +01:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new file_error_alert(*this)); }
};
2004-01-26 11:29:00 +01:00
struct TORRENT_EXPORT metadata_failed_alert: torrent_alert
{
metadata_failed_alert(
const torrent_handle& h
, const std::string& msg)
: torrent_alert(h, alert::info, msg)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new metadata_failed_alert(*this)); }
};
struct TORRENT_EXPORT metadata_received_alert: torrent_alert
2004-09-10 02:47:30 +02:00
{
metadata_received_alert(
const torrent_handle& h
, const std::string& msg)
: torrent_alert(h, alert::info, msg)
2004-09-10 02:47:30 +02:00
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new metadata_received_alert(*this)); }
};
2008-03-25 05:46:18 +01:00
struct TORRENT_EXPORT udp_error_alert: alert
{
udp_error_alert(
udp::endpoint const& ep
, std::string const& msg)
: alert(alert::info, msg)
, endpoint(ep)
{}
udp::endpoint endpoint;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new udp_error_alert(*this)); }
};
struct TORRENT_EXPORT external_ip_alert: alert
{
external_ip_alert(
address const& ip
, std::string const& msg)
: alert(alert::info, msg)
, external_address(ip)
{}
address external_address;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new external_ip_alert(*this)); }
};
struct TORRENT_EXPORT listen_failed_alert: alert
2004-01-26 11:29:00 +01:00
{
listen_failed_alert(
tcp::endpoint const& ep
, std::string const& msg)
2004-01-26 11:29:00 +01:00
: alert(alert::fatal, msg)
, endpoint(ep)
2004-01-26 11:29:00 +01:00
{}
tcp::endpoint endpoint;
2004-01-26 11:29:00 +01:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new listen_failed_alert(*this)); }
};
2005-06-16 17:41:04 +02:00
struct TORRENT_EXPORT listen_succeeded_alert: alert
{
listen_succeeded_alert(
tcp::endpoint const& ep
, std::string const& msg)
: alert(alert::fatal, msg)
, endpoint(ep)
{}
tcp::endpoint endpoint;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new listen_succeeded_alert(*this)); }
};
struct TORRENT_EXPORT portmap_error_alert: alert
{
2008-04-07 01:18:35 +02:00
portmap_error_alert(int i, int t, const std::string& msg)
: alert(alert::warning, msg), mapping(i), type(t)
{}
int mapping;
2008-04-07 01:18:35 +02:00
int type;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new portmap_error_alert(*this)); }
};
struct TORRENT_EXPORT portmap_alert: alert
{
2008-04-07 01:18:35 +02:00
portmap_alert(int i, int port, int t, const std::string& msg)
: alert(alert::info, msg), mapping(i), external_port(port), type(t)
{}
int mapping;
int external_port;
2008-04-07 01:18:35 +02:00
int type;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new portmap_alert(*this)); }
};
2007-03-16 08:59:04 +01:00
struct TORRENT_EXPORT fastresume_rejected_alert: torrent_alert
2005-06-16 17:41:04 +02:00
{
fastresume_rejected_alert(torrent_handle const& h
, std::string const& msg)
2007-03-16 08:59:04 +01:00
: torrent_alert(h, alert::warning, msg)
2005-08-11 01:32:39 +02:00
{}
2005-06-16 17:41:04 +02:00
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new fastresume_rejected_alert(*this)); }
};
struct TORRENT_EXPORT peer_blocked_alert: alert
{
peer_blocked_alert(address const& ip_
, std::string const& msg)
: alert(alert::info, msg)
, ip(ip_)
{}
address ip;
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new peer_blocked_alert(*this)); }
};
2004-01-18 20:12:18 +01:00
}
#endif