Browse Source

- FEATURE: Dropped dependency on libcurl (Using Qt >= 4.4 for downloads now)

- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is required)
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
bc308741b7
  1. 2
      Changelog
  2. 14
      INSTALL
  3. 90
      configure
  4. 3
      qbittorrent.qc
  5. 61
      qcm/libcurl.qcm
  6. 9
      qcm/qt4.qcm
  7. 16
      src/GUI.cpp
  8. 14
      src/GUI.h
  9. 268
      src/downloadThread.cpp
  10. 60
      src/downloadThread.h
  11. 1
      src/engineSelectDlg.cpp
  12. 22
      src/main.cpp
  13. 6
      src/src.pro

2
Changelog

@ -11,6 +11,8 @@ @@ -11,6 +11,8 @@
- FEATURE: Tracker connections are now also subject to IP filtering
- FEATURE: Include DHT traffic in the rate limiter
- FEATURE: Support for bitcomet padding files
- FEATURE: Dropped dependency on libcurl
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is required)
* Thu Sep 3 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.0
- FEATURE: Added Magnet URI support

14
INSTALL

@ -1,12 +1,6 @@ @@ -1,12 +1,6 @@
qBittorrent - A BitTorrent client in C++ / Qt4
------------------------------------------
*** Necessary if qt3 is default on your system ***
export QTDIR=/usr/include/qt4
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
*** End ***
./configure
make && make install
qbittorrent
@ -14,8 +8,7 @@ qbittorrent @@ -14,8 +8,7 @@ qbittorrent
will install and execute qBittorrent hopefully without any problems.
Dependencies:
- Qt >= 4.3.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)
Qt >= 4.4.0 is advised
- Qt >= 4.4.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)
- libtorrent-rasterbar by Arvid Norberg (>= v0.15.0 REQUIRED)
-> http://www.qbittorrent.org/download.php (advised)
@ -24,13 +17,8 @@ Dependencies: @@ -24,13 +17,8 @@ Dependencies:
- libboost: libboost-filesystem, libboost-date-time, libboost-thread, libboost-serialization
- libcurl
- python >= 2.3 (needed by search engine)
- libmagick++ (advised, not required)
* Needed for favicons support (RSS / Search plugins)
- libzzip (advised, not required)
* Needed for zip support (Search plugins)

90
configure vendored

@ -19,8 +19,6 @@ Main options: @@ -19,8 +19,6 @@ Main options:
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-libzzip Disable use of libzzip
--with-libzzip-inc=[path] Path to libzzip++ include files
--with-libzzip-lib=[path] Path to libzzip++ library files
@ -145,16 +143,6 @@ while [ $# -gt 0 ]; do @@ -145,16 +143,6 @@ while [ $# -gt 0 ]; do
shift
;;
--with-libcurl-inc=*)
QC_WITH_LIBCURL_INC=$optarg
shift
;;
--with-libcurl-lib=*)
QC_WITH_LIBCURL_LIB=$optarg
shift
;;
--disable-libzzip)
QC_DISABLE_libzzip="Y"
shift
@ -192,8 +180,6 @@ echo BINDIR=$BINDIR @@ -192,8 +180,6 @@ echo BINDIR=$BINDIR
echo DATADIR=$DATADIR
echo EX_QTDIR=$EX_QTDIR
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_libzzip=$QC_DISABLE_libzzip
echo QC_WITH_LIBZZIP_INC=$QC_WITH_LIBZZIP_INC
echo QC_WITH_LIBZZIP_LIB=$QC_WITH_LIBZZIP_LIB
@ -308,14 +294,11 @@ class qc_qt4 : public ConfObj @@ -308,14 +294,11 @@ class qc_qt4 : public ConfObj
{
public:
qc_qt4(Conf *c) : ConfObj(c) {}
QString name() const { return "Qt >= 4.3"; }
QString shortname() const { return "Qt 4.3"; }
QString name() const { return "Qt >= 4.4"; }
QString shortname() const { return "Qt 4.4"; }
bool exec()
{
if(QT_VERSION >= 0x040400) {
conf->addDefine("QT_4_4");
}
return(QT_VERSION >= 0x040300);
return(QT_VERSION >= 0x040400);
}
};
@ -403,68 +386,6 @@ public: @@ -403,68 +386,6 @@ public:
return true;
}
};
#line 1 "libcurl.qcm"
/*
-----BEGIN QCMOD-----
name: libcommoncpp2
arg: with-libcurl-inc=[path], Path to libcurl include files
arg: with-libcurl-lib=[path], Path to libcurl library files
-----END QCMOD-----
*/
class qc_libcurl : public ConfObj
{
public:
qc_libcurl(Conf *c) : ConfObj(c) {}
QString name() const { return "libcurl"; }
QString shortname() const { return "libcurl"; }
bool exec(){
QString s;
s = conf->getenv("QC_WITH_LIBCURL_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "curl/curl.h")) {
return false;
}
}else{
QStringList sl;
sl << "/usr/include";
sl << "/usr/local/include";
bool found = false;
foreach(s, sl){
if(conf->checkHeader(s, "curl/curl.h")){
found = true;
break;
}
}
if(!found) {
return false;
}
}
conf->addIncludePath(s);
s = conf->getenv("QC_WITH_LIBCURL_LIB");
if(!s.isEmpty()) {
if(!QFile::exists(s+QString("/libcurl.so")))
return false;
conf->addLib(QString("-L") + s);
}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("libcurl.so"))){
found = true;
break;
}
}
if(!found) return false;
conf->addLib(QString("-L") + s);
}
return true;
}
};
#line 1 "libzzip.qcm"
/*
-----BEGIN QCMOD-----
@ -549,9 +470,6 @@ cat >$1/modules_new.cpp <<EOT @@ -549,9 +470,6 @@ cat >$1/modules_new.cpp <<EOT
o = new qc_libboost(conf);
o->required = true;
o->disabled = false;
o = new qc_libcurl(conf);
o->required = true;
o->disabled = false;
o = new qc_libzzip(conf);
o->required = false;
o->disabled = false;
@ -1501,8 +1419,6 @@ export BINDIR @@ -1501,8 +1419,6 @@ export BINDIR
export DATADIR
export EX_QTDIR
export QC_WITH_LIBBOOST_INC
export QC_WITH_LIBCURL_INC
export QC_WITH_LIBCURL_LIB
export QC_DISABLE_libzzip
export QC_WITH_LIBZZIP_INC
export QC_WITH_LIBZZIP_LIB

3
qbittorrent.qc

@ -12,8 +12,5 @@ @@ -12,8 +12,5 @@
<dep type='libboost'>
<required/>
</dep>
<dep type='libcurl'>
<required/>
</dep>
<dep type='libzzip'/>
</qconf>

61
qcm/libcurl.qcm

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
/*
-----BEGIN QCMOD-----
name: libcommoncpp2
arg: with-libcurl-inc=[path], Path to libcurl include files
arg: with-libcurl-lib=[path], Path to libcurl library files
-----END QCMOD-----
*/
class qc_libcurl : public ConfObj
{
public:
qc_libcurl(Conf *c) : ConfObj(c) {}
QString name() const { return "libcurl"; }
QString shortname() const { return "libcurl"; }
bool exec(){
QString s;
s = conf->getenv("QC_WITH_LIBCURL_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "curl/curl.h")) {
return false;
}
}else{
QStringList sl;
sl << "/usr/include";
sl << "/usr/local/include";
bool found = false;
foreach(s, sl){
if(conf->checkHeader(s, "curl/curl.h")){
found = true;
break;
}
}
if(!found) {
return false;
}
}
conf->addIncludePath(s);
s = conf->getenv("QC_WITH_LIBCURL_LIB");
if(!s.isEmpty()) {
if(!QFile::exists(s+QString("/libcurl.so")))
return false;
conf->addLib(QString("-L") + s);
}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("libcurl.so"))){
found = true;
break;
}
}
if(!found) return false;
conf->addLib(QString("-L") + s);
}
return true;
}
};

9
qcm/qt4.qcm

@ -7,14 +7,11 @@ class qc_qt4 : public ConfObj @@ -7,14 +7,11 @@ class qc_qt4 : public ConfObj
{
public:
qc_qt4(Conf *c) : ConfObj(c) {}
QString name() const { return "Qt >= 4.3"; }
QString shortname() const { return "Qt 4.3"; }
QString name() const { return "Qt >= 4.4"; }
QString shortname() const { return "Qt 4.4"; }
bool exec()
{
if(QT_VERSION >= 0x040400) {
conf->addDefine("QT_4_4");
}
return(QT_VERSION >= 0x040300);
return(QT_VERSION >= 0x040400);
}
};

16
src/GUI.cpp

@ -35,15 +35,10 @@ @@ -35,15 +35,10 @@
#include <QStatusBar>
#include <QFrame>
#include <QClipboard>
#ifdef QT_4_4
#include <QLocalServer>
#include <QLocalSocket>
#include <unistd.h>
#include <sys/types.h>
#else
#include <QTcpServer>
#include <QTcpSocket>
#endif
#include <stdlib.h>
#include <QCloseEvent>
#include <QShortcut>
@ -189,7 +184,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis @@ -189,7 +184,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
initWebUi(username, password, port);
}
// Use a tcp server to allow only one instance of qBittorrent
#ifdef QT_4_4
localServer = new QLocalServer();
QString uid = QString::number(getuid());
#ifdef Q_WS_X11
@ -200,18 +194,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis @@ -200,18 +194,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
}
#endif
if (!localServer->listen("qBittorrent-"+uid)) {
#else
localServer = new QTcpServer();
if (!localServer->listen(QHostAddress::LocalHost)) {
#endif
std::cerr << "Couldn't create socket, single instance mode won't work...\n";
}
#ifndef QT_4_4
else {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue(QString::fromUtf8("uniqueInstancePort"), localServer->serverPort());
}
#endif
connect(localServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
// Start connection checking timer
checkConnect = new QTimer(this);

14
src/GUI.h

@ -44,13 +44,8 @@ class DownloadingTorrents; @@ -44,13 +44,8 @@ class DownloadingTorrents;
class FinishedTorrents;
class downloadFromURL;
class SearchEngine;
#ifdef QT_4_4
class QLocalServer;
class QLocalSocket;
#else
class QTcpServer;
class QTcpSocket;
#endif
class QLocalServer;
class QLocalSocket;
class QCloseEvent;
class RSSImp;
class QShortcut;
@ -109,13 +104,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{ @@ -109,13 +104,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
// Web UI
QPointer<HttpServer> httpServer;
// Misc
#ifdef QT_4_4
QLocalServer *localServer;
QLocalSocket *clientConnection;
#else
QTcpServer *localServer;
QTcpSocket *clientConnection;
#endif
protected slots:
// GUI related slots

268
src/downloadThread.cpp

@ -29,215 +29,139 @@ @@ -29,215 +29,139 @@
*/
#include "downloadThread.h"
#include <iostream>
#include <QTemporaryFile>
#include <QSettings>
#include <stdio.h>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkProxy>
#define MAX_THREADS 3
/** Download Thread **/
// http://curl.rtin.bz/libcurl/c/libcurl-errors.html
QString subDownloadThread::errorCodeToString(CURLcode status) {
switch(status){
case CURLE_FTP_CANT_GET_HOST:
case CURLE_COULDNT_RESOLVE_HOST:
return tr("Host is unreachable");
case CURLE_READ_ERROR:
case CURLE_FILE_COULDNT_READ_FILE:
return tr("File was not found (404)");
case CURLE_FTP_ACCESS_DENIED:
case CURLE_LOGIN_DENIED:
case CURLE_FTP_USER_PASSWORD_INCORRECT:
return tr("Connection was denied");
case CURLE_URL_MALFORMAT:
return tr("Url is invalid");
case CURLE_COULDNT_RESOLVE_PROXY:
return tr("Could not resolve proxy");
//case 5:
// return tr("Connection forbidden (403)");
//case 6:
// return tr("Connection was not authorized (401)");
//case 7:
// return tr("Content has moved (301)");
case CURLE_COULDNT_CONNECT:
return tr("Connection failure");
case CURLE_OPERATION_TIMEOUTED:
return tr("Connection was timed out");
case CURLE_INTERFACE_FAILED:
return tr("Incorrect network interface");
default:
return tr("Unknown error");
}
downloadThread::downloadThread(QObject* parent) : QObject(parent) {
networkManager = new QNetworkAccessManager(this);
connect(networkManager, SIGNAL(finished (QNetworkReply*)), this, SLOT(processDlFinished(QNetworkReply*)));
}
subDownloadThread::subDownloadThread(QObject *parent, QString url) : QThread(parent), url(url), abort(false){}
subDownloadThread::~subDownloadThread(){
abort = true;
wait();
downloadThread::~downloadThread(){
delete networkManager;
}
void subDownloadThread::run(){
// Get a unique filename
void downloadThread::processDlFinished(QNetworkReply* reply) {
QString url = reply->url().toString();
if(reply->error() != QNetworkReply::NoError) {
// Failure
emit downloadFailure(url, errorCodeToString(reply->error()));
} else {
// Success
QString filePath;
QTemporaryFile tmpfile;
tmpfile.setAutoRemove(false);
if (tmpfile.open()) {
filePath = tmpfile.fileName();
qDebug("Temporary filename is: %s", filePath.toLocal8Bit().data());
if(reply->open(QIODevice::ReadOnly)) {
tmpfile.write(reply->readAll());
reply->close();
// Send finished signal
emit downloadFinished(url, filePath);
} else {
emit downloadFailureST(this, url, tr("I/O Error"));
return;
// Error when reading the request
emit downloadFailure(url, tr("I/O Error"));
}
tmpfile.close();
// Now temporary file is created but closed so that
// curl can use it
FILE *f = fopen(filePath.toLocal8Bit().data(), "wb");
if(!f) {
std::cerr << "couldn't open destination file" << "\n";
return;
} else {
emit downloadFailure(url, tr("I/O Error"));
}
CURL *curl;
CURLcode res = (CURLcode)-1;
curl = curl_easy_init();
if(curl) {
std::string c_url = url.toLocal8Bit().data();
curl_easy_setopt(curl, CURLOPT_URL, c_url.c_str());
// SSL support
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
// PROXY SUPPORT
}
// Clean up
reply->deleteLater();
}
void downloadThread::downloadUrl(QString url){
// Update proxy settings
applyProxySettings();
// Process download request
networkManager->get(QNetworkRequest(QUrl(url)));
}
void downloadThread::applyProxySettings() {
QNetworkProxy proxy;
QSettings settings("qBittorrent", "qBittorrent");
int intValue = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt();
if(intValue > 0) {
// Proxy enabled
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString();
proxy.setHostName(IP);
QString port = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toString();
qDebug("Using proxy: %s", (IP+QString(":")+port).toLocal8Bit().data());
curl_easy_setopt(curl, CURLOPT_PROXYPORT, (IP+QString(":")+port).toLocal8Bit().data());
proxy.setPort(port.toUShort());
// Default proxy type is HTTP, we must change if it is SOCKS5
if(intValue%2==0) {
qDebug("Proxy is SOCKS5, not HTTP");
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
proxy.setType(QNetworkProxy::Socks5Proxy);
} else {
proxy.setType(QNetworkProxy::HttpProxy);
}
// Authentication?
if(intValue > 2) {
qDebug("Proxy requires authentication, authenticating");
QString username = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), QString()).toString();
proxy.setUser(username);
QString password = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), QString()).toString();
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (username+QString(":")+password).toLocal8Bit().data());
}
}
// We have to define CURLOPT_WRITEFUNCTION or it will crash on windows
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
// Verbose
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
// No progress info (we don't use it)
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
// Redirections
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, -1);
qDebug("Downloading %s", url.toLocal8Bit().data());
if(!abort)
res = curl_easy_perform(curl);
qDebug("done downloading %s", url.toLocal8Bit().data());
/* always cleanup */
curl_easy_cleanup(curl);
fclose(f);
if(abort)
return;
if(res) {
emit downloadFailureST(this, url, errorCodeToString(res));
} else {
emit downloadFinishedST(this, url, filePath);
}
qDebug("%s Raised the signal", url.toLocal8Bit().data());
} else {
std::cerr << "Could not initialize CURL" << "\n";
proxy.setPassword(password);
}
}
/** Download Thread **/
downloadThread::downloadThread(QObject* parent) : QThread(parent), abort(false){}
downloadThread::~downloadThread(){
mutex.lock();
abort = true;
condition.wakeOne();
mutex.unlock();
//qDebug("downloadThread deleting subthreads...");
qDeleteAll(subThreads);
//qDebug("downloadThread deleted subthreads");
wait();
}
void downloadThread::downloadUrl(QString url){
QMutexLocker locker(&mutex);
urls_queue.enqueue(url);
if(!isRunning()){
start();
}else{
condition.wakeOne();
}
}
void downloadThread::run(){
forever{
if(abort) {
qDebug("DownloadThread aborting...");
return;
}
mutex.lock();
if(!urls_queue.empty() && subThreads.size() < MAX_THREADS){
QString url = urls_queue.dequeue();
mutex.unlock();
//qDebug("DownloadThread downloading %s...", url.toLocal8Bit().data());
subDownloadThread *st = new subDownloadThread(0, url);
subThreads << st;
connect(st, SIGNAL(downloadFinishedST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadedFile(subDownloadThread*, QString, QString)));
connect(st, SIGNAL(downloadFailureST(subDownloadThread*, QString, QString)), this, SLOT(propagateDownloadFailure(subDownloadThread*, QString, QString)));
st->start();
}else{
//qDebug("DownloadThread sleeping...");
condition.wait(&mutex);
//qDebug("DownloadThread woke up");
mutex.unlock();
}
}
}
void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url, QString path){
qDebug("Downloading %s was successful", url.toLocal8Bit().data());
mutex.lock();
int index = subThreads.indexOf(st);
Q_ASSERT(index != -1);
subThreads.removeAt(index);
mutex.unlock();
qDebug("Deleting subthread");
delete st;
emit downloadFinished(url, path);
mutex.lock();
if(!urls_queue.empty()) {
condition.wakeOne();
} else {
proxy.setType(QNetworkProxy::NoProxy);
}
mutex.unlock();
qDebug("Out of propagateDownloadedFile");
networkManager->setProxy(proxy);
}
void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url, QString reason){
qDebug("Downloading %s failed", url.toLocal8Bit().data());
mutex.lock();
int index = subThreads.indexOf(st);
Q_ASSERT(index != -1);
subThreads.removeAt(index);
mutex.unlock();
delete st;
emit downloadFailure(url, reason);
mutex.lock();
if(!urls_queue.empty()) {
condition.wakeOne();
QString downloadThread::errorCodeToString(QNetworkReply::NetworkError status) {
switch(status){
case QNetworkReply::HostNotFoundError:
return tr("The remote host name was not found (invalid hostname)");
case QNetworkReply::OperationCanceledError:
return tr("The operation was canceled");
case QNetworkReply::RemoteHostClosedError:
return tr("The remote server closed the connection prematurely, before the entire reply was received and processed");
case QNetworkReply::TimeoutError:
return tr("The connection to the remote server timed out");
case QNetworkReply::SslHandshakeFailedError:
return tr("SSL/TLS handshake failed");
case QNetworkReply::ConnectionRefusedError:
return tr("The remote server refused the connection");
case QNetworkReply::ProxyConnectionRefusedError:
return tr("The connection to the proxy server was refused");
case QNetworkReply::ProxyConnectionClosedError:
return tr("The proxy server closed the connection prematurely");
case QNetworkReply::ProxyNotFoundError:
return tr("The proxy host name was not found");
case QNetworkReply::ProxyTimeoutError:
return tr("The connection to the proxy timed out or the proxy did not reply in time to the request sent");
case QNetworkReply::ProxyAuthenticationRequiredError:
return tr("The proxy requires authentication in order to honour the request but did not accept any credentials offered");
case QNetworkReply::ContentAccessDenied:
return tr("The access to the remote content was denied (401)");
case QNetworkReply::ContentOperationNotPermittedError:
return tr("The operation requested on the remote content is not permitted");
case QNetworkReply::ContentNotFoundError:
return tr("The remote content was not found at the server (404)");
case QNetworkReply::AuthenticationRequiredError:
return tr("The remote server requires authentication to serve the content but the credentials provided were not accepted");
case QNetworkReply::ProtocolUnknownError:
return tr("The Network Access API cannot honor the request because the protocol is not known");
case QNetworkReply::ProtocolInvalidOperationError:
return tr("The requested operation is invalid for this protocol");
case QNetworkReply::UnknownNetworkError:
return tr("An unknown network-related error was detected");
case QNetworkReply::UnknownProxyError:
return tr("An unknown proxy-related error was detected");
case QNetworkReply::UnknownContentError:
return tr("An unknown error related to the remote content was detected");
case QNetworkReply::ProtocolFailure:
return tr("A breakdown in protocol was detected");
default:
return tr("Unknown error");
}
mutex.unlock();
}

60
src/downloadThread.h

@ -31,64 +31,34 @@ @@ -31,64 +31,34 @@
#ifndef DOWNLOADTHREAD_H
#define DOWNLOADTHREAD_H
#include <QThread>
#include <QFile>
#include <QTemporaryFile>
#include <QMutex>
#include <QMutexLocker>
#include <QWaitCondition>
#include <QStringList>
#include <curl/curl.h>
#include <QQueue>
#include <QNetworkReply>
#include <QObject>
class subDownloadThread : public QThread {
Q_OBJECT
private:
QString url;
bool abort;
public:
subDownloadThread(QObject *parent, QString url);
~subDownloadThread();
QString errorCodeToString(CURLcode status);
signals:
// For subthreads
void downloadFinishedST(subDownloadThread* st, QString url, QString file_path);
void downloadFailureST(subDownloadThread* st, QString url, QString reason);
protected:
void run();
};
class QNetworkAccessManager;
class downloadThread : public QThread {
class downloadThread : public QObject {
Q_OBJECT
private:
QQueue<QString> urls_queue;
QMutex mutex;
QWaitCondition condition;
bool abort;
QList<subDownloadThread*> subThreads;
private:
QNetworkAccessManager *networkManager;
signals:
signals:
void downloadFinished(QString url, QString file_path);
void downloadFailure(QString url, QString reason);
public:
public:
downloadThread(QObject* parent);
~downloadThread();
void downloadUrl(QString url);
void setProxy(QString IP, int port, QString username, QString password);
//void setProxy(QString IP, int port, QString username, QString password);
protected:
QString errorCodeToString(QNetworkReply::NetworkError status);
void applyProxySettings();
protected:
void run();
protected slots:
void processDlFinished(QNetworkReply* reply);
protected slots:
void propagateDownloadedFile(subDownloadThread* st, QString url, QString path);
void propagateDownloadFailure(subDownloadThread* st, QString url, QString reason);
};
#endif

1
src/engineSelectDlg.cpp

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
#include <QFileDialog>
#include <QDropEvent>
#include <QInputDialog>
#include <QTemporaryFile>
#ifdef HAVE_ZZIP
#include <zzip/zzip.h>

22
src/main.cpp

@ -34,14 +34,9 @@ @@ -34,14 +34,9 @@
#include <QFile>
#include <QSplashScreen>
#include <QSettings>
#ifdef QT_4_4
#include <QLocalSocket>
#include <unistd.h>
#include <sys/types.h>
#else
#include <QTcpSocket>
#include <QHostAddress>
#endif
#include <QPlastiqueStyle>
#include "qgnomelook.h"
#include <QMotifStyle>
@ -143,19 +138,9 @@ int main(int argc, char *argv[]){ @@ -143,19 +138,9 @@ int main(int argc, char *argv[]){
std::cerr << "Couldn't set environment variable...\n";
}
//Check if there is another instance running
#ifdef QT_4_4
QLocalSocket localSocket;
QString uid = QString::number(getuid());
#else
QTcpSocket localSocket;
#endif
#ifdef QT_4_4
localSocket.connectToServer("qBittorrent-"+uid, QIODevice::WriteOnly);
#else
int serverPort = settings.value(QString::fromUtf8("uniqueInstancePort"), -1).toInt();
if(serverPort != -1) {
localSocket.connectToHost(QHostAddress::LocalHost, serverPort, QIODevice::WriteOnly);
#endif
if (localSocket.waitForConnected(1000)){
std::cout << "Another qBittorrent instance is already running...\n";
// Send parameters
@ -174,19 +159,12 @@ int main(int argc, char *argv[]){ @@ -174,19 +159,12 @@ int main(int argc, char *argv[]){
}else{
std::cerr << "Writing to the socket timed out\n";
}
#ifdef QT_4_4
localSocket.disconnectFromServer();
#else
localSocket.disconnectFromHost();
#endif
std::cout << "disconnected\n";
}
localSocket.close();
return 0;
}
#ifndef QT_4_4
}
#endif
app = new QApplication(argc, argv);
useStyle(app, settings.value("Preferences/General/Style", 0).toInt());
app->setStyleSheet("QStatusBar::item { border-width: 0; }");

6
src/src.pro

@ -14,7 +14,7 @@ CONFIG += qt \ @@ -14,7 +14,7 @@ CONFIG += qt \
network
# Update this VERSION for each release
DEFINES += VERSION=\\\"v1.6.0alpha2\\\"
DEFINES += VERSION=\\\"v1.6.0beta1\\\"
DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=6
DEFINES += VERSION_BUGFIX=0
@ -90,7 +90,7 @@ contains(DEBUG_MODE, 0) { @@ -90,7 +90,7 @@ contains(DEBUG_MODE, 0) {
# QMAKE_CXXFLAGS_DEBUG += -fwrapv
unix:QMAKE_LFLAGS_SHAPP += -rdynamic
CONFIG += link_pkgconfig
PKGCONFIG += "libtorrent-rasterbar libcurl"
PKGCONFIG += "libtorrent-rasterbar"
QT += network \
xml
DEFINES += QT_NO_CAST_TO_ASCII
@ -98,7 +98,7 @@ DEFINES += QT_NO_CAST_TO_ASCII @@ -98,7 +98,7 @@ DEFINES += QT_NO_CAST_TO_ASCII
# QT_NO_CAST_FROM_ASCII
# Windows
# usually built as static
# win32:LIBS += -ltorrent -lcurl -lboost_system
# win32:LIBS += -ltorrent -lboost_system
# win32:LIBS += -lz ?
win32:LIBS += -lssl32 \
-lws2_32 \

Loading…
Cancel
Save