~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/alert_types.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Cristian Greco
  • Date: 2008-07-02 10:46:21 UTC
  • Revision ID: james.westby@ubuntu.com-20080702104621-jzx3pfke9lkcxfxn
Tags: upstream-0.13.1
ImportĀ upstreamĀ versionĀ 0.13.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright (c) 2003, Arvid Norberg
 
4
All rights reserved.
 
5
 
 
6
Redistribution and use in source and binary forms, with or without
 
7
modification, are permitted provided that the following conditions
 
8
are met:
 
9
 
 
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.
 
18
 
 
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.
 
30
 
 
31
*/
 
32
 
 
33
#ifndef TORRENT_ALERT_TYPES_HPP_INCLUDED
 
34
#define TORRENT_ALERT_TYPES_HPP_INCLUDED
 
35
 
 
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"
 
42
 
 
43
namespace libtorrent
 
44
{
 
45
        struct TORRENT_EXPORT torrent_alert: alert
 
46
        {
 
47
                torrent_alert(torrent_handle const& h, alert::severity_t s
 
48
                        , std::string const& msg)
 
49
                        : alert(s, msg)
 
50
                        , handle(h)
 
51
                {}
 
52
                
 
53
                torrent_handle handle;
 
54
        };
 
55
 
 
56
        struct TORRENT_EXPORT tracker_alert: torrent_alert
 
57
        {
 
58
                tracker_alert(torrent_handle const& h
 
59
                        , int times
 
60
                        , int status
 
61
                        , std::string const& url_
 
62
                        , std::string const& msg)
 
63
                        : torrent_alert(h, alert::warning, msg)
 
64
                        , times_in_row(times)
 
65
                        , status_code(status)
 
66
                        , url(url_)
 
67
                {}
 
68
 
 
69
                virtual std::auto_ptr<alert> clone() const
 
70
                { return std::auto_ptr<alert>(new tracker_alert(*this)); }
 
71
 
 
72
                int times_in_row;
 
73
                int status_code;
 
74
                std::string url;
 
75
        };
 
76
 
 
77
        struct TORRENT_EXPORT tracker_warning_alert: torrent_alert
 
78
        {
 
79
                tracker_warning_alert(torrent_handle const& h
 
80
                        , std::string const& msg)
 
81
                        : torrent_alert(h, alert::warning, msg)
 
82
                {}
 
83
 
 
84
                virtual std::auto_ptr<alert> clone() const
 
85
                { return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
 
86
        };
 
87
 
 
88
        struct TORRENT_EXPORT scrape_reply_alert: torrent_alert
 
89
        {
 
90
                scrape_reply_alert(torrent_handle const& h
 
91
                        , int incomplete_
 
92
                        , int complete_
 
93
                        , std::string const& msg)
 
94
                        : torrent_alert(h, alert::info, msg)
 
95
                        , incomplete(incomplete_)
 
96
                        , complete(complete_)
 
97
                {}
 
98
 
 
99
                int incomplete;
 
100
                int complete;
 
101
 
 
102
                virtual std::auto_ptr<alert> clone() const
 
103
                { return std::auto_ptr<alert>(new scrape_reply_alert(*this)); }
 
104
        };
 
105
 
 
106
        struct TORRENT_EXPORT scrape_failed_alert: torrent_alert
 
107
        {
 
108
                scrape_failed_alert(torrent_handle const& h
 
109
                        , std::string const& msg)
 
110
                        : torrent_alert(h, alert::warning, msg)
 
111
                {}
 
112
 
 
113
                virtual std::auto_ptr<alert> clone() const
 
114
                { return std::auto_ptr<alert>(new scrape_failed_alert(*this)); }
 
115
        };
 
116
 
 
117
        struct TORRENT_EXPORT tracker_reply_alert: torrent_alert
 
118
        {
 
119
                tracker_reply_alert(torrent_handle const& h
 
120
                        , int np
 
121
                        , std::string const& msg)
 
122
                        : torrent_alert(h, alert::info, msg)
 
123
                        , num_peers(np)
 
124
                {}
 
125
 
 
126
                int num_peers;
 
127
 
 
128
                virtual std::auto_ptr<alert> clone() const
 
129
                { return std::auto_ptr<alert>(new tracker_reply_alert(*this)); }
 
130
        };
 
131
 
 
132
        struct TORRENT_EXPORT tracker_announce_alert: torrent_alert
 
133
        {
 
134
                tracker_announce_alert(torrent_handle const& h, std::string const& msg)
 
135
                        : torrent_alert(h, alert::info, msg)
 
136
                {}
 
137
        
 
138
                virtual std::auto_ptr<alert> clone() const
 
139
                { return std::auto_ptr<alert>(new tracker_announce_alert(*this)); }
 
140
        };
 
141
        
 
142
        struct TORRENT_EXPORT hash_failed_alert: torrent_alert
 
143
        {
 
144
                hash_failed_alert(
 
145
                        torrent_handle const& h
 
146
                        , int index
 
147
                        , std::string const& msg)
 
148
                        : torrent_alert(h, alert::info, msg)
 
149
                        , piece_index(index)
 
150
                { TORRENT_ASSERT(index >= 0);}
 
151
 
 
152
                virtual std::auto_ptr<alert> clone() const
 
153
                { return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
 
154
 
 
155
                int piece_index;
 
156
        };
 
157
 
 
158
        struct TORRENT_EXPORT peer_ban_alert: torrent_alert
 
159
        {
 
160
                peer_ban_alert(tcp::endpoint const& pip, torrent_handle h, std::string const& msg)
 
161
                        : torrent_alert(h, alert::info, msg)
 
162
                        , ip(pip)
 
163
                {}
 
164
 
 
165
                virtual std::auto_ptr<alert> clone() const
 
166
                { return std::auto_ptr<alert>(new peer_ban_alert(*this)); }
 
167
 
 
168
                tcp::endpoint ip;
 
169
        };
 
170
 
 
171
        struct TORRENT_EXPORT peer_error_alert: alert
 
172
        {
 
173
                peer_error_alert(tcp::endpoint const& pip, peer_id const& pid_, std::string const& msg)
 
174
                        : alert(alert::debug, msg)
 
175
                        , ip(pip)
 
176
                        , pid(pid_)
 
177
                {}
 
178
 
 
179
                virtual std::auto_ptr<alert> clone() const
 
180
                { return std::auto_ptr<alert>(new peer_error_alert(*this)); }
 
181
 
 
182
                tcp::endpoint ip;
 
183
                peer_id pid;
 
184
        };
 
185
 
 
186
        struct TORRENT_EXPORT invalid_request_alert: torrent_alert
 
187
        {
 
188
                invalid_request_alert(
 
189
                        peer_request const& r
 
190
                        , torrent_handle const& h
 
191
                        , tcp::endpoint const& sender
 
192
                        , peer_id const& pid_
 
193
                        , std::string const& msg)
 
194
                        : torrent_alert(h, alert::debug, msg)
 
195
                        , ip(sender)
 
196
                        , request(r)
 
197
                        , pid(pid_)
 
198
                {}
 
199
 
 
200
                virtual std::auto_ptr<alert> clone() const
 
201
                { return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
 
202
 
 
203
                tcp::endpoint ip;
 
204
                peer_request request;
 
205
                peer_id pid;
 
206
        };
 
207
 
 
208
        struct TORRENT_EXPORT torrent_finished_alert: torrent_alert
 
209
        {
 
210
                torrent_finished_alert(
 
211
                        const torrent_handle& h
 
212
                        , const std::string& msg)
 
213
                        : torrent_alert(h, alert::warning, msg)
 
214
                {}
 
215
 
 
216
                virtual std::auto_ptr<alert> clone() const
 
217
                { return std::auto_ptr<alert>(new torrent_finished_alert(*this)); }
 
218
        };
 
219
 
 
220
        struct TORRENT_EXPORT piece_finished_alert: torrent_alert
 
221
        {
 
222
                piece_finished_alert(
 
223
                        const torrent_handle& h
 
224
                        , int piece_num
 
225
                        , const std::string& msg)
 
226
                        : torrent_alert(h, alert::debug, msg)
 
227
                        , piece_index(piece_num)
 
228
                { TORRENT_ASSERT(piece_index >= 0);}
 
229
 
 
230
                int piece_index;
 
231
 
 
232
                virtual std::auto_ptr<alert> clone() const
 
233
                { return std::auto_ptr<alert>(new piece_finished_alert(*this)); }
 
234
        };
 
235
 
 
236
        struct TORRENT_EXPORT block_finished_alert: torrent_alert
 
237
        {
 
238
                block_finished_alert(
 
239
                        const torrent_handle& h
 
240
                        , int block_num
 
241
                        , int piece_num
 
242
                        , const std::string& msg)
 
243
                        : torrent_alert(h, alert::debug, msg)
 
244
                        , block_index(block_num)
 
245
                        , piece_index(piece_num)
 
246
                { TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
 
247
 
 
248
                int block_index;
 
249
                int piece_index;
 
250
 
 
251
                virtual std::auto_ptr<alert> clone() const
 
252
                { return std::auto_ptr<alert>(new block_finished_alert(*this)); }
 
253
        };
 
254
 
 
255
        struct TORRENT_EXPORT block_downloading_alert: torrent_alert
 
256
        {
 
257
                block_downloading_alert(
 
258
                        const torrent_handle& h
 
259
                        , char const* speedmsg
 
260
                        , int block_num
 
261
                        , int piece_num
 
262
                        , const std::string& msg)
 
263
                        : torrent_alert(h, alert::debug, msg)
 
264
                        , peer_speedmsg(speedmsg)
 
265
                        , block_index(block_num)
 
266
                        , piece_index(piece_num)
 
267
                { TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
 
268
 
 
269
                std::string peer_speedmsg;
 
270
                int block_index;
 
271
                int piece_index;
 
272
 
 
273
                virtual std::auto_ptr<alert> clone() const
 
274
                { return std::auto_ptr<alert>(new block_downloading_alert(*this)); }
 
275
        };
 
276
 
 
277
        struct TORRENT_EXPORT storage_moved_alert: torrent_alert
 
278
        {
 
279
                storage_moved_alert(torrent_handle const& h, std::string const& path)
 
280
                        : torrent_alert(h, alert::warning, path)
 
281
                {}
 
282
        
 
283
                virtual std::auto_ptr<alert> clone() const
 
284
                { return std::auto_ptr<alert>(new storage_moved_alert(*this)); }
 
285
        };
 
286
 
 
287
        struct TORRENT_EXPORT torrent_deleted_alert: torrent_alert
 
288
        {
 
289
                torrent_deleted_alert(torrent_handle const& h, std::string const& msg)
 
290
                        : torrent_alert(h, alert::warning, msg)
 
291
                {}
 
292
        
 
293
                virtual std::auto_ptr<alert> clone() const
 
294
                { return std::auto_ptr<alert>(new torrent_deleted_alert(*this)); }
 
295
        };
 
296
 
 
297
        struct TORRENT_EXPORT torrent_paused_alert: torrent_alert
 
298
        {
 
299
                torrent_paused_alert(torrent_handle const& h, std::string const& msg)
 
300
                        : torrent_alert(h, alert::warning, msg)
 
301
                {}
 
302
        
 
303
                virtual std::auto_ptr<alert> clone() const
 
304
                { return std::auto_ptr<alert>(new torrent_paused_alert(*this)); }
 
305
        };
 
306
 
 
307
        struct TORRENT_EXPORT torrent_checked_alert: torrent_alert
 
308
        {
 
309
                torrent_checked_alert(torrent_handle const& h, std::string const& msg)
 
310
                        : torrent_alert(h, alert::info, msg)
 
311
                {}
 
312
 
 
313
                virtual std::auto_ptr<alert> clone() const
 
314
                { return std::auto_ptr<alert>(new torrent_checked_alert(*this)); }
 
315
  };
 
316
 
 
317
 
 
318
        struct TORRENT_EXPORT url_seed_alert: torrent_alert
 
319
        {
 
320
                url_seed_alert(
 
321
                        torrent_handle const& h
 
322
                        , const std::string& url_
 
323
                        , const std::string& msg)
 
324
                        : torrent_alert(h, alert::warning, msg)
 
325
                        , url(url_)
 
326
                {}
 
327
 
 
328
                virtual std::auto_ptr<alert> clone() const
 
329
                { return std::auto_ptr<alert>(new url_seed_alert(*this)); }
 
330
 
 
331
                std::string url;
 
332
        };
 
333
 
 
334
        struct TORRENT_EXPORT file_error_alert: torrent_alert
 
335
        {
 
336
                file_error_alert(
 
337
                        const torrent_handle& h
 
338
                        , const std::string& msg)
 
339
                        : torrent_alert(h, alert::fatal, msg)
 
340
                {}
 
341
 
 
342
                virtual std::auto_ptr<alert> clone() const
 
343
                { return std::auto_ptr<alert>(new file_error_alert(*this)); }
 
344
        };
 
345
 
 
346
        struct TORRENT_EXPORT metadata_failed_alert: torrent_alert
 
347
        {
 
348
                metadata_failed_alert(
 
349
                        const torrent_handle& h
 
350
                        , const std::string& msg)
 
351
                        : torrent_alert(h, alert::info, msg)
 
352
                {}
 
353
 
 
354
                virtual std::auto_ptr<alert> clone() const
 
355
                { return std::auto_ptr<alert>(new metadata_failed_alert(*this)); }
 
356
        };
 
357
        
 
358
        struct TORRENT_EXPORT metadata_received_alert: torrent_alert
 
359
        {
 
360
                metadata_received_alert(
 
361
                        const torrent_handle& h
 
362
                        , const std::string& msg)
 
363
                        : torrent_alert(h, alert::info, msg)
 
364
                {}
 
365
 
 
366
                virtual std::auto_ptr<alert> clone() const
 
367
                { return std::auto_ptr<alert>(new metadata_received_alert(*this)); }
 
368
        };
 
369
 
 
370
        struct TORRENT_EXPORT listen_failed_alert: alert
 
371
        {
 
372
                listen_failed_alert(
 
373
                        tcp::endpoint const& ep
 
374
                        , std::string const& msg)
 
375
                        : alert(alert::fatal, msg)
 
376
                        , endpoint(ep)
 
377
                {}
 
378
 
 
379
                tcp::endpoint endpoint;
 
380
 
 
381
                virtual std::auto_ptr<alert> clone() const
 
382
                { return std::auto_ptr<alert>(new listen_failed_alert(*this)); }
 
383
        };
 
384
 
 
385
        struct TORRENT_EXPORT listen_succeeded_alert: alert
 
386
        {
 
387
                listen_succeeded_alert(
 
388
                        tcp::endpoint const& ep
 
389
                        , std::string const& msg)
 
390
                        : alert(alert::fatal, msg)
 
391
                        , endpoint(ep)
 
392
                {}
 
393
 
 
394
                tcp::endpoint endpoint;
 
395
 
 
396
                virtual std::auto_ptr<alert> clone() const
 
397
                { return std::auto_ptr<alert>(new listen_succeeded_alert(*this)); }
 
398
        };
 
399
 
 
400
        struct TORRENT_EXPORT portmap_error_alert: alert
 
401
        {
 
402
                portmap_error_alert(const std::string& msg)
 
403
                        : alert(alert::warning, msg)
 
404
                {}
 
405
 
 
406
                virtual std::auto_ptr<alert> clone() const
 
407
                { return std::auto_ptr<alert>(new portmap_error_alert(*this)); }
 
408
        };
 
409
 
 
410
        struct TORRENT_EXPORT portmap_alert: alert
 
411
        {
 
412
                portmap_alert(const std::string& msg)
 
413
                        : alert(alert::info, msg)
 
414
                {}
 
415
 
 
416
                virtual std::auto_ptr<alert> clone() const
 
417
                { return std::auto_ptr<alert>(new portmap_alert(*this)); }
 
418
        };
 
419
 
 
420
        struct TORRENT_EXPORT fastresume_rejected_alert: torrent_alert
 
421
        {
 
422
                fastresume_rejected_alert(torrent_handle const& h
 
423
                        , std::string const& msg)
 
424
                        : torrent_alert(h, alert::warning, msg)
 
425
                {}
 
426
 
 
427
                virtual std::auto_ptr<alert> clone() const
 
428
                { return std::auto_ptr<alert>(new fastresume_rejected_alert(*this)); }
 
429
        };
 
430
 
 
431
        struct TORRENT_EXPORT peer_blocked_alert: alert
 
432
        {
 
433
                peer_blocked_alert(address const& ip_
 
434
                        , std::string const& msg)
 
435
                        : alert(alert::info, msg)
 
436
                        , ip(ip_)
 
437
                {}
 
438
                
 
439
                address ip;
 
440
 
 
441
                virtual std::auto_ptr<alert> clone() const
 
442
                { return std::auto_ptr<alert>(new peer_blocked_alert(*this)); }
 
443
        };
 
444
 
 
445
}
 
446
 
 
447
 
 
448
#endif