premiere-libtorrent/include/libtorrent/alert_types.hpp

171 lines
4.3 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
2004-03-08 13:26:07 +01:00
#include <string>
2004-01-18 20:12:18 +01:00
#include "libtorrent/alert.hpp"
#include "libtorrent/torrent_handle.hpp"
namespace libtorrent
{
struct tracker_alert: alert
{
tracker_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 tracker_alert(*this)); }
torrent_handle handle;
};
struct hash_failed_alert: alert
{
hash_failed_alert(
const torrent_handle& h
, int index
, const std::string& msg)
: alert(alert::info, msg)
, handle(h)
, piece_index(index)
2004-01-25 23:41:55 +01: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;
};
struct peer_error_alert: alert
{
2004-01-31 11:20:19 +01:00
peer_error_alert(const address& pip, const std::string& msg)
2004-01-18 20:12:18 +01:00
: alert(alert::debug, msg)
2004-01-31 11:20:19 +01:00
, ip(pip)
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-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(
const peer_request& r
, 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::debug, msg)
, handle(h)
2004-01-31 11:20:19 +01:00
, ip(sender)
2004-01-18 20:12:18 +01:00
, request(r)
{}
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;
};
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
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)); }
};
2004-01-18 20:12:18 +01:00
}
#endif