00001 /* 00002 00003 Copyright (C) 2006-2007 by Peter Dimov. 00004 00005 This file is part of Calitko (http://www.calitko.org). 00006 00007 Calitko is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 Calitko is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Calitko; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 */ 00022 00023 #ifndef PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_RESPONSE_H 00024 #define PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_RESPONSE_H 00025 00026 #include "PeerInfo.h" 00027 #include "Imports.h" 00028 00029 namespace Protocols { 00030 namespace BitTorrent { 00031 namespace Trackers { 00032 00034 00061 class TrackerResponse 00062 { 00063 public: 00064 VALUE_OBJECT (TrackerResponse) 00065 00066 public: 00068 typedef QList <PeerInfo> PeerInfoList; 00069 00070 TrackerResponse(); 00071 ~TrackerResponse(); 00072 00073 QString failureReason() const; 00074 QString warningMessage() const; 00075 uint interval() const; 00076 uint minInterval() const; 00077 QByteArray trackerId() const; 00078 uint complete() const; 00079 uint incomplete() const; 00080 PeerInfoList peers() const; 00081 00082 private: 00083 // TrackerResponseParser is friend because of response data validation 00084 // (now it's possible to validate data only in the TrackerResponseParser and 00085 // there is no way how the user can corrupt them externally). 00086 friend class TrackerResponseParser; 00087 00089 struct PrivateData : public QSharedData 00090 { 00091 QString failureReason; 00092 QString warningMessage; 00093 uint interval; 00094 uint minInterval; 00095 QByteArray trackerId; 00096 uint complete; 00097 uint incomplete; 00098 PeerInfoList peers; 00099 }; 00100 00101 QSharedDataPointer <PrivateData> d; 00102 }; 00103 00105 00109 inline QString TrackerResponse::failureReason() const 00110 { return d->failureReason; } 00111 00113 00117 inline QString TrackerResponse::warningMessage() const 00118 { return d->warningMessage; } 00119 00121 inline uint TrackerResponse::interval() const 00122 { return d->interval; } 00123 00125 inline uint TrackerResponse::minInterval() const 00126 { return d->minInterval; } 00127 00129 inline QByteArray TrackerResponse::trackerId() const 00130 { return d->trackerId; } 00131 00133 inline uint TrackerResponse::complete() const 00134 { return d->complete; } 00135 00137 inline uint TrackerResponse::incomplete() const 00138 { return d->incomplete; } 00139 00141 inline TrackerResponse::PeerInfoList TrackerResponse::peers() const 00142 { return d->peers; } 00143 00144 } // namespace Trackers 00145 } // namespace BitTorrent 00146 } // namespace Protocols 00147 00148 #endif // PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_RESPONSE_H