|
|
@ -31,7 +31,6 @@ |
|
|
|
#include <QDir> |
|
|
|
#include <QDir> |
|
|
|
#include <QDateTime> |
|
|
|
#include <QDateTime> |
|
|
|
#include <QString> |
|
|
|
#include <QString> |
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
#include <QSettings> |
|
|
|
#include <QSettings> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
|
|
@ -132,6 +131,8 @@ Bittorrent::Bittorrent() |
|
|
|
timerAlerts = new QTimer(); |
|
|
|
timerAlerts = new QTimer(); |
|
|
|
connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts())); |
|
|
|
connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts())); |
|
|
|
timerAlerts->start(3000); |
|
|
|
timerAlerts->start(3000); |
|
|
|
|
|
|
|
connect(&resumeDataTimer, SIGNAL(timeout()), this, SLOT(saveTempFastResumeData())); |
|
|
|
|
|
|
|
resumeDataTimer.start(180000); // 3min
|
|
|
|
// To download from urls
|
|
|
|
// To download from urls
|
|
|
|
downloader = new downloadThread(this); |
|
|
|
downloader = new downloadThread(this); |
|
|
|
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); |
|
|
|
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); |
|
|
@ -1393,10 +1394,23 @@ float Bittorrent::getRealRatio(QString hash) const{ |
|
|
|
return ratio; |
|
|
|
return ratio; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Bittorrent::saveTempFastResumeData() { |
|
|
|
|
|
|
|
std::vector<torrent_handle> torrents = s->get_torrents(); |
|
|
|
|
|
|
|
std::vector<torrent_handle>::iterator torrentIT; |
|
|
|
|
|
|
|
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { |
|
|
|
|
|
|
|
QTorrentHandle h = QTorrentHandle(*torrentIT); |
|
|
|
|
|
|
|
if(!h.is_valid() || !h.has_metadata() || h.is_seed() || h.is_paused()) continue; |
|
|
|
|
|
|
|
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue; |
|
|
|
|
|
|
|
qDebug("Saving fastresume data for %s", qPrintable(h.name())); |
|
|
|
|
|
|
|
h.save_resume_data(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Only save fast resume data for unfinished and unpaused torrents (Optimization)
|
|
|
|
// Only save fast resume data for unfinished and unpaused torrents (Optimization)
|
|
|
|
// Called periodically and on exit
|
|
|
|
// Called periodically and on exit
|
|
|
|
void Bittorrent::saveFastResumeData() { |
|
|
|
void Bittorrent::saveFastResumeData() { |
|
|
|
// Stop listening for alerts
|
|
|
|
// Stop listening for alerts
|
|
|
|
|
|
|
|
resumeDataTimer.stop(); |
|
|
|
timerAlerts->stop(); |
|
|
|
timerAlerts->stop(); |
|
|
|
int num_resume_data = 0; |
|
|
|
int num_resume_data = 0; |
|
|
|
// Pause session
|
|
|
|
// Pause session
|
|
|
@ -1985,12 +1999,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
/*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
|
|
|
|
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) { |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
p->handle.save_resume_data(); |
|
|
|
if(h.is_valid()) { |
|
|
|
|
|
|
|
emit torrentPaused(h); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) { |
|
|
|
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) { |
|
|
|
// Level: fatal
|
|
|
|
// Level: fatal
|
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|