|
|
@ -81,7 +81,7 @@ using namespace libtorrent; |
|
|
|
QBtSession* QBtSession::m_instance = 0; |
|
|
|
QBtSession* QBtSession::m_instance = 0; |
|
|
|
|
|
|
|
|
|
|
|
const int MAX_TRACKER_ERRORS = 2; |
|
|
|
const int MAX_TRACKER_ERRORS = 2; |
|
|
|
const float MAX_RATIO = 100.; |
|
|
|
const qreal MAX_RATIO = 100.; |
|
|
|
enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL }; |
|
|
|
enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL }; |
|
|
|
|
|
|
|
|
|
|
|
// Main constructor
|
|
|
|
// Main constructor
|
|
|
@ -198,7 +198,7 @@ void QBtSession::processBigRatios() { |
|
|
|
if(!h.is_valid()) continue; |
|
|
|
if(!h.is_valid()) continue; |
|
|
|
if(h.is_seed()) { |
|
|
|
if(h.is_seed()) { |
|
|
|
const QString hash = h.hash(); |
|
|
|
const QString hash = h.hash(); |
|
|
|
const float ratio = getRealRatio(hash); |
|
|
|
const qreal ratio = getRealRatio(hash); |
|
|
|
qDebug("Ratio: %f (limit: %f)", ratio, ratio_limit); |
|
|
|
qDebug("Ratio: %f (limit: %f)", ratio, ratio_limit); |
|
|
|
if(ratio <= MAX_RATIO && ratio >= ratio_limit) { |
|
|
|
if(ratio <= MAX_RATIO && ratio >= ratio_limit) { |
|
|
|
if(high_ratio_action == REMOVE_ACTION) { |
|
|
|
if(high_ratio_action == REMOVE_ACTION) { |
|
|
@ -1395,7 +1395,7 @@ bool QBtSession::enableDHT(bool b) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float QBtSession::getRealRatio(QString hash) const{ |
|
|
|
qreal QBtSession::getRealRatio(QString hash) const{ |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
if(!h.is_valid()) { |
|
|
|
if(!h.is_valid()) { |
|
|
|
return 0.; |
|
|
|
return 0.; |
|
|
@ -1407,7 +1407,7 @@ float QBtSession::getRealRatio(QString hash) const{ |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
return 101; |
|
|
|
return 101; |
|
|
|
} |
|
|
|
} |
|
|
|
float ratio = (float)h.all_time_upload()/(float)h.total_done(); |
|
|
|
qreal ratio = (float)h.all_time_upload()/(float)h.total_done(); |
|
|
|
Q_ASSERT(ratio >= 0.); |
|
|
|
Q_ASSERT(ratio >= 0.); |
|
|
|
if(ratio > 100.) |
|
|
|
if(ratio > 100.) |
|
|
|
ratio = 100.; |
|
|
|
ratio = 100.; |
|
|
@ -1731,7 +1731,7 @@ void QBtSession::setUploadRateLimit(long rate) { |
|
|
|
|
|
|
|
|
|
|
|
// Torrents will a ratio superior to the given value will
|
|
|
|
// Torrents will a ratio superior to the given value will
|
|
|
|
// be automatically deleted
|
|
|
|
// be automatically deleted
|
|
|
|
void QBtSession::setMaxRatio(float ratio) { |
|
|
|
void QBtSession::setMaxRatio(qreal ratio) { |
|
|
|
if(ratio < 0) ratio = -1.; |
|
|
|
if(ratio < 0) ratio = -1.; |
|
|
|
if(ratio_limit == -1 && ratio != -1) { |
|
|
|
if(ratio_limit == -1 && ratio != -1) { |
|
|
|
Q_ASSERT(!BigRatioTimer); |
|
|
|
Q_ASSERT(!BigRatioTimer); |
|
|
@ -2459,14 +2459,14 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) { |
|
|
|
// Return current download rate for the BT
|
|
|
|
// Return current download rate for the BT
|
|
|
|
// session. Payload means that it only take into
|
|
|
|
// session. Payload means that it only take into
|
|
|
|
// account "useful" part of the rate
|
|
|
|
// account "useful" part of the rate
|
|
|
|
float QBtSession::getPayloadDownloadRate() const{ |
|
|
|
qreal QBtSession::getPayloadDownloadRate() const{ |
|
|
|
return s->status().payload_download_rate; |
|
|
|
return s->status().payload_download_rate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Return current upload rate for the BT
|
|
|
|
// Return current upload rate for the BT
|
|
|
|
// session. Payload means that it only take into
|
|
|
|
// session. Payload means that it only take into
|
|
|
|
// account "useful" part of the rate
|
|
|
|
// account "useful" part of the rate
|
|
|
|
float QBtSession::getPayloadUploadRate() const{ |
|
|
|
qreal QBtSession::getPayloadUploadRate() const{ |
|
|
|
return s->status().payload_upload_rate; |
|
|
|
return s->status().payload_upload_rate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|