From 06448509fb1409a12ef3a0bc38075baa3a3f9d03 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 12 Apr 2007 21:42:05 +0000 Subject: [PATCH] - BUGFIX: The torrent size displayed now takes filtered files into consideration - BUGFIX: Fixed compiling errors with libtorrent svn (adds UPnP support) --- Changelog | 2 ++ TODO | 3 --- configure | 6 ++++++ qcm/libtorrent.qcm | 6 ++++++ src/GUI.cpp | 20 +++++++++++++++++++- src/GUI.h | 4 +++- src/bittorrent.cpp | 2 ++ src/bittorrent.h | 1 + src/createtorrent_imp.cpp | 12 +++++++++++- src/properties_imp.cpp | 6 +----- src/properties_imp.h | 1 + 11 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Changelog b/Changelog index bf3aa5b78..74f5d8e3d 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ * Unknown - Christophe Dumez - v0.9.3 - BUGFIX: Fixed pause toggle on double-click in download + - BUGFIX: The torrent size displayed now takes filtered files into consideration + - BUGFIX: Fixed compiling errors with libtorrent svn (future v0.13 with UPnP enabled) * Tue Apr 10 2007 - Christophe Dumez - v0.9.2 - BUGFIX: Window can now stay maximized on exit diff --git a/TODO b/TODO index 6d8dde09b..31dacdea9 100644 --- a/TODO +++ b/TODO @@ -36,6 +36,3 @@ - Add IPv6 support (at least start working on it) - UPnP support? -// In v0.9.0 -- Update translations (FR, SV, NB, PL, RU, DE, SK, KO, ZH_CN, EL, BG, ES, DA, UK, PT, IT, NL done) -- Wait for libtorrent v0.12 official release diff --git a/configure b/configure index c5a6ddc7c..9af93bf91 100755 --- a/configure +++ b/configure @@ -308,6 +308,9 @@ public: qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled."); conf->addDefine("NO_PEX"); } + if(conf->checkHeader(s, "libtorrent/lsd.hpp")){ + conf->addDefine("V_0_13"); + } }else{ QStringList sl; sl << "/usr/include"; @@ -324,6 +327,9 @@ public: qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled."); conf->addDefine("NO_PEX"); } + if(conf->checkHeader(s, "libtorrent/lsd.hpp")){ + conf->addDefine("V_0_13"); + } } conf->addIncludePath(s); conf->addIncludePath(s+QDir::separator()+"libtorrent"); diff --git a/qcm/libtorrent.qcm b/qcm/libtorrent.qcm index 4acd6755a..5f01033cb 100644 --- a/qcm/libtorrent.qcm +++ b/qcm/libtorrent.qcm @@ -22,6 +22,9 @@ public: qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled."); conf->addDefine("NO_PEX"); } + if(conf->checkHeader(s, "libtorrent/lsd.hpp")){ + conf->addDefine("V_0_13"); + } }else{ QStringList sl; sl << "/usr/include"; @@ -38,6 +41,9 @@ public: qWarning("Libtorrent >= v0.12 was not detected, PeX will be disabled."); conf->addDefine("NO_PEX"); } + if(conf->checkHeader(s, "libtorrent/lsd.hpp")){ + conf->addDefine("V_0_13"); + } } conf->addIncludePath(s); conf->addIncludePath(s+QDir::separator()+"libtorrent"); diff --git a/src/GUI.cpp b/src/GUI.cpp index 23a037d5a..5be94e17c 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -132,6 +132,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ // Configure BT session according to options configureSession(true); force_exit = false; + connect(&BTSession, SIGNAL(updateFileSize(QString)), this, SLOT(updateFileSize(QString))); // Resume unfinished torrents BTSession.resumeUnfinishedTorrents(); // Add torrent given on command line @@ -1038,6 +1039,18 @@ void GUI::deleteSelection(){ } } +size_type GUI::torrentEffectiveSize(QString hash) const{ + torrent_handle h = BTSession.getTorrentHandle(hash); + torrent_info t = h.get_torrent_info(); + unsigned short nbFiles = t.num_files(); + size_type effective_size = 0; + for(unsigned int i=0; irowCount(); @@ -1045,7 +1058,7 @@ void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){ // Adding torrent to download list DLListModel->insertRow(row); DLListModel->setData(DLListModel->index(row, NAME), QVariant(h.get_torrent_info().name().c_str())); - DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.get_torrent_info().total_size())); + DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)torrentEffectiveSize(hash))); DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0")); @@ -1145,6 +1158,11 @@ void GUI::showProperties(const QModelIndex &index){ prop->show(); } +void GUI::updateFileSize(QString hash){ + int row = getRowFromHash(hash); + DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)torrentEffectiveSize(hash))); +} + // Set BT session configuration void GUI::configureSession(bool deleteOptions){ qDebug("Configuring session"); diff --git a/src/GUI.h b/src/GUI.h index 1ebaa0427..74fd4eca4 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -136,6 +136,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void readSettings(); void forceExit(); // Torrent actions + size_type torrentEffectiveSize(QString hash) const; void showProperties(const QModelIndex &index); void propertiesSelection(); void pauseSelection(); @@ -183,6 +184,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void portListeningFailure(); void trackerError(const QString& hash, const QString& time, const QString& msg); void trackerAuthenticationRequired(torrent_handle& h); + void updateFileSize(QString hash); protected: void closeEvent(QCloseEvent *); @@ -193,7 +195,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); ~GUI(); // Methods - int getRowFromHash(const QString& name) const; + int getRowFromHash(const QString& hash) const; float getNovaVersion(const QString& novaPath) const; QByteArray getNovaChangelog(const QString& novaPath) const; void updateNova() const; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 576837881..30f5b0b49 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -656,6 +656,7 @@ void bittorrent::readAlerts(){ } void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){ + qDebug("** Reloading a torrent"); if(!h.is_valid()){ qDebug("/!\\ Error: Invalid handle"); return; @@ -714,6 +715,7 @@ void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){ qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8()); new_h.set_sequenced_download_threshold(15); } + emit updateFileSize(fileHash); } int bittorrent::getListenPort() const{ diff --git a/src/bittorrent.h b/src/bittorrent.h index dccfb4b2d..cbce8d289 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -144,6 +144,7 @@ class bittorrent : public QObject{ void scanDirFoundTorrents(const QStringList& pathList); void newDownloadedTorrent(const QString& path, const QString& url); void aboutToDownloadFromUrl(const QString& url); + void updateFileSize(QString hash); }; #endif diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index 5d0a23ebf..27277804a 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -109,8 +109,13 @@ void createtorrent::on_createButton_clicked(){ add_files(t, full_path.branch_path(), full_path.leaf()); t.set_piece_size(piece_size); #ifndef NO_PEX - file_pool fp; + file_pool fp; + #ifndef V_0_13 storage st(t, full_path.branch_path(), fp); + #endif + #ifdef V_0_13 + boost::scoped_ptr st(default_storage_constructor(t, full_path.branch_path(), fp)); + #endif #endif #ifdef NO_PEX storage st(t, full_path.branch_path()); @@ -125,7 +130,12 @@ void createtorrent::on_createButton_clicked(){ std::vector buf(piece_size); for (int i = 0; i < num; ++i) { +#ifndef V_0_13 st.read(&buf[0], i, 0, t.piece_size(i)); +#endif +#ifdef V_0_13 + st->read(&buf[0], i, 0, t.piece_size(i)); +#endif hasher h(&buf[0], t.piece_size(i)); t.set_hash(i, h.final()); } diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index f2415ffad..6919fe860 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -290,10 +290,6 @@ void properties::saveFilteredFiles(){ } } pieces_file.close(); - if(!has_filtered_files){ - // Don't need to reload torrent - // if already in full allocation mode - emit changedFilteredFiles(h, !hasFilteredFiles); - } + emit changedFilteredFiles(h, !hasFilteredFiles); has_filtered_files = hasFilteredFiles; } diff --git a/src/properties_imp.h b/src/properties_imp.h index 99028b023..20844cdaa 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -56,6 +56,7 @@ class properties : public QDialog, private Ui::properties{ signals: void changedFilteredFiles(torrent_handle h, bool compact_mode); + void fileSizeChanged(QString fileHash); public: // Constructor