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

« back to all changes in this revision

Viewing changes to include/libtorrent/error_code.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#define TORRENT_ERROR_CODE_HPP_INCLUDED
35
35
 
36
36
#include <boost/version.hpp>
 
37
#include <boost/shared_ptr.hpp>
 
38
 
 
39
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
 
40
// asio assumes that the windows error codes are defined already
 
41
#include <winsock2.h>
 
42
#endif
37
43
 
38
44
#if BOOST_VERSION < 103500
39
45
#include <asio/error_code.hpp>
42
48
#endif
43
49
 
44
50
#include "libtorrent/config.hpp"
45
 
#include <boost/shared_ptr.hpp>
46
 
#include <string>
47
51
 
48
52
namespace libtorrent
49
53
{
53
57
                enum error_code_enum
54
58
                {
55
59
                        no_error = 0,
56
 
                        file_collision
 
60
                        file_collision,
 
61
                        failed_hash_check,
 
62
                        torrent_is_no_dict,
 
63
                        torrent_missing_info,
 
64
                        torrent_info_no_dict,
 
65
                        torrent_missing_piece_length,
 
66
                        torrent_missing_name,
 
67
                        torrent_invalid_name,
 
68
                        torrent_invalid_length,
 
69
                        torrent_file_parse_failed,
 
70
                        torrent_missing_pieces,
 
71
                        torrent_invalid_hashes,
 
72
                        too_many_pieces_in_torrent,
 
73
                        invalid_swarm_metadata,
 
74
                        invalid_bencoding,
 
75
                        no_files_in_torrent,
 
76
                        invalid_escaped_string,
 
77
                        session_is_closing,
 
78
                        duplicate_torrent,
 
79
                        invalid_torrent_handle,
 
80
                        invalid_entry_type,
 
81
                        missing_info_hash_in_uri,
 
82
                        file_too_short,
 
83
                        unsupported_url_protocol,
 
84
                        url_parse_error,
 
85
                        peer_sent_empty_piece,
 
86
                        parse_failed,
 
87
                        invalid_file_tag,
 
88
                        missing_info_hash,
 
89
                        mismatching_info_hash,
 
90
                        invalid_hostname,
 
91
                        invalid_port,
 
92
                        port_blocked,
 
93
                        expected_close_bracket_in_address,
 
94
                        destructing_torrent,
 
95
                        timed_out,
 
96
                        upload_upload_connection,
 
97
                        uninteresting_upload_peer,
 
98
                        invalid_info_hash,
 
99
                        torrent_paused,
 
100
                        invalid_have,
 
101
                        invalid_bitfield_size,
 
102
                        too_many_requests_when_choked,
 
103
                        invalid_piece,
 
104
                        no_memory,
 
105
                        torrent_aborted,
 
106
                        self_connection,
 
107
                        invalid_piece_size,
 
108
                        timed_out_no_interest,
 
109
                        timed_out_inactivity,
 
110
                        timed_out_no_handshake,
 
111
                        timed_out_no_request,
 
112
                        invalid_choke,
 
113
                        invalid_unchoke,
 
114
                        invalid_interested,
 
115
                        invalid_not_interested,
 
116
                        invalid_request,
 
117
                        invalid_hash_list,
 
118
                        invalid_hash_piece,
 
119
                        invalid_cancel,
 
120
                        invalid_dht_port,
 
121
                        invalid_suggest,
 
122
                        invalid_have_all,
 
123
                        invalid_have_none,
 
124
                        invalid_reject,
 
125
                        invalid_allow_fast,
 
126
                        invalid_extended,
 
127
                        invalid_message,
 
128
                        sync_hash_not_found,
 
129
                        invalid_encryption_constant,
 
130
                        no_plaintext_mode,
 
131
                        no_rc4_mode,
 
132
                        unsupported_encryption_mode,
 
133
                        unsupported_encryption_mode_selected,
 
134
                        invalid_pad_size,
 
135
                        invalid_encrypt_handshake,
 
136
                        no_incoming_encrypted,
 
137
                        no_incoming_regular,
 
138
                        duplicate_peer_id,
 
139
                        torrent_removed,
 
140
                        packet_too_large,
 
141
                        reserved,
 
142
                        http_error,
 
143
                        missing_location,
 
144
                        invalid_redirection,
 
145
                        redirecting,
 
146
                        invalid_range,
 
147
                        no_content_length,
 
148
                        banned_by_ip_filter,
 
149
                        too_many_connections,
 
150
                        peer_banned,
 
151
                        stopping_torrent,
 
152
                        too_many_corrupt_pieces,
 
153
                        torrent_not_ready,
 
154
                        peer_not_constructed,
 
155
                        session_closing,
 
156
                        optimistic_disconnect,
 
157
                        torrent_finished,
 
158
                        no_router,
 
159
                        metadata_too_large,
 
160
                        invalid_metadata_request,
 
161
                        invalid_metadata_size,
 
162
                        invalid_metadata_offset,
 
163
                        invalid_metadata_message,
 
164
                        pex_message_too_large,
 
165
                        invalid_pex_message,
 
166
                        invalid_lt_tracker_message,
 
167
                        reserved108,
 
168
                        reserved109,
 
169
                        reserved110,
 
170
                        reserved111,
 
171
                        reserved112,
 
172
                        reserved113,
 
173
                        reserved114,
 
174
                        reserved115,
 
175
                        reserved116,
 
176
                        reserved117,
 
177
                        reserved118,
 
178
                        reserved119,
 
179
 
 
180
// natpmp errors
 
181
                        unsupported_protocol_version, // 120
 
182
                        natpmp_not_authorized,
 
183
                        network_failure,
 
184
                        no_resources,
 
185
                        unsupported_opcode,
 
186
                        reserved125,
 
187
                        reserved126,
 
188
                        reserved127,
 
189
                        reserved128,
 
190
                        reserved129,
 
191
 
 
192
// fastresume errors
 
193
                        missing_file_sizes, // 130
 
194
                        no_files_in_resume_data,
 
195
                        missing_pieces,
 
196
                        mismatching_number_of_files,
 
197
                        mismatching_file_size,
 
198
                        mismatching_file_timestamp,
 
199
                        not_a_dictionary,
 
200
                        invalid_blocks_per_piece,
 
201
                        missing_slots,
 
202
                        too_many_slots,
 
203
                        invalid_slot_list,
 
204
                        invalid_piece_index,
 
205
                        pieces_need_reorder,
 
206
                        reserved143,
 
207
                        reserved144,
 
208
                        reserved145,
 
209
                        reserved146,
 
210
                        reserved147,
 
211
                        reserved148,
 
212
                        reserved149,
 
213
// HTTP errors
 
214
                        http_parse_error, // 150
 
215
                        http_missing_location,
 
216
                        http_failed_decompress,
 
217
                        reserved153,
 
218
                        reserved154,
 
219
                        reserved155,
 
220
                        reserved156,
 
221
                        reserved157,
 
222
                        reserved158,
 
223
                        reserved159,
 
224
 
 
225
                        error_code_max
57
226
                };
58
227
        }
 
228
}
 
229
 
 
230
#if BOOST_VERSION >= 103500
 
231
 
 
232
namespace boost { namespace system {
 
233
 
 
234
        template<> struct is_error_code_enum<libtorrent::errors::error_code_enum>
 
235
        { static const bool value = true; };
 
236
 
 
237
        template<> struct is_error_condition_enum<libtorrent::errors::error_code_enum>
 
238
        { static const bool value = true; };
 
239
} }
 
240
 
 
241
#endif
 
242
 
 
243
namespace libtorrent
 
244
{
59
245
 
60
246
#if BOOST_VERSION < 103500
61
247
        typedef asio::error_code error_code;
62
248
        inline asio::error::error_category get_posix_category() { return asio::error::system_category; }
63
249
        inline asio::error::error_category get_system_category() { return asio::error::system_category; }
 
250
 
 
251
        boost::system::error_category const& get_libtorrent_category()
 
252
        {
 
253
                static ::asio::error::error_category libtorrent_category(20);
 
254
                return libtorrent_category;
 
255
        }
 
256
 
64
257
#else
65
258
 
66
 
        struct libtorrent_error_category : boost::system::error_category
 
259
        struct TORRENT_EXPORT libtorrent_error_category : boost::system::error_category
67
260
        {
68
261
                virtual const char* name() const;
69
262
                virtual std::string message(int ev) const;
71
264
                { return boost::system::error_condition(ev, *this); }
72
265
        };
73
266
 
74
 
        extern libtorrent_error_category libtorrent_category;
 
267
        inline boost::system::error_category& get_libtorrent_category()
 
268
        {
 
269
                static libtorrent_error_category libtorrent_category;
 
270
                return libtorrent_category;
 
271
        }
 
272
 
 
273
        namespace errors
 
274
        {
 
275
                inline boost::system::error_code make_error_code(error_code_enum e)
 
276
                {
 
277
                        return boost::system::error_code(e, get_libtorrent_category());
 
278
                }
 
279
        }
75
280
 
76
281
        using boost::system::error_code;
77
282
        inline boost::system::error_category const& get_system_category()
81
286
        { return boost::system::get_posix_category(); }
82
287
#else
83
288
        { return boost::system::get_generic_category(); }
84
 
#endif
85
 
#endif
 
289
#endif // BOOST_VERSION < 103600
 
290
#endif // BOOST_VERSION < 103500
86
291
 
87
292
#ifndef BOOST_NO_EXCEPTIONS
88
293
        struct TORRENT_EXPORT libtorrent_exception: std::exception