Browse Source

- Added Encryption support!

- Removed old UPnP code
- Removed UPnP in options since libtorrent doesn't allow to disable it. Thus, UPnP is always enabled
- Made options window a bit larger
- Added Arnaud Demaiziere to developpers list
- Updated TODO & Changelog
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
c39da36cca
  1. 6
      AUTHORS
  2. 1
      Changelog
  3. 1
      TODO
  4. 24
      qBittorrent.kdevelop
  5. 49
      src/GUI.cpp
  6. 4
      src/GUI.h
  7. 68
      src/bittorrent.cpp
  8. 26
      src/bittorrent.h
  9. 3
      src/lang/qbittorrent_fr.ts
  10. 797
      src/options.ui
  11. 61
      src/options_imp.cpp
  12. 8
      src/options_imp.h
  13. 5
      src/src.pro

6
AUTHORS

@ -1 +1,5 @@ @@ -1 +1,5 @@
Christophe Dumez <chris@qbittorrent.org>
Author:
* Christophe Dumez <chris@qbittorrent.org>
Other developers:
* Arnaud Demaizière <arnaud@qbittorrent.org>

1
Changelog

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.0.0
- FEATURE: Based on new libtorrent v0.13
- FEATURE: Added UPnP / NAT-PMP port forwarding support
- FEATURE: Added encryption support (compatible with Azureus)
- FEATURE: Added RSS support
- FEATURE: Support files prioritizing in a torrent
- FEATURE: Finished torrents are now moved to another tab for seeding

1
TODO

@ -36,7 +36,6 @@ @@ -36,7 +36,6 @@
- Use tooltips to explain options?
- Improve ratio display / calculation / saving / per torrent...
- Sorting in Download Status column should be smarter than just an alphabetical sort
- Encryption support!
- File selection in a torrent in compact mode???
- Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip
- Make use of QSessionManager to save application state?

24
qBittorrent.kdevelop

@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
<ignoreparts/>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<defaultencoding/>
<description></description>
<defaultencoding></defaultencoding>
<versioncontrol>kdevsubversion</versioncontrol>
</general>
<kdevfileview>
@ -72,11 +72,11 @@ @@ -72,11 +72,11 @@
</kdevdoctreeview>
<kdevdebugger>
<general>
<dbgshell/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<dbgshell></dbgshell>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
@ -153,11 +153,11 @@ @@ -153,11 +153,11 @@
</general>
<run>
<directoryradio>executable</directoryradio>
<mainprogram>/home/chris/qbittorrent_svn/trunk</mainprogram>
<programargs/>
<globaldebugarguments/>
<mainprogram>/home/chris/qbittorrent_svn/trunk/src/qbittorrent</mainprogram>
<programargs></programargs>
<globaldebugarguments></globaldebugarguments>
<globalcwd>/home/chris/qbittorrent_svn/trunk</globalcwd>
<useglobalprogram>false</useglobalprogram>
<useglobalprogram>true</useglobalprogram>
<terminal>false</terminal>
<autocompile>true</autocompile>
<autoinstall>false</autoinstall>
@ -169,7 +169,7 @@ @@ -169,7 +169,7 @@
<runmultiplejobs>false</runmultiplejobs>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin/>
<makebin></makebin>
<prio>0</prio>
<envvars/>
</make>

49
src/GUI.cpp

@ -132,10 +132,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ @@ -132,10 +132,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Hide hash column
downloadList->hideColumn(HASH);
#ifndef NO_UPNP
connect(&BTSession, SIGNAL(noWanServiceDetected()), this, SLOT(displayNoUPnPWanServiceDetected()));
connect(&BTSession, SIGNAL(wanServiceDetected()), this, SLOT(displayUPnPWanServiceDetected()));
#endif
connect(&BTSession, SIGNAL(addedTorrent(const QString&, torrent_handle&, bool)), this, SLOT(torrentAdded(const QString&, torrent_handle&, bool)));
connect(&BTSession, SIGNAL(duplicateTorrent(const QString&)), this, SLOT(torrentDuplicate(const QString&)));
connect(&BTSession, SIGNAL(invalidTorrent(const QString&)), this, SLOT(torrentCorrupted(const QString&)));
@ -278,17 +274,6 @@ void GUI::readParamsOnSocket(){ @@ -278,17 +274,6 @@ void GUI::readParamsOnSocket(){
}
}
#ifndef NO_UPNP
void GUI::displayNoUPnPWanServiceDetected(){
setInfoBar(tr("UPnP: no WAN service detected..."), "red");
}
void GUI::displayUPnPWanServiceDetected(){
setInfoBar(tr("UPnP: WAN service detected!"), "green");
}
#endif
// Toggle paused state of selected torrent
void GUI::togglePausedState(const QModelIndex& index){
int row = index.row();
@ -1151,6 +1136,7 @@ void GUI::configureSession(bool deleteOptions){ @@ -1151,6 +1136,7 @@ void GUI::configureSession(bool deleteOptions){
unsigned short old_listenPort, new_listenPort;
proxy_settings proxySettings;
session_settings sessionSettings;
pe_settings encryptionSettings;
// Configure session regarding options
BTSession.setDefaultSavePath(options->getSavePath());
old_listenPort = BTSession.getListenPort();
@ -1190,18 +1176,29 @@ void GUI::configureSession(bool deleteOptions){ @@ -1190,18 +1176,29 @@ void GUI::configureSession(bool deleteOptions){
setInfoBar(tr("DHT support [OFF]"), "blue");
BTSession.disableDHT();
}
#ifndef NO_UPNP
// Upnp
if(options->isUPnPEnabled()){
setInfoBar(tr("UPnP support [ON], port: %1").arg(options->getUPnPPort()), "blue");
BTSession.enableUPnP(options->getUPnPPort());
BTSession.setUPnPPort(options->getUPnPPort());
}else{
setInfoBar(tr("UPnP support [OFF]"), "blue");
BTSession.disableUPnP();
}
#endif
// UPnP can't be disabled
setInfoBar(tr("UPnP support [ON]"), "blue");
// Encryption settings
int encryptionState = options->getEncryptionSetting();
encryptionSettings.allowed_enc_level = pe_settings::both;
encryptionSettings.prefer_rc4 = true;
switch(encryptionState){
case 0: //Enabled
encryptionSettings.out_enc_policy = pe_settings::enabled;
encryptionSettings.in_enc_policy = pe_settings::enabled;
setInfoBar(tr("Encryption support [ON]"), "blue");
break;
case 1: // Forced
encryptionSettings.out_enc_policy = pe_settings::forced;
encryptionSettings.in_enc_policy = pe_settings::forced;
setInfoBar(tr("Encryption support [FORCED]"), "blue");
break;
default: // Disabled
encryptionSettings.out_enc_policy = pe_settings::disabled;
encryptionSettings.in_enc_policy = pe_settings::disabled;
setInfoBar(tr("Encryption support [OFF]"), "blue");
}
BTSession.applyEncryptionSettings(encryptionSettings);
// PeX
if(!options->isPeXDisabled()){
qDebug("Enabling Peer eXchange (PeX)");

4
src/GUI.h

@ -154,10 +154,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{ @@ -154,10 +154,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void OptionsSaved(const QString& info, bool deleteOptions);
// HTTP slots
void on_actionDownload_from_URL_triggered();
#ifndef NO_UPNP
void displayNoUPnPWanServiceDetected();
void displayUPnPWanServiceDetected();
#endif
public slots:

68
src/bittorrent.cpp

@ -28,10 +28,6 @@ @@ -28,10 +28,6 @@
#include "misc.h"
#include "downloadThread.h"
#ifndef NO_UPNP
#include "UPnP.h"
#endif
// Main constructor
bittorrent::bittorrent(){
// To avoid some exceptions
@ -45,9 +41,6 @@ bittorrent::bittorrent(){ @@ -45,9 +41,6 @@ bittorrent::bittorrent(){
s->set_severity_level(alert::info);
// DHT (Trackerless), disabled until told otherwise
DHTEnabled = false;
#ifndef NO_UPNP
UPnPEnabled = false;
#endif
// Enabling metadata plugin
s->add_extension(&create_metadata_plugin);
timerAlerts = new QTimer(this);
@ -66,9 +59,6 @@ void bittorrent::resumeUnfinishedTorrents(){ @@ -66,9 +59,6 @@ void bittorrent::resumeUnfinishedTorrents(){
// Main destructor
bittorrent::~bittorrent(){
disableDirectoryScanning();
#ifndef NO_UPNP
disableUPnP();
#endif
delete timerAlerts;
delete downloader;
delete s;
@ -79,60 +69,6 @@ torrent_handle bittorrent::getTorrentHandle(const QString& hash) const{ @@ -79,60 +69,6 @@ torrent_handle bittorrent::getTorrentHandle(const QString& hash) const{
return s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
}
#ifndef NO_UPNP
void bittorrent::enableUPnP(int port){
if(!UPnPEnabled){
qDebug("Enabling UPnP");
UPnPEnabled = true;
m_upnpMappings.resize(1);
m_upnpMappings[0] = CUPnPPortMapping(
getListenPort(),
"TCP",
true,
"qBittorrent");
m_upnp = new CUPnPControlPoint(port);
connect(m_upnp, SIGNAL(noWanServiceDetected()), this, SLOT(noWanServiceEventHandler()));
connect(m_upnp, SIGNAL(yeswanServiceDetected()), this, SLOT(wanServiceEventHandler()));
m_upnp->AddPortMappings(m_upnpMappings);
}
}
void bittorrent::noWanServiceEventHandler(){
// Forward this signal
emit noWanServiceDetected();
}
void bittorrent::wanServiceEventHandler(){
// Forward this signal
emit wanServiceDetected();
}
// Set UPnP port (>= 1000)
void bittorrent::setUPnPPort(int upnp_port){
if(!UPnPEnabled){
qDebug("Cannot set UPnP port because it is disabled");
return;
}
if(m_upnp->getUPnPPort() != upnp_port){
qDebug("Changing UPnP port to %d", upnp_port);
delete m_upnp;
m_upnp = new CUPnPControlPoint(upnp_port);
m_upnp->AddPortMappings(m_upnpMappings);
}else{
qDebug("UPnP: No need to set the port, it is already listening on this port");
}
}
void bittorrent::disableUPnP(){
if(UPnPEnabled){
qDebug("Disabling UPnP");
UPnPEnabled = false;
m_upnp->DeletePortMappings(m_upnpMappings);
delete m_upnp;
}
}
#endif
// Return true if the torrent corresponding to the
// hash is paused
bool bittorrent::isPaused(const QString& hash) const{
@ -895,6 +831,10 @@ void bittorrent::saveDHTEntry(){ @@ -895,6 +831,10 @@ void bittorrent::saveDHTEntry(){
}
}
void bittorrent::applyEncryptionSettings(pe_settings se){
s->set_pe_settings(se);
}
// Will fast resume unfinished torrents in
// backup directory
void bittorrent::resumeUnfinished(){

26
src/bittorrent.h

@ -44,10 +44,6 @@ class QString; @@ -44,10 +44,6 @@ class QString;
using namespace libtorrent;
class downloadThread;
#ifndef NO_UPNP
class CUPnPControlPoint;
class CUPnPPortMapping;
#endif
class bittorrent : public QObject{
Q_OBJECT
@ -55,19 +51,12 @@ class bittorrent : public QObject{ @@ -55,19 +51,12 @@ class bittorrent : public QObject{
private:
session *s;
bool DHTEnabled;
#ifndef NO_UPNP
bool UPnPEnabled;
#endif
QString scan_dir;
QTimer *timerScan;
QTimer *timerAlerts;
downloadThread *downloader;
QStringList supported_preview_extensions;
QString defaultSavePath;
#ifndef NO_UPNP
CUPnPControlPoint* m_upnp;
std::vector<CUPnPPortMapping> m_upnpMappings;
#endif
protected:
QString getSavePath(const QString& hash);
@ -118,11 +107,7 @@ class bittorrent : public QObject{ @@ -118,11 +107,7 @@ class bittorrent : public QObject{
void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true);
void setSessionSettings(session_settings sessionSettings);
void setDefaultSavePath(const QString& savepath);
#ifndef NO_UPNP
void enableUPnP(int port=50000);
void disableUPnP();
void setUPnPPort(int upnp_port);
#endif
void applyEncryptionSettings(pe_settings se);
protected slots:
void cleanDeleter(deleteThread* deleter);
@ -133,10 +118,6 @@ class bittorrent : public QObject{ @@ -133,10 +118,6 @@ class bittorrent : public QObject{
void resumeUnfinished();
bool loadTrackerFile(const QString& hash);
void saveTrackerFile(const QString& hash);
#ifndef NO_UPNP
void noWanServiceEventHandler();
void wanServiceEventHandler();
#endif
signals:
void invalidTorrent(const QString& path);
@ -152,10 +133,7 @@ class bittorrent : public QObject{ @@ -152,10 +133,7 @@ class bittorrent : public QObject{
void newDownloadedTorrent(const QString& path, const QString& url);
void aboutToDownloadFromUrl(const QString& url);
void updateFileSize(QString hash);
#ifndef NO_UPNP
void noWanServiceDetected();
void wanServiceDetected();
#endif
};
#endif

3
src/lang/qbittorrent_fr.ts

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1" language="fr">
<defaultcodec></defaultcodec>
<context>
<name>@default</name>
<message>
@ -2859,7 +2860,7 @@ Changements: @@ -2859,7 +2860,7 @@ Changements:
<message>
<location filename="../downloadFromURLImp.h" line="64"/>
<source>No URL entered</source>
<translation type="unfinished">Aucune URL entrée</translation>
<translation>Aucune URL entrée</translation>
</message>
<message>
<location filename="../downloadFromURLImp.h" line="64"/>

797
src/options.ui

File diff suppressed because it is too large Load Diff

61
src/options_imp.cpp

@ -68,11 +68,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ @@ -68,11 +68,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
delFilterRange->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
enableProxyAuth_checkBox->setIcon(QIcon(QString::fromUtf8(":/Icons/encrypted.png")));
to_range->setText(tr("to", "<min port> to <max port>"));
// If UPnP is not supported then disable it
#ifdef NO_UPNP
groupMainUPnP->setEnabled(false);
disableUPnP->setChecked(false);
#endif
#ifdef Q_WS_WIN
radioWinXPStyle->setEnabled(true);
#endif
@ -146,9 +141,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ @@ -146,9 +141,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(disableUPLimit, SIGNAL(stateChanged(int)), this, SLOT(disableUpload(int)));
connect(disableDLLimit, SIGNAL(stateChanged(int)), this, SLOT(disableDownload(int)));
connect(disableDHT, SIGNAL(stateChanged(int)), this, SLOT(disableDHTGroup(int)));
#ifndef NO_UPNP
connect(disableUPnP, SIGNAL(stateChanged(int)), this, SLOT(disableUPnPGroup(int)));
#endif
connect(check_disableSystray, SIGNAL(stateChanged(int)), this, SLOT(systrayDisabled(int)));
connect(disableRatio, SIGNAL(stateChanged(int)), this, SLOT(disableShareRatio(int)));
connect(activateFilter, SIGNAL(stateChanged(int)), this, SLOT(enableFilter(int)));
@ -172,12 +164,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ @@ -172,12 +164,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(enableScan_checkBox, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(disableMaxConnec, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(disableDHT, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
#ifndef NO_UPNP
connect(disableUPnP, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
#endif
connect(disablePeX, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(spin_dht_port, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spin_upnp_port, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(comboEncryption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
// Language
connect(combo_i18n, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
// IPFilter
@ -275,10 +263,7 @@ void options_imp::saveOptions(){ @@ -275,10 +263,7 @@ void options_imp::saveOptions(){
settings.setValue("PortRangeMin", getPorts().first);
settings.setValue("PortRangeMax", getPorts().second);
settings.setValue("ShareRatio", getRatio());
settings.setValue("DHTPort", getDHTPort());
#ifndef NO_UPNP
settings.setValue("UPnPPort", getUPnPPort());
#endif
settings.setValue("EncryptionState", getEncryptionSetting());
settings.setValue("PeXState", !isPeXDisabled());
settings.setValue("ScanDir", getScanDir());
// End Main options
@ -495,20 +480,8 @@ void options_imp::loadOptions(){ @@ -495,20 +480,8 @@ void options_imp::loadOptions(){
}
spin_dht_port->setValue(value);
}
#ifndef NO_UPNP
value = settings.value("UPnPPort", -1).toInt();
if(value < 0){
disableUPnP->setChecked(true);
groupUPnP->setEnabled(false);
}else{
disableUPnP->setChecked(false);
groupUPnP->setEnabled(true);
if(value < 1000){
value = 50000;
}
spin_upnp_port->setValue(value);
}
#endif
value = settings.value("EncryptionState", 0).toInt();
comboEncryption->setCurrentIndex(value);
boolValue = settings.value("PeXState", true).toBool();
if(boolValue){
// Pex disabled
@ -661,19 +634,9 @@ int options_imp::getDHTPort() const{ @@ -661,19 +634,9 @@ int options_imp::getDHTPort() const{
}
}
#ifndef NO_UPNP
int options_imp::getUPnPPort() const{
if(isUPnPEnabled()){
return spin_upnp_port->value();
}else{
return -1;
}
}
bool options_imp::isUPnPEnabled() const{
return !disableUPnP->isChecked();
int options_imp::getEncryptionSetting() const{
return comboEncryption->currentIndex();
}
#endif
QString options_imp::getPreviewProgram() const{
QString preview_txt = preview_program->text();
@ -815,18 +778,6 @@ void options_imp::disableDHTGroup(int checkBoxValue){ @@ -815,18 +778,6 @@ void options_imp::disableDHTGroup(int checkBoxValue){
}
}
#ifndef NO_UPNP
void options_imp::disableUPnPGroup(int checkBoxValue){
if(checkBoxValue==2){
//Disable
groupUPnP->setEnabled(false);
}else{
//enable
groupUPnP->setEnabled(true);
}
}
#endif
void options_imp::enableSavePath(int checkBoxValue){
if(checkBoxValue==2){
//enable

8
src/options_imp.h

@ -59,10 +59,7 @@ class options_imp : public QDialog, private Ui::Dialog{ @@ -59,10 +59,7 @@ class options_imp : public QDialog, private Ui::Dialog{
QString getScanDir() const;
bool isDHTEnabled() const;
int getDHTPort() const;
#ifndef NO_UPNP
bool isUPnPEnabled() const;
int getUPnPPort() const;
#endif
int getEncryptionSetting() const;
bool isPeXDisabled() const;
// Filter Settings
bool isFilteringEnabled() const;
@ -105,9 +102,6 @@ class options_imp : public QDialog, private Ui::Dialog{ @@ -105,9 +102,6 @@ class options_imp : public QDialog, private Ui::Dialog{
void on_filterBrowse_clicked();
void disableDownload(int checkBoxValue);
void disableDHTGroup(int checkBoxValue);
#ifndef NO_UPNP
void disableUPnPGroup(int checkBoxValue);
#endif
void disableMaxConnecLimit(int);
void enableFilter(int checkBoxValue);
void disableUpload(int checkBoxValue);

5
src/src.pro

@ -11,14 +11,11 @@ TARGET = qbittorrent @@ -11,14 +11,11 @@ TARGET = qbittorrent
CONFIG += qt thread x11 network
# Update this VERSION for each release
DEFINES += VERSION=\\\"v1.0.0alpha8\\\"
DEFINES += VERSION=\\\"v1.0.0alpha9\\\"
DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=0
DEFINES += VERSION_BUGFIX=0
# Temporary hack
DEFINES += NO_UPNP
contains(DEBUG_MODE, 1){
CONFIG += debug
message(Debug build!)

Loading…
Cancel
Save