diff --git a/TODO b/TODO index fff9b8f12..f54f56a35 100644 --- a/TODO +++ b/TODO @@ -27,22 +27,24 @@ // in v1.1.0 - Tabs support in search - 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 - Check storage st creation + hasher in torrent creation - 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 column sorting with Qt 4.3 - Reported to Trolltech, waiting for their fix - 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 * beta3 - Windows port (Chris - Peerkoel) - Translations update - Optimize and cleanup code + - document url seeds - Improve trackers edition code + - check painting problems in dl list - Wait for some bug fixes in libtorrent : - upload/download limit per torrent - double free or corruption on exit diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 8e810f4d8..1d0145a38 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -237,8 +237,7 @@ void FinishedTorrents::showProperties(const QModelIndex &index){ int row = index.row(); QString fileHash = finishedListModel->data(finishedListModel->index(row, F_HASH)).toString(); 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, errors); + properties *prop = new properties(this, BTSession, h); connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString))); prop->show(); diff --git a/src/GUI.cpp b/src/GUI.cpp index 50929426a..b22a961dd 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -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(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&))); 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(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&))); connect(BTSession, SIGNAL(peerBlocked(QString)), this, SLOT(addLogPeerBlocked(const QString))); @@ -1231,8 +1230,7 @@ void GUI::showProperties(const QModelIndex &index){ int row = index.row(); QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString(); 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, errors); + properties *prop = new properties(this, BTSession, h); connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString))); prop->show(); @@ -1429,10 +1427,10 @@ void GUI::on_actionStart_All_triggered(){ for(unsigned int i=0; idata(DLListModel->index(i, HASH)).toString(); // Remove .paused file - 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); - setRowColor(i, "grey"); + if(QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){ + DLListModel->setData(DLListModel->index(i, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole); + setRowColor(i, "grey"); + } } 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"); } -// 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(""+time+" - "+msg+""); - trackerErrors.insert(hash, errors); -} - // Called when a tracker requires authentication void GUI::trackerAuthenticationRequired(torrent_handle& h){ if(unauthenticated_trackers.indexOf(QPair(h, h.status().current_tracker)) < 0){ diff --git a/src/GUI.h b/src/GUI.h index b24a3d0f5..086fd220f 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -52,9 +52,6 @@ namespace fs = boost::filesystem; class GUI : public QMainWindow, private Ui::MainWindow{ Q_OBJECT - public: - QHash trackerErrors; - private: // Bittorrent bittorrent *BTSession; @@ -78,21 +75,10 @@ class GUI : public QMainWindow, private Ui::MainWindow{ bool delayedSorting; Qt::SortOrder delayedSortingOrder; // Keyboard shortcuts - QShortcut *createShortcut; - QShortcut *openShortcut; - QShortcut *quitShortcut; QShortcut *switchSearchShortcut; QShortcut *switchDownShortcut; QShortcut *switchUpShortcut; QShortcut *switchRSSShortcut; - QShortcut *propertiesShortcut; - QShortcut *optionsShortcut; - QShortcut *delShortcut; - QShortcut *delPermShortcut; - QShortcut *startShortcut; - QShortcut *startAllShortcut; - QShortcut *pauseShortcut; - QShortcut *pauseAllPermShortcut; // Preview previewSelect *previewSelection; QProcess *previewProcess; @@ -185,7 +171,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void finishedTorrent(torrent_handle& h); void fullDiskError(torrent_handle& h); void portListeningFailure(); - void trackerError(QString hash, QString time, QString msg); void trackerAuthenticationRequired(torrent_handle& h); void setTabText(int index, QString text); void updateFileSize(QString hash); diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 8e60052db..2876aa155 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -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(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 > errors = trackersErrors.value(hash, QList >()); + if(errors.size() > 5) + errors.removeAt(0); + errors << QPair(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 > bittorrent::getTrackersErrors(QString hash) const{ + return trackersErrors.value(hash, QList >()); +} + // Reload a torrent with full allocation mode void bittorrent::reloadTorrent(const torrent_handle &h){ qDebug("** Reloading a torrent"); diff --git a/src/bittorrent.h b/src/bittorrent.h index 82870522c..81918e851 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include @@ -52,6 +54,7 @@ class bittorrent : public QObject{ QHash > ratioData; QTimer ETARefresher; QList fullAllocationModeList; + QHash > > trackersErrors; protected: QString getSavePath(QString hash); @@ -78,6 +81,7 @@ class bittorrent : public QObject{ bool inFullAllocationMode(QString hash) const; float getRealRatio(QString hash) const; session* getSession() const; + QList > getTrackersErrors(QString hash) const; public slots: void addTorrent(QString path, bool fromScanDir = false, bool onStartup = false, QString from_url = QString()); diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index 0c6144037..718660e6d 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -31,7 +31,7 @@ #include // 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); this->BTSession = BTSession; changedFilteredfiles = false; @@ -100,10 +100,7 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h } snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio); shareRatio->setText(tmp); - // Tracker Errors - for(int i=0; i < trackerErrors.size(); ++i){ - this->trackerErrors->append(trackerErrors.at(i)); - } + loadTrackersErrors(); std::vector fp; h.file_progress(fp); // List files in torrent @@ -125,18 +122,31 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h }else{ incrementalDownload->setChecked(false); } - updateProgressTimer = new QTimer(this); - connect(updateProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgress())); - updateProgressTimer->start(2000); + updateInfosTimer = new QTimer(this); + connect(updateInfosTimer, SIGNAL(timeout()), this, SLOT(updateInfos())); + updateInfosTimer->start(2000); } properties::~properties(){ qDebug("Properties destroyed"); - delete updateProgressTimer; + delete updateInfosTimer; delete PropDelegate; delete PropListModel; } +void properties::loadTrackersErrors(){ + // Tracker Errors + QList > errors = BTSession->getTrackersErrors(fileHash); + unsigned int nbTrackerErrors = errors.size(); + trackerErrors->clear(); + for(unsigned int i=0; i < nbTrackerErrors; ++i){ + QPair pair = errors.at(i); + trackerErrors->append(""+pair.first+" - "+pair.second+""); + } + if(!nbTrackerErrors) + trackerErrors->append(tr("None", "i.e: No error message")); +} + void properties::loadWebSeeds(){ QString url_seed; torrent_info torrentInfo = h.get_torrent_info(); @@ -424,7 +434,7 @@ void properties::lowerSelectedTracker(){ } } -void properties::updateProgress(){ +void properties::updateInfos(){ std::vector fp; try{ h.file_progress(fp); @@ -436,6 +446,7 @@ void properties::updateProgress(){ // torrent was removed, closing properties close(); } + loadTrackersErrors(); } // Set the color of a row in data model diff --git a/src/properties_imp.h b/src/properties_imp.h index c8fcd022f..bbdf6a1f4 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -39,7 +39,7 @@ class properties : public QDialog, private Ui::properties{ QString fileHash; PropListDelegate *PropDelegate; QStandardItemModel *PropListModel; - QTimer *updateProgressTimer; + QTimer *updateInfosTimer; bool has_filtered_files; bool changedFilteredfiles; bittorrent *BTSession; @@ -50,7 +50,7 @@ class properties : public QDialog, private Ui::properties{ void on_incrementalDownload_stateChanged(int); void setRowColor(int row, QString color); void savePiecesPriorities(); - void updateProgress(); + void updateInfos(); void loadPiecesPriorities(); void setAllPiecesState(unsigned short priority); void askForTracker(); @@ -68,6 +68,7 @@ class properties : public QDialog, private Ui::properties{ void saveWebSeeds(); void loadWebSeedsFromFile(); void deleteSelectedUrlSeeds(); + void loadTrackersErrors(); signals: void filteredFilesChanged(QString fileHash); @@ -76,7 +77,7 @@ class properties : public QDialog, private Ui::properties{ public: // Constructor - properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h, QStringList trackerErrors = QStringList()); + properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h); ~properties(); };