1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-25 14:04:23 +00:00

- 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

8
TODO
View File

@ -27,22 +27,24 @@
// in v1.1.0 // in v1.1.0
- Tabs support in search - Tabs support in search
- Have a look at libcommoncpp2 to see if it can be useful for other stuff than url downloading - Have a look at libcommoncpp2 to see if it can be useful for other stuff than url downloading
- Allow to hide columns?
- Allow to scan multiple directories?
// in v1.0.0 (partial) - WIP // in v1.0.0 (partial) - WIP
- Check storage st creation + hasher in torrent creation - Check storage st creation + hasher in torrent creation
- test IPv6 support (How? Who uses IPv6?) - test IPv6 support (How? Who uses IPv6?)
- Sorting in Download Status column should be smarter than just an alphabetical sort
- Allow to scan multiple directories?
- Fix all (or almost all) opened bugs in bug tracker - Fix all (or almost all) opened bugs in bug tracker
- Fix column sorting with Qt 4.3 - Reported to Trolltech, waiting for their fix - Fix column sorting with Qt 4.3 - Reported to Trolltech, waiting for their fix
- update sorting when a new torrent is added? - update sorting when a new torrent is added?
- Allow to hide columns? - Add a checking icon in dl list to differenciate from connecting.
- Complete documentation and english translation - Complete documentation and english translation
* beta3 * beta3
- Windows port (Chris - Peerkoel) - Windows port (Chris - Peerkoel)
- Translations update - Translations update
- Optimize and cleanup code - Optimize and cleanup code
- document url seeds
- Improve trackers edition code - Improve trackers edition code
- check painting problems in dl list
- Wait for some bug fixes in libtorrent : - Wait for some bug fixes in libtorrent :
- upload/download limit per torrent - upload/download limit per torrent
- double free or corruption on exit - double free or corruption on exit

View File

@ -237,8 +237,7 @@ void FinishedTorrents::showProperties(const QModelIndex &index){
int row = index.row(); int row = index.row();
QString fileHash = finishedListModel->data(finishedListModel->index(row, F_HASH)).toString(); QString fileHash = finishedListModel->data(finishedListModel->index(row, F_HASH)).toString();
torrent_handle h = BTSession->getTorrentHandle(fileHash); torrent_handle h = BTSession->getTorrentHandle(fileHash);
QStringList errors = ((GUI*)parent)->trackerErrors.value(fileHash, QStringList(tr("None", "i.e: No error message"))); properties *prop = new properties(this, BTSession, h);
properties *prop = new properties(this, BTSession, h, errors);
connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle))); connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle)));
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString)));
prop->show(); prop->show();

View File

@ -138,7 +138,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
connect(BTSession, SIGNAL(finishedTorrent(torrent_handle&)), this, SLOT(finishedTorrent(torrent_handle&))); connect(BTSession, SIGNAL(finishedTorrent(torrent_handle&)), this, SLOT(finishedTorrent(torrent_handle&)));
connect(BTSession, SIGNAL(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&))); connect(BTSession, SIGNAL(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&)));
connect(BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure())); connect(BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure()));
connect(BTSession, SIGNAL(trackerError(QString, QString, QString)), this, SLOT(trackerError(QString, QString, QString)));
connect(BTSession,SIGNAL(allTorrentsFinishedChecking()), this, SLOT(sortProgressColumnDelayed())); connect(BTSession,SIGNAL(allTorrentsFinishedChecking()), this, SLOT(sortProgressColumnDelayed()));
connect(BTSession, SIGNAL(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&))); connect(BTSession, SIGNAL(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&)));
connect(BTSession, SIGNAL(peerBlocked(QString)), this, SLOT(addLogPeerBlocked(const QString))); connect(BTSession, SIGNAL(peerBlocked(QString)), this, SLOT(addLogPeerBlocked(const QString)));
@ -1231,8 +1230,7 @@ void GUI::showProperties(const QModelIndex &index){
int row = index.row(); int row = index.row();
QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString(); QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
torrent_handle h = BTSession->getTorrentHandle(fileHash); torrent_handle h = BTSession->getTorrentHandle(fileHash);
QStringList errors = trackerErrors.value(fileHash, QStringList(tr("None", "i.e: No error message"))); properties *prop = new properties(this, BTSession, h);
properties *prop = new properties(this, BTSession, h, errors);
connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle))); connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle)));
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString)));
prop->show(); prop->show();
@ -1429,10 +1427,10 @@ void GUI::on_actionStart_All_triggered(){
for(unsigned int i=0; i<nbRows; ++i){ for(unsigned int i=0; i<nbRows; ++i){
fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString(); fileHash = DLListModel->data(DLListModel->index(i, HASH)).toString();
// Remove .paused file // Remove .paused file
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused"); if(QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){
// Update DL list items DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole); setRowColor(i, "grey");
setRowColor(i, "grey"); }
} }
setInfoBar(tr("All downloads were resumed.")); setInfoBar(tr("All downloads were resumed."));
} }
@ -1530,17 +1528,6 @@ void GUI::portListeningFailure(){
setInfoBar(tr("Couldn't listen on any of the given ports."), "red"); setInfoBar(tr("Couldn't listen on any of the given ports."), "red");
} }
// Called when we receive an error from tracker
void GUI::trackerError(QString hash, QString time, QString msg){
// Check trackerErrors list size and clear it if it is too big
if(trackerErrors.size() > 50){
trackerErrors.clear();
}
QStringList errors = trackerErrors.value(hash, QStringList());
errors.append("<font color='grey'>"+time+"</font> - <font color='red'>"+msg+"</font>");
trackerErrors.insert(hash, errors);
}
// Called when a tracker requires authentication // Called when a tracker requires authentication
void GUI::trackerAuthenticationRequired(torrent_handle& h){ void GUI::trackerAuthenticationRequired(torrent_handle& h){
if(unauthenticated_trackers.indexOf(QPair<torrent_handle,std::string>(h, h.status().current_tracker)) < 0){ if(unauthenticated_trackers.indexOf(QPair<torrent_handle,std::string>(h, h.status().current_tracker)) < 0){

View File

@ -52,9 +52,6 @@ namespace fs = boost::filesystem;
class GUI : public QMainWindow, private Ui::MainWindow{ class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT Q_OBJECT
public:
QHash<QString, QStringList> trackerErrors;
private: private:
// Bittorrent // Bittorrent
bittorrent *BTSession; bittorrent *BTSession;
@ -78,21 +75,10 @@ class GUI : public QMainWindow, private Ui::MainWindow{
bool delayedSorting; bool delayedSorting;
Qt::SortOrder delayedSortingOrder; Qt::SortOrder delayedSortingOrder;
// Keyboard shortcuts // Keyboard shortcuts
QShortcut *createShortcut;
QShortcut *openShortcut;
QShortcut *quitShortcut;
QShortcut *switchSearchShortcut; QShortcut *switchSearchShortcut;
QShortcut *switchDownShortcut; QShortcut *switchDownShortcut;
QShortcut *switchUpShortcut; QShortcut *switchUpShortcut;
QShortcut *switchRSSShortcut; QShortcut *switchRSSShortcut;
QShortcut *propertiesShortcut;
QShortcut *optionsShortcut;
QShortcut *delShortcut;
QShortcut *delPermShortcut;
QShortcut *startShortcut;
QShortcut *startAllShortcut;
QShortcut *pauseShortcut;
QShortcut *pauseAllPermShortcut;
// Preview // Preview
previewSelect *previewSelection; previewSelect *previewSelection;
QProcess *previewProcess; QProcess *previewProcess;
@ -185,7 +171,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void finishedTorrent(torrent_handle& h); void finishedTorrent(torrent_handle& h);
void fullDiskError(torrent_handle& h); void fullDiskError(torrent_handle& h);
void portListeningFailure(); void portListeningFailure();
void trackerError(QString hash, QString time, QString msg);
void trackerAuthenticationRequired(torrent_handle& h); void trackerAuthenticationRequired(torrent_handle& h);
void setTabText(int index, QString text); void setTabText(int index, QString text);
void updateFileSize(QString hash); void updateFileSize(QString hash);

View File

@ -167,6 +167,8 @@ void bittorrent::deleteTorrent(QString hash, bool permanent){
// Remove it from ETAs hash tables // Remove it from ETAs hash tables
ETAstats.take(hash); ETAstats.take(hash);
ETAs.take(hash); ETAs.take(hash);
// Remove tracker errors
trackersErrors.take(hash);
// Remove it from ratio table // Remove it from ratio table
ratioData.take(hash); ratioData.take(hash);
int index = fullAllocationModeList.indexOf(hash); int index = fullAllocationModeList.indexOf(hash);
@ -900,8 +902,12 @@ 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
QString fileHash = QString(misc::toString(p->handle.info_hash()).c_str()); QString hash = QString(misc::toString(p->handle.info_hash()).c_str());
emit trackerError(fileHash, QTime::currentTime().toString("hh:mm:ss"), QString(a->msg().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 // Authentication
if(p->status_code == 401){ if(p->status_code == 401){
emit trackerAuthenticationRequired(p->handle); 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 // Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const torrent_handle &h){ void bittorrent::reloadTorrent(const torrent_handle &h){
qDebug("** Reloading a torrent"); qDebug("** Reloading a torrent");

View File

@ -23,6 +23,8 @@
#include <QHash> #include <QHash>
#include <QTimer> #include <QTimer>
#include <QList>
#include <QPair>
#include <QStringList> #include <QStringList>
#include <libtorrent/torrent_handle.hpp> #include <libtorrent/torrent_handle.hpp>
@ -52,6 +54,7 @@ class bittorrent : public QObject{
QHash<QString, QPair<size_type,size_type> > ratioData; QHash<QString, QPair<size_type,size_type> > ratioData;
QTimer ETARefresher; QTimer ETARefresher;
QList<QString> fullAllocationModeList; QList<QString> fullAllocationModeList;
QHash<QString, QList<QPair<QString, QString> > > trackersErrors;
protected: protected:
QString getSavePath(QString hash); QString getSavePath(QString hash);
@ -78,6 +81,7 @@ class bittorrent : public QObject{
bool inFullAllocationMode(QString hash) const; bool inFullAllocationMode(QString hash) const;
float getRealRatio(QString hash) const; float getRealRatio(QString hash) const;
session* getSession() const; session* getSession() const;
QList<QPair<QString, QString> > getTrackersErrors(QString hash) const;
public slots: public slots:
void addTorrent(QString path, bool fromScanDir = false, bool onStartup = false, QString from_url = QString()); void addTorrent(QString path, bool fromScanDir = false, bool onStartup = false, QString from_url = QString());

View File

@ -31,7 +31,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
// Constructor // Constructor
properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h, QStringList trackerErrors): QDialog(parent), h(h){ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h): QDialog(parent), h(h){
setupUi(this); setupUi(this);
this->BTSession = BTSession; this->BTSession = BTSession;
changedFilteredfiles = false; changedFilteredfiles = false;
@ -100,10 +100,7 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
} }
snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio); snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio);
shareRatio->setText(tmp); shareRatio->setText(tmp);
// Tracker Errors loadTrackersErrors();
for(int i=0; i < trackerErrors.size(); ++i){
this->trackerErrors->append(trackerErrors.at(i));
}
std::vector<float> fp; std::vector<float> fp;
h.file_progress(fp); h.file_progress(fp);
// List files in torrent // List files in torrent
@ -125,18 +122,31 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
}else{ }else{
incrementalDownload->setChecked(false); incrementalDownload->setChecked(false);
} }
updateProgressTimer = new QTimer(this); updateInfosTimer = new QTimer(this);
connect(updateProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgress())); connect(updateInfosTimer, SIGNAL(timeout()), this, SLOT(updateInfos()));
updateProgressTimer->start(2000); updateInfosTimer->start(2000);
} }
properties::~properties(){ properties::~properties(){
qDebug("Properties destroyed"); qDebug("Properties destroyed");
delete updateProgressTimer; delete updateInfosTimer;
delete PropDelegate; delete PropDelegate;
delete PropListModel; delete PropListModel;
} }
void properties::loadTrackersErrors(){
// Tracker Errors
QList<QPair<QString, QString> > errors = BTSession->getTrackersErrors(fileHash);
unsigned int nbTrackerErrors = errors.size();
trackerErrors->clear();
for(unsigned int i=0; i < nbTrackerErrors; ++i){
QPair<QString, QString> pair = errors.at(i);
trackerErrors->append("<font color='grey'>"+pair.first+"</font> - <font color='red'>"+pair.second+"</font>");
}
if(!nbTrackerErrors)
trackerErrors->append(tr("None", "i.e: No error message"));
}
void properties::loadWebSeeds(){ void properties::loadWebSeeds(){
QString url_seed; QString url_seed;
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
@ -424,7 +434,7 @@ void properties::lowerSelectedTracker(){
} }
} }
void properties::updateProgress(){ void properties::updateInfos(){
std::vector<float> fp; std::vector<float> fp;
try{ try{
h.file_progress(fp); h.file_progress(fp);
@ -436,6 +446,7 @@ void properties::updateProgress(){
// torrent was removed, closing properties // torrent was removed, closing properties
close(); close();
} }
loadTrackersErrors();
} }
// Set the color of a row in data model // Set the color of a row in data model

View File

@ -39,7 +39,7 @@ class properties : public QDialog, private Ui::properties{
QString fileHash; QString fileHash;
PropListDelegate *PropDelegate; PropListDelegate *PropDelegate;
QStandardItemModel *PropListModel; QStandardItemModel *PropListModel;
QTimer *updateProgressTimer; QTimer *updateInfosTimer;
bool has_filtered_files; bool has_filtered_files;
bool changedFilteredfiles; bool changedFilteredfiles;
bittorrent *BTSession; bittorrent *BTSession;
@ -50,7 +50,7 @@ class properties : public QDialog, private Ui::properties{
void on_incrementalDownload_stateChanged(int); void on_incrementalDownload_stateChanged(int);
void setRowColor(int row, QString color); void setRowColor(int row, QString color);
void savePiecesPriorities(); void savePiecesPriorities();
void updateProgress(); void updateInfos();
void loadPiecesPriorities(); void loadPiecesPriorities();
void setAllPiecesState(unsigned short priority); void setAllPiecesState(unsigned short priority);
void askForTracker(); void askForTracker();
@ -68,6 +68,7 @@ class properties : public QDialog, private Ui::properties{
void saveWebSeeds(); void saveWebSeeds();
void loadWebSeedsFromFile(); void loadWebSeedsFromFile();
void deleteSelectedUrlSeeds(); void deleteSelectedUrlSeeds();
void loadTrackersErrors();
signals: signals:
void filteredFilesChanged(QString fileHash); void filteredFilesChanged(QString fileHash);
@ -76,7 +77,7 @@ class properties : public QDialog, private Ui::properties{
public: public:
// Constructor // Constructor
properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h, QStringList trackerErrors = QStringList()); properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h);
~properties(); ~properties();
}; };