|
|
@ -998,14 +998,17 @@ void bittorrent::readAlerts() { |
|
|
|
while (a.get()) { |
|
|
|
while (a.get()) { |
|
|
|
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) { |
|
|
|
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) { |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QString hash = h.hash(); |
|
|
|
if(h.is_valid()){ |
|
|
|
qDebug("Received finished alert for %s", h.name().toUtf8().data()); |
|
|
|
QString hash = h.hash(); |
|
|
|
setFinishedTorrent(hash); |
|
|
|
qDebug("Received finished alert for %s", h.name().toUtf8().data()); |
|
|
|
emit finishedTorrent(h); |
|
|
|
setFinishedTorrent(hash); |
|
|
|
|
|
|
|
emit finishedTorrent(h); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) { |
|
|
|
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) { |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
emit fullDiskError(h); |
|
|
|
if(h.is_valid()) |
|
|
|
|
|
|
|
emit fullDiskError(h); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (dynamic_cast<listen_failed_alert*>(a.get())) { |
|
|
|
else if (dynamic_cast<listen_failed_alert*>(a.get())) { |
|
|
|
// Level: fatal
|
|
|
|
// Level: fatal
|
|
|
@ -1014,32 +1017,36 @@ void bittorrent::readAlerts() { |
|
|
|
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())) { |
|
|
|
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())) { |
|
|
|
// Level: fatal
|
|
|
|
// Level: fatal
|
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QString hash = h.hash(); |
|
|
|
if(h.is_valid()){ |
|
|
|
QList<QPair<QString, QString> > errors = trackersErrors.value(hash, QList<QPair<QString, QString> >()); |
|
|
|
QString hash = h.hash(); |
|
|
|
if(errors.size() > 5) |
|
|
|
QList<QPair<QString, QString> > errors = trackersErrors.value(hash, QList<QPair<QString, QString> >()); |
|
|
|
errors.removeAt(0); |
|
|
|
if(errors.size() > 5) |
|
|
|
errors << QPair<QString,QString>(QTime::currentTime().toString("hh:mm:ss"), QString::fromUtf8(a->msg().c_str())); |
|
|
|
errors.removeAt(0); |
|
|
|
trackersErrors[hash] = errors; |
|
|
|
errors << QPair<QString,QString>(QTime::currentTime().toString("hh:mm:ss"), QString::fromUtf8(a->msg().c_str())); |
|
|
|
// Authentication
|
|
|
|
trackersErrors[hash] = errors; |
|
|
|
if(p->status_code == 401) { |
|
|
|
// Authentication
|
|
|
|
emit trackerAuthenticationRequired(h); |
|
|
|
if(p->status_code == 401) { |
|
|
|
|
|
|
|
emit trackerAuthenticationRequired(h); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QString hash = h.hash(); |
|
|
|
if(h.is_valid()){ |
|
|
|
qDebug("Received torrent_paused_alert for %s", hash.toUtf8().data()); |
|
|
|
QString hash = h.hash(); |
|
|
|
if(!pausedTorrents.contains(hash)) { |
|
|
|
qDebug("Received torrent_paused_alert for %s", hash.toUtf8().data()); |
|
|
|
if(h.is_valid() && h.is_paused()) { |
|
|
|
if(!pausedTorrents.contains(hash)) { |
|
|
|
pausedTorrents << hash; |
|
|
|
if(h.is_valid() && h.is_paused()) { |
|
|
|
if(reloadingTorrents.indexOf(hash) != -1) { |
|
|
|
pausedTorrents << hash; |
|
|
|
reloadTorrent(h); |
|
|
|
if(reloadingTorrents.indexOf(hash) != -1) { |
|
|
|
|
|
|
|
reloadTorrent(h); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
qDebug("Not adding torrent no pausedList, it is invalid or resumed"); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
qDebug("Not adding torrent no pausedList, it is invalid or resumed"); |
|
|
|
qDebug("Received alert for already paused torrent"); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
|
|
|
|
qDebug("Received alert for already paused torrent"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) { |
|
|
|
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) { |
|
|
@ -1047,23 +1054,27 @@ void bittorrent::readAlerts() { |
|
|
|
} |
|
|
|
} |
|
|
|
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) { |
|
|
|
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) { |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->msg().c_str()); |
|
|
|
if(h.is_valid()){ |
|
|
|
emit fastResumeDataRejected(QString::fromUtf8(p->handle.name().c_str())); |
|
|
|
qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->msg().c_str()); |
|
|
|
|
|
|
|
emit fastResumeDataRejected(h.name()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())) { |
|
|
|
else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())) { |
|
|
|
emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str())); |
|
|
|
emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str())); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) { |
|
|
|
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) { |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QTorrentHandle h(p->handle); |
|
|
|
QString hash = h.hash(); |
|
|
|
if(h.is_valid()){ |
|
|
|
qDebug("%s have just finished checking", hash.toUtf8().data()); |
|
|
|
QString hash = h.hash(); |
|
|
|
int index = torrentsToPauseAfterChecking.indexOf(hash); |
|
|
|
qDebug("%s have just finished checking", hash.toUtf8().data()); |
|
|
|
if(index != -1) { |
|
|
|
int index = torrentsToPauseAfterChecking.indexOf(hash); |
|
|
|
// Pause torrent
|
|
|
|
if(index != -1) { |
|
|
|
pauseTorrent(hash); |
|
|
|
// Pause torrent
|
|
|
|
qDebug("%s was paused after checking", hash.toUtf8().data()); |
|
|
|
pauseTorrent(hash); |
|
|
|
|
|
|
|
qDebug("%s was paused after checking", hash.toUtf8().data()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
emit torrentFinishedChecking(hash); |
|
|
|
} |
|
|
|
} |
|
|
|
emit torrentFinishedChecking(hash); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
a = s->pop_alert(); |
|
|
|
a = s->pop_alert(); |
|
|
|
} |
|
|
|
} |
|
|
|