From 2b5522e16535e5181ac388f99e651b240e9be88a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 17 Nov 2009 17:20:25 +0000 Subject: [PATCH] - Dropped dependency on libzzip --- Changelog | 2 +- configure | 99 --------------------------- qbittorrent.qc | 1 - qcm/libzzip.qcm | 71 -------------------- src/engineSelectDlg.cpp | 145 +--------------------------------------- 5 files changed, 2 insertions(+), 316 deletions(-) delete mode 100644 qcm/libzzip.qcm diff --git a/Changelog b/Changelog index 1153b3ebd..ac8bd03b7 100644 --- a/Changelog +++ b/Changelog @@ -12,7 +12,7 @@ - FEATURE: Include DHT traffic in the rate limiter - FEATURE: Support for bitcomet padding files - FEATURE: Option to skip file checking and start seeding immediately in torrent addition dialog (Stephanos Antaris) - - FEATURE: Dropped dependency on libcurl + - FEATURE: Dropped dependency on libcurl and libzzip - FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is required) - FEATURE: Display more information regarding the torrent in its properties - FEATURE: Various optimizations to save CPU and memory diff --git a/configure b/configure index af45cc823..acebb41f4 100755 --- a/configure +++ b/configure @@ -19,9 +19,6 @@ Main options: Dependency options: --with-libboost-inc=[path] Path to libboost include files - --disable-libzzip Disable use of libzzip - --with-libzzip-inc=[path] Path to libzzip++ include files - --with-libzzip-lib=[path] Path to libzzip++ library files EOT } @@ -143,21 +140,6 @@ while [ $# -gt 0 ]; do shift ;; - --disable-libzzip) - QC_DISABLE_libzzip="Y" - shift - ;; - - --with-libzzip-inc=*) - QC_WITH_LIBZZIP_INC=$optarg - shift - ;; - - --with-libzzip-lib=*) - QC_WITH_LIBZZIP_LIB=$optarg - shift - ;; - --verbose) QC_VERBOSE="Y" shift @@ -180,9 +162,6 @@ echo BINDIR=$BINDIR echo DATADIR=$DATADIR echo EX_QTDIR=$EX_QTDIR echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC -echo QC_DISABLE_libzzip=$QC_DISABLE_libzzip -echo QC_WITH_LIBZZIP_INC=$QC_WITH_LIBZZIP_INC -echo QC_WITH_LIBZZIP_LIB=$QC_WITH_LIBZZIP_LIB echo fi @@ -386,78 +365,6 @@ public: return true; } }; -#line 1 "libzzip.qcm" -/* ------BEGIN QCMOD----- -name: libzzip -arg: with-libzzip-inc=[path], Path to libzzip++ include files -arg: with-libzzip-lib=[path], Path to libzzip++ library files ------END QCMOD----- -*/ -#include -class qc_libzzip : public ConfObj -{ -public: - qc_libzzip(Conf *c) : ConfObj(c) {} - QString name() const { return "Zzip library (libzzip)"; } - QString shortname() const { return "libzzip"; } - QString checkString() const { - if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty()) - return ""; - return ConfObj::checkString(); - } - bool exec(){ - if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty()) - return false; - QString s; - s = conf->getenv("QC_WITH_LIBZZIP_INC"); - if(!s.isEmpty()) { - if(!conf->checkHeader(s, "zzip/zzip.h")) { - return false; - } - }else{ - QStringList sl; - sl << "/usr/include"; - sl << "/usr/local/include"; - bool found = false; - foreach(s, sl){ - if(conf->checkHeader(s, "zzip/zzip.h")){ - found = true; - break; - } - } - if(!found) - return false; - } - conf->addIncludePath(s); - - s = conf->getenv("QC_WITH_LIBZZIP_LIB"); - if(!s.isEmpty()) { - if(!QFile::exists(s+QString("/libzzip.so"))){ - return false; - } - }else{ - QStringList sl; - sl << "/usr/lib/"; - sl << "/usr/lib64/"; - sl << "/usr/local/lib/"; - sl << "/usr/local/lib64/"; - bool found = false; - foreach(s, sl){ - if(QFile::exists(s+QString("libzzip.so"))){ - found = true; - break; - } - } - if(!found) - return false; - } - conf->addLib(QString("-L") + s); - conf->addLib("-lzzip"); - conf->addDefine("HAVE_ZZIP"); - return true; - } -}; EOT cat >$1/modules_new.cpp <$1/modules_new.cpp <required = true; o->disabled = false; - o = new qc_libzzip(conf); - o->required = false; - o->disabled = false; EOT cat >$1/conf4.h < - diff --git a/qcm/libzzip.qcm b/qcm/libzzip.qcm deleted file mode 100644 index acec24caa..000000000 --- a/qcm/libzzip.qcm +++ /dev/null @@ -1,71 +0,0 @@ -/* ------BEGIN QCMOD----- -name: libzzip -arg: with-libzzip-inc=[path], Path to libzzip++ include files -arg: with-libzzip-lib=[path], Path to libzzip++ library files ------END QCMOD----- -*/ -#include -class qc_libzzip : public ConfObj -{ -public: - qc_libzzip(Conf *c) : ConfObj(c) {} - QString name() const { return "Zzip library (libzzip)"; } - QString shortname() const { return "libzzip"; } - QString checkString() const { - if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty()) - return ""; - return ConfObj::checkString(); - } - bool exec(){ - if(!conf->getenv("QC_DISABLE_LIBZZIP").isEmpty()) - return false; - QString s; - s = conf->getenv("QC_WITH_LIBZZIP_INC"); - if(!s.isEmpty()) { - if(!conf->checkHeader(s, "zzip/zzip.h")) { - return false; - } - }else{ - QStringList sl; - sl << "/usr/include"; - sl << "/usr/local/include"; - bool found = false; - foreach(s, sl){ - if(conf->checkHeader(s, "zzip/zzip.h")){ - found = true; - break; - } - } - if(!found) - return false; - } - conf->addIncludePath(s); - - s = conf->getenv("QC_WITH_LIBZZIP_LIB"); - if(!s.isEmpty()) { - if(!QFile::exists(s+QString("/libzzip.so"))){ - return false; - } - }else{ - QStringList sl; - sl << "/usr/lib/"; - sl << "/usr/lib64/"; - sl << "/usr/local/lib/"; - sl << "/usr/local/lib64/"; - bool found = false; - foreach(s, sl){ - if(QFile::exists(s+QString("libzzip.so"))){ - found = true; - break; - } - } - if(!found) - return false; - } - conf->addLib(QString("-L") + s); - conf->addLib("-lzzip"); - conf->addDefine("HAVE_ZZIP"); - return true; - } -}; diff --git a/src/engineSelectDlg.cpp b/src/engineSelectDlg.cpp index 584d90c71..b07fae61c 100644 --- a/src/engineSelectDlg.cpp +++ b/src/engineSelectDlg.cpp @@ -43,14 +43,7 @@ #include #include -#ifdef HAVE_ZZIP -#include -#endif - -#define ENGINE_NAME 0 -#define ENGINE_URL 1 -#define ENGINE_STATE 2 -#define ENGINE_ID 3 +enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID}; engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) { setupUi(this); @@ -97,11 +90,6 @@ void engineSelectDlg::dropEvent(QDropEvent *event) { plugin_name.replace(".py", ""); installPlugin(file, plugin_name); } -#ifdef HAVE_ZZIP - if(file.endsWith(".zip", Qt::CaseInsensitive)) { - installZipPlugin(file); - } -#endif } } @@ -260,112 +248,6 @@ bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) con return (new_version > old_version); } -#ifdef HAVE_ZZIP -void engineSelectDlg::installZipPlugin(QString path) { - QStringList plugins; - QStringList favicons; - ZZIP_DIR* dir = zzip_dir_open(path.toLocal8Bit().data(), 0); - if(!dir) { - QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("Search engine plugin archive could not be read.")); - return; - } - ZZIP_DIRENT dirent; - while(zzip_dir_read(dir, &dirent)) { - /* show info for first file */ - QString name(dirent.d_name); - if(name.endsWith(".py", Qt::CaseInsensitive)) { - plugins << name; - } else { - if(name.endsWith(".png", Qt::CaseInsensitive)) { - favicons << name; - } - } - } - QString plugin; - std::cout << dirent.d_name << std::endl; - ZZIP_FILE* fp = zzip_file_open(dir, dirent.d_name, 0); - if (fp) { - char buf[10]; - zzip_ssize_t len = zzip_file_read(fp, buf, 10); - if (len) { - /* show head of README */ - std::cout << buf; - } - zzip_file_close(fp); - std::cout << std::endl; - } - foreach(plugin, plugins) { - QString plugin_name = plugin.split(QDir::separator()).last(); - plugin_name.chop(3); // Remove .py extension - qDebug("Detected plugin %s in archive", plugin_name.toLocal8Bit().data()); - ZZIP_FILE* fp = zzip_file_open(dir, plugin.toLocal8Bit().data(), 0); - if(fp) { - QTemporaryFile *tmpfile = new QTemporaryFile(); - QString tmpPath; - // Write file - if(tmpfile->open()) { - tmpPath = tmpfile->fileName(); - char buf[255]; - zzip_ssize_t len = zzip_file_read(fp, buf, 255); - while(len) { - tmpfile->write(buf, len); - len = zzip_file_read(fp, buf, 255); - } - zzip_file_close(fp); - tmpfile->close(); - } else { - qDebug("Could not open tmp file"); - QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); - delete tmpfile; - continue; - } - // Install plugin - installPlugin(tmpPath, plugin_name); - qDebug("installPlugin() finished"); - delete tmpfile; - qDebug("Deleted tmpfile"); - } else { - qDebug("Cannot read file in archive"); - QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); - } - } - QString favicon; - foreach(favicon, favicons) { - qDebug("Detected favicon %s in archive", favicon.toLocal8Bit().data()); - // Ok we have a favicon here - QString plugin_name = favicon.split(QDir::separator()).last(); - plugin_name.chop(4); // Remove .png extension - if(!QFile::exists(misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py")) - continue; - // Check if we already have a favicon for this plugin - QString iconPath = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".png"; - if(QFile::exists(iconPath)) { - QFile::remove(iconPath); - } - ZZIP_FILE* fp = zzip_file_open(dir, favicon.toLocal8Bit().data(), 0); - if(fp) { - QFile dest_icon(iconPath); - // Write icon - if(dest_icon.open(QIODevice::WriteOnly | QIODevice::Text)) { - char buf[255]; - zzip_ssize_t len = zzip_file_read(fp, buf, 255); - while(len) { - dest_icon.write(buf, len); - len = zzip_file_read(fp, buf, 255); - } - zzip_file_close(fp); - dest_icon.close(); - // Update icon in list - QTreeWidgetItem *item = findItemWithID(plugin_name); - Q_ASSERT(item); - item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); - } - } - } - zzip_dir_close(dir); -} -#endif - void engineSelectDlg::installPlugin(QString path, QString plugin_name) { qDebug("Asked to install plugin at %s", path.toLocal8Bit().data()); float new_version = misc::getPluginVersion(path); @@ -473,11 +355,7 @@ void engineSelectDlg::addNewEngine(QString engine_name) { void engineSelectDlg::askForLocalPlugin() { QStringList pathsList = QFileDialog::getOpenFileNames(0, tr("Select search plugins"), QDir::homePath(), -#ifdef HAVE_ZZIP - tr("qBittorrent search plugins")+QString::fromUtf8(" (*.py *.zip)")); -#else tr("qBittorrent search plugins")+QString::fromUtf8(" (*.py)")); -#endif QString path; foreach(path, pathsList) { if(path.endsWith(".py", Qt::CaseInsensitive)) { @@ -485,13 +363,6 @@ void engineSelectDlg::addNewEngine(QString engine_name) { plugin_name.replace(".py", "", Qt::CaseInsensitive); installPlugin(path, plugin_name); } -#ifdef HAVE_ZZIP - else { - if(path.endsWith(".zip", Qt::CaseInsensitive)) { - installZipPlugin(path); - } - } -#endif } } @@ -588,13 +459,6 @@ void engineSelectDlg::addNewEngine(QString engine_name) { QFile::remove(filePath); return; } -#ifdef HAVE_ZZIP - if(url.endsWith(".zip", Qt::CaseInsensitive)) { - installZipPlugin(filePath); - QFile::remove(filePath); - return; - } -#endif } void engineSelectDlg::handleDownloadFailure(QString url, QString reason) { @@ -619,11 +483,4 @@ void engineSelectDlg::addNewEngine(QString engine_name) { plugin_name.replace(".py", "", Qt::CaseInsensitive); QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); } -#ifdef HAVE_ZZIP - if(url.endsWith(".zip", Qt::CaseInsensitive)) { - QString plugin_name = url.split('/').last(); - plugin_name.replace(".zip", "", Qt::CaseInsensitive); - QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data())); - } -#endif }