1 /***************************************************************************
2 * Copyright (C) 2010 by Ixonos Plc *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; version 2 of the License. *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
13 * You should have received a copy of the GNU General Public License *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17 ***************************************************************************/
18 #ifndef QTORRENTHANDLE_H
19 #define QTORRENTHANDLE_H
24 #include <qtrapids/info.hpp>
25 #include <libtorrent/torrent_handle.hpp>
30 typedef libtorrent::torrent_info const& torrent_info_cref;
31 typedef libtorrent::torrent_handle torrent_handle_t;
32 typedef libtorrent::sha1_hash Sha1Hash;
35 inline QString Hash2QStr(Sha1Hash const& hash)
37 return QString(hash.to_string().c_str());
41 @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
47 TorrentHandle(libtorrent::torrent_handle handle);
52 torrent_info_cref getTorrentInfo() const;
56 Sha1Hash hash() const {
57 return torrentHandle_.info_hash();
61 size_t getTotalSize() const;
62 size_t getTotalDone() const;
63 TorrentStatus::Id state() const;
64 float progress() const;
65 float uploadRate() const;
66 float downloadRate() const;
67 qint32 numSeeds() const;
68 qint32 numLeeches() const;
71 torrent_handle_t getHandle() const;
72 bool operator==(TorrentHandle const& h) const;
73 bool operator<(TorrentHandle const& h) const;
76 TorrentHandle(); // Prevent default construct.
77 torrent_handle_t torrentHandle_;
79 TorrentStatus_t status() const;