From 99268bfc0667dacef83379e6ed3913e163965d6c Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 29 Aug 2007 09:22:21 +0000 Subject: [PATCH] - Added .ico support, which is really useful for RSS favicons. We use libMagick++ in order to convert ICO icons to PNG. If this library is not installed, qBittorrent will still compile but this feature will be disabled. --- INSTALL | 2 ++ TODO | 4 ++- configure | 86 +++++++++++++++++++++++++++++++++++++++++++++++ qbittorrent.qc | 3 ++ qcm/libmagick.qcm | 58 ++++++++++++++++++++++++++++++++ src/rss.h | 17 ++++++++++ src/src.pro | 2 +- 7 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 qcm/libmagick.qcm diff --git a/INSTALL b/INSTALL index 6ee3c1c96..43a5c698c 100644 --- a/INSTALL +++ b/INSTALL @@ -28,6 +28,8 @@ Dependencies: - python >= 2.3 (previous might work - not tested): needed by search engine. +- libmagick++ (advised, not required) + NOTE FOR GNOME USERS: - qt4-qtconfig package is advised when using Plastique style (default) or just change qBittorrent style to Cleanlooks (GNOME like) diff --git a/TODO b/TODO index 8d8a3be96..b7ab67a4a 100644 --- a/TODO +++ b/TODO @@ -9,7 +9,6 @@ // Harder - Display a progress bar that really displays the pieces we have (like in eMule) -- .ico support (unsupported by Qt4.3 Free edition) // Waiting for libtorrent - File selection in a torrent in compact mode @@ -38,6 +37,7 @@ - Allow to disable UPnP/NAT-PMP/LSD in options? - Allow to automatically delete torrents when they reach a given ratio (in options) : easy - Allow to limit the number of downloading torrents simultaneously (other are paused until a download finishes) +- Add "Mark all as read" feature for RSS // in v1.0.0 (partial) - WIP - Check storage st creation + hasher in torrent creation @@ -48,6 +48,7 @@ - write a patch for file_priority(int index), actual_size(); - valgrind --tool=memcheck --leak-check=full src/qbittorrent (Looks ok) * beta 6 + - clean rss icons on exit - Translations update (IN PROGRESS) - Wait for some bug fixes in libtorrent : - Number of seeds non null for finished torrent (Ticket #122) @@ -73,6 +74,7 @@ LANGUAGES UPDATED: beta5->beta6 changelog: - FEATURE: Split download tab from GUI class and cleaned up code - FEATURE: A lot of code optimization +- FEATURE: Added support for .ico format (useful for RSS favicons) - BUGFIX: Made torrent deletion from hard-drive safer - BUGFIX: Fixed a bug when switching from finished to downloading list - BUGFIX: Showing checking progress for paused torrents too diff --git a/configure b/configure index 8e054fecb..7361c48cb 100755 --- a/configure +++ b/configure @@ -24,6 +24,9 @@ Dependency options: --with-libboost-inc=[path] Path to libboost include files --with-libcommoncpp2-inc=[path] Path to libcommoncpp2 include files --with-libcommoncpp2-lib=[path] Path to libcommoncpp2 library files + --disable-libmagick Disable use of libmagick + --with-libmagick-inc=[path] Path to libmagick++ include files + --with-libmagick-lib=[path] Path to libmagick++ library files EOT } @@ -170,6 +173,21 @@ while [ $# -gt 0 ]; do shift ;; + --disable-libmagick) + QC_DISABLE_libmagick="Y" + shift + ;; + + --with-libmagick-inc=*) + QC_WITH_LIBMAGICK_INC=$optarg + shift + ;; + + --with-libmagick-lib=*) + QC_WITH_LIBMAGICK_LIB=$optarg + shift + ;; + --verbose) QC_DEBUG="Y" shift @@ -197,6 +215,9 @@ echo QC_WITH_LIBTORRENT_STATIC_LIB=$QC_WITH_LIBTORRENT_STATIC_LIB echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC echo QC_WITH_LIBCOMMONCPP2_INC=$QC_WITH_LIBCOMMONCPP2_INC echo QC_WITH_LIBCOMMONCPP2_LIB=$QC_WITH_LIBCOMMONCPP2_LIB +echo QC_DISABLE_libmagick=$QC_DISABLE_libmagick +echo QC_WITH_LIBMAGICK_INC=$QC_WITH_LIBMAGICK_INC +echo QC_WITH_LIBMAGICK_LIB=$QC_WITH_LIBMAGICK_LIB echo fi @@ -500,6 +521,65 @@ public: return true; } }; +#line 1 "libmagick.qcm" +/* +-----BEGIN QCMOD----- +name: libmagick +arg: with-libmagick-inc=[path], Path to libmagick++ include files +arg: with-libmagick-lib=[path], Path to libmagick++ library files +-----END QCMOD----- +*/ +class qc_libmagick : public ConfObj +{ +public: + qc_libmagick(Conf *c) : ConfObj(c) {} + QString name() const { return "ImageMagick library (libmagick++)"; } + QString shortname() const { return "libmagick++"; } + bool exec(){ + QString s; + s = conf->getenv("QC_WITH_LIBMAGICK_INC"); + if(!s.isEmpty()) { + if(!conf->checkHeader(s, "Magick++.h")) { + return false; + } + }else{ + QStringList sl; + sl << "/usr/include"; + sl << "/usr/local/include"; + bool found = false; + foreach(s, sl){ + if(conf->checkHeader(s, "Magick++.h")){ + found = true; + break; + } + } + if(!found) { + return false; + } + } + conf->addIncludePath(s); + + s = conf->getenv("QC_WITH_LIBMAGICK_LIB"); + if(!s.isEmpty()) { + if(!QFile::exists(s+QString("libMagick++.so"))) + return false; + conf->addLib(QString("-L") + s); + }else{ + QStringList sl; + sl << "/usr/lib/"; + sl << "/usr/local/lib/"; + bool found = false; + foreach(s, sl){ + if(QFile::exists(s+QString("libMagick++.so"))){ + found = true; + } + } + if(!found) return false; + conf->addLib(QString("-L") + s); + } + return true; + } +}; #line 1 "python.qcm" /* -----BEGIN QCMOD----- @@ -535,6 +615,9 @@ cat >$1/modules_new.cpp <required = true; o->disabled = false; + o = new qc_libmagick(conf); + o->required = false; + o->disabled = false; o = new qc_python(conf); o->required = true; o->disabled = false; @@ -1470,6 +1553,9 @@ export QC_WITH_LIBTORRENT_STATIC_LIB export QC_WITH_LIBBOOST_INC export QC_WITH_LIBCOMMONCPP2_INC export QC_WITH_LIBCOMMONCPP2_LIB +export QC_DISABLE_libmagick +export QC_WITH_LIBMAGICK_INC +export QC_WITH_LIBMAGICK_LIB export QC_DEBUG rm -rf .qconftemp ( diff --git a/qbittorrent.qc b/qbittorrent.qc index c418b834a..32921e49c 100644 --- a/qbittorrent.qc +++ b/qbittorrent.qc @@ -14,6 +14,9 @@ + + + diff --git a/qcm/libmagick.qcm b/qcm/libmagick.qcm new file mode 100644 index 000000000..0c21387f6 --- /dev/null +++ b/qcm/libmagick.qcm @@ -0,0 +1,58 @@ +/* +-----BEGIN QCMOD----- +name: libmagick +arg: with-libmagick-inc=[path], Path to libmagick++ include files +arg: with-libmagick-lib=[path], Path to libmagick++ library files +-----END QCMOD----- +*/ +class qc_libmagick : public ConfObj +{ +public: + qc_libmagick(Conf *c) : ConfObj(c) {} + QString name() const { return "ImageMagick library (libmagick++)"; } + QString shortname() const { return "libmagick++"; } + bool exec(){ + QString s; + s = conf->getenv("QC_WITH_LIBMAGICK_INC"); + if(!s.isEmpty()) { + if(!conf->checkHeader(s, "Magick++.h")) { + return false; + } + }else{ + QStringList sl; + sl << "/usr/include"; + sl << "/usr/local/include"; + bool found = false; + foreach(s, sl){ + if(conf->checkHeader(s, "Magick++.h")){ + found = true; + break; + } + } + if(!found) { + return false; + } + } + conf->addIncludePath(s); + + s = conf->getenv("QC_WITH_LIBMAGICK_LIB"); + if(!s.isEmpty()) { + if(!QFile::exists(s+QString("libMagick++.so"))) + return false; + conf->addLib(QString("-L") + s); + }else{ + QStringList sl; + sl << "/usr/lib/"; + sl << "/usr/local/lib/"; + bool found = false; + foreach(s, sl){ + if(QFile::exists(s+QString("libMagick++.so"))){ + found = true; + } + } + if(!found) return false; + conf->addLib(QString("-L") + s); + } + return true; + } +}; diff --git a/src/rss.h b/src/rss.h index 117e2d11f..372e5f99b 100644 --- a/src/rss.h +++ b/src/rss.h @@ -41,6 +41,11 @@ #include "misc.h" #include "downloadThread.h" +#ifndef NO_MAGICK + #include + using namespace Magick; +#endif + class RssManager; class RssStream; class RssItem; @@ -384,6 +389,18 @@ class RssManager : public QObject{ if(url.endsWith("favicon.ico")){ // Icon downloaded QImage fileIcon; +#ifndef NO_MAGICK + try{ + QFile::copy(path, path+".ico"); + Image image(QDir::cleanPath(path+".ico").toUtf8().data()); + // Convert to PNG since we can't read ICO format + image.magick("PNG"); + image.write(path.toUtf8().data()); + QFile::remove(path+".ico"); + }catch(Magick::Exception &error_){ + qDebug("favicon conversion to PNG failure: %s", error_.what()); + } +#endif if(fileIcon.load(path)) { QList res = findFeedsWithIcon(url); RssStream* stream; diff --git a/src/src.pro b/src/src.pro index 6da6819b8..db96bd7bb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -31,7 +31,7 @@ QMAKE_CXXFLAGS_RELEASE += -fwrapv -O2 QMAKE_CXXFLAGS_DEBUG += -fwrapv -O1 CONFIG += link_pkgconfig -PKGCONFIG += libtorrent libccext2 libccgnu2 +PKGCONFIG += libtorrent libccext2 libccgnu2 ImageMagick++ QT += network xml DEFINES += QT_NO_CAST_TO_ASCII