libktorrent  2.2.0
torrentfile.h
1 /***************************************************************************
2  * Copyright (C) 2005 by *
3  * Joris Guisson <joris.guisson@gmail.com> *
4  * Ivan Vasic <ivasic@gmail.com> *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20  ***************************************************************************/
21 #ifndef BTTORRENTFILE_H
22 #define BTTORRENTFILE_H
23 
24 #include <qstring.h>
25 #include <util/constants.h>
26 #include <interfaces/torrentfileinterface.h>
27 
28 namespace bt
29 {
30  class ChunkManager;
31  class Torrent;
32 
33 
34 
41  class KTORRENT_EXPORT TorrentFile : public TorrentFileInterface
42  {
43  Q_OBJECT
44 
45  Torrent* tor;
46  Uint64 cache_offset;
47  Priority priority;
48  Priority old_priority;
49  bool missing;
50 
51  public:
55  TorrentFile(Torrent* tor = 0);
56 
66  TorrentFile(Torrent* tor,Uint32 index,const QString & path,Uint64 off,Uint64 size,Uint64 chunk_size);
67 
72  TorrentFile(const TorrentFile & tf);
73  ~TorrentFile() override;
74 
76  Uint64 getCacheOffset() const {return cache_offset;}
77 
79  Uint64 getFirstChunkOffset() const {return first_chunk_off;}
80 
82  Uint64 getLastChunkSize() const {return last_chunk_size;}
83 
85  bool doNotDownload() const override {return (priority == EXCLUDED);}
86 
88  void setDoNotDownload(bool dnd) override;
89 
91  bool isMultimedia() const override;
92 
94  Priority getPriority() const override {return priority;}
95 
97  void setPriority(Priority newpriority = NORMAL_PRIORITY) override;
98 
100  Priority getOldPriority() const {return old_priority;}
101 
102 
104  void emitDownloadStatusChanged() override;
105 
106  void setEmitDownloadStatusChanged(bool show) override { emit_status_changed = show; }
107 
113  TorrentFile & operator = (const TorrentFile & tf);
114 
116  bool isMissing() const {return missing;}
117 
119  void setMissing(bool m) {missing = m;}
120 
126  Uint64 fileOffset(Uint32 cindex,Uint64 chunk_size) const;
127 
128  static TorrentFile null;
129 
134  void updateNumDownloadedChunks(ChunkManager & cman);
135  };
136 
137 }
138 
139 #endif
bt::ChunkManager
Definition: chunkmanager.h:61
bt::TorrentFile
Definition: torrentfile.h:61