From 658771612a6b2f1e7f9a69a06605c84ed0453b34 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 12 Apr 2007 17:17:04 +0000 Subject: [PATCH] - Upgraded to libtorrent svn (0.13) --- INSTALL | 7 +-- TODO | 6 +-- configure | 104 ++------------------------------------ qbittorrent.qc | 3 -- qcm/libtorrent.qcm | 6 +-- qcm/libupnp.qcm | 62 ----------------------- src/allocationDlg.h | 47 ++++++++++------- src/createtorrent_imp.cpp | 4 +- src/src.pro | 3 ++ 9 files changed, 44 insertions(+), 198 deletions(-) delete mode 100644 qcm/libupnp.qcm diff --git a/INSTALL b/INSTALL index e5ab3a543..801225343 100644 --- a/INSTALL +++ b/INSTALL @@ -16,8 +16,8 @@ will install and execute qBittorrent hopefully without any problems. Dependencies: - Qt >= 4.2 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml) -- libtorrent by Arvid Norberg (>= v0.12 REQUIRED) - -> http://libtorrent.sf.net +- libtorrent by Arvid Norberg (>= v0.13 REQUIRED) + -> http://www.libtorrent.net Be carefull: another library (the one used by rtorrent) use the same name. These are TWO different libraries and qBittorrent will only work with the one provided on sourceforge (created by Arvid Norberg). The two libraries conflicts with each other. @@ -26,9 +26,6 @@ Dependencies: - libcurl -- libupnp (>= 1.2.1) *OPTIONAL* - -> For Universal Plug 'n Play Port forwarding support - - python >= 2.3 (previous might work - not tested): needed by search engine. NOTE FOR GNOME USERS: diff --git a/TODO b/TODO index 84e4bf9eb..23824119a 100644 --- a/TODO +++ b/TODO @@ -40,10 +40,10 @@ - Display Url seeds in torrent properties and allow to edit them - Use tooltips to explain options? - Display more info in log (UPnP) -- Update to libtorrent SVN (0.13) - - Use its UPnP/NAT-PMP built-in support instead of ours +- Update to libtorrent SVN (0.13) - DONE + - Use its UPnP/NAT-PMP built-in support instead of ours ALMOST - Use its piece prioritization support - - Get upload/download limit per torrent (uncomment some code) + - Get upload/download limit per torrent (uncomment some code) ALMOST - Improve ratio display / calculation / saving / per torrent... - Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list - Sorting in Download Status column should be smarter than just an alphabetical sort diff --git a/configure b/configure index 1ece61fd6..b362c1b72 100755 --- a/configure +++ b/configure @@ -23,10 +23,6 @@ Dependency options: --with-libboost-inc=[path] Path to libboost include files --with-libcurl-inc=[path] Path to libcurl include files --with-libcurl-lib=[path] Path to libcurl library files - --disable-libupnp Disable use of libupnp - --disable-upnp disable UPnP support - --with-libupnp-inc=[path] Path to libupnp include files - --with-libupnp-lib=[path] Path to libupnp library files EOT } @@ -168,26 +164,6 @@ while [ $# -gt 0 ]; do shift ;; - --disable-libupnp) - QC_DISABLE_libupnp="Y" - shift - ;; - - --disable-upnp) - QC_DISABLE_UPNP="Y" - shift - ;; - - --with-libupnp-inc=*) - QC_WITH_LIBUPNP_INC=$optarg - shift - ;; - - --with-libupnp-lib=*) - QC_WITH_LIBUPNP_LIB=$optarg - shift - ;; - --verbose) QC_DEBUG="Y" shift @@ -214,10 +190,6 @@ echo QC_WITH_LIBTORRENT_LIB=$QC_WITH_LIBTORRENT_LIB echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB -echo QC_DISABLE_libupnp=$QC_DISABLE_libupnp -echo QC_DISABLE_UPNP=$QC_DISABLE_UPNP -echo QC_WITH_LIBUPNP_INC=$QC_WITH_LIBUPNP_INC -echo QC_WITH_LIBUPNP_LIB=$QC_WITH_LIBUPNP_LIB echo fi @@ -323,13 +295,13 @@ class qc_libtorrent : public ConfObj { public: qc_libtorrent(Conf *c) : ConfObj(c) {} - QString name() const { return "libtorrent >= 0.12"; } + QString name() const { return "libtorrent >= 0.13"; } QString shortname() const { return "libtorrent"; } bool exec(){ QString s; s = conf->getenv("QC_WITH_LIBTORRENT_INC"); if(!s.isEmpty()) { - if(!conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")) { + if(!conf->checkHeader(s, "libtorrent/lsd.hpp")) { return false; } }else{ @@ -338,7 +310,7 @@ public: sl << "/usr/local/include"; bool found = false; foreach(s, sl){ - if(conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")){ + if(conf->checkHeader(s, "libtorrent/lsd.hpp")){ found = true; break; } @@ -513,69 +485,6 @@ public: return false; } }; -#line 1 "libupnp.qcm" -/* ------BEGIN QCMOD----- -name: libupnp -arg: disable-upnp, disable UPnP support -arg: with-libupnp-inc=[path], Path to libupnp include files -arg: with-libupnp-lib=[path], Path to libupnp library files ------END QCMOD----- -*/ -class qc_libupnp : public ConfObj -{ -public: - qc_libupnp(Conf *c) : ConfObj(c) {} - QString name() const { return "libupnp"; } - QString shortname() const { return "libupnp"; } - bool exec(){ - QString s; - s = conf->getenv("QC_DISABLE_UPNP"); - if(!s.isEmpty()){ - conf->addDefine("NO_UPNP"); - return false; - } - s = conf->getenv("QC_WITH_LIBUPNP_INC"); - if(!s.isEmpty()) { - if(!conf->checkHeader(s, "upnp/upnp.h")) { - //qWarning("libupnp includes not found!"); - conf->addDefine("NO_UPNP"); - return false; - } - conf->addIncludePath(s); - }else{ - QStringList sl; - sl += "/usr/include"; - sl += "/usr/local/include"; - if(!conf->findHeader("upnp/upnp.h", sl, &s)) { - //qWarning("libupnp includes not found!"); - conf->addDefine("NO_UPNP"); - return false; - } - conf->addIncludePath(s); - } - - s = conf->getenv("QC_WITH_LIBUPNP_LIB"); - if(!s.isEmpty()) { - if(!conf->checkLibrary(s, "upnp")) { - qWarning("libupnp library not found!"); - return false; - } - conf->addLib(QString("-L") + s); - }else{ - if(!conf->findLibrary("upnp", &s)) { - qWarning("libupnp library not found!"); - return false; - } - if (!s.isEmpty()) - conf->addLib(QString("-L") + s); - } - - conf->addLib("-lupnp"); - - return true; - } -}; EOT cat >$1/modules_new.cpp <$1/modules_new.cpp <required = true; o->disabled = false; - o = new qc_libupnp(conf); - o->required = false; - o->disabled = false; EOT cat >$1/conf4.h < - - - diff --git a/qcm/libtorrent.qcm b/qcm/libtorrent.qcm index 80c3c0f41..27e248085 100644 --- a/qcm/libtorrent.qcm +++ b/qcm/libtorrent.qcm @@ -9,13 +9,13 @@ class qc_libtorrent : public ConfObj { public: qc_libtorrent(Conf *c) : ConfObj(c) {} - QString name() const { return "libtorrent >= 0.12"; } + QString name() const { return "libtorrent >= 0.13"; } QString shortname() const { return "libtorrent"; } bool exec(){ QString s; s = conf->getenv("QC_WITH_LIBTORRENT_INC"); if(!s.isEmpty()) { - if(!conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")) { + if(!conf->checkHeader(s, "libtorrent/lsd.hpp")) { return false; } }else{ @@ -24,7 +24,7 @@ public: sl << "/usr/local/include"; bool found = false; foreach(s, sl){ - if(conf->checkHeader(s, "libtorrent/extensions/ut_pex.hpp")){ + if(conf->checkHeader(s, "libtorrent/lsd.hpp")){ found = true; break; } diff --git a/qcm/libupnp.qcm b/qcm/libupnp.qcm deleted file mode 100644 index 2f06f6cec..000000000 --- a/qcm/libupnp.qcm +++ /dev/null @@ -1,62 +0,0 @@ -/* ------BEGIN QCMOD----- -name: libupnp -arg: disable-upnp, disable UPnP support -arg: with-libupnp-inc=[path], Path to libupnp include files -arg: with-libupnp-lib=[path], Path to libupnp library files ------END QCMOD----- -*/ -class qc_libupnp : public ConfObj -{ -public: - qc_libupnp(Conf *c) : ConfObj(c) {} - QString name() const { return "libupnp"; } - QString shortname() const { return "libupnp"; } - bool exec(){ - QString s; - s = conf->getenv("QC_DISABLE_UPNP"); - if(!s.isEmpty()){ - conf->addDefine("NO_UPNP"); - return false; - } - s = conf->getenv("QC_WITH_LIBUPNP_INC"); - if(!s.isEmpty()) { - if(!conf->checkHeader(s, "upnp/upnp.h")) { - //qWarning("libupnp includes not found!"); - conf->addDefine("NO_UPNP"); - return false; - } - conf->addIncludePath(s); - }else{ - QStringList sl; - sl += "/usr/include"; - sl += "/usr/local/include"; - if(!conf->findHeader("upnp/upnp.h", sl, &s)) { - //qWarning("libupnp includes not found!"); - conf->addDefine("NO_UPNP"); - return false; - } - conf->addIncludePath(s); - } - - s = conf->getenv("QC_WITH_LIBUPNP_LIB"); - if(!s.isEmpty()) { - if(!conf->checkLibrary(s, "upnp")) { - qWarning("libupnp library not found!"); - return false; - } - conf->addLib(QString("-L") + s); - }else{ - if(!conf->findLibrary("upnp", &s)) { - qWarning("libupnp library not found!"); - return false; - } - if (!s.isEmpty()) - conf->addLib(QString("-L") + s); - } - - conf->addLib("-lupnp"); - - return true; - } -}; diff --git a/src/allocationDlg.h b/src/allocationDlg.h index cc1f59206..9e2cd6d31 100644 --- a/src/allocationDlg.h +++ b/src/allocationDlg.h @@ -55,23 +55,28 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { } unsigned int nbTorrents = handles.size(); if(!nbTorrents) close(); - // TODO: Uncomment the following lines as soon as we upgrade - // to libtorrent svn to correctly initialize the bandwidth slider. -// if(nbTorrents == 1){ -// if(uploadMode) { -// int val = h.upload_limit(); -// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum()) -// val = -1; -// bandwidthSlider->setValue(val); -// } else { -// int val = h.download_limit(); -// if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum()) -// val = -1; -// bandwidthSlider->setValue(val); -// } -// }else{ -// bandwidthSlider->setValue(-1); -// } + int val; + if(nbTorrents == 1){ + torrent_handle h = handles[0]; + if(uploadMode) + val = h.upload_limit(); + else + val = h.download_limit(); + if(val > bandwidthSlider->maximum() || val < bandwidthSlider->minimum()) + val = -1; + bandwidthSlider->setValue(val); + if(val == -1) { + limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); + kb_lbl->setText(""); + } else { + limit_lbl->setText(QString(misc::toString(val).c_str())); + } + }else{ + qDebug("More than one torrent selected, no initilization"); + bandwidthSlider->setValue(-1); + limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); + kb_lbl->setText(""); + } connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth())); show(); } @@ -95,11 +100,15 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { int val = bandwidthSlider->value(); torrent_handle h; if(uploadMode) { - foreach(h, handles) + foreach(h, handles) { h.set_upload_limit(val); + qDebug("Setting upload limit"); + } } else { - foreach(h, handles) + foreach(h, handles) { h.set_download_limit(val); + qDebug("Setting download limit"); + } } close(); } diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index c21df477e..7a8ea85ec 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -182,11 +182,11 @@ void createtorrent::on_createButton_clicked(){ // calculate the hash for all pieces file_pool fp; - storage st(t, full_path.branch_path(), fp); + boost::scoped_ptr st(default_storage_constructor(t, full_path.branch_path(), fp)); int num = t.num_pieces(); std::vector buf(piece_size); for (int i = 0; i < num; ++i) { - st.read(&buf[0], i, 0, t.piece_size(i)); + st->read(&buf[0], i, 0, t.piece_size(i)); hasher h(&buf[0], t.piece_size(i)); t.set_hash(i, h.final()); } diff --git a/src/src.pro b/src/src.pro index 3ce1f9e98..93342f3cc 100644 --- a/src/src.pro +++ b/src/src.pro @@ -16,6 +16,9 @@ DEFINES += VERSION_MAJOR=0 DEFINES += VERSION_MINOR=10 DEFINES += VERSION_BUGFIX=0 +# Temporary hack +DEFINES += NO_UPNP + contains(DEBUG_MODE, 1){ CONFIG += debug message(Debug build!)