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"
|
2004-01-18 20:12:18 +01:00
|
|
|
|
|
|
|
namespace libtorrent
|
|
|
|
{
|
|
|
|
struct tracker_alert: alert
|
|
|
|
{
|
2005-06-06 12:33:44 +02:00
|
|
|
tracker_alert(torrent_handle const& h
|
2004-09-12 12:12:16 +02:00
|
|
|
, int times
|
2005-04-21 01:00:27 +02:00
|
|
|
, int status
|
2005-06-06 12:33:44 +02:00
|
|
|
, std::string const& msg)
|
2004-01-18 20:12:18 +01:00
|
|
|
: alert(alert::warning, msg)
|
|
|
|
, handle(h)
|
2004-09-12 12:12:16 +02:00
|
|
|
, times_in_row(times)
|
2005-04-21 01:00:27 +02:00
|
|
|
, 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)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
2004-09-12 12:12:16 +02:00
|
|
|
int times_in_row;
|
2005-04-21 01:00:27 +02:00
|
|
|
int status_code;
|
2004-01-18 20:12:18 +01:00
|
|
|
};
|
|
|
|
|
2005-08-11 01:32:39 +02:00
|
|
|
struct tracker_warning_alert: alert
|
|
|
|
{
|
|
|
|
tracker_warning_alert(torrent_handle const& h
|
|
|
|
, std::string const& msg)
|
|
|
|
: alert(alert::warning, msg)
|
|
|
|
, handle(h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual std::auto_ptr<alert> clone() const
|
|
|
|
{ return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-10 10:59:12 +01:00
|
|
|
struct tracker_reply_alert: alert
|
|
|
|
{
|
2005-06-06 12:33:44 +02:00
|
|
|
tracker_reply_alert(torrent_handle const& h
|
|
|
|
, std::string const& msg)
|
2005-03-10 10:59:12 +01:00
|
|
|
: alert(alert::info, msg)
|
|
|
|
, handle(h)
|
2005-08-11 01:32:39 +02:00
|
|
|
{}
|
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)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
2005-06-06 12:33:44 +02:00
|
|
|
|
|
|
|
struct tracker_announce_alert: alert
|
|
|
|
{
|
|
|
|
tracker_announce_alert(torrent_handle const& h, std::string const& msg)
|
|
|
|
: alert(alert::info, msg)
|
|
|
|
, handle(h)
|
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)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
2005-03-10 10:59:12 +01:00
|
|
|
|
2004-01-18 20:12:18 +01:00
|
|
|
struct hash_failed_alert: alert
|
|
|
|
{
|
|
|
|
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)
|
2004-01-18 20:12:18 +01:00
|
|
|
: alert(alert::info, msg)
|
|
|
|
, handle(h)
|
|
|
|
, piece_index(index)
|
2005-08-11 01:32:39 +02:00
|
|
|
{ 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)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
int piece_index;
|
|
|
|
};
|
|
|
|
|
2004-03-21 03:03:37 +01:00
|
|
|
struct peer_ban_alert: alert
|
|
|
|
{
|
2005-06-06 12:33:44 +02:00
|
|
|
peer_ban_alert(address const& pip, torrent_handle h, std::string const& msg)
|
2004-03-21 03:03:37 +01:00
|
|
|
: alert(alert::info, msg)
|
|
|
|
, ip(pip)
|
|
|
|
, handle(h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual std::auto_ptr<alert> clone() const
|
|
|
|
{ return std::auto_ptr<alert>(new peer_ban_alert(*this)); }
|
|
|
|
|
|
|
|
address ip;
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
|
|
|
|
2004-01-18 20:12:18 +01:00
|
|
|
struct peer_error_alert: alert
|
|
|
|
{
|
2005-06-06 12:33:44 +02:00
|
|
|
peer_error_alert(address 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)
|
2004-03-28 19:45:37 +02:00
|
|
|
, id(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)); }
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
address ip;
|
2004-03-28 19:45:37 +02:00
|
|
|
peer_id id;
|
2004-01-18 20:12:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct chat_message_alert: alert
|
|
|
|
{
|
|
|
|
chat_message_alert(
|
|
|
|
const torrent_handle& h
|
2004-01-31 11:20:19 +01:00
|
|
|
, const address& sender
|
2004-01-18 20:12:18 +01:00
|
|
|
, const std::string& msg)
|
|
|
|
: alert(alert::critical, msg)
|
|
|
|
, handle(h)
|
2004-01-31 11:20:19 +01:00
|
|
|
, ip(sender)
|
2004-01-18 20:12:18 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual std::auto_ptr<alert> clone() const
|
|
|
|
{ return std::auto_ptr<alert>(new chat_message_alert(*this)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
2004-01-31 11:20:19 +01:00
|
|
|
address ip;
|
2004-01-18 20:12:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct invalid_request_alert: alert
|
|
|
|
{
|
|
|
|
invalid_request_alert(
|
2004-03-28 19:45:37 +02:00
|
|
|
peer_request const& r
|
|
|
|
, torrent_handle const& h
|
|
|
|
, address const& sender
|
|
|
|
, peer_id const& pid
|
|
|
|
, std::string const& msg)
|
2004-01-18 20:12:18 +01:00
|
|
|
: alert(alert::debug, msg)
|
|
|
|
, handle(h)
|
2004-01-31 11:20:19 +01:00
|
|
|
, ip(sender)
|
2004-01-18 20:12:18 +01:00
|
|
|
, request(r)
|
2004-03-28 19:45:37 +02:00
|
|
|
, id(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)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
2004-01-31 11:20:19 +01:00
|
|
|
address ip;
|
2004-01-18 20:12:18 +01:00
|
|
|
peer_request request;
|
2004-03-28 19:45:37 +02:00
|
|
|
peer_id id;
|
2004-01-18 20:12:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct torrent_finished_alert: alert
|
|
|
|
{
|
|
|
|
torrent_finished_alert(
|
|
|
|
const torrent_handle& h
|
|
|
|
, const std::string& msg)
|
|
|
|
: alert(alert::warning, msg)
|
|
|
|
, handle(h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual std::auto_ptr<alert> clone() const
|
|
|
|
{ return std::auto_ptr<alert>(new torrent_finished_alert(*this)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
|
|
|
|
2004-01-26 02:08:59 +01:00
|
|
|
struct file_error_alert: alert
|
|
|
|
{
|
|
|
|
file_error_alert(
|
|
|
|
const torrent_handle& h
|
|
|
|
, const std::string& msg)
|
|
|
|
: alert(alert::fatal, msg)
|
|
|
|
, handle(h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual std::auto_ptr<alert> clone() const
|
|
|
|
{ return std::auto_ptr<alert>(new file_error_alert(*this)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
2004-01-26 11:29:00 +01:00
|
|
|
|
2004-09-10 02:47:30 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2004-01-26 11:29:00 +01:00
|
|
|
struct listen_failed_alert: alert
|
|
|
|
{
|
|
|
|
listen_failed_alert(
|
|
|
|
const std::string& msg)
|
|
|
|
: alert(alert::fatal, msg)
|
|
|
|
{}
|
|
|
|
|
|
|
|
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 fastresume_rejected_alert: alert
|
|
|
|
{
|
|
|
|
fastresume_rejected_alert(torrent_handle const& h
|
|
|
|
, std::string const& msg)
|
|
|
|
: alert(alert::warning, msg)
|
|
|
|
, handle(h)
|
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)); }
|
|
|
|
|
|
|
|
torrent_handle handle;
|
|
|
|
};
|
|
|
|
|
2004-01-18 20:12:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|