2007-08-20 10:29:18 +04:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2006 Christophe Dumez
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2009-04-05 21:00:55 +04:00
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
2007-08-20 10:29:18 +04:00
|
|
|
* Contact : chris@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QTORRENTHANDLE_H
|
|
|
|
#define QTORRENTHANDLE_H
|
|
|
|
|
2010-06-07 12:32:41 +04:00
|
|
|
#include <libtorrent/version.hpp>
|
2007-08-20 10:29:18 +04:00
|
|
|
#include <libtorrent/torrent_handle.hpp>
|
2007-08-23 18:04:53 +04:00
|
|
|
#include <libtorrent/torrent_info.hpp>
|
2007-09-16 13:19:22 +04:00
|
|
|
|
2007-08-20 10:29:18 +04:00
|
|
|
using namespace libtorrent;
|
2009-11-28 23:23:17 +03:00
|
|
|
|
2009-11-12 10:42:21 +03:00
|
|
|
#include <QString>
|
2007-08-23 18:04:53 +04:00
|
|
|
class QStringList;
|
2007-08-20 10:29:18 +04:00
|
|
|
|
|
|
|
// A wrapper for torrent_handle in libtorrent
|
|
|
|
// to interact well with Qt types
|
2010-10-20 00:00:50 +04:00
|
|
|
class QTorrentHandle : public torrent_handle {
|
2007-08-20 10:29:18 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
//
|
|
|
|
// Constructors
|
|
|
|
//
|
|
|
|
|
|
|
|
QTorrentHandle() {}
|
2010-03-12 00:43:09 +03:00
|
|
|
explicit QTorrentHandle(torrent_handle h);
|
2007-08-20 10:29:18 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Getters
|
|
|
|
//
|
|
|
|
QString hash() const;
|
|
|
|
QString name() const;
|
|
|
|
float progress() const;
|
2008-11-02 00:42:56 +03:00
|
|
|
bitfield pieces() const;
|
2007-08-20 10:29:18 +04:00
|
|
|
QString current_tracker() const;
|
|
|
|
bool is_paused() const;
|
2007-08-29 18:30:30 +04:00
|
|
|
bool has_filtered_pieces() const;
|
2007-11-18 21:06:44 +03:00
|
|
|
size_type total_size() const;
|
|
|
|
size_type piece_length() const;
|
|
|
|
int num_pieces() const;
|
2007-10-10 23:10:34 +04:00
|
|
|
size_type total_wanted_done() const;
|
2010-11-16 20:43:54 +03:00
|
|
|
size_type total_wanted() const;
|
2007-08-20 10:29:18 +04:00
|
|
|
float download_payload_rate() const;
|
|
|
|
float upload_payload_rate() const;
|
2009-11-12 10:42:21 +03:00
|
|
|
int num_connections() const;
|
|
|
|
int connections_limit() const;
|
2007-08-20 10:29:18 +04:00
|
|
|
int num_peers() const;
|
|
|
|
int num_seeds() const;
|
2009-07-12 09:37:09 +04:00
|
|
|
int num_complete() const;
|
|
|
|
int num_incomplete() const;
|
2007-08-20 10:29:18 +04:00
|
|
|
QString save_path() const;
|
|
|
|
QStringList url_seeds() const;
|
|
|
|
size_type actual_size() const;
|
|
|
|
int num_files() const;
|
2008-11-02 13:47:59 +03:00
|
|
|
int queue_position() const;
|
2008-11-02 14:43:20 +03:00
|
|
|
bool is_queued() const;
|
2010-10-23 20:21:56 +04:00
|
|
|
QString filename_at(unsigned int index) const;
|
2007-08-29 20:07:37 +04:00
|
|
|
size_type filesize_at(unsigned int index) const;
|
2007-08-20 10:29:18 +04:00
|
|
|
torrent_status::state_t state() const;
|
|
|
|
QString creator() const;
|
|
|
|
QString comment() const;
|
|
|
|
size_type total_failed_bytes() const;
|
2009-11-12 10:42:21 +03:00
|
|
|
size_type total_redundant_bytes() const;
|
2010-03-03 20:27:25 +03:00
|
|
|
size_type total_payload_download() const;
|
|
|
|
size_type total_payload_upload() const;
|
|
|
|
size_type all_time_upload() const;
|
|
|
|
size_type all_time_download() const;
|
|
|
|
size_type total_done() const;
|
2007-08-23 18:04:53 +04:00
|
|
|
QStringList files_path() const;
|
2010-10-18 21:44:37 +04:00
|
|
|
QStringList uneeded_files_path() const;
|
2010-08-22 00:22:59 +04:00
|
|
|
bool has_missing_files() const;
|
2007-08-24 16:25:52 +04:00
|
|
|
int num_uploads() const;
|
2008-09-03 22:19:17 +04:00
|
|
|
bool is_seed() const;
|
2009-11-17 14:46:43 +03:00
|
|
|
bool is_checking() const;
|
2008-11-02 14:43:20 +03:00
|
|
|
bool is_auto_managed() const;
|
2009-11-12 10:42:21 +03:00
|
|
|
qlonglong active_time() const;
|
|
|
|
qlonglong seeding_time() const;
|
|
|
|
QString creation_date() const;
|
2010-05-18 13:35:55 +04:00
|
|
|
QString next_announce() const;
|
|
|
|
qlonglong next_announce_s() const;
|
2009-11-19 18:43:00 +03:00
|
|
|
bool priv() const;
|
2009-11-21 13:17:57 +03:00
|
|
|
bool first_last_piece_first() const;
|
2010-01-23 12:54:50 +03:00
|
|
|
QString root_path() const;
|
2010-06-27 21:58:08 +04:00
|
|
|
QString firstFileSavePath() const;
|
2010-01-31 22:03:34 +03:00
|
|
|
bool has_error() const;
|
2010-05-24 18:19:25 +04:00
|
|
|
QString error() const;
|
2010-03-19 01:58:32 +03:00
|
|
|
void downloading_pieces(bitfield &bf) const;
|
2007-08-20 10:29:18 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Setters
|
|
|
|
//
|
2008-12-27 20:05:26 +03:00
|
|
|
void pause();
|
2007-08-20 10:29:18 +04:00
|
|
|
void resume();
|
|
|
|
void remove_url_seed(QString seed);
|
|
|
|
void add_url_seed(QString seed);
|
2010-07-23 21:15:47 +04:00
|
|
|
void prioritize_files(const std::vector<int> &v);
|
2009-08-16 07:09:20 +04:00
|
|
|
void file_priority(int index, int priority) const;
|
2007-08-20 10:29:18 +04:00
|
|
|
void set_tracker_login(QString username, QString password);
|
2008-11-02 22:55:55 +03:00
|
|
|
void move_storage(QString path) const;
|
2010-07-23 21:15:47 +04:00
|
|
|
void add_tracker(const announce_entry& url);
|
2009-11-21 13:17:57 +03:00
|
|
|
void prioritize_first_last_piece(bool b);
|
2009-12-18 16:36:47 +03:00
|
|
|
void rename_file(int index, QString name);
|
2010-01-20 00:47:53 +03:00
|
|
|
bool save_torrent_file(QString path);
|
2007-08-20 10:29:18 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Operators
|
|
|
|
//
|
|
|
|
bool operator ==(const QTorrentHandle& new_h) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|