mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-28 15:34:16 +00:00
- fixed some bugs introduced recently
- improved debug output
This commit is contained in:
parent
35a9fab3b4
commit
829c358f10
@ -367,9 +367,11 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
|
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
|
||||||
// Getting torrent file informations
|
// Getting torrent file informations
|
||||||
torrent_info t(e);
|
torrent_info t(e);
|
||||||
std::cout << t.info_hash() << "\n";
|
qDebug(" -> Hash: %s", misc::toString(t.info_hash()).c_str());
|
||||||
QString hash = QString::fromUtf8(misc::toString(t.info_hash()).c_str());
|
qDebug(" -> Name: %s", t.name().c_str());
|
||||||
|
QString hash = misc::toQString(t.info_hash());
|
||||||
if(s->find_torrent(t.info_hash()).is_valid()) {
|
if(s->find_torrent(t.info_hash()).is_valid()) {
|
||||||
|
qDebug("/!\\ Torrent is already in download list");
|
||||||
// Update info Bar
|
// Update info Bar
|
||||||
if(!fromScanDir) {
|
if(!fromScanDir) {
|
||||||
if(file.startsWith(torrentBackup.path())){
|
if(file.startsWith(torrentBackup.path())){
|
||||||
@ -377,7 +379,8 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
// XXX: Why does this happen sometimes?
|
// XXX: Why does this happen sometimes?
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
QString old_hash = fi.baseName();
|
QString old_hash = fi.baseName();
|
||||||
qDebug("Strange, hash changed to %s", old_hash.toUtf8().data());
|
qDebug("Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
|
||||||
|
Q_ASSERT(old_hash != hash);
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << old_hash+".*";
|
filters << old_hash+".*";
|
||||||
QStringList files = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
QStringList files = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
@ -421,10 +424,10 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
if(index == -1) {
|
if(index == -1) {
|
||||||
fullAllocationModeList << hash;
|
fullAllocationModeList << hash;
|
||||||
}
|
}
|
||||||
qDebug("Full allocation mode");
|
qDebug(" -> Full allocation mode");
|
||||||
}else{
|
}else{
|
||||||
h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, true, true);
|
h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, true, true);
|
||||||
qDebug("Compact allocation mode");
|
qDebug(" -> Compact allocation mode");
|
||||||
}
|
}
|
||||||
if(!h.is_valid()) {
|
if(!h.is_valid()) {
|
||||||
// No need to keep on, it failed.
|
// No need to keep on, it failed.
|
||||||
@ -436,7 +439,6 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
|||||||
// Is this really useful and appropriate ?
|
// Is this really useful and appropriate ?
|
||||||
//h.set_max_connections(60);
|
//h.set_max_connections(60);
|
||||||
h.set_max_uploads(-1);
|
h.set_max_uploads(-1);
|
||||||
qDebug("Torrent hash is " + hash.toUtf8());
|
|
||||||
// Load filtered files
|
// Load filtered files
|
||||||
loadFilesPriorities(h);
|
loadFilesPriorities(h);
|
||||||
// Load custom url seeds
|
// Load custom url seeds
|
||||||
@ -605,7 +607,7 @@ void bittorrent::saveTorrentSpeedLimits(QString hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bittorrent::loadTorrentSpeedLimits(QString hash) {
|
void bittorrent::loadTorrentSpeedLimits(QString hash) {
|
||||||
qDebug("Loading speedLimits file for %s", hash.toUtf8().data());
|
// qDebug("Loading speedLimits file for %s", hash.toUtf8().data());
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".speedLimits");
|
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".speedLimits");
|
||||||
if(!speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(!speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
@ -633,12 +635,11 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) {
|
|||||||
QString hash = h.hash();
|
QString hash = h.hash();
|
||||||
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".priorities");
|
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".priorities");
|
||||||
if(!pieces_file.exists()){
|
if(!pieces_file.exists()){
|
||||||
qDebug("Info: priorities file does not exist for %s", hash.toUtf8().data());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Read saved file
|
// Read saved file
|
||||||
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
qDebug("* Error: Couldn't open priorities file: %s");
|
qDebug("* Error: Couldn't open priorities file: %s", hash.toUtf8().data());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray pieces_priorities = pieces_file.readAll();
|
QByteArray pieces_priorities = pieces_file.readAll();
|
||||||
@ -667,9 +668,9 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
|
|||||||
if(! torrentBackup.exists()) {
|
if(! torrentBackup.exists()) {
|
||||||
torrentBackup.mkpath(torrentBackup.path());
|
torrentBackup.mkpath(torrentBackup.path());
|
||||||
}
|
}
|
||||||
qDebug("Loading ratio data for %s", hash.toUtf8().data());
|
// qDebug("Loading ratio data for %s", hash.toUtf8().data());
|
||||||
QFile ratio_file(torrentBackup.path()+QDir::separator()+ hash + ".ratio");
|
QFile ratio_file(torrentBackup.path()+QDir::separator()+ hash + ".ratio");
|
||||||
if(!ratio_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(!ratio_file.exists() || !ratio_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray data = ratio_file.readAll();
|
QByteArray data = ratio_file.readAll();
|
||||||
@ -1105,7 +1106,6 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h) {
|
|||||||
fullAllocationModeList << hash;
|
fullAllocationModeList << hash;
|
||||||
}
|
}
|
||||||
qDebug("Reloading torrent: %s", fileName.toUtf8().data());
|
qDebug("Reloading torrent: %s", fileName.toUtf8().data());
|
||||||
QTorrentHandle new_h;
|
|
||||||
entry resumeData;
|
entry resumeData;
|
||||||
// Checking if torrentBackup Dir exists
|
// Checking if torrentBackup Dir exists
|
||||||
// create it if it is not
|
// create it if it is not
|
||||||
@ -1128,7 +1128,7 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h) {
|
|||||||
SleeperThread::msleep(1000);
|
SleeperThread::msleep(1000);
|
||||||
++timeout;
|
++timeout;
|
||||||
}
|
}
|
||||||
new_h = s->add_torrent(t, saveDir, resumeData, false);
|
QTorrentHandle new_h = s->add_torrent(t, saveDir, resumeData, false);
|
||||||
qDebug("Using full allocation mode");
|
qDebug("Using full allocation mode");
|
||||||
|
|
||||||
new_h.set_max_uploads(-1);
|
new_h.set_max_uploads(-1);
|
||||||
@ -1174,7 +1174,7 @@ QString bittorrent::getSavePath(QString hash) {
|
|||||||
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
line = savepath_file.readAll();
|
line = savepath_file.readAll();
|
||||||
savepath_file.close();
|
savepath_file.close();
|
||||||
qDebug("Save path: %s", line.data());
|
qDebug(" -> Save path: %s", line.data());
|
||||||
savePath = QString::fromUtf8(line.data());
|
savePath = QString::fromUtf8(line.data());
|
||||||
}else{
|
}else{
|
||||||
// use default save path
|
// use default save path
|
||||||
|
@ -91,7 +91,7 @@ class previewSelect: public QDialog, private Ui::preview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
previewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent){
|
previewSelect(QWidget* parent, QTorrentHandle h): QDialog(parent), h(h){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
// Preview list
|
// Preview list
|
||||||
@ -105,7 +105,6 @@ class previewSelect: public QDialog, private Ui::preview {
|
|||||||
supported_preview_extensions << QString::fromUtf8("AVI") << QString::fromUtf8("DIVX") << QString::fromUtf8("MPG") << QString::fromUtf8("MPEG") << QString::fromUtf8("MPE") << QString::fromUtf8("MP3") << QString::fromUtf8("OGG") << QString::fromUtf8("WMV") << QString::fromUtf8("WMA") << QString::fromUtf8("RMV") << QString::fromUtf8("RMVB") << QString::fromUtf8("ASF") << QString::fromUtf8("MOV") << QString::fromUtf8("WAV") << QString::fromUtf8("MP2") << QString::fromUtf8("SWF") << QString::fromUtf8("AC3") << QString::fromUtf8("OGM") << QString::fromUtf8("MP4") << QString::fromUtf8("FLV") << QString::fromUtf8("VOB") << QString::fromUtf8("QT") << QString::fromUtf8("MKV") << QString::fromUtf8("AIF") << QString::fromUtf8("AIFF") << QString::fromUtf8("AIFC") << QString::fromUtf8("MID") << QString::fromUtf8("MPG") << QString::fromUtf8("RA") << QString::fromUtf8("RAM") << QString::fromUtf8("AU") << QString::fromUtf8("M4A") << QString::fromUtf8("FLAC") << QString::fromUtf8("M4P") << QString::fromUtf8("3GP") << QString::fromUtf8("AAC") << QString::fromUtf8("RM") << QString::fromUtf8("SWA") << QString::fromUtf8("MPC") << QString::fromUtf8("MPP");
|
supported_preview_extensions << QString::fromUtf8("AVI") << QString::fromUtf8("DIVX") << QString::fromUtf8("MPG") << QString::fromUtf8("MPEG") << QString::fromUtf8("MPE") << QString::fromUtf8("MP3") << QString::fromUtf8("OGG") << QString::fromUtf8("WMV") << QString::fromUtf8("WMA") << QString::fromUtf8("RMV") << QString::fromUtf8("RMVB") << QString::fromUtf8("ASF") << QString::fromUtf8("MOV") << QString::fromUtf8("WAV") << QString::fromUtf8("MP2") << QString::fromUtf8("SWF") << QString::fromUtf8("AC3") << QString::fromUtf8("OGM") << QString::fromUtf8("MP4") << QString::fromUtf8("FLV") << QString::fromUtf8("VOB") << QString::fromUtf8("QT") << QString::fromUtf8("MKV") << QString::fromUtf8("AIF") << QString::fromUtf8("AIFF") << QString::fromUtf8("AIFC") << QString::fromUtf8("MID") << QString::fromUtf8("MPG") << QString::fromUtf8("RA") << QString::fromUtf8("RAM") << QString::fromUtf8("AU") << QString::fromUtf8("M4A") << QString::fromUtf8("FLAC") << QString::fromUtf8("M4P") << QString::fromUtf8("3GP") << QString::fromUtf8("AAC") << QString::fromUtf8("RM") << QString::fromUtf8("SWA") << QString::fromUtf8("MPC") << QString::fromUtf8("MPP");
|
||||||
previewList->header()->resizeSection(0, 200);
|
previewList->header()->resizeSection(0, 200);
|
||||||
// Fill list in
|
// Fill list in
|
||||||
this->h = h;
|
|
||||||
std::vector<float> fp;
|
std::vector<float> fp;
|
||||||
h.file_progress(fp);
|
h.file_progress(fp);
|
||||||
unsigned int nbFiles = h.num_files();
|
unsigned int nbFiles = h.num_files();
|
||||||
|
@ -27,82 +27,96 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
QTorrentHandle::QTorrentHandle(torrent_handle h) : h(h) {
|
QTorrentHandle::QTorrentHandle(torrent_handle h): h(h) {}
|
||||||
t = h.get_torrent_info();
|
|
||||||
s = h.status();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getters
|
// Getters
|
||||||
//
|
//
|
||||||
|
|
||||||
torrent_handle QTorrentHandle::get_torrent_handle() const {
|
torrent_handle QTorrentHandle::get_torrent_handle() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_info QTorrentHandle::get_torrent_info() const {
|
torrent_info QTorrentHandle::get_torrent_info() const {
|
||||||
return t;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.get_torrent_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::hash() const {
|
QString QTorrentHandle::hash() const {
|
||||||
return misc::toQString(t.info_hash());
|
Q_ASSERT(h.is_valid());
|
||||||
|
return misc::toQString(h.get_torrent_info().info_hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::name() const {
|
QString QTorrentHandle::name() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return misc::toQString(h.name());
|
return misc::toQString(h.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
float QTorrentHandle::progress() const {
|
float QTorrentHandle::progress() const {
|
||||||
return s.progress;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::current_tracker() const {
|
QString QTorrentHandle::current_tracker() const {
|
||||||
return misc::toQString(s.current_tracker);
|
Q_ASSERT(h.is_valid());
|
||||||
|
return misc::toQString(h.status().current_tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QTorrentHandle::is_valid() const {
|
bool QTorrentHandle::is_valid() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.is_valid();
|
return h.is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QTorrentHandle::is_paused() const {
|
bool QTorrentHandle::is_paused() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.is_paused();
|
return h.is_paused();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::total_size() const {
|
size_type QTorrentHandle::total_size() const {
|
||||||
return t.total_size();
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.get_torrent_info().total_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::total_done() const {
|
size_type QTorrentHandle::total_done() const {
|
||||||
return s.total_done;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().total_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
float QTorrentHandle::download_payload_rate() const {
|
float QTorrentHandle::download_payload_rate() const {
|
||||||
return s.download_payload_rate;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().download_payload_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
float QTorrentHandle::upload_payload_rate() const {
|
float QTorrentHandle::upload_payload_rate() const {
|
||||||
return s.upload_payload_rate;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().upload_payload_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QTorrentHandle::num_peers() const {
|
int QTorrentHandle::num_peers() const {
|
||||||
return s.num_peers;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().num_peers;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QTorrentHandle::num_seeds() const {
|
int QTorrentHandle::num_seeds() const {
|
||||||
return s.num_seeds;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().num_seeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::save_path() const {
|
QString QTorrentHandle::save_path() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return misc::toQString(h.save_path().string());
|
return misc::toQString(h.save_path().string());
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path QTorrentHandle::save_path_boost() const {
|
fs::path QTorrentHandle::save_path_boost() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.save_path();
|
return h.save_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QTorrentHandle::url_seeds() const {
|
QStringList QTorrentHandle::url_seeds() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
QStringList res;
|
QStringList res;
|
||||||
std::vector<std::string> existing_seeds = t.url_seeds();
|
std::vector<std::string> existing_seeds = h.get_torrent_info().url_seeds();
|
||||||
unsigned int nbSeeds = existing_seeds.size();
|
unsigned int nbSeeds = existing_seeds.size();
|
||||||
QString existing_seed;
|
QString existing_seed;
|
||||||
for(unsigned int i=0; i<nbSeeds; ++i){
|
for(unsigned int i=0; i<nbSeeds; ++i){
|
||||||
@ -113,24 +127,24 @@ QStringList QTorrentHandle::url_seeds() const {
|
|||||||
|
|
||||||
// get the size of the torrent without the filtered files
|
// get the size of the torrent without the filtered files
|
||||||
size_type QTorrentHandle::actual_size() const{
|
size_type QTorrentHandle::actual_size() const{
|
||||||
unsigned int nbFiles = t.num_files();
|
Q_ASSERT(h.is_valid());
|
||||||
|
unsigned int nbFiles = h.get_torrent_info().num_files();
|
||||||
if(!h.is_valid()){
|
if(!h.is_valid()){
|
||||||
qDebug("/!\\ Error: Invalid handle");
|
qDebug("/!\\ Error: Invalid handle");
|
||||||
return t.total_size();
|
return h.get_torrent_info().total_size();
|
||||||
}
|
}
|
||||||
QString hash = misc::toQString(t.info_hash());
|
QString hash = misc::toQString(h.get_torrent_info().info_hash());
|
||||||
QFile pieces_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".priorities"));
|
QFile pieces_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".priorities"));
|
||||||
// Read saved file
|
// Read saved file
|
||||||
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
qDebug("* Error: Couldn't open priorities file");
|
return h.get_torrent_info().total_size();
|
||||||
return t.total_size();
|
|
||||||
}
|
}
|
||||||
QByteArray pieces_priorities = pieces_file.readAll();
|
QByteArray pieces_priorities = pieces_file.readAll();
|
||||||
pieces_file.close();
|
pieces_file.close();
|
||||||
QList<QByteArray> pieces_priorities_list = pieces_priorities.split('\n');
|
QList<QByteArray> pieces_priorities_list = pieces_priorities.split('\n');
|
||||||
if((unsigned int)pieces_priorities_list.size() != nbFiles+1){
|
if((unsigned int)pieces_priorities_list.size() != nbFiles+1){
|
||||||
std::cerr << "* Error: Corrupted priorities file\n";
|
std::cerr << "* Error: Corrupted priorities file\n";
|
||||||
return t.total_size();
|
return h.get_torrent_info().total_size();
|
||||||
}
|
}
|
||||||
size_type effective_size = 0;
|
size_type effective_size = 0;
|
||||||
for(unsigned int i=0; i<nbFiles; ++i){
|
for(unsigned int i=0; i<nbFiles; ++i){
|
||||||
@ -139,78 +153,94 @@ size_type QTorrentHandle::actual_size() const{
|
|||||||
priority = 1;
|
priority = 1;
|
||||||
}
|
}
|
||||||
if(priority)
|
if(priority)
|
||||||
effective_size += t.file_at(i).size;
|
effective_size += h.get_torrent_info().file_at(i).size;
|
||||||
}
|
}
|
||||||
return effective_size;
|
return effective_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QTorrentHandle::download_limit() const {
|
int QTorrentHandle::download_limit() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.download_limit();
|
return h.download_limit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QTorrentHandle::upload_limit() const {
|
int QTorrentHandle::upload_limit() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.upload_limit();
|
return h.upload_limit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QTorrentHandle::num_files() const {
|
int QTorrentHandle::num_files() const {
|
||||||
return t.num_files();
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.get_torrent_info().num_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QTorrentHandle::has_metadata() const {
|
bool QTorrentHandle::has_metadata() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.has_metadata();
|
return h.has_metadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
entry QTorrentHandle::write_resume_data() const {
|
entry QTorrentHandle::write_resume_data() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.write_resume_data();
|
return h.write_resume_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::file_at(int index) const {
|
QString QTorrentHandle::file_at(int index) const {
|
||||||
return misc::toQString(t.file_at(index).path.leaf());
|
Q_ASSERT(h.is_valid());
|
||||||
|
return misc::toQString(h.get_torrent_info().file_at(index).path.leaf());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::filesize_at(int index) const {
|
size_type QTorrentHandle::filesize_at(int index) const {
|
||||||
return t.file_at(index).size;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.get_torrent_info().file_at(index).size;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<announce_entry> const& QTorrentHandle::trackers() const {
|
std::vector<announce_entry> const& QTorrentHandle::trackers() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.trackers();
|
return h.trackers();
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_status::state_t QTorrentHandle::state() const {
|
torrent_status::state_t QTorrentHandle::state() const {
|
||||||
return s.state;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().state;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::creator() const {
|
QString QTorrentHandle::creator() const {
|
||||||
return misc::toQString(t.creator());
|
Q_ASSERT(h.is_valid());
|
||||||
|
return misc::toQString(h.get_torrent_info().creator());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::comment() const {
|
QString QTorrentHandle::comment() const {
|
||||||
return misc::toQString(t.comment());
|
Q_ASSERT(h.is_valid());
|
||||||
|
return misc::toQString(h.get_torrent_info().comment());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::total_failed_bytes() const {
|
size_type QTorrentHandle::total_failed_bytes() const {
|
||||||
return s.total_failed_bytes;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().total_failed_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::file_progress(std::vector<float>& fp) {
|
void QTorrentHandle::file_progress(std::vector<float>& fp) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
return h.file_progress(fp);
|
return h.file_progress(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::total_payload_download() {
|
size_type QTorrentHandle::total_payload_download() {
|
||||||
return s.total_payload_download;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().total_payload_download;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::total_payload_upload() {
|
size_type QTorrentHandle::total_payload_upload() {
|
||||||
return s.total_payload_upload;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().total_payload_upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of absolute paths corresponding
|
// Return a list of absolute paths corresponding
|
||||||
// to all files in a torrent
|
// to all files in a torrent
|
||||||
QStringList QTorrentHandle::files_path() const {
|
QStringList QTorrentHandle::files_path() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
QString saveDir = misc::toQString(h.save_path().string()) + QDir::separator();
|
QString saveDir = misc::toQString(h.save_path().string()) + QDir::separator();
|
||||||
QStringList res;
|
QStringList res;
|
||||||
torrent_info::file_iterator fi = t.begin_files();
|
torrent_info::file_iterator fi = h.get_torrent_info().begin_files();
|
||||||
while(fi != t.end_files()) {
|
while(fi != h.get_torrent_info().end_files()) {
|
||||||
res << QDir::cleanPath(saveDir + misc::toQString(fi->path.string()));
|
res << QDir::cleanPath(saveDir + misc::toQString(fi->path.string()));
|
||||||
fi++;
|
fi++;
|
||||||
}
|
}
|
||||||
@ -218,7 +248,8 @@ QStringList QTorrentHandle::files_path() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int QTorrentHandle::num_uploads() const {
|
int QTorrentHandle::num_uploads() const {
|
||||||
return s.num_uploads;
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.status().num_uploads;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -226,54 +257,67 @@ int QTorrentHandle::num_uploads() const {
|
|||||||
//
|
//
|
||||||
|
|
||||||
void QTorrentHandle::set_download_limit(int limit) {
|
void QTorrentHandle::set_download_limit(int limit) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_download_limit(limit);
|
h.set_download_limit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_upload_limit(int limit) {
|
void QTorrentHandle::set_upload_limit(int limit) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_upload_limit(limit);
|
h.set_upload_limit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::pause() {
|
void QTorrentHandle::pause() {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.pause();
|
h.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::resume() {
|
void QTorrentHandle::resume() {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.resume();
|
h.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::remove_url_seed(QString seed) {
|
void QTorrentHandle::remove_url_seed(QString seed) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.remove_url_seed(misc::toString((const char*)seed.toUtf8()));
|
h.remove_url_seed(misc::toString((const char*)seed.toUtf8()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::add_url_seed(QString seed) {
|
void QTorrentHandle::add_url_seed(QString seed) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.add_url_seed(misc::toString((const char*)seed.toUtf8()));
|
h.add_url_seed(misc::toString((const char*)seed.toUtf8()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_max_uploads(int val){
|
void QTorrentHandle::set_max_uploads(int val){
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_max_uploads(val);
|
h.set_max_uploads(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::prioritize_files(std::vector<int> v) {
|
void QTorrentHandle::prioritize_files(std::vector<int> v) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.prioritize_files(v);
|
h.prioritize_files(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_ratio(float ratio) const {
|
void QTorrentHandle::set_ratio(float ratio) const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_ratio(ratio);
|
h.set_ratio(ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::replace_trackers(std::vector<announce_entry> const& v) const {
|
void QTorrentHandle::replace_trackers(std::vector<announce_entry> const& v) const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.replace_trackers(v);
|
h.replace_trackers(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::force_reannounce() {
|
void QTorrentHandle::force_reannounce() {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_sequenced_download_threshold(int val) {
|
void QTorrentHandle::set_sequenced_download_threshold(int val) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_sequenced_download_threshold(val);
|
h.set_sequenced_download_threshold(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::set_tracker_login(QString username, QString password){
|
void QTorrentHandle::set_tracker_login(QString username, QString password){
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
h.set_tracker_login(std::string(username.toUtf8().data()), std::string(password.toUtf8().data()));
|
h.set_tracker_login(std::string(username.toUtf8().data()), std::string(password.toUtf8().data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,12 +327,10 @@ void QTorrentHandle::set_tracker_login(QString username, QString password){
|
|||||||
|
|
||||||
QTorrentHandle& QTorrentHandle::operator =(const torrent_handle& new_h) {
|
QTorrentHandle& QTorrentHandle::operator =(const torrent_handle& new_h) {
|
||||||
h = new_h;
|
h = new_h;
|
||||||
t = h.get_torrent_info();
|
|
||||||
s = h.status();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QTorrentHandle::operator ==(const QTorrentHandle& new_h) const{
|
bool QTorrentHandle::operator ==(const QTorrentHandle& new_h) const{
|
||||||
QString hash = misc::toQString(t.info_hash());
|
QString hash = misc::toQString(h.get_torrent_info().info_hash());
|
||||||
return (hash == new_h.hash());
|
return (hash == new_h.hash());
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,6 @@ class QStringList;
|
|||||||
class QTorrentHandle {
|
class QTorrentHandle {
|
||||||
private:
|
private:
|
||||||
torrent_handle h;
|
torrent_handle h;
|
||||||
torrent_info t;
|
|
||||||
torrent_status s;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -107,7 +105,6 @@ class QTorrentHandle {
|
|||||||
//
|
//
|
||||||
// Operators
|
// Operators
|
||||||
//
|
//
|
||||||
|
|
||||||
QTorrentHandle& operator =(const torrent_handle& new_h);
|
QTorrentHandle& operator =(const torrent_handle& new_h);
|
||||||
bool operator ==(const QTorrentHandle& new_h) const;
|
bool operator ==(const QTorrentHandle& new_h) const;
|
||||||
};
|
};
|
||||||
|
@ -37,11 +37,10 @@ class trackerLogin : public QDialog, private Ui::authentication{
|
|||||||
QTorrentHandle h;
|
QTorrentHandle h;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
trackerLogin(QWidget *parent, QTorrentHandle h): QDialog(parent){
|
trackerLogin(QWidget *parent, QTorrentHandle h): QDialog(parent), h(h){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
login_logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/encrypted.png")));
|
login_logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/encrypted.png")));
|
||||||
this->h = h;
|
|
||||||
tracker_url->setText(h.current_tracker());
|
tracker_url->setText(h.current_tracker());
|
||||||
connect(this, SIGNAL(trackerLoginCancelled(QPair<QTorrentHandle,QString>)), parent, SLOT(addUnauthenticatedTracker(QPair<QTorrentHandle,QString>)));
|
connect(this, SIGNAL(trackerLoginCancelled(QPair<QTorrentHandle,QString>)), parent, SLOT(addUnauthenticatedTracker(QPair<QTorrentHandle,QString>)));
|
||||||
show();
|
show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user