Compare commits

...

1 Commits

Author SHA1 Message Date
Christophe Dumez
22f0f20a45 Tagged rc9 release 2007-11-24 12:11:12 +00:00
13 changed files with 281 additions and 204 deletions

View File

@@ -25,7 +25,7 @@ Dependencies:
- libboost: libboost-filesystem, libboost-date-time, libboost-thread, libboost-serialization - libboost: libboost-filesystem, libboost-date-time, libboost-thread, libboost-serialization
- libcommoncpp2 - libcurl
- python >= 2.3 (needed by search engine) - python >= 2.3 (needed by search engine)

10
TODO
View File

@@ -50,14 +50,11 @@
-> in download list -> in download list
-> in seeding list -> in seeding list
// TODO v1.0.0
- Fix libcommoncpp proxy support
- Fix layout in preferences/Proxy
rc8->rc9 changelog: rc8->rc9 changelog:
- FEATURE: Better media file preview (player detected automatically) - FEATURE: Better media file preview (player detected automatically)
- BUGFIX: Remember properties window size and position - BUGFIX: Remember properties window size and position
- BUGFIX: Added proxy support in search engine, RSS, downloads from urls - BUGFIX: Added HTTP and SOCKS5 proxy support in downloads from urls, RSS
- BUGFIX: Added HTTP proxy support in search engine (no SOCKS yet)
- BUGFIX: Do no pause torrents before saving fastresume data anymore (no longer needed) - BUGFIX: Do no pause torrents before saving fastresume data anymore (no longer needed)
- BUGFIX: Save fast resume data regularly (every 60 seconds) to avoid downloading from scratch if qBittorrent crashes - BUGFIX: Save fast resume data regularly (every 60 seconds) to avoid downloading from scratch if qBittorrent crashes
- BUGFIX: Do not save fastresume data for checking torrents anymore - BUGFIX: Do not save fastresume data for checking torrents anymore
@@ -66,3 +63,6 @@ rc8->rc9 changelog:
- BUGFIX: Fixed possible overflow in ETA calculation - BUGFIX: Fixed possible overflow in ETA calculation
- BUGFIX: title bar is now reset when "Display speed in title" is disabled - BUGFIX: title bar is now reset when "Display speed in title" is disabled
- BUGFIX: Fixed HTTP_PW and SOCKS5_PW in proxy combobox - BUGFIX: Fixed HTTP_PW and SOCKS5_PW in proxy combobox
- BUGFIX: Fixed proxy auth disable problem when disabling proxy
- BUGFIX: Fixed proxy layout in program preferences
- BUGFIX: Fixed everlasting libtorrent session destruction on exit

52
configure vendored
View File

@@ -22,8 +22,8 @@ Dependency options:
--with-libtorrent-lib=[path] Path to libtorrent library files --with-libtorrent-lib=[path] Path to libtorrent library files
--with-libtorrent-static-lib=[path] Path to libtorrent .a file --with-libtorrent-static-lib=[path] Path to libtorrent .a file
--with-libboost-inc=[path] Path to libboost include files --with-libboost-inc=[path] Path to libboost include files
--with-libcommoncpp2-inc=[path] Path to libcommoncpp2 include files --with-libcurl-inc=[path] Path to libcurl include files
--with-libcommoncpp2-lib=[path] Path to libcommoncpp2 library files --with-libcurl-lib=[path] Path to libcurl library files
--disable-libmagick Disable use of libmagick --disable-libmagick Disable use of libmagick
--with-libmagick-inc=[path] Path to libmagick++ include files --with-libmagick-inc=[path] Path to libmagick++ include files
--with-libmagick-lib=[path] Path to libmagick++ library files --with-libmagick-lib=[path] Path to libmagick++ library files
@@ -166,13 +166,13 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
--with-libcommoncpp2-inc=*) --with-libcurl-inc=*)
QC_WITH_LIBCOMMONCPP2_INC=$optarg QC_WITH_LIBCURL_INC=$optarg
shift shift
;; ;;
--with-libcommoncpp2-lib=*) --with-libcurl-lib=*)
QC_WITH_LIBCOMMONCPP2_LIB=$optarg QC_WITH_LIBCURL_LIB=$optarg
shift shift
;; ;;
@@ -231,8 +231,8 @@ echo QC_WITH_LIBTORRENT_INC=$QC_WITH_LIBTORRENT_INC
echo QC_WITH_LIBTORRENT_LIB=$QC_WITH_LIBTORRENT_LIB echo QC_WITH_LIBTORRENT_LIB=$QC_WITH_LIBTORRENT_LIB
echo QC_WITH_LIBTORRENT_STATIC_LIB=$QC_WITH_LIBTORRENT_STATIC_LIB echo QC_WITH_LIBTORRENT_STATIC_LIB=$QC_WITH_LIBTORRENT_STATIC_LIB
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
echo QC_WITH_LIBCOMMONCPP2_INC=$QC_WITH_LIBCOMMONCPP2_INC echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC
echo QC_WITH_LIBCOMMONCPP2_LIB=$QC_WITH_LIBCOMMONCPP2_LIB echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB
echo QC_DISABLE_libmagick=$QC_DISABLE_libmagick echo QC_DISABLE_libmagick=$QC_DISABLE_libmagick
echo QC_WITH_LIBMAGICK_INC=$QC_WITH_LIBMAGICK_INC echo QC_WITH_LIBMAGICK_INC=$QC_WITH_LIBMAGICK_INC
echo QC_WITH_LIBMAGICK_LIB=$QC_WITH_LIBMAGICK_LIB echo QC_WITH_LIBMAGICK_LIB=$QC_WITH_LIBMAGICK_LIB
@@ -485,25 +485,25 @@ public:
return true; return true;
} }
}; };
#line 1 "libcommoncpp2.qcm" #line 1 "libcurl.qcm"
/* /*
-----BEGIN QCMOD----- -----BEGIN QCMOD-----
name: libcommoncpp2 name: libcommoncpp2
arg: with-libcommoncpp2-inc=[path], Path to libcommoncpp2 include files arg: with-libcurl-inc=[path], Path to libcurl include files
arg: with-libcommoncpp2-lib=[path], Path to libcommoncpp2 library files arg: with-libcurl-lib=[path], Path to libcurl library files
-----END QCMOD----- -----END QCMOD-----
*/ */
class qc_libcommoncpp2 : public ConfObj class qc_libcurl : public ConfObj
{ {
public: public:
qc_libcommoncpp2(Conf *c) : ConfObj(c) {} qc_libcurl(Conf *c) : ConfObj(c) {}
QString name() const { return "GNU Common C++ library (libcommoncpp2)"; } QString name() const { return "libcurl"; }
QString shortname() const { return "libcommoncpp2"; } QString shortname() const { return "libcurl"; }
bool exec(){ bool exec(){
QString s; QString s;
s = conf->getenv("QC_WITH_LIBCOMMONCPP2_INC"); s = conf->getenv("QC_WITH_LIBCURL_INC");
if(!s.isEmpty()) { if(!s.isEmpty()) {
if(!conf->checkHeader(s, "cc++/url.h")) { if(!conf->checkHeader(s, "curl/curl.h")) {
return false; return false;
} }
}else{ }else{
@@ -512,7 +512,7 @@ public:
sl << "/usr/local/include"; sl << "/usr/local/include";
bool found = false; bool found = false;
foreach(s, sl){ foreach(s, sl){
if(conf->checkHeader(s, "cc++/url.h")){ if(conf->checkHeader(s, "curl/curl.h")){
found = true; found = true;
break; break;
} }
@@ -523,11 +523,9 @@ public:
} }
conf->addIncludePath(s); conf->addIncludePath(s);
s = conf->getenv("QC_WITH_LIBCOMMONCPP2_LIB"); s = conf->getenv("QC_WITH_LIBCURL_LIB");
if(!s.isEmpty()) { if(!s.isEmpty()) {
if(!QFile::exists(s+QString("/libccext2.so"))) if(!QFile::exists(s+QString("/libcurl.so")))
return false;
if(!QFile::exists(s+QString("/libccgnu2.so")))
return false; return false;
conf->addLib(QString("-L") + s); conf->addLib(QString("-L") + s);
}else{ }else{
@@ -538,13 +536,11 @@ public:
sl << "/usr/local/lib64/"; sl << "/usr/local/lib64/";
bool found = false; bool found = false;
foreach(s, sl){ foreach(s, sl){
if(QFile::exists(s+QString("libccext2.so"))){ if(QFile::exists(s+QString("libcurl.so"))){
if(QFile::exists(s+QString("libccgnu2.so"))){
found = true; found = true;
break; break;
} }
} }
}
if(!found) return false; if(!found) return false;
conf->addLib(QString("-L") + s); conf->addLib(QString("-L") + s);
} }
@@ -715,7 +711,7 @@ cat >$1/modules_new.cpp <<EOT
o = new qc_libboost(conf); o = new qc_libboost(conf);
o->required = true; o->required = true;
o->disabled = false; o->disabled = false;
o = new qc_libcommoncpp2(conf); o = new qc_libcurl(conf);
o->required = true; o->required = true;
o->disabled = false; o->disabled = false;
o = new qc_libmagick(conf); o = new qc_libmagick(conf);
@@ -1673,8 +1669,8 @@ export QC_WITH_LIBTORRENT_INC
export QC_WITH_LIBTORRENT_LIB export QC_WITH_LIBTORRENT_LIB
export QC_WITH_LIBTORRENT_STATIC_LIB export QC_WITH_LIBTORRENT_STATIC_LIB
export QC_WITH_LIBBOOST_INC export QC_WITH_LIBBOOST_INC
export QC_WITH_LIBCOMMONCPP2_INC export QC_WITH_LIBCURL_INC
export QC_WITH_LIBCOMMONCPP2_LIB export QC_WITH_LIBCURL_LIB
export QC_DISABLE_libmagick export QC_DISABLE_libmagick
export QC_WITH_LIBMAGICK_INC export QC_WITH_LIBMAGICK_INC
export QC_WITH_LIBMAGICK_LIB export QC_WITH_LIBMAGICK_LIB

View File

@@ -12,7 +12,7 @@
<dep type='libboost'> <dep type='libboost'>
<required/> <required/>
</dep> </dep>
<dep type='libcommoncpp2'> <dep type='libcurl'>
<required/> <required/>
</dep> </dep>
<dep type='libmagick'/> <dep type='libmagick'/>

61
qcm/libcurl.qcm Normal file
View File

@@ -0,0 +1,61 @@
/*
-----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;
}
};

View File

@@ -43,7 +43,7 @@
#define MAX_TRACKER_ERRORS 2 #define MAX_TRACKER_ERRORS 2
// Main constructor // Main constructor
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1) { bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false) {
// To avoid some exceptions // To avoid some exceptions
fs::path::default_name_check(fs::no_check); fs::path::default_name_check(fs::no_check);
// Creating bittorrent session // Creating bittorrent session
@@ -59,7 +59,7 @@ bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false
connect(ETARefresher, SIGNAL(timeout()), this, SLOT(updateETAs())); connect(ETARefresher, SIGNAL(timeout()), this, SLOT(updateETAs()));
ETARefresher->start(ETA_REFRESH_INTERVAL); ETARefresher->start(ETA_REFRESH_INTERVAL);
fastResumeSaver = new QTimer(); fastResumeSaver = new QTimer();
connect(fastResumeSaver, SIGNAL(timeout()), this, SLOT(saveFastResumeAndRatioDataUnfinished())); connect(fastResumeSaver, SIGNAL(timeout()), this, SLOT(saveFastResumeAndRatioData()));
fastResumeSaver->start(60000); fastResumeSaver->start(60000);
// To download from urls // To download from urls
downloader = new downloadThread(this); downloader = new downloadThread(this);
@@ -321,6 +321,8 @@ bool bittorrent::pauseTorrent(QString hash) {
if(h.is_valid() && !h.is_paused()) { if(h.is_valid() && !h.is_paused()) {
h.pause(); h.pause();
change = true; change = true;
// Save fast resume data
saveFastResumeAndRatioData(hash);
qDebug("Torrent paused successfully"); qDebug("Torrent paused successfully");
}else{ }else{
if(!h.is_valid()) { if(!h.is_valid()) {
@@ -629,25 +631,49 @@ bool bittorrent::isDHTEnabled() const{
void bittorrent::enableUPnP(bool b) { void bittorrent::enableUPnP(bool b) {
if(b) { if(b) {
if(!UPnPEnabled) {
qDebug("Enabling UPnP");
s->start_upnp(); s->start_upnp();
UPnPEnabled = true;
}
} else { } else {
if(UPnPEnabled) {
qDebug("Disabling UPnP");
s->stop_upnp(); s->stop_upnp();
UPnPEnabled = false;
}
} }
} }
void bittorrent::enableNATPMP(bool b) { void bittorrent::enableNATPMP(bool b) {
if(b) { if(b) {
if(!NATPMPEnabled) {
qDebug("Enabling NAT-PMP");
s->start_natpmp(); s->start_natpmp();
NATPMPEnabled = true;
}
} else { } else {
if(NATPMPEnabled) {
qDebug("Disabling NAT-PMP");
s->stop_natpmp(); s->stop_natpmp();
NATPMPEnabled = false;
}
} }
} }
void bittorrent::enableLSD(bool b) { void bittorrent::enableLSD(bool b) {
if(b) { if(b) {
if(!LSDEnabled) {
qDebug("Enabling LSD");
s->start_lsd(); s->start_lsd();
LSDEnabled = true;
}
} else { } else {
if(LSDEnabled) {
qDebug("Disabling LSD");
s->stop_lsd(); s->stop_lsd();
LSDEnabled = false;
}
} }
} }
@@ -833,32 +859,23 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash) {
ratio_file.close(); ratio_file.close();
} }
// Only save fast resume data for unfinished torrents (Optimization) // Only save fast resume data for unfinished and unpaused torrents (Optimization)
void bittorrent::saveFastResumeAndRatioDataUnfinished() { // Called periodically and on exit
void bittorrent::saveFastResumeAndRatioData() {
QString hash; QString hash;
QStringList hashes = getUnfinishedTorrents(); QStringList hashes = getUnfinishedTorrents();
foreach(hash, hashes) { foreach(hash, hashes) {
saveFastResumeAndRatioData(hash); QTorrentHandle h = getTorrentHandle(hash);
}
}
// Save fastresume data for all torrents (called periodically)
void bittorrent::saveFastResumeAndRatioData() {
qDebug("Saving fast resume and ratio data");
std::vector<torrent_handle> handles = s->get_torrents();
// It is not necessary to pause the torrents before saving fastresume data anymore
// because we either use Full allocation or sparse mode.
// Write fast resume data
for(unsigned int i=0; i<handles.size(); ++i) {
QTorrentHandle h = handles[i];
if(!h.is_valid()) { if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
continue; continue;
} }
QString hash = h.hash(); if(h.is_paused()) {
// Do not need to save fast resume data for paused torrents
continue;
}
saveFastResumeAndRatioData(hash); saveFastResumeAndRatioData(hash);
} }
qDebug("Fast resume and ratio data saved");
} }
void bittorrent::saveFastResumeAndRatioData(QString hash) { void bittorrent::saveFastResumeAndRatioData(QString hash) {

View File

@@ -62,6 +62,9 @@ class bittorrent : public QObject{
int maxConnecsPerTorrent; int maxConnecsPerTorrent;
int maxUploadsPerTorrent; int maxUploadsPerTorrent;
float max_ratio; float max_ratio;
bool UPnPEnabled;
bool NATPMPEnabled;
bool LSDEnabled;
protected: protected:
QString getSavePath(QString hash); QString getSavePath(QString hash);
@@ -99,7 +102,6 @@ class bittorrent : public QObject{
void preAllocateAllFiles(bool b); void preAllocateAllFiles(bool b);
void saveFastResumeAndRatioData(); void saveFastResumeAndRatioData();
void saveFastResumeAndRatioData(QString hash); void saveFastResumeAndRatioData(QString hash);
void saveFastResumeAndRatioDataUnfinished();
void enableDirectoryScanning(QString scan_dir); void enableDirectoryScanning(QString scan_dir);
void disableDirectoryScanning(); void disableDirectoryScanning();
void enablePeerExchange(); void enablePeerExchange();

View File

@@ -21,56 +21,48 @@
#include "downloadThread.h" #include "downloadThread.h"
#include <iostream> #include <iostream>
#include <cc++/common.h>
#include <QSettings> #include <QSettings>
#include <stdio.h>
QString subDownloadThread::errorCodeToString(int status) { // http://curl.rtin.bz/libcurl/c/libcurl-errors.html
QString subDownloadThread::errorCodeToString(CURLcode status) {
switch(status){ switch(status){
case 1://ost::URLStream::errUnreachable: case CURLE_FTP_CANT_GET_HOST:
case CURLE_COULDNT_RESOLVE_HOST:
return tr("Host is unreachable"); return tr("Host is unreachable");
case 2://ost::URLStream::errMissing: case CURLE_READ_ERROR:
case CURLE_FILE_COULDNT_READ_FILE:
return tr("File was not found (404)"); return tr("File was not found (404)");
case 3://ost::URLStream::errDenied: case CURLE_FTP_ACCESS_DENIED:
case CURLE_LOGIN_DENIED:
case CURLE_FTP_USER_PASSWORD_INCORRECT:
return tr("Connection was denied"); return tr("Connection was denied");
case 4://ost::URLStream::errInvalid: case CURLE_URL_MALFORMAT:
return tr("Url is invalid"); return tr("Url is invalid");
case 5://ost::URLStream::errForbidden: case CURLE_COULDNT_RESOLVE_PROXY:
return tr("Connection forbidden (403)"); return tr("Could not resolve proxy");
case 6://ost::URLStream::errUnauthorized: //case 5:
return tr("Connection was not authorized (401)"); // return tr("Connection forbidden (403)");
case 7://ost::URLStream::errRelocated: //case 6:
return tr("Content has moved (301)"); // return tr("Connection was not authorized (401)");
case 8://ost::URLStream::errFailure: //case 7:
// return tr("Content has moved (301)");
case CURLE_COULDNT_CONNECT:
return tr("Connection failure"); return tr("Connection failure");
case 9://ost::URLStream::errTimeout: case CURLE_OPERATION_TIMEOUTED:
return tr("Connection was timed out"); return tr("Connection was timed out");
case 10://ost::URLStream::errInterface: case CURLE_INTERFACE_FAILED:
return tr("Incorrect network interface"); return tr("Incorrect network interface");
default: default:
return tr("Unknown error"); return tr("Unknown error");
} }
} }
subDownloadThread::subDownloadThread(QObject *parent, QString url) : QThread(parent), url(url), abort(false){ subDownloadThread::subDownloadThread(QObject *parent, QString url) : QThread(parent), url(url), abort(false){}
url_stream = new ost::URLStream();
// Proxy support
QSettings settings("qBittorrent", "qBittorrent");
int intValue = settings.value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
if(intValue > 0) {
// Proxy enabled
url_stream->setProxy(settings.value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString().toUtf8().data(), settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt());
if(settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool()) {
// Authentication required
url_stream->setProxyUser(settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString().toUtf8().data());
url_stream->setProxyPassword(settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString().toUtf8().data());
}
}
}
subDownloadThread::~subDownloadThread(){ subDownloadThread::~subDownloadThread(){
abort = true; abort = true;
wait(); wait();
delete url_stream;
} }
void subDownloadThread::run(){ void subDownloadThread::run(){
@@ -81,38 +73,57 @@ void subDownloadThread::run(){
filePath = tmpfile->fileName(); filePath = tmpfile->fileName();
} }
delete tmpfile; delete tmpfile;
QFile dest_file(filePath); FILE *f = fopen(filePath.toUtf8().data(), "w");
if(!dest_file.open(QIODevice::WriteOnly | QIODevice::Text)){ if(!f) {
std::cerr << "Error: could't create temporary file: " << (const char*)filePath.toUtf8() << '\n'; std::cerr << "couldn't open destination file" << "\n";
return; return;
} }
ost::URLStream::Error status = url_stream->get((const char*)url.toUtf8()); CURL *curl;
if(status){ CURLcode res;
// Failure curl = curl_easy_init();
QString error_msg = errorCodeToString((int)status); if(curl) {
qDebug("Download failed for %s, reason: %s", (const char*)url.toUtf8(), (const char*)error_msg.toUtf8()); std::string c_url = url.toUtf8().data();
url_stream->close(); curl_easy_setopt(curl, CURLOPT_URL, c_url.c_str());
emit downloadFailureST(this, url, error_msg); // SSL support
return; curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
// PROXY SUPPORT
QSettings settings("qBittorrent", "qBittorrent");
int intValue = settings.value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
if(intValue > 0) {
// Proxy enabled
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
QString port = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toString();
qDebug("Using proxy: %s", (IP+QString(":")+port).toUtf8().data());
curl_easy_setopt(curl, CURLOPT_PROXYPORT, (IP+QString(":")+port).toUtf8().data());
// 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);
} }
qDebug("Downloading %s...", (const char*)url.toUtf8()); // Authentication?
char cbuf[1024]; if(intValue > 2) {
int len; qDebug("Proxy requires authentication, authenticating");
while(!url_stream->eof()) { QString username = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
url_stream->read(cbuf, sizeof(cbuf)); QString password = settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
len = url_stream->gcount(); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (username+QString(":")+password).toUtf8().data());
if(len > 0)
dest_file.write(cbuf, len);
if(abort){
dest_file.close();
url_stream->close();
return;
} }
} }
dest_file.close(); // TODO: define CURLOPT_WRITEFUNCTION or it will crash on windows
url_stream->close(); curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
qDebug("Downloading %s", url.toUtf8().data());
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
fclose(f);
if(res) {
emit downloadFailureST(this, url, errorCodeToString(res));
} else {
emit downloadFinishedST(this, url, filePath); emit downloadFinishedST(this, url, filePath);
qDebug("download completed here: %s", (const char*)filePath.toUtf8()); }
} else {
std::cerr << "Could not initialize CURL" << "\n";
}
} }
/** Download Thread **/ /** Download Thread **/

View File

@@ -29,29 +29,18 @@
#include <QMutexLocker> #include <QMutexLocker>
#include <QWaitCondition> #include <QWaitCondition>
#include <QStringList> #include <QStringList>
#include <curl/curl.h>
namespace ost {
class URLStream;
}
typedef struct {
QString IP;
int port;
QString username;
QString password;
} tmp_proxy;
class subDownloadThread : public QThread { class subDownloadThread : public QThread {
Q_OBJECT Q_OBJECT
private: private:
QString url; QString url;
ost::URLStream *url_stream;
bool abort; bool abort;
public: public:
subDownloadThread(QObject *parent, QString url); subDownloadThread(QObject *parent, QString url);
~subDownloadThread(); ~subDownloadThread();
QString errorCodeToString(int status); QString errorCodeToString(CURLcode status);
signals: signals:
// For subthreads // For subthreads
@@ -90,7 +79,6 @@ class downloadThread : public QThread {
protected slots: protected slots:
void propagateDownloadedFile(subDownloadThread* st, QString url, QString path); void propagateDownloadedFile(subDownloadThread* st, QString url, QString path);
void propagateDownloadFailure(subDownloadThread* st, QString url, QString reason); void propagateDownloadFailure(subDownloadThread* st, QString url, QString reason);
}; };

View File

@@ -190,7 +190,6 @@ void DownloadingTorrents::setInfoBar(QString info, QColor color) {
infoBar->clear(); infoBar->clear();
nbLines = 1; nbLines = 1;
} }
qDebug("Color is %s", color.name().toUtf8().data());
infoBar->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + info + QString::fromUtf8("</i></font>")); infoBar->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + info + QString::fromUtf8("</i></font>"));
} }

View File

@@ -947,14 +947,14 @@
<property name="title" > <property name="title" >
<string>Affected connections</string> <string>Affected connections</string>
</property> </property>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="checkProxyTrackers" > <widget class="QCheckBox" name="checkProxyTrackers" >
<property name="geometry" > <property name="sizePolicy" >
<rect> <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<x>10</x> <horstretch>0</horstretch>
<y>20</y> <verstretch>0</verstretch>
<width>341</width> </sizepolicy>
<height>22</height>
</rect>
</property> </property>
<property name="text" > <property name="text" >
<string>Use proxy for connections to trackers</string> <string>Use proxy for connections to trackers</string>
@@ -963,14 +963,14 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QCheckBox" name="checkProxyPeers" > <widget class="QCheckBox" name="checkProxyPeers" >
<property name="geometry" > <property name="sizePolicy" >
<rect> <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<x>10</x> <horstretch>0</horstretch>
<y>40</y> <verstretch>0</verstretch>
<width>341</width> </sizepolicy>
<height>22</height>
</rect>
</property> </property>
<property name="text" > <property name="text" >
<string>Use proxy for connections to regular peers</string> <string>Use proxy for connections to regular peers</string>
@@ -979,30 +979,14 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="checkProxyWebseeds" > </item>
<property name="geometry" > <item>
<rect>
<x>10</x>
<y>60</y>
<width>341</width>
<height>22</height>
</rect>
</property>
<property name="text" >
<string>Use proxy for connections to web seeds</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkProxyDHT" > <widget class="QCheckBox" name="checkProxyDHT" >
<property name="geometry" > <property name="sizePolicy" >
<rect> <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<x>10</x> <horstretch>0</horstretch>
<y>80</y> <verstretch>0</verstretch>
<width>341</width> </sizepolicy>
<height>22</height>
</rect>
</property> </property>
<property name="text" > <property name="text" >
<string>Use proxy for DHT messages</string> <string>Use proxy for DHT messages</string>
@@ -1011,6 +995,24 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QCheckBox" name="checkProxyWebseeds" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Use proxy for connections to web seeds</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@@ -871,6 +871,7 @@ void options_imp::enableProxy(int index){
textProxyIP->setEnabled(false); textProxyIP->setEnabled(false);
lblProxyPort->setEnabled(false); lblProxyPort->setEnabled(false);
spinProxyPort->setEnabled(false); spinProxyPort->setEnabled(false);
checkProxyAuth->setChecked(false);
checkProxyAuth->setEnabled(false); checkProxyAuth->setEnabled(false);
ProxyConnecsBox->setEnabled(false); ProxyConnecsBox->setEnabled(false);
} }

View File

@@ -11,7 +11,7 @@ TARGET = qbittorrent
CONFIG += qt thread x11 network CONFIG += qt thread x11 network
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v1.0.0rc8\\\" DEFINES += VERSION=\\\"v1.0.0rc9\\\"
DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=0 DEFINES += VERSION_MINOR=0
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=0
@@ -81,7 +81,7 @@ QMAKE_CXXFLAGS_RELEASE += -fwrapv -O2
QMAKE_CXXFLAGS_DEBUG += -fwrapv -O1 QMAKE_CXXFLAGS_DEBUG += -fwrapv -O1
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += libtorrent libccext2 libccgnu2 PKGCONFIG += "libtorrent libcurl"
!contains(DEFINES, HAVE_MAGICK){ !contains(DEFINES, HAVE_MAGICK){
message(ImageMagick disabled) message(ImageMagick disabled)