Send correct informations to a http tracker.
[tairent.git] / src / main / hashchecker.h
blobc5b1c5d9e25726e886c1403a34249452eb9dffcf
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
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 GNU *
13 * General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #ifndef _main_hashchecker_h
18 #define _main_hashchecker_h
20 #include <list>
22 #include <tairon/core/signals.h>
24 namespace Tairent
27 namespace Main
30 struct PieceStruct;
32 class Storage;
34 /** \brief HashChecker is used to check a piece against its hash.
36 class HashChecker
38 public:
39 /** Constructs a HashChecker object.
41 * \param i Number of the piece to check.
42 * \param s Storage with the piece.
44 HashChecker(uint32_t i, Storage *s);
46 /** Destroys the object.
48 ~HashChecker();
50 /** Checks the piece's hash. This job is done in a different thread, so
51 * it shouldn't slow down main processing. When the job is done a
52 * specific signal is emitted. This method just creates a functor to
53 * call checkPiece() in a different thread.
55 * \sa hashCorrectSignal
56 * \sa hashIncorrectSignal
58 void check();
60 /** Returns index of the piece that is checked by this object.
62 uint32_t getIndex() {
63 return index;
66 public:
67 /** This signal is emitted when the piece has the correct hash.
69 Tairon::Core::DSignal2<uint32_t, HashChecker *> hashCorrectSignal;
71 /** This signal is emitted when the piece has an incorrect hash.
73 Tairon::Core::DSignal2<uint32_t, HashChecker *> hashIncorrectSignal;
75 private:
76 /** Checks the piece.
78 void checkPiece();
80 private:
81 /** Disabler for functor that calls checkPiece() method.
83 Tairon::Core::FunctorDisabler *disabler;
85 /** Index of the piece.
87 uint32_t index;
89 /** Informations about the piece.
91 PieceStruct *piece;
93 /** Hash of the piece from the torrent's metainfo.
95 String pieceHash;
98 }; // namespace Main
100 }; // namespace Tairent
102 #endif
104 // vim: ai sw=4 ts=4 noet fdm=marker