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. 6
      src/search_engine/engines/piratebay.py
  10. 2
      src/search_engine/engines/versions.txt

1
Changelog

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
- FEATURE: RSS feeds can now be grouped into folders
- 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: A random listening port can be chosen automatically
- BUGFIX: torrent resume code rewrited
- COSMETIC: Redesigned search 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 @@ -1027,7 +1027,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// Connection
// * Ports binding
unsigned short old_listenPort = BTSession->getListenPort();
BTSession->setListeningPortsRange(options->getPorts());
BTSession->setListeningPort(options->getPort());
unsigned short new_listenPort = BTSession->getListenPort();
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)));

3
src/bittorrent.cpp

@ -1084,7 +1084,8 @@ void bittorrent::disableDirectoryScanning() { @@ -1084,7 +1084,8 @@ void bittorrent::disableDirectoryScanning() {
// Set the ports range in which is chosen the port the bittorrent
// 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);
}

2
src/bittorrent.h

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

4
src/downloadingTorrents.cpp

@ -64,10 +64,10 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) @@ -64,10 +64,10 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
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(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(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->setRootIsDecorated(false);
downloadList->setAllColumnsShowFocus(true);

51
src/options.ui

@ -122,7 +122,7 @@ @@ -122,7 +122,7 @@
</item>
<item>
<property name="text">
<string>Network</string>
<string>Connection</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
@ -465,7 +465,7 @@ @@ -465,7 +465,7 @@
</sizepolicy>
</property>
<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>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
@ -490,17 +490,17 @@ @@ -490,17 +490,17 @@
</property>
<item>
<property name="text">
<string>Pause/Start torrent</string>
<string>Start/Stop</string>
</property>
</item>
<item>
<property name="text">
<string>Open destination folder</string>
<string>Open folder</string>
</property>
</item>
<item>
<property name="text">
<string>Display torrent properties</string>
<string>Show properties</string>
</property>
</item>
</widget>
@ -533,17 +533,17 @@ @@ -533,17 +533,17 @@
<widget class="QComboBox" name="actionTorrentFnOnDblClBox">
<item>
<property name="text">
<string>Pause/Start torrent</string>
<string>Start/Stop</string>
</property>
</item>
<item>
<property name="text">
<string>Open destination folder</string>
<string>Open folder</string>
</property>
</item>
<item>
<property name="text">
<string>Display torrent properties</string>
<string>Show properties</string>
</property>
</item>
</widget>
@ -1052,17 +1052,17 @@ @@ -1052,17 +1052,17 @@
<item>
<widget class="QLabel" name="lbl_ports">
<property name="text">
<string>Port range:</string>
<string>Port used for incoming connections:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinPortMin">
<widget class="QSpinBox" name="spinPort">
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>65525</number>
<number>65535</number>
</property>
<property name="value">
<number>6881</number>
@ -1070,25 +1070,9 @@ @@ -1070,25 +1070,9 @@
</widget>
</item>
<item>
<widget class="QLabel" name="to_range">
<widget class="QPushButton" name="randomButton">
<property name="text">
<string comment="i.e: 1200 to 1300">to</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>
<string>Random</string>
</property>
</widget>
</item>
@ -1783,7 +1767,7 @@ @@ -1783,7 +1767,7 @@
<bool>false</bool>
</property>
<property name="maximum">
<number>65525</number>
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
@ -1978,7 +1962,7 @@ @@ -1978,7 +1962,7 @@
<bool>false</bool>
</property>
<property name="maximum">
<number>65525</number>
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
@ -2315,7 +2299,7 @@ @@ -2315,7 +2299,7 @@
<bool>true</bool>
</property>
<property name="maximum">
<number>65525</number>
<number>65535</number>
</property>
<property name="value">
<number>80</number>
@ -2659,8 +2643,7 @@ @@ -2659,8 +2643,7 @@
<tabstop>checkStartPaused</tabstop>
<tabstop>checkScanDir</tabstop>
<tabstop>browseScanDirButton</tabstop>
<tabstop>spinPortMin</tabstop>
<tabstop>spinPortMax</tabstop>
<tabstop>spinPort</tabstop>
<tabstop>checkUPnP</tabstop>
<tabstop>checkNATPMP</tabstop>
<tabstop>checkDHT</tabstop>

36
src/options_imp.cpp

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

4
src/options_imp.h

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

6
src/search_engine/engines/piratebay.py

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

2
src/search_engine/engines/versions.txt

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

Loading…
Cancel
Save