libktorrent  2.2.0
metadatadownload.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 
22 #ifndef BT_METADATADOWNLOAD_H
23 #define BT_METADATADOWNLOAD_H
24 
25 
26 #include <util/constants.h>
27 #include <util/bitset.h>
28 #include <QByteArray>
29 
30 namespace bt
31 {
32  class UTMetaData;
33 
34  const int METADATA_PIECE_SIZE = 16 * 1024;
35 
39  class MetadataDownload
40  {
41  public:
42  MetadataDownload(UTMetaData* ext,Uint32 size);
43  virtual ~MetadataDownload();
44 
46  void reject(Uint32 piece);
47 
52  bool data(Uint32 piece,const QByteArray & piece_data);
53 
55  const QByteArray & result() const {return metadata;}
56 
57  private:
58  void download(Uint32 piece);
59  void downloadNext();
60 
61  private:
62  UTMetaData* ext;
63  BitSet pieces;
64  QByteArray metadata;
65  Uint32 total_size;
66  };
67 
68 }
69 
70 #endif // BT_METADATADOWNLOAD_H
bt::BitSet
Simple implementation of a BitSet.
Definition: bitset.h:55
bt::MetadataDownload::result
const QByteArray & result() const
Get the result.
Definition: metadatadownload.h:73
bt::MetadataDownload::reject
void reject(Uint32 piece)
A reject of a piece was received.
bt::MetadataDownload::data
bool data(Uint32 piece, const QByteArray &piece_data)
bt::UTMetaData
Definition: utmetadata.h:55