3
Copyright (c) 2003, Arvid Norberg
6
Redistribution and use in source and binary forms, with or without
7
modification, are permitted provided that the following conditions
10
* Redistributions of source code must retain the above copyright
11
notice, this list of conditions and the following disclaimer.
12
* Redistributions in binary form must reproduce the above copyright
13
notice, this list of conditions and the following disclaimer in
14
the documentation and/or other materials provided with the distribution.
15
* Neither the name of the author nor the names of its
16
contributors may be used to endorse or promote products derived
17
from this software without specific prior written permission.
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
POSSIBILITY OF SUCH DAMAGE.
33
#ifndef TORRENT_ALERT_TYPES_HPP_INCLUDED
34
#define TORRENT_ALERT_TYPES_HPP_INCLUDED
36
#include "libtorrent/alert.hpp"
37
#include "libtorrent/torrent_handle.hpp"
38
#include "libtorrent/socket.hpp"
39
#include "libtorrent/peer_connection.hpp"
40
#include "libtorrent/config.hpp"
41
#include "libtorrent/assert.hpp"
45
struct TORRENT_EXPORT torrent_alert: alert
47
torrent_alert(torrent_handle const& h, alert::severity_t s
48
, std::string const& msg)
53
torrent_handle handle;
56
struct TORRENT_EXPORT tracker_alert: torrent_alert
58
tracker_alert(torrent_handle const& h
61
, std::string const& msg)
62
: torrent_alert(h, alert::warning, msg)
67
virtual std::auto_ptr<alert> clone() const
68
{ return std::auto_ptr<alert>(new tracker_alert(*this)); }
74
struct TORRENT_EXPORT tracker_warning_alert: torrent_alert
76
tracker_warning_alert(torrent_handle const& h
77
, std::string const& msg)
78
: torrent_alert(h, alert::warning, msg)
81
virtual std::auto_ptr<alert> clone() const
82
{ return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
85
struct TORRENT_EXPORT tracker_reply_alert: torrent_alert
87
tracker_reply_alert(torrent_handle const& h
89
, std::string const& msg)
90
: torrent_alert(h, alert::info, msg)
96
virtual std::auto_ptr<alert> clone() const
97
{ return std::auto_ptr<alert>(new tracker_reply_alert(*this)); }
100
struct TORRENT_EXPORT tracker_announce_alert: torrent_alert
102
tracker_announce_alert(torrent_handle const& h, std::string const& msg)
103
: torrent_alert(h, alert::info, msg)
106
virtual std::auto_ptr<alert> clone() const
107
{ return std::auto_ptr<alert>(new tracker_announce_alert(*this)); }
110
struct TORRENT_EXPORT hash_failed_alert: torrent_alert
113
torrent_handle const& h
115
, std::string const& msg)
116
: torrent_alert(h, alert::info, msg)
118
{ TORRENT_ASSERT(index >= 0);}
120
virtual std::auto_ptr<alert> clone() const
121
{ return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
126
struct TORRENT_EXPORT peer_ban_alert: torrent_alert
128
peer_ban_alert(tcp::endpoint const& pip, torrent_handle h, std::string const& msg)
129
: torrent_alert(h, alert::info, msg)
133
virtual std::auto_ptr<alert> clone() const
134
{ return std::auto_ptr<alert>(new peer_ban_alert(*this)); }
139
struct TORRENT_EXPORT peer_error_alert: alert
141
peer_error_alert(tcp::endpoint const& pip, peer_id const& pid_, std::string const& msg)
142
: alert(alert::debug, msg)
147
virtual std::auto_ptr<alert> clone() const
148
{ return std::auto_ptr<alert>(new peer_error_alert(*this)); }
154
struct TORRENT_EXPORT invalid_request_alert: torrent_alert
156
invalid_request_alert(
157
peer_request const& r
158
, torrent_handle const& h
159
, tcp::endpoint const& sender
160
, peer_id const& pid_
161
, std::string const& msg)
162
: torrent_alert(h, alert::debug, msg)
168
virtual std::auto_ptr<alert> clone() const
169
{ return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
172
peer_request request;
176
struct TORRENT_EXPORT torrent_finished_alert: torrent_alert
178
torrent_finished_alert(
179
const torrent_handle& h
180
, const std::string& msg)
181
: torrent_alert(h, alert::warning, msg)
184
virtual std::auto_ptr<alert> clone() const
185
{ return std::auto_ptr<alert>(new torrent_finished_alert(*this)); }
188
struct TORRENT_EXPORT piece_finished_alert: torrent_alert
190
piece_finished_alert(
191
const torrent_handle& h
193
, const std::string& msg)
194
: torrent_alert(h, alert::debug, msg)
195
, piece_index(piece_num)
196
{ TORRENT_ASSERT(piece_index >= 0);}
200
virtual std::auto_ptr<alert> clone() const
201
{ return std::auto_ptr<alert>(new piece_finished_alert(*this)); }
204
struct TORRENT_EXPORT block_finished_alert: torrent_alert
206
block_finished_alert(
207
const torrent_handle& h
210
, const std::string& msg)
211
: torrent_alert(h, alert::debug, msg)
212
, block_index(block_num)
213
, piece_index(piece_num)
214
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
219
virtual std::auto_ptr<alert> clone() const
220
{ return std::auto_ptr<alert>(new block_finished_alert(*this)); }
223
struct TORRENT_EXPORT block_downloading_alert: torrent_alert
225
block_downloading_alert(
226
const torrent_handle& h
227
, char const* speedmsg
230
, const std::string& msg)
231
: torrent_alert(h, alert::debug, msg)
232
, peer_speedmsg(speedmsg)
233
, block_index(block_num)
234
, piece_index(piece_num)
235
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
237
std::string peer_speedmsg;
241
virtual std::auto_ptr<alert> clone() const
242
{ return std::auto_ptr<alert>(new block_downloading_alert(*this)); }
245
struct TORRENT_EXPORT storage_moved_alert: torrent_alert
247
storage_moved_alert(torrent_handle const& h, std::string const& path)
248
: torrent_alert(h, alert::warning, path)
251
virtual std::auto_ptr<alert> clone() const
252
{ return std::auto_ptr<alert>(new storage_moved_alert(*this)); }
255
struct TORRENT_EXPORT torrent_deleted_alert: torrent_alert
257
torrent_deleted_alert(torrent_handle const& h, std::string const& msg)
258
: torrent_alert(h, alert::warning, msg)
261
virtual std::auto_ptr<alert> clone() const
262
{ return std::auto_ptr<alert>(new torrent_deleted_alert(*this)); }
265
struct TORRENT_EXPORT torrent_paused_alert: torrent_alert
267
torrent_paused_alert(torrent_handle const& h, std::string const& msg)
268
: torrent_alert(h, alert::warning, msg)
271
virtual std::auto_ptr<alert> clone() const
272
{ return std::auto_ptr<alert>(new torrent_paused_alert(*this)); }
275
struct TORRENT_EXPORT torrent_checked_alert: torrent_alert
277
torrent_checked_alert(torrent_handle const& h, std::string const& msg)
278
: torrent_alert(h, alert::info, msg)
281
virtual std::auto_ptr<alert> clone() const
282
{ return std::auto_ptr<alert>(new torrent_checked_alert(*this)); }
286
struct TORRENT_EXPORT url_seed_alert: torrent_alert
289
torrent_handle const& h
290
, const std::string& url_
291
, const std::string& msg)
292
: torrent_alert(h, alert::warning, msg)
296
virtual std::auto_ptr<alert> clone() const
297
{ return std::auto_ptr<alert>(new url_seed_alert(*this)); }
302
struct TORRENT_EXPORT file_error_alert: torrent_alert
305
const torrent_handle& h
306
, const std::string& msg)
307
: torrent_alert(h, alert::fatal, msg)
310
virtual std::auto_ptr<alert> clone() const
311
{ return std::auto_ptr<alert>(new file_error_alert(*this)); }
314
struct TORRENT_EXPORT metadata_failed_alert: torrent_alert
316
metadata_failed_alert(
317
const torrent_handle& h
318
, const std::string& msg)
319
: torrent_alert(h, alert::info, msg)
322
virtual std::auto_ptr<alert> clone() const
323
{ return std::auto_ptr<alert>(new metadata_failed_alert(*this)); }
326
struct TORRENT_EXPORT metadata_received_alert: torrent_alert
328
metadata_received_alert(
329
const torrent_handle& h
330
, const std::string& msg)
331
: torrent_alert(h, alert::info, msg)
334
virtual std::auto_ptr<alert> clone() const
335
{ return std::auto_ptr<alert>(new metadata_received_alert(*this)); }
338
struct TORRENT_EXPORT listen_failed_alert: alert
341
tcp::endpoint const& ep
342
, std::string const& msg)
343
: alert(alert::fatal, msg)
347
tcp::endpoint endpoint;
349
virtual std::auto_ptr<alert> clone() const
350
{ return std::auto_ptr<alert>(new listen_failed_alert(*this)); }
353
struct TORRENT_EXPORT listen_succeeded_alert: alert
355
listen_succeeded_alert(
356
tcp::endpoint const& ep
357
, std::string const& msg)
358
: alert(alert::fatal, msg)
362
tcp::endpoint endpoint;
364
virtual std::auto_ptr<alert> clone() const
365
{ return std::auto_ptr<alert>(new listen_succeeded_alert(*this)); }
368
struct TORRENT_EXPORT portmap_error_alert: alert
370
portmap_error_alert(const std::string& msg)
371
: alert(alert::warning, msg)
374
virtual std::auto_ptr<alert> clone() const
375
{ return std::auto_ptr<alert>(new portmap_error_alert(*this)); }
378
struct TORRENT_EXPORT portmap_alert: alert
380
portmap_alert(const std::string& msg)
381
: alert(alert::info, msg)
384
virtual std::auto_ptr<alert> clone() const
385
{ return std::auto_ptr<alert>(new portmap_alert(*this)); }
388
struct TORRENT_EXPORT fastresume_rejected_alert: torrent_alert
390
fastresume_rejected_alert(torrent_handle const& h
391
, std::string const& msg)
392
: torrent_alert(h, alert::warning, msg)
395
virtual std::auto_ptr<alert> clone() const
396
{ return std::auto_ptr<alert>(new fastresume_rejected_alert(*this)); }
399
struct TORRENT_EXPORT peer_blocked_alert: alert
401
peer_blocked_alert(address const& ip_
402
, std::string const& msg)
403
: alert(alert::info, msg)
409
virtual std::auto_ptr<alert> clone() const
410
{ return std::auto_ptr<alert>(new peer_blocked_alert(*this)); }