~ubuntu-branches/ubuntu/intrepid/miro/intrepid

« back to all changes in this revision

Viewing changes to portable/libtorrent/include/libtorrent/alert_types.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-02-09 13:37:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080209133710-9rs90q6gckvp1b6i
Tags: 1.1.2-0ubuntu1
New upstream release

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& msg)
 
62
                        : torrent_alert(h, alert::warning, msg)
 
63
                        , times_in_row(times)
 
64
                        , status_code(status)
 
65
                {}
 
66
 
 
67
                virtual std::auto_ptr<alert> clone() const
 
68
                { return std::auto_ptr<alert>(new tracker_alert(*this)); }
 
69
 
 
70
                int times_in_row;
 
71
                int status_code;
 
72
        };
 
73
 
 
74
        struct TORRENT_EXPORT tracker_warning_alert: torrent_alert
 
75
        {
 
76
                tracker_warning_alert(torrent_handle const& h
 
77
                        , std::string const& msg)
 
78
                        : torrent_alert(h, alert::warning, msg)
 
79
                {}
 
80
 
 
81
                virtual std::auto_ptr<alert> clone() const
 
82
                { return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
 
83
        };
 
84
 
 
85
        struct TORRENT_EXPORT tracker_reply_alert: torrent_alert
 
86
        {
 
87
                tracker_reply_alert(torrent_handle const& h
 
88
                        , int np
 
89
                        , std::string const& msg)
 
90
                        : torrent_alert(h, alert::info, msg)
 
91
                        , num_peers(np)
 
92
                {}
 
93
 
 
94
                int num_peers;
 
95
 
 
96
                virtual std::auto_ptr<alert> clone() const
 
97
                { return std::auto_ptr<alert>(new tracker_reply_alert(*this)); }
 
98
        };
 
99
 
 
100
        struct TORRENT_EXPORT tracker_announce_alert: torrent_alert
 
101
        {
 
102
                tracker_announce_alert(torrent_handle const& h, std::string const& msg)
 
103
                        : torrent_alert(h, alert::info, msg)
 
104
                {}
 
105
        
 
106
                virtual std::auto_ptr<alert> clone() const
 
107
                { return std::auto_ptr<alert>(new tracker_announce_alert(*this)); }
 
108
        };
 
109
        
 
110
        struct TORRENT_EXPORT hash_failed_alert: torrent_alert
 
111
        {
 
112
                hash_failed_alert(
 
113
                        torrent_handle const& h
 
114
                        , int index
 
115
                        , std::string const& msg)
 
116
                        : torrent_alert(h, alert::info, msg)
 
117
                        , piece_index(index)
 
118
                { TORRENT_ASSERT(index >= 0);}
 
119
 
 
120
                virtual std::auto_ptr<alert> clone() const
 
121
                { return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
 
122
 
 
123
                int piece_index;
 
124
        };
 
125
 
 
126
        struct TORRENT_EXPORT peer_ban_alert: torrent_alert
 
127
        {
 
128
                peer_ban_alert(tcp::endpoint const& pip, torrent_handle h, std::string const& msg)
 
129
                        : torrent_alert(h, alert::info, msg)
 
130
                        , ip(pip)
 
131
                {}
 
132
 
 
133
                virtual std::auto_ptr<alert> clone() const
 
134
                { return std::auto_ptr<alert>(new peer_ban_alert(*this)); }
 
135
 
 
136
                tcp::endpoint ip;
 
137
        };
 
138
 
 
139
        struct TORRENT_EXPORT peer_error_alert: alert
 
140
        {
 
141
                peer_error_alert(tcp::endpoint const& pip, peer_id const& pid_, std::string const& msg)
 
142
                        : alert(alert::debug, msg)
 
143
                        , ip(pip)
 
144
                        , pid(pid_)
 
145
                {}
 
146
 
 
147
                virtual std::auto_ptr<alert> clone() const
 
148
                { return std::auto_ptr<alert>(new peer_error_alert(*this)); }
 
149
 
 
150
                tcp::endpoint ip;
 
151
                peer_id pid;
 
152
        };
 
153
 
 
154
        struct TORRENT_EXPORT invalid_request_alert: torrent_alert
 
155
        {
 
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)
 
163
                        , ip(sender)
 
164
                        , request(r)
 
165
                        , pid(pid_)
 
166
                {}
 
167
 
 
168
                virtual std::auto_ptr<alert> clone() const
 
169
                { return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
 
170
 
 
171
                tcp::endpoint ip;
 
172
                peer_request request;
 
173
                peer_id pid;
 
174
        };
 
175
 
 
176
        struct TORRENT_EXPORT torrent_finished_alert: torrent_alert
 
177
        {
 
178
                torrent_finished_alert(
 
179
                        const torrent_handle& h
 
180
                        , const std::string& msg)
 
181
                        : torrent_alert(h, alert::warning, msg)
 
182
                {}
 
183
 
 
184
                virtual std::auto_ptr<alert> clone() const
 
185
                { return std::auto_ptr<alert>(new torrent_finished_alert(*this)); }
 
186
        };
 
187
 
 
188
        struct TORRENT_EXPORT piece_finished_alert: torrent_alert
 
189
        {
 
190
                piece_finished_alert(
 
191
                        const torrent_handle& h
 
192
                        , int piece_num
 
193
                        , const std::string& msg)
 
194
                        : torrent_alert(h, alert::debug, msg)
 
195
                        , piece_index(piece_num)
 
196
                { TORRENT_ASSERT(piece_index >= 0);}
 
197
 
 
198
                int piece_index;
 
199
 
 
200
                virtual std::auto_ptr<alert> clone() const
 
201
                { return std::auto_ptr<alert>(new piece_finished_alert(*this)); }
 
202
        };
 
203
 
 
204
        struct TORRENT_EXPORT block_finished_alert: torrent_alert
 
205
        {
 
206
                block_finished_alert(
 
207
                        const torrent_handle& h
 
208
                        , int block_num
 
209
                        , int piece_num
 
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);}
 
215
 
 
216
                int block_index;
 
217
                int piece_index;
 
218
 
 
219
                virtual std::auto_ptr<alert> clone() const
 
220
                { return std::auto_ptr<alert>(new block_finished_alert(*this)); }
 
221
        };
 
222
 
 
223
        struct TORRENT_EXPORT block_downloading_alert: torrent_alert
 
224
        {
 
225
                block_downloading_alert(
 
226
                        const torrent_handle& h
 
227
                        , char const* speedmsg
 
228
                        , int block_num
 
229
                        , int piece_num
 
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);}
 
236
 
 
237
                std::string peer_speedmsg;
 
238
                int block_index;
 
239
                int piece_index;
 
240
 
 
241
                virtual std::auto_ptr<alert> clone() const
 
242
                { return std::auto_ptr<alert>(new block_downloading_alert(*this)); }
 
243
        };
 
244
 
 
245
        struct TORRENT_EXPORT storage_moved_alert: torrent_alert
 
246
        {
 
247
                storage_moved_alert(torrent_handle const& h, std::string const& path)
 
248
                        : torrent_alert(h, alert::warning, path)
 
249
                {}
 
250
        
 
251
                virtual std::auto_ptr<alert> clone() const
 
252
                { return std::auto_ptr<alert>(new storage_moved_alert(*this)); }
 
253
        };
 
254
 
 
255
        struct TORRENT_EXPORT torrent_deleted_alert: torrent_alert
 
256
        {
 
257
                torrent_deleted_alert(torrent_handle const& h, std::string const& msg)
 
258
                        : torrent_alert(h, alert::warning, msg)
 
259
                {}
 
260
        
 
261
                virtual std::auto_ptr<alert> clone() const
 
262
                { return std::auto_ptr<alert>(new torrent_deleted_alert(*this)); }
 
263
        };
 
264
 
 
265
        struct TORRENT_EXPORT torrent_paused_alert: torrent_alert
 
266
        {
 
267
                torrent_paused_alert(torrent_handle const& h, std::string const& msg)
 
268
                        : torrent_alert(h, alert::warning, msg)
 
269
                {}
 
270
        
 
271
                virtual std::auto_ptr<alert> clone() const
 
272
                { return std::auto_ptr<alert>(new torrent_paused_alert(*this)); }
 
273
        };
 
274
 
 
275
        struct TORRENT_EXPORT torrent_checked_alert: torrent_alert
 
276
        {
 
277
                torrent_checked_alert(torrent_handle const& h, std::string const& msg)
 
278
                        : torrent_alert(h, alert::info, msg)
 
279
                {}
 
280
 
 
281
                virtual std::auto_ptr<alert> clone() const
 
282
                { return std::auto_ptr<alert>(new torrent_checked_alert(*this)); }
 
283
  };
 
284
 
 
285
 
 
286
        struct TORRENT_EXPORT url_seed_alert: torrent_alert
 
287
        {
 
288
                url_seed_alert(
 
289
                        torrent_handle const& h
 
290
                        , const std::string& url_
 
291
                        , const std::string& msg)
 
292
                        : torrent_alert(h, alert::warning, msg)
 
293
                        , url(url_)
 
294
                {}
 
295
 
 
296
                virtual std::auto_ptr<alert> clone() const
 
297
                { return std::auto_ptr<alert>(new url_seed_alert(*this)); }
 
298
 
 
299
                std::string url;
 
300
        };
 
301
 
 
302
        struct TORRENT_EXPORT file_error_alert: torrent_alert
 
303
        {
 
304
                file_error_alert(
 
305
                        const torrent_handle& h
 
306
                        , const std::string& msg)
 
307
                        : torrent_alert(h, alert::fatal, msg)
 
308
                {}
 
309
 
 
310
                virtual std::auto_ptr<alert> clone() const
 
311
                { return std::auto_ptr<alert>(new file_error_alert(*this)); }
 
312
        };
 
313
 
 
314
        struct TORRENT_EXPORT metadata_failed_alert: torrent_alert
 
315
        {
 
316
                metadata_failed_alert(
 
317
                        const torrent_handle& h
 
318
                        , const std::string& msg)
 
319
                        : torrent_alert(h, alert::info, msg)
 
320
                {}
 
321
 
 
322
                virtual std::auto_ptr<alert> clone() const
 
323
                { return std::auto_ptr<alert>(new metadata_failed_alert(*this)); }
 
324
        };
 
325
        
 
326
        struct TORRENT_EXPORT metadata_received_alert: torrent_alert
 
327
        {
 
328
                metadata_received_alert(
 
329
                        const torrent_handle& h
 
330
                        , const std::string& msg)
 
331
                        : torrent_alert(h, alert::info, msg)
 
332
                {}
 
333
 
 
334
                virtual std::auto_ptr<alert> clone() const
 
335
                { return std::auto_ptr<alert>(new metadata_received_alert(*this)); }
 
336
        };
 
337
 
 
338
        struct TORRENT_EXPORT listen_failed_alert: alert
 
339
        {
 
340
                listen_failed_alert(
 
341
                        tcp::endpoint const& ep
 
342
                        , std::string const& msg)
 
343
                        : alert(alert::fatal, msg)
 
344
                        , endpoint(ep)
 
345
                {}
 
346
 
 
347
                tcp::endpoint endpoint;
 
348
 
 
349
                virtual std::auto_ptr<alert> clone() const
 
350
                { return std::auto_ptr<alert>(new listen_failed_alert(*this)); }
 
351
        };
 
352
 
 
353
        struct TORRENT_EXPORT listen_succeeded_alert: alert
 
354
        {
 
355
                listen_succeeded_alert(
 
356
                        tcp::endpoint const& ep
 
357
                        , std::string const& msg)
 
358
                        : alert(alert::fatal, msg)
 
359
                        , endpoint(ep)
 
360
                {}
 
361
 
 
362
                tcp::endpoint endpoint;
 
363
 
 
364
                virtual std::auto_ptr<alert> clone() const
 
365
                { return std::auto_ptr<alert>(new listen_succeeded_alert(*this)); }
 
366
        };
 
367
 
 
368
        struct TORRENT_EXPORT portmap_error_alert: alert
 
369
        {
 
370
                portmap_error_alert(const std::string& msg)
 
371
                        : alert(alert::warning, msg)
 
372
                {}
 
373
 
 
374
                virtual std::auto_ptr<alert> clone() const
 
375
                { return std::auto_ptr<alert>(new portmap_error_alert(*this)); }
 
376
        };
 
377
 
 
378
        struct TORRENT_EXPORT portmap_alert: alert
 
379
        {
 
380
                portmap_alert(const std::string& msg)
 
381
                        : alert(alert::info, msg)
 
382
                {}
 
383
 
 
384
                virtual std::auto_ptr<alert> clone() const
 
385
                { return std::auto_ptr<alert>(new portmap_alert(*this)); }
 
386
        };
 
387
 
 
388
        struct TORRENT_EXPORT fastresume_rejected_alert: torrent_alert
 
389
        {
 
390
                fastresume_rejected_alert(torrent_handle const& h
 
391
                        , std::string const& msg)
 
392
                        : torrent_alert(h, alert::warning, msg)
 
393
                {}
 
394
 
 
395
                virtual std::auto_ptr<alert> clone() const
 
396
                { return std::auto_ptr<alert>(new fastresume_rejected_alert(*this)); }
 
397
        };
 
398
 
 
399
        struct TORRENT_EXPORT peer_blocked_alert: alert
 
400
        {
 
401
                peer_blocked_alert(address const& ip_
 
402
                        , std::string const& msg)
 
403
                        : alert(alert::info, msg)
 
404
                        , ip(ip_)
 
405
                {}
 
406
                
 
407
                address ip;
 
408
 
 
409
                virtual std::auto_ptr<alert> clone() const
 
410
                { return std::auto_ptr<alert>(new peer_blocked_alert(*this)); }
 
411
        };
 
412
 
 
413
}
 
414
 
 
415
 
 
416
#endif