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.
|
|
|
|
*
|
|
|
|
* Contact : chris@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QTORRENTHANDLE_H
|
|
|
|
#define QTORRENTHANDLE_H
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
class 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
|
|
|
|
class QTorrentHandle {
|
|
|
|
private:
|
|
|
|
torrent_handle h;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
//
|
|
|
|
// Constructors
|
|
|
|
//
|
|
|
|
|
|
|
|
QTorrentHandle() {}
|
|
|
|
QTorrentHandle(torrent_handle h);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Getters
|
|
|
|
//
|
|
|
|
|
|
|
|
torrent_handle get_torrent_handle() const;
|
|
|
|
torrent_info get_torrent_info() const;
|
|
|
|
QString hash() const;
|
|
|
|
QString name() const;
|
|
|
|
float progress() const;
|
2008-11-02 00:42:56 +03:00
|
|
|
bitfield pieces() const;
|
2007-11-18 21:06:44 +03:00
|
|
|
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
2007-08-20 10:29:18 +04:00
|
|
|
QString current_tracker() const;
|
|
|
|
bool is_valid() 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;
|
2007-08-20 10:29:18 +04:00
|
|
|
float download_payload_rate() const;
|
|
|
|
float upload_payload_rate() const;
|
|
|
|
int num_peers() const;
|
|
|
|
int num_seeds() const;
|
|
|
|
QString save_path() const;
|
|
|
|
fs::path save_path_boost() const;
|
|
|
|
QStringList url_seeds() const;
|
|
|
|
size_type actual_size() const;
|
|
|
|
int download_limit() const;
|
|
|
|
int upload_limit() const;
|
|
|
|
int num_files() const;
|
|
|
|
bool has_metadata() const;
|
2008-11-02 00:42:56 +03:00
|
|
|
void save_resume_data() const;
|
2007-08-29 20:07:37 +04:00
|
|
|
QString file_at(unsigned int index) const;
|
|
|
|
size_type filesize_at(unsigned int index) const;
|
2007-08-20 10:29:18 +04:00
|
|
|
std::vector<announce_entry> const& trackers() const;
|
|
|
|
torrent_status::state_t state() const;
|
|
|
|
QString creator() const;
|
|
|
|
QString comment() const;
|
|
|
|
size_type total_failed_bytes() const;
|
2008-11-02 00:42:56 +03:00
|
|
|
void file_progress(std::vector<size_type>& fp);
|
2007-08-20 10:29:18 +04:00
|
|
|
size_type total_payload_download();
|
|
|
|
size_type total_payload_upload();
|
2007-08-23 18:04:53 +04:00
|
|
|
QStringList files_path() 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;
|
2007-08-20 10:29:18 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Setters
|
|
|
|
//
|
|
|
|
|
|
|
|
void set_download_limit(int limit);
|
|
|
|
void set_upload_limit(int limit);
|
|
|
|
void pause();
|
|
|
|
void resume();
|
|
|
|
void remove_url_seed(QString seed);
|
|
|
|
void add_url_seed(QString seed);
|
|
|
|
void set_max_uploads(int val);
|
2007-09-09 11:44:22 +04:00
|
|
|
void set_max_connections(int val);
|
2007-08-20 10:29:18 +04:00
|
|
|
void prioritize_files(std::vector<int> v);
|
|
|
|
void set_ratio(float ratio) const;
|
|
|
|
void replace_trackers(std::vector<announce_entry> const&) const;
|
|
|
|
void force_reannounce();
|
2008-11-02 00:42:56 +03:00
|
|
|
void set_sequential_download(bool);
|
2007-08-20 10:29:18 +04:00
|
|
|
void set_tracker_login(QString username, QString password);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Operators
|
|
|
|
//
|
|
|
|
QTorrentHandle& operator =(const torrent_handle& new_h);
|
|
|
|
bool operator ==(const QTorrentHandle& new_h) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|