libktorrent  2.2.0
utmetadata.h
1 /***************************************************************************
2  * Copyright (C) 2009 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef BT_UTMETADATA_H
22 #define BT_UTMETADATA_H
23 
24 #include <peer/peerprotocolextension.h>
25 
26 namespace bt
27 {
28  class MetadataDownload;
29  class BDictNode;
30  class Peer;
31  class Torrent;
32 
36  class KTORRENT_EXPORT UTMetaData : public PeerProtocolExtension
37  {
38  public:
39  UTMetaData(const Torrent & tor,bt::Uint32 id,Peer* peer);
40  ~UTMetaData() override;
41 
45  void handlePacket(const bt::Uint8* packet, Uint32 size) override;
46 
50  void setReportedMetadataSize(Uint32 metadata_size);
51 
52  private:
53  void request(BDictNode* dict);
54  void reject(BDictNode* dict);
55  void data(BDictNode* dict,const QByteArray & piece_data);
56  void sendReject(int piece);
57  void sendData(int piece,int total_size,const QByteArray & data);
58  void startDownload();
59 
60  private:
61  const Torrent & tor;
62  Uint32 reported_metadata_size;
63  MetadataDownload* download;
64  };
65 
66 }
67 
68 #endif // BT_UTMETADATA_H
bt::Torrent
Loads a .torrent file.
Definition: torrent.h:80
bt::MetadataDownload
Definition: metadatadownload.h:58
bt::BDictNode
Represents a dictionary in bencoded data.
Definition: bnode.h:119