- Improved trackers errors code a lot and moved it to Bittorrent class

- When using startAll() command and when only some torrents are paused : already started torrents are not displayed as connecting untill next refresh anymore (they keep their current state).
This commit is contained in:
Christophe Dumez 2007-07-27 13:58:12 +00:00
parent ff9b9d7148
commit f839d6fe41
8 changed files with 52 additions and 53 deletions

View file

@ -167,6 +167,8 @@ void bittorrent::deleteTorrent(QString hash, bool permanent){
// Remove it from ETAs hash tables
ETAstats.take(hash);
ETAs.take(hash);
// Remove tracker errors
trackersErrors.take(hash);
// Remove it from ratio table
ratioData.take(hash);
int index = fullAllocationModeList.indexOf(hash);
@ -900,8 +902,12 @@ void bittorrent::readAlerts(){
}
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())){
// Level: fatal
QString fileHash = QString(misc::toString(p->handle.info_hash()).c_str());
emit trackerError(fileHash, QTime::currentTime().toString("hh:mm:ss"), QString(a->msg().c_str()));
QString hash = QString(misc::toString(p->handle.info_hash()).c_str());
QList<QPair<QString, QString> > errors = trackersErrors.value(hash, QList<QPair<QString, QString> >());
if(errors.size() > 5)
errors.removeAt(0);
errors << QPair<QString,QString>(QTime::currentTime().toString("hh:mm:ss"), QString(a->msg().c_str()));
trackersErrors[hash] = errors;
// Authentication
if(p->status_code == 401){
emit trackerAuthenticationRequired(p->handle);
@ -920,6 +926,10 @@ void bittorrent::readAlerts(){
}
}
QList<QPair<QString, QString> > bittorrent::getTrackersErrors(QString hash) const{
return trackersErrors.value(hash, QList<QPair<QString, QString> >());
}
// Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const torrent_handle &h){
qDebug("** Reloading a torrent");