00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef TORRENT_ALERT_TYPES_HPP_INCLUDED
00034 #define TORRENT_ALERT_TYPES_HPP_INCLUDED
00035
00036 #include "libtorrent/alert.hpp"
00037 #include "libtorrent/torrent_handle.hpp"
00038 #include "libtorrent/socket.hpp"
00039 #include "libtorrent/peer_connection.hpp"
00040 #include "libtorrent/config.hpp"
00041
00042 namespace libtorrent
00043 {
00044 struct TORRENT_EXPORT torrent_alert: alert
00045 {
00046 torrent_alert(torrent_handle const& h, alert::severity_t s
00047 , std::string const& msg)
00048 : alert(s, msg)
00049 , handle(h)
00050 {}
00051
00052 torrent_handle handle;
00053 };
00054
00055 struct TORRENT_EXPORT tracker_alert: torrent_alert
00056 {
00057 tracker_alert(torrent_handle const& h
00058 , int times
00059 , int status
00060 , std::string const& msg)
00061 : torrent_alert(h, alert::warning, msg)
00062 , times_in_row(times)
00063 , status_code(status)
00064 {}
00065
00066 virtual std::auto_ptr<alert> clone() const
00067 { return std::auto_ptr<alert>(new tracker_alert(*this)); }
00068
00069 int times_in_row;
00070 int status_code;
00071 };
00072
00073 struct TORRENT_EXPORT tracker_warning_alert: torrent_alert
00074 {
00075 tracker_warning_alert(torrent_handle const& h
00076 , std::string const& msg)
00077 : torrent_alert(h, alert::warning, msg)
00078 {}
00079
00080 virtual std::auto_ptr<alert> clone() const
00081 { return std::auto_ptr<alert>(new tracker_warning_alert(*this)); }
00082 };
00083
00084
00085
00086 struct TORRENT_EXPORT tracker_reply_alert: torrent_alert
00087 {
00088 tracker_reply_alert(torrent_handle const& h
00089 , int np
00090 , std::string const& msg)
00091 : torrent_alert(h, alert::info, msg)
00092 , num_peers(np)
00093 {}
00094
00095 int num_peers;
00096
00097 virtual std::auto_ptr<alert> clone() const
00098 { return std::auto_ptr<alert>(new tracker_reply_alert(*this)); }
00099 };
00100
00101 struct TORRENT_EXPORT tracker_announce_alert: torrent_alert
00102 {
00103 tracker_announce_alert(torrent_handle const& h, std::string const& msg)
00104 : torrent_alert(h, alert::info, msg)
00105 {}
00106
00107 virtual std::auto_ptr<alert> clone() const
00108 { return std::auto_ptr<alert>(new tracker_announce_alert(*this)); }
00109 };
00110
00111 struct TORRENT_EXPORT hash_failed_alert: torrent_alert
00112 {
00113 hash_failed_alert(
00114 torrent_handle const& h
00115 , int index
00116 , std::string const& msg)
00117 : torrent_alert(h, alert::info, msg)
00118 , piece_index(index)
00119 { assert(index >= 0);}
00120
00121 virtual std::auto_ptr<alert> clone() const
00122 { return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
00123
00124 int piece_index;
00125 };
00126
00127 struct TORRENT_EXPORT peer_ban_alert: torrent_alert
00128 {
00129 peer_ban_alert(tcp::endpoint const& pip, torrent_handle h, std::string const& msg)
00130 : torrent_alert(h, alert::info, msg)
00131 , ip(pip)
00132 {}
00133
00134 virtual std::auto_ptr<alert> clone() const
00135 { return std::auto_ptr<alert>(new peer_ban_alert(*this)); }
00136
00137 tcp::endpoint ip;
00138 };
00139
00140 struct TORRENT_EXPORT peer_error_alert: alert
00141 {
00142 peer_error_alert(tcp::endpoint const& pip, peer_id const& pid_, std::string const& msg)
00143 : alert(alert::debug, msg)
00144 , ip(pip)
00145 , pid(pid_)
00146 {}
00147
00148 virtual std::auto_ptr<alert> clone() const
00149 { return std::auto_ptr<alert>(new peer_error_alert(*this)); }
00150
00151 tcp::endpoint ip;
00152 peer_id pid;
00153 };
00154
00155 struct TORRENT_EXPORT invalid_request_alert: torrent_alert
00156 {
00157 invalid_request_alert(
00158 peer_request const& r
00159 , torrent_handle const& h
00160 , tcp::endpoint const& sender
00161 , peer_id const& pid_
00162 , std::string const& msg)
00163 : torrent_alert(h, alert::debug, msg)
00164 , ip(sender)
00165 , request(r)
00166 , pid(pid_)
00167 {}
00168
00169 virtual std::auto_ptr<alert> clone() const
00170 { return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
00171
00172 tcp::endpoint ip;
00173 peer_request request;
00174 peer_id pid;
00175 };
00176
00177 struct TORRENT_EXPORT torrent_finished_alert: torrent_alert
00178 {
00179 torrent_finished_alert(
00180 const torrent_handle& h
00181 , const std::string& msg)
00182 : torrent_alert(h, alert::warning, msg)
00183 {}
00184
00185 virtual std::auto_ptr<alert> clone() const
00186 { return std::auto_ptr<alert>(new torrent_finished_alert(*this)); }
00187 };
00188
00189 struct TORRENT_EXPORT url_seed_alert: torrent_alert
00190 {
00191 url_seed_alert(
00192 torrent_handle const& h
00193 , const std::string& url_
00194 , const std::string& msg)
00195 : torrent_alert(h, alert::warning, msg)
00196 , url(url_)
00197 {}
00198
00199 virtual std::auto_ptr<alert> clone() const
00200 { return std::auto_ptr<alert>(new url_seed_alert(*this)); }
00201
00202 std::string url;
00203 };
00204
00205 struct TORRENT_EXPORT file_error_alert: torrent_alert
00206 {
00207 file_error_alert(
00208 const torrent_handle& h
00209 , const std::string& msg)
00210 : torrent_alert(h, alert::fatal, msg)
00211 {}
00212
00213 virtual std::auto_ptr<alert> clone() const
00214 { return std::auto_ptr<alert>(new file_error_alert(*this)); }
00215 };
00216
00217 struct TORRENT_EXPORT metadata_failed_alert: torrent_alert
00218 {
00219 metadata_failed_alert(
00220 const torrent_handle& h
00221 , const std::string& msg)
00222 : torrent_alert(h, alert::info, msg)
00223 {}
00224
00225 virtual std::auto_ptr<alert> clone() const
00226 { return std::auto_ptr<alert>(new metadata_failed_alert(*this)); }
00227 };
00228
00229 struct TORRENT_EXPORT metadata_received_alert: torrent_alert
00230 {
00231 metadata_received_alert(
00232 const torrent_handle& h
00233 , const std::string& msg)
00234 : torrent_alert(h, alert::info, msg)
00235 {}
00236
00237 virtual std::auto_ptr<alert> clone() const
00238 { return std::auto_ptr<alert>(new metadata_received_alert(*this)); }
00239 };
00240
00241 struct TORRENT_EXPORT listen_failed_alert: alert
00242 {
00243 listen_failed_alert(
00244 const std::string& msg)
00245 : alert(alert::fatal, msg)
00246 {}
00247
00248 virtual std::auto_ptr<alert> clone() const
00249 { return std::auto_ptr<alert>(new listen_failed_alert(*this)); }
00250 };
00251
00252 struct TORRENT_EXPORT fastresume_rejected_alert: torrent_alert
00253 {
00254 fastresume_rejected_alert(torrent_handle const& h
00255 , std::string const& msg)
00256 : torrent_alert(h, alert::warning, msg)
00257 {}
00258
00259 virtual std::auto_ptr<alert> clone() const
00260 { return std::auto_ptr<alert>(new fastresume_rejected_alert(*this)); }
00261 };
00262
00263 }
00264
00265
00266 #endif