TrackerRequest.h

Go to the documentation of this file.
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_REQUEST_H
00024 #define PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_REQUEST_H
00025 
00026 #include "PeerInfo.h"
00027 #include "Imports.h"
00028 
00029 namespace Protocols {
00030 namespace BitTorrent {
00031 namespace Trackers {
00032 
00034 
00064 class TrackerRequest
00065 {
00066 public:
00067     VALUE_OBJECT (TrackerRequest)
00068 
00069 public:
00071     enum Event
00072     {
00073         Empty = 0,      
00074         Started,        
00075         Completed,      
00076         Stopped         
00077     };
00078 
00079                         TrackerRequest (const Uri &announceUrl,
00080                                         const PeerInfo &peerInfo,
00081                                         const Torrent::InfoHash &infoHash,
00082                                         quint64 uploaded,
00083                                         quint64 downloaded,
00084                                         quint64 left,
00085                                         bool compact,
00086                                         Event event = Empty,
00087                                         uint numWant = 0,
00088                                         QByteArray key = QByteArray(),
00089                                         QByteArray trackerId = QByteArray());
00090                         ~TrackerRequest();
00091 
00092     Uri                 announceUrl() const;
00093     PeerInfo            peerInfo() const;
00094     Torrent::InfoHash   infoHash() const;
00095     quint64             uploaded() const;
00096     quint64             downloaded() const;
00097     quint64             left() const;
00098     bool                compact() const;
00099     Event               event() const;
00100     uint                numWant() const;
00101     QByteArray          key() const;
00102     QByteArray          trackerId() const;
00103 
00104 private:
00106     struct PrivateData : public QSharedData
00107     {
00108         Uri                 announceUrl; 
00109         PeerInfo            peerInfo;    
00110         Torrent::InfoHash   infoHash;    
00111         quint64             uploaded;    
00112         quint64             downloaded;  
00113         quint64             left;        
00114         bool                compact;     
00115         Event               event;       
00116         uint                numWant;     
00117         QByteArray          key;         
00118         QByteArray          trackerId;   
00119     };
00120 
00121     QSharedDataPointer <PrivateData> d; 
00122 };
00123 
00125 inline Uri TrackerRequest::announceUrl() const
00126 { return d->announceUrl; }
00127 
00129 inline PeerInfo TrackerRequest::peerInfo() const
00130 { return d->peerInfo; }
00131 
00133 inline Torrent::InfoHash TrackerRequest::infoHash() const
00134 { return d->infoHash; }
00135 
00137 inline quint64 TrackerRequest::uploaded() const
00138 { return d->uploaded; }
00139 
00141 inline quint64 TrackerRequest::downloaded() const
00142 { return d->downloaded; }
00143 
00145 inline quint64 TrackerRequest::left() const
00146 { return d->left; }
00147 
00149 inline bool TrackerRequest::compact() const
00150 { return d->compact; }
00151 
00153 inline TrackerRequest::Event TrackerRequest::event() const
00154 { return d->event; }
00155 
00157 inline uint TrackerRequest::numWant() const
00158 { return d->numWant; }
00159 
00161 inline QByteArray TrackerRequest::key() const
00162 { return d->key; }
00163 
00165 inline QByteArray TrackerRequest::trackerId() const
00166 { return d->trackerId; }
00167 
00168 } // namespace Trackers
00169 } // namespace BitTorrent
00170 } // namespace Protocols
00171 
00172 #endif // PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_REQUEST_H