Browse Source

- FEATURE: A random listening port can be chosen automatically

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
9a14c4c599
  1. 1
      Changelog
  2. 2
      src/GUI.cpp
  3. 3
      src/bittorrent.cpp
  4. 2
      src/bittorrent.h
  5. 4
      src/downloadingTorrents.cpp
  6. 51
      src/options.ui
  7. 36
      src/options_imp.cpp
  8. 4
      src/options_imp.h
  9. 8
      src/search_engine/engines/piratebay.py
  10. 2
      src/search_engine/engines/versions.txt

1
Changelog

@ -10,6 +10,7 @@
- FEATURE: RSS feeds can now be grouped into folders - FEATURE: RSS feeds can now be grouped into folders
- FEATURE: Added "Unread" item to RSS feed list to display all unread news - FEATURE: Added "Unread" item to RSS feed list to display all unread news
- FEATURE: If a torrent contains a torrent file, process downloaded torrent file too - FEATURE: If a torrent contains a torrent file, process downloaded torrent file too
- FEATURE: A random listening port can be chosen automatically
- BUGFIX: torrent resume code rewrited - BUGFIX: torrent resume code rewrited
- COSMETIC: Redesigned search tab to improve usability - COSMETIC: Redesigned search tab to improve usability
- COSMETIC: Redesigned RSS tab to improve usability - COSMETIC: Redesigned RSS tab to improve usability

2
src/GUI.cpp

@ -1027,7 +1027,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// Connection // Connection
// * Ports binding // * Ports binding
unsigned short old_listenPort = BTSession->getListenPort(); unsigned short old_listenPort = BTSession->getListenPort();
BTSession->setListeningPortsRange(options->getPorts()); BTSession->setListeningPort(options->getPort());
unsigned short new_listenPort = BTSession->getListenPort(); unsigned short new_listenPort = BTSession->getListenPort();
if(new_listenPort != old_listenPort) { if(new_listenPort != old_listenPort) {
BTSession->addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg( misc::toQString(new_listenPort))); BTSession->addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg( misc::toQString(new_listenPort)));

3
src/bittorrent.cpp

@ -1084,7 +1084,8 @@ void bittorrent::disableDirectoryScanning() {
// Set the ports range in which is chosen the port the bittorrent // Set the ports range in which is chosen the port the bittorrent
// session will listen to // session will listen to
void bittorrent::setListeningPortsRange(std::pair<unsigned short, unsigned short> ports) { void bittorrent::setListeningPort(int port) {
std::pair<int,int> ports(port, port);
s->listen_on(ports); s->listen_on(ports);
} }

2
src/bittorrent.h

@ -141,7 +141,7 @@ class bittorrent : public QObject {
void decreaseDlTorrentPriority(QString hash); void decreaseDlTorrentPriority(QString hash);
void downloadUrlAndSkipDialog(QString url, QString save_path=QString::null); void downloadUrlAndSkipDialog(QString url, QString save_path=QString::null);
// Session configuration - Setters // Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports); void setListeningPort(int port);
void setMaxConnections(int maxConnec); void setMaxConnections(int maxConnec);
void setMaxConnectionsPerTorrent(int max); void setMaxConnectionsPerTorrent(int max);
void setMaxUploadsPerTorrent(int max); void setMaxUploadsPerTorrent(int max);

4
src/downloadingTorrents.cpp

@ -64,10 +64,10 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded")); DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed")); DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("DL Speed", "i.e: Download speed"));
DLListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed")); DLListModel->setHeaderData(UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
DLListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechs", "i.e: full/partial sources")); DLListModel->setHeaderData(SEEDSLEECH, Qt::Horizontal, tr("Seeds/Leechers", "i.e: full/partial sources"));
DLListModel->setHeaderData(RATIO, Qt::Horizontal, tr("Ratio")); DLListModel->setHeaderData(RATIO, Qt::Horizontal, tr("Ratio"));
DLListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left")); DLListModel->setHeaderData(ETA, Qt::Horizontal, tr("ETA", "i.e: Estimated Time of Arrival / Time left"));
DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Priority")); DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, "#");
downloadList->setModel(DLListModel); downloadList->setModel(DLListModel);
downloadList->setRootIsDecorated(false); downloadList->setRootIsDecorated(false);
downloadList->setAllColumnsShowFocus(true); downloadList->setAllColumnsShowFocus(true);

51
src/options.ui

@ -122,7 +122,7 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Network</string> <string>Connection</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignHCenter|AlignVCenter|AlignCenter</set>
@ -465,7 +465,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="title"> <property name="title">
<string comment="Action executed when doucle-clicking on an item in transfer (download/upload) list">Transfer lists double-click action</string> <string comment="Action executed when doucle-clicking on an item in transfer (download/upload) list">Action for double click</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
@ -490,17 +490,17 @@
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>Pause/Start torrent</string> <string>Start/Stop</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Open destination folder</string> <string>Open folder</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Display torrent properties</string> <string>Show properties</string>
</property> </property>
</item> </item>
</widget> </widget>
@ -533,17 +533,17 @@
<widget class="QComboBox" name="actionTorrentFnOnDblClBox"> <widget class="QComboBox" name="actionTorrentFnOnDblClBox">
<item> <item>
<property name="text"> <property name="text">
<string>Pause/Start torrent</string> <string>Start/Stop</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Open destination folder</string> <string>Open folder</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Display torrent properties</string> <string>Show properties</string>
</property> </property>
</item> </item>
</widget> </widget>
@ -1052,17 +1052,17 @@
<item> <item>
<widget class="QLabel" name="lbl_ports"> <widget class="QLabel" name="lbl_ports">
<property name="text"> <property name="text">
<string>Port range:</string> <string>Port used for incoming connections:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinPortMin"> <widget class="QSpinBox" name="spinPort">
<property name="minimum"> <property name="minimum">
<number>1000</number> <number>1000</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>65525</number> <number>65535</number>
</property> </property>
<property name="value"> <property name="value">
<number>6881</number> <number>6881</number>
@ -1070,25 +1070,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="to_range"> <widget class="QPushButton" name="randomButton">
<property name="text"> <property name="text">
<string comment="i.e: 1200 to 1300">to</string> <string>Random</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinPortMax">
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>65525</number>
</property>
<property name="value">
<number>6889</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -1783,7 +1767,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>65525</number> <number>65535</number>
</property> </property>
<property name="value"> <property name="value">
<number>8080</number> <number>8080</number>
@ -1978,7 +1962,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>65525</number> <number>65535</number>
</property> </property>
<property name="value"> <property name="value">
<number>8080</number> <number>8080</number>
@ -2315,7 +2299,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>65525</number> <number>65535</number>
</property> </property>
<property name="value"> <property name="value">
<number>80</number> <number>80</number>
@ -2659,8 +2643,7 @@
<tabstop>checkStartPaused</tabstop> <tabstop>checkStartPaused</tabstop>
<tabstop>checkScanDir</tabstop> <tabstop>checkScanDir</tabstop>
<tabstop>browseScanDirButton</tabstop> <tabstop>browseScanDirButton</tabstop>
<tabstop>spinPortMin</tabstop> <tabstop>spinPort</tabstop>
<tabstop>spinPortMax</tabstop>
<tabstop>checkUPnP</tabstop> <tabstop>checkUPnP</tabstop>
<tabstop>checkNATPMP</tabstop> <tabstop>checkNATPMP</tabstop>
<tabstop>checkDHT</tabstop> <tabstop>checkDHT</tabstop>

36
src/options_imp.cpp

@ -49,6 +49,9 @@
#include <QMacStyle> #include <QMacStyle>
#endif #endif
#include <time.h>
#include <stdlib.h>
#include "options_imp.h" #include "options_imp.h"
#include "misc.h" #include "misc.h"
@ -187,8 +190,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(checkScanDir, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkScanDir, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(textScanDir, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textScanDir, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
// Connection tab // Connection tab
connect(spinPortMin, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinPortMax, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkUPnP, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkUPnP, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(checkNATPMP, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkNATPMP, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(checkUploadLimit, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(checkUploadLimit, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
@ -319,8 +321,6 @@ void options_imp::saveOptions(){
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
// Apply style // Apply style
useStyle(); useStyle();
// Check if min port < max port
checkPortsLogic();
settings.beginGroup("Preferences"); settings.beginGroup("Preferences");
// General preferences // General preferences
settings.beginGroup("General"); settings.beginGroup("General");
@ -352,8 +352,7 @@ void options_imp::saveOptions(){
settings.endGroup(); settings.endGroup();
// Connection preferences // Connection preferences
settings.beginGroup("Connection"); settings.beginGroup("Connection");
settings.setValue(QString::fromUtf8("PortRangeMin"), getPorts().first); settings.setValue(QString::fromUtf8("PortRangeMin"), getPort());
settings.setValue(QString::fromUtf8("PortRangeMax"), getPorts().second);
settings.setValue(QString::fromUtf8("UPnP"), isUPnPEnabled()); settings.setValue(QString::fromUtf8("UPnP"), isUPnPEnabled());
settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled()); settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled());
settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first); settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first);
@ -578,10 +577,7 @@ void options_imp::loadOptions(){
settings.endGroup(); settings.endGroup();
// Connection preferences // Connection preferences
settings.beginGroup("Connection"); settings.beginGroup("Connection");
spinPortMin->setValue(settings.value(QString::fromUtf8("PortRangeMin"), 6881).toInt()); spinPort->setValue(settings.value(QString::fromUtf8("PortRangeMin"), 6881).toInt());
spinPortMax->setValue(settings.value(QString::fromUtf8("PortRangeMax"), 6889).toInt());
// Check if min port < max port
checkPortsLogic();
checkUPnP->setChecked(settings.value(QString::fromUtf8("UPnP"), true).toBool()); checkUPnP->setChecked(settings.value(QString::fromUtf8("UPnP"), true).toBool());
checkNATPMP->setChecked(settings.value(QString::fromUtf8("NAT-PMP"), true).toBool()); checkNATPMP->setChecked(settings.value(QString::fromUtf8("NAT-PMP"), true).toBool());
intValue = settings.value(QString::fromUtf8("GlobalDLLimit"), -1).toInt(); intValue = settings.value(QString::fromUtf8("GlobalDLLimit"), -1).toInt();
@ -777,12 +773,19 @@ void options_imp::loadOptions(){
textWebUiPassword->setText(settings.value("Password", "").toString()); textWebUiPassword->setText(settings.value("Password", "").toString());
// End Web UI // End Web UI
settings.endGroup(); settings.endGroup();
// Random stuff
srand(time(0));
} }
// return min & max ports // return min & max ports
// [min, max] // [min, max]
std::pair<unsigned short, unsigned short> options_imp::getPorts() const{ int options_imp::getPort() const{
return std::make_pair(spinPortMin->value(), spinPortMax->value()); return spinPort->value();
}
void options_imp::on_randomButton_clicked() {
// Range [1024: 65535]
spinPort->setValue(rand() % 64512 + 1024);
} }
int options_imp::getEncryptionSetting() const{ int options_imp::getEncryptionSetting() const{
@ -1317,15 +1320,6 @@ void options_imp::setLocale(QString locale){
} }
} }
// Is called before saving to check if minPort < maxPort
void options_imp::checkPortsLogic(){
int maxValue = spinPortMax->value();
if(spinPortMin->value() > spinPortMax->value()){
spinPortMax->setValue(spinPortMin->value());
spinPortMin->setValue(maxValue);
}
}
// Return scan dir set in options // Return scan dir set in options
QString options_imp::getScanDir() const { QString options_imp::getScanDir() const {
if(checkScanDir->isChecked()){ if(checkScanDir->isChecked()){

4
src/options_imp.h

@ -88,7 +88,7 @@ class options_imp : public QDialog, private Ui::Dialog {
int getActionOnDblClOnTorrentDl() const; int getActionOnDblClOnTorrentDl() const;
int getActionOnDblClOnTorrentFn() const; int getActionOnDblClOnTorrentFn() const;
// Connection options // Connection options
std::pair<unsigned short, unsigned short> getPorts() const; int getPort() const;
bool isUPnPEnabled() const; bool isUPnPEnabled() const;
bool isNATPMPEnabled() const; bool isNATPMPEnabled() const;
QPair<int,int> getGlobalBandwidthLimits() const; QPair<int,int> getGlobalBandwidthLimits() const;
@ -165,13 +165,13 @@ class options_imp : public QDialog, private Ui::Dialog {
void on_browseFilterButton_clicked(); void on_browseFilterButton_clicked();
void on_browseSaveDirButton_clicked(); void on_browseSaveDirButton_clicked();
void enableApplyButton(); void enableApplyButton();
void checkPortsLogic();
void enableSystrayOptions(); void enableSystrayOptions();
void disableSystrayOptions(); void disableSystrayOptions();
void setSystrayOptionsState(int checkBoxValue); void setSystrayOptionsState(int checkBoxValue);
void enableWebUi(bool checkBoxValue); void enableWebUi(bool checkBoxValue);
void changePage(QListWidgetItem*, QListWidgetItem*); void changePage(QListWidgetItem*, QListWidgetItem*);
void adaptToScreenSize(); void adaptToScreenSize();
void on_randomButton_clicked();
public slots: public slots:
void setLocale(QString locale); void setLocale(QString locale);

8
src/search_engine/engines/piratebay.py

@ -1,5 +1,6 @@
#VERSION: 1.11 #VERSION: 1.20
#AUTHORS: Fabien Devaux (fab@gnux.info) #AUTHORS: Fabien Devaux (fab@gnux.info)
#CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org)
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -32,7 +33,8 @@ from helpers import retrieve_url, download_file
class piratebay(object): class piratebay(object):
url = 'http://thepiratebay.org' url = 'http://thepiratebay.org'
name = 'The Pirate Bay' name = 'The Pirate Bay'
supported_categories = {'all': '', 'movies': '', 'music': '', 'games': '', 'software': ''}
def __init__(self): def __init__(self):
self.results = [] self.results = []
self.parser = self.SimpleSGMLParser(self.results, self.url) self.parser = self.SimpleSGMLParser(self.results, self.url)
@ -92,7 +94,7 @@ class piratebay(object):
self.current_item['leech'] = 0 self.current_item['leech'] = 0
prettyPrinter(self.current_item) prettyPrinter(self.current_item)
self.results.append('a') self.results.append('a')
def search(self, what): def search(self, what, cat='all'):
ret = [] ret = []
i = 0 i = 0
order = 'se' order = 'se'

2
src/search_engine/engines/versions.txt

@ -1,5 +1,5 @@
isohunt: 1.30 isohunt: 1.30
torrentreactor: 1.11 torrentreactor: 1.20
btjunkie: 2.21 btjunkie: 2.21
mininova: 1.31 mininova: 1.31
piratebay: 1.11 piratebay: 1.11

Loading…
Cancel
Save