Commit 2d332ca5 authored by Cristian Greco's avatar Cristian Greco

Imported Upstream version 2.2.0

parent fdc91e8a
......@@ -6,6 +6,7 @@ Contributors:
* Ishan Arora <ishan@qbittorrent.org>
* Arnaud Demaizière <arnaud@qbittorrent.org>
* Grigis Gaëtan <cipher16@gmail.com>
* Christian Kandeler <zambesi@users.sourceforge.net>
Code from other projects:
* files src/ico.cpp src/ico.h
......@@ -60,7 +61,7 @@ Translations authors:
* files: src/lang/*.ts
copyright:
- Brazilian: Nick Marinho (nickmarinho@gmail.com)
- Bulgarian: Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)
- Bulgarian: Tsvetan & Boyko Bankoff (emerge_life@users.sourceforge.net)
- Catalan: Francisco Luque Contreras (frannoe@ya.com)
- Chinese (Simplified): Guo Yue (yue.guo0418@gmail.com)
- Chinese (Traditional): Yi-Shun Wang (dnextstep@gmail.com)
......@@ -86,5 +87,5 @@ Translations authors:
- Spanish: Francisco Luque Contreras (frannoe@ya.com)
- Swedish: Daniel Nylander (po@danielnylander.se)
- Turkish: Hasan Yilmaz (iletisim@hedefturkce.com)
- Ukrainian: Andrey Shpachenko (masterfix@users.sourceforge.net)
- Ukrainian: Andrey Shpachenko (masterfix@users.sourceforge.net) and Oleh Prypin (blaxpirit@gmail.com)
license: GPLv2
* Thu Mar 4 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.6
- BUGFIX: Fix Web UI authentication with Konqueror
- BUGFIX: Fix save path display in properties
- BUGFIX: Fix ratio calculation for directly seeded torrents (Thanks phorane)
- BUGFIX: Fix memory leak in RSS parser
* Sun Mar 14 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.0
- FEATURE: User can set alternative speed limits for fast toggling
- FEATURE: Bandwidth scheduler (automatically use alternative speed limits for a given period)
- FEATURE: Added "Added/Completed On" columns to transfer list
- FEATURE: Added "Upload/Download limit" columns to transfer list
- FEATURE: Torrent files can be exported to a given directory
- FEATURE: Outgoing ports range can be customized (for QoS)
- FEATURE: User can choose to apply transfer limits on LAN too
- FEATURE: User can choose to include the protocol overhead in transfer limits
- FEATURE: Torrents can be automatically rechecked on completion
- FEATURE: If 2 torrents have the same hash, add new trackers/URL seeds to the existing torrent
- FEATURE: Trackers can be added from Web UI
- FEATURE: Global transfer information are displayed in the new Web UI status bar
- FEATURE: Allow to change the priority of several files at once
- FEATURE: Support for multiple scan folders (Patch by Christian Kandeler)
- BUGFIX: Only one log window can be opened at a time
- BUGFIX: Command-line parameters are no longer required to be in UTF-8
* Web Feb 10 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.5
- BUGFIX: Fix actions on selected torrents (non-selected torrents could be affected)
- BUGFIX: Only one program preferences dialog is allowed at a time
- BUGFIX: Link against boost and ssl to fix issues with gold linker
- BUGFIX: Fix memory leak in RSS
- BUGFIX: Improved HTTP gzip compression detection in downloader
- BUGFIX: Fix possible race condition in search engine
* Mon Feb 8 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.4
- BUGFIX: Fix file prioritizing in a torrent
- BUGFIX: Make sure seeding torrents display a progress of 100%
- BUGFIX: Usage display was improved and localized (--help)
- BUGFIX: Fix possible crash when deleting a torrent
- BUGFIX: Fix possible crash when changing torrents label
* Sun Jan 31 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.3
- BUGFIX: Fix "Append .!qB extension to complete files" (libtorrent v0.15)
- BUGFIX: Make sure bandwidth limiting dialogs are centered on screen
- BUGFIX: Added support for HTTP redirection
- BUGFIX: Fix compilation error when geoip database is embedded
- BUGFIX: Fix crash when double-clicking on a torrent that has no metadata to open its save path
- BUGFIX: Fix Scan directory preferences in Web UI
- BUGFIX: Clear torrent error state when resuming it
* Sun Jan 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.2
- FEATURE: Added back file prioritizing in a torrent
- BUGFIX: Fix issue causing torrents not to be displayed in the list
- BUGFIX: Make sure invalid torrent are removed from the transfer list
- BUGFIX: Fix overwrite check when renaming a folder in a torrent
- BUGFIX: Force a recheck after renaming files to avoid overwriting
- BUGFIX: Improve "Open destination folder" behavior
- BUGFIX: Fix race condition in RSS that could cause a crash on startup
- BUGFIX: Improved user friendlyness of size units
- BUGFIX: Optimized transfer list repainting
- COSMETIC: Improved transfer speed display in peers list
* Wed Jan 20 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.1
- BUGFIX: Fix compilation with Qt4.4
- BUGFIX: Save torrent metadata so that it does not have to be re-downloaded on restart (Magnet links)
- BUGFIX: Fix folder renaming in a torrent (would rename children under certain conditions)
- BUGFIX: Nox version no longer requires libQtXml
- BUGFIX: Configure file now checks for pkg-config executable which is required
- BUGFIX: Torrents added from magnet links were not remembered on restart
- BUGFIX: "Add in pause" setting can be ignored from torrent addition dialog
- BUGFIX: Fix renaming of files with unicode characters in their name
- BUGFIX: Fix typo in legal notice (startup)
- BUGFIX: Can listen on ports < 1024 (must be root)
- BUGFIX: Paused torrents can now be rechecked
- BUGFIX: Fix "open torrent destination" feature when path contains spaces
- I18N: Updated translations (Hungarian, Chinese, Russian)
- BUGFIX: Optimized RSS module memory usage
- BUGFIX: Consider HTTP downloads >1MB as invalid .torrent files and abort
- BUGFIX: Fix Web UI authentication with some browsers
- BUGFIX: Set Web UI ban period to 1 hour
- COSMETIC: Improved style management
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0
- FEATURE: Graphical User Interface can be disabled at compilation time (headless running)
......
......@@ -312,11 +312,7 @@ public:
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
conf->addDefine("DISABLE_GUI");
}
if(QT_VERSION >= 0x040500) {
conf->addDefine("QT_4_5");
}
return(QT_VERSION >= 0x040400);
}
};
#line 1 "pkg-config.qcm"
......
......@@ -15,10 +15,6 @@ public:
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
conf->addDefine("DISABLE_GUI");
}
if(QT_VERSION >= 0x040500) {
conf->addDefine("QT_4_5");
}
return(QT_VERSION >= 0x040400);
}
};
This diff is collapsed.
......@@ -56,44 +56,27 @@ class QSplitter;
class PropertiesWidget;
class StatusBar;
class consoleDlg;
class about;
class createtorrent;
class downloadFromURL;
class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
private:
// Bittorrent
Bittorrent *BTSession;
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
// GUI related
QTimer *guiUpdater;
QTabWidget *tabs;
StatusBar *status_bar;
QPointer<options_imp> options;
QPointer<consoleDlg> console;
QPointer<QSystemTrayIcon> systrayIcon;
QPointer<QTimer> systrayCreator;
QMenu *myTrayIconMenu;
TransferListWidget *transferList;
TransferListFiltersWidget *transferListFilters;
PropertiesWidget *properties;
bool displaySpeedInTitle;
bool force_exit;
// Keyboard shortcuts
QShortcut *switchSearchShortcut;
QShortcut *switchSearchShortcut2;
QShortcut *switchTransferShortcut;
QShortcut *switchRSSShortcut;
// Widgets
QAction *prioSeparator;
QAction *prioSeparator2;
QSplitter *hSplitter;
QSplitter *vSplitter;
// Search
SearchEngine *searchEngine;
// RSS
QPointer<RSSImp> rssWidget;
// Misc
QLocalServer *localServer;
public:
// Construct / Destruct
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI();
// Methods
int getCurrentTabIndex() const;
TransferListWidget* getTransferList() const { return transferList; }
public slots:
void trackerAuthenticationRequired(QTorrentHandle& h);
void setTabText(int index, QString text) const;
void showNotificationBaloon(QString title, QString msg) const;
void downloadFromURLList(const QStringList& urls);
void updateAltSpeedsBtn(bool alternative);
protected slots:
// GUI related slots
......@@ -130,7 +113,7 @@ protected slots:
void loadPreferences(bool configure_session=true);
void processParams(const QStringList& params);
void addTorrent(QString path);
void addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker);
void addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker);
void processDownloadedFiles(QString path, QString url);
void finishedTorrent(QTorrentHandle& h) const;
// Options slots
......@@ -139,26 +122,49 @@ protected slots:
// HTTP slots
void on_actionDownload_from_URL_triggered();
public slots:
void trackerAuthenticationRequired(QTorrentHandle& h);
void setTabText(int index, QString text) const;
void showNotificationBaloon(QString title, QString msg) const;
void downloadFromURLList(const QStringList& urls);
protected:
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
bool event(QEvent * event);
void displayRSSTab(bool enable);
public:
// Construct / Destruct
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI();
// Methods
int getCurrentTabIndex() const;
TransferListWidget* getTransferList() const { return transferList; }
private:
// Bittorrent
Bittorrent *BTSession;
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
// GUI related
QTimer *guiUpdater;
QTabWidget *tabs;
StatusBar *status_bar;
QPointer<options_imp> options;
QPointer<consoleDlg> console;
QPointer<about> aboutDlg;
QPointer<createtorrent> createTorrentDlg;
QPointer<downloadFromURL> downloadFromURLDialog;
QPointer<QSystemTrayIcon> systrayIcon;
QPointer<QTimer> systrayCreator;
QMenu *myTrayIconMenu;
TransferListWidget *transferList;
TransferListFiltersWidget *transferListFilters;
PropertiesWidget *properties;
bool displaySpeedInTitle;
bool force_exit;
// Keyboard shortcuts
QShortcut *switchSearchShortcut;
QShortcut *switchSearchShortcut2;
QShortcut *switchTransferShortcut;
QShortcut *switchRSSShortcut;
// Widgets
QAction *prioSeparator;
QAction *prioSeparator2;
QSplitter *hSplitter;
QSplitter *vSplitter;
// Search
SearchEngine *searchEngine;
// RSS
QPointer<RSSImp> rssWidget;
// Misc
QLocalServer *localServer;
};
#endif
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
[Desktop Entry]
Categories=Qt;Network;P2P;
Comment=V2.1.6
Comment=V2.2.0
Exec=qbittorrent %f
GenericName=Bittorrent client
GenericName[bg]=Торент клиент
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
......@@ -63,7 +63,7 @@ class about : public QDialog, private Ui::AboutDlg{
te_translation->append(tr("I would like to thank the following people who volunteered to translate qBittorrent:")+QString::fromUtf8("<br>"));
te_translation->append(QString::fromUtf8(
"<i>- <u>Brazilian:</u> Nick Marinho (nickmarinho@gmail.com)<br>\
- <u>Bulgarian:</u> Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)<br>\
- <u>Bulgarian:</u> Tsvetan & Boyko Bankoff (emerge_life@users.sourceforge.net)<br>\
- <u>Catalan:</u> Francisco Luque Contreras (frannoe@ya.com)<br>\
- <u>Chinese (Simplified):</u> Guo Yue (yue.guo0418@gmail.com)<br>\
- <u>Chinese (Traditional):</u> Yi-Shun Wang (dnextstep@gmail.com)<br>\
......@@ -87,7 +87,7 @@ class about : public QDialog, private Ui::AboutDlg{
- <u>Spanish:</u> Francisco Luque Contreras (frannoe@ya.com)<br>\
- <u>Swedish:</u> Daniel Nylander (po@danielnylander.se)<br>\
- <u>Turkish:</u> Hasan YILMAZ (iletisim@hedefturkce.com) and Erdem Bingöl (erdem84@gmail.com)<br>\
- <u>Ukrainian:</u> Andrey Shpachenko (masterfix@users.sourceforge.net)<br><br>"));
- <u>Ukrainian:</u> Andrey Shpachenko (masterfix@users.sourceforge.net) and Oleh Prypin (blaxpirit@gmail.com)<br><br>"));
te_translation->append(tr("Please contact me if you would like to translate qBittorrent into your own language."));
te_translation->scrollToAnchor(QString::fromUtf8("top"));
// License
......
#ifndef ADVANCEDSETTINGS_H
#define ADVANCEDSETTINGS_H
#include <QTableWidget>
#include <QHeaderView>
#include <QSpinBox>
#include <QCheckBox>
#include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS };
#define ROW_COUNT 9
class AdvancedSettings: public QTableWidget {
Q_OBJECT
private:
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh;
QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts;
public:
AdvancedSettings(QWidget *parent=0): QTableWidget(parent) {
// Set visual appearance
setEditTriggers(QAbstractItemView::NoEditTriggers);
setAlternatingRowColors(true);
setColumnCount(2);
QStringList header;
header << tr("Property") << tr("Value");
setHorizontalHeaderLabels(header);
setColumnWidth(0, width()/2);
horizontalHeader()->setStretchLastSection(true);
verticalHeader()->setVisible(false);
setRowCount(ROW_COUNT);
// Load settings
loadAdvancedSettings();
}
~AdvancedSettings() {
delete spin_cache;
delete outgoing_ports_min;
delete outgoing_ports_max;
delete cb_ignore_limits_lan;
delete cb_count_overhead;
delete cb_recheck_completed;
delete spin_list_refresh;
delete cb_resolve_countries;
delete cb_resolve_hosts;
}
public slots:
void saveAdvancedSettings() {
// Disk write cache
Preferences::setDiskCacheSize(spin_cache->value());
// Outgoing ports
Preferences::setOutgoingPortsMin(outgoing_ports_min->value());
Preferences::setOutgoingPortsMax(outgoing_ports_max->value());
// Ignore limits on LAN
Preferences::ignoreLimitsOnLAN(cb_ignore_limits_lan->isChecked());
// Include protocol overhead in transfer limits
Preferences::includeOverheadInLimits(cb_count_overhead->isChecked());
// Recheck torrents on completion
Preferences::recheckTorrentsOnCompletion(cb_recheck_completed->isChecked());
// Transfer list refresh interval
Preferences::setRefreshInterval(spin_list_refresh->value());
// Peer resolution
Preferences::resolvePeerCountries(cb_resolve_countries->isChecked());
Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked());
}
protected slots:
void loadAdvancedSettings() {
// Disk write cache
setItem(DISK_CACHE, PROPERTY, new QTableWidgetItem(tr("Disk write cache size")));
spin_cache = new QSpinBox();
connect(spin_cache, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged()));
spin_cache->setMinimum(1);
spin_cache->setMaximum(200);
spin_cache->setValue(Preferences::diskCacheSize());
spin_cache->setSuffix(tr(" MiB"));
setCellWidget(DISK_CACHE, VALUE, spin_cache);
// Outgoing port Min
setItem(OUTGOING_PORT_MIN, PROPERTY, new QTableWidgetItem(tr("Outgoing ports (Min) [0: Disabled]")));
outgoing_ports_min = new QSpinBox();
connect(outgoing_ports_min, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged()));
outgoing_ports_min->setMinimum(0);
outgoing_ports_min->setMaximum(65535);
outgoing_ports_min->setValue(Preferences::outgoingPortsMin());
setCellWidget(OUTGOING_PORT_MIN, VALUE, outgoing_ports_min);
// Outgoing port Min
setItem(OUTGOING_PORT_MAX, PROPERTY, new QTableWidgetItem(tr("Outgoing ports (Max) [0: Disabled]")));
outgoing_ports_max = new QSpinBox();
connect(outgoing_ports_max, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged()));
outgoing_ports_max->setMinimum(0);
outgoing_ports_max->setMaximum(65535);
outgoing_ports_max->setValue(Preferences::outgoingPortsMax());
setCellWidget(OUTGOING_PORT_MAX, VALUE, outgoing_ports_max);
// Ignore transfer limits on local network
setItem(IGNORE_LIMIT_LAN, PROPERTY, new QTableWidgetItem(tr("Ignore transfer limits on local network")));
cb_ignore_limits_lan = new QCheckBox();
connect(cb_ignore_limits_lan, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_ignore_limits_lan->setChecked(Preferences::ignoreLimitsOnLAN());
setCellWidget(IGNORE_LIMIT_LAN, VALUE, cb_ignore_limits_lan);
// Consider protocol overhead in transfer limits
setItem(COUNT_OVERHEAD, PROPERTY, new QTableWidgetItem(tr("Include TCP/IP overhead in transfer limits")));
cb_count_overhead = new QCheckBox();
connect(cb_count_overhead, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_count_overhead->setChecked(Preferences::includeOverheadInLimits());
setCellWidget(COUNT_OVERHEAD, VALUE, cb_count_overhead);
// Recheck completed torrents
setItem(RECHECK_COMPLETED, PROPERTY, new QTableWidgetItem(tr("Recheck torrents on completion")));
cb_recheck_completed = new QCheckBox();
connect(cb_recheck_completed, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_recheck_completed->setChecked(Preferences::recheckTorrentsOnCompletion());
setCellWidget(RECHECK_COMPLETED, VALUE, cb_recheck_completed);
// Transfer list refresh interval
setItem(LIST_REFRESH, PROPERTY, new QTableWidgetItem(tr("Transfer list refresh interval")));
spin_list_refresh = new QSpinBox();
connect(spin_list_refresh, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged()));
spin_list_refresh->setMinimum(30);
spin_list_refresh->setMaximum(99999);
spin_list_refresh->setValue(Preferences::getRefreshInterval());
spin_list_refresh->setSuffix(tr(" ms", " milliseconds"));
setCellWidget(LIST_REFRESH, VALUE, spin_list_refresh);
// Resolve Peer countries
setItem(RESOLVE_COUNTRIES, PROPERTY, new QTableWidgetItem(tr("Resolve peer countries (GeoIP)")));
cb_resolve_countries = new QCheckBox();
connect(cb_resolve_countries, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_resolve_countries->setChecked(Preferences::resolvePeerCountries());
setCellWidget(RESOLVE_COUNTRIES, VALUE, cb_resolve_countries);
// Resolve peer hosts
setItem(RESOLVE_HOSTS, PROPERTY, new QTableWidgetItem(tr("Resolve peer host names")));
cb_resolve_hosts = new QCheckBox();
connect(cb_resolve_hosts, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_resolve_hosts->setChecked(Preferences::resolvePeerHostNames());
setCellWidget(RESOLVE_HOSTS, VALUE, cb_resolve_hosts);
}
void emitSettingsChanged() {
emit settingsChanged();
}
signals:
void settingsChanged();
};
#endif // ADVANCEDSETTINGS_H
#ifndef BANDWIDTHSCHEDULER_H
#define BANDWIDTHSCHEDULER_H
#include <QTimer>
#include <QTime>
#include <QDateTime>
#include "preferences.h"
#include <iostream>
class BandwidthScheduler: public QTimer {
Q_OBJECT
private:
bool in_alternative_mode;
public:
BandwidthScheduler(QObject *parent): QTimer(parent), in_alternative_mode(false) {
Q_ASSERT(Preferences::isSchedulerEnabled());
// Signal shot, we call start() again manually
setSingleShot(true);
// Connect Signals/Slots
connect(this, SIGNAL(timeout()), this, SLOT(switchMode()));
}
public slots:
void start() {
Q_ASSERT(Preferences::isSchedulerEnabled());
QTime startAltSpeeds = Preferences::getSchedulerStartTime();
QTime endAltSpeeds = Preferences::getSchedulerEndTime();
if(startAltSpeeds == endAltSpeeds) {
std::cerr << "Error: bandwidth scheduler have the same start time and end time." << std::endl;
std::cerr << "The bandwidth scheduler will be disabled" << std::endl;
stop();
emit switchToAlternativeMode(false);
return;
}
// Determine what the closest QTime is
QTime now = QTime::currentTime();
uint time_to_start = secsTo(now, startAltSpeeds);
uint time_to_end = secsTo(now, endAltSpeeds);
if(time_to_end < time_to_start) {
// We should be in alternative mode
in_alternative_mode = true;
// Start counting
QTimer::start(time_to_end*1000);
} else {
// We should be in normal mode
in_alternative_mode = false;
// Start counting
QTimer::start(time_to_start*1000);
}
// Send signal to notify BTSession
emit switchToAlternativeMode(in_alternative_mode);
}
void switchMode() {
// Get the day this mode was started (either today or yesterday)
QDate current_date = QDateTime::currentDateTime().toLocalTime().date();
int day = current_date.dayOfWeek();
if(in_alternative_mode) {
// It is possible that starttime was yesterday
if(QTime::currentTime().secsTo(Preferences::getSchedulerStartTime()) > 0) {
current_date.addDays(-1); // Go to yesterday
day = current_date.day();
}
}
// Check if the day is in scheduler days
// Notify BTSession only if necessary
switch(Preferences::getSchedulerDays()) {
case EVERY_DAY:
emit switchToAlternativeMode(!in_alternative_mode);
break;
case WEEK_ENDS:
if(day == Qt::Saturday || day == Qt::Sunday)
emit switchToAlternativeMode(!in_alternative_mode);
break;
case WEEK_DAYS:
if(day != Qt::Saturday && day != Qt::Sunday)
emit switchToAlternativeMode(!in_alternative_mode);
break;
default:
// Convert our enum index to Qt enum index
int scheduler_day = ((int)Preferences::getSchedulerDays()) - 2;
if(day == scheduler_day)
emit switchToAlternativeMode(!in_alternative_mode);
break;
}
// Call start again
start();
}
signals:
void switchToAlternativeMode(bool alternative);
private:
// Qt function can return negative values and we
// don't want that
uint secsTo(QTime now, QTime t) {
int diff = now.secsTo(t);
if(diff < 0) {
// 86400 seconds in a day
diff += 86400;
}
Q_ASSERT(diff >= 0);
return diff;
}
};
#endif // BANDWIDTHSCHEDULER_H
This diff is collapsed.
......@@ -52,9 +52,10 @@ using namespace libtorrent;
class downloadThread;
class QTimer;
class FileSystemWatcher;
class FilterParserThread;
class HttpServer;
class BandwidthScheduler;
class ScanFoldersModel;
class TrackerInfos {
public:
......@@ -88,60 +89,6 @@ public:
class Bittorrent : public QObject {
Q_OBJECT
private:
// Bittorrent
session *s;
QPointer<QTimer> timerAlerts;
QMap<QUrl, QString> savepath_fromurl;
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
QStringList torrentsToPausedAfterChecking;
// Ratio
QPointer<QTimer> BigRatioTimer;
// HTTP
QPointer<downloadThread> downloader;
// File System
QPointer<FileSystemWatcher> FSWatcher;
// Console / Log
QStringList consoleMessages;
QStringList peerBanMessages;
// Settings
bool preAllocateAll;
bool addInPause;
float ratio_limit;
bool UPnPEnabled;
bool NATPMPEnabled;
bool LSDEnabled;
bool DHTEnabled;
int current_dht_port;
bool PeXEnabled;
bool queueingEnabled;
bool appendLabelToSavePath;
#ifdef LIBTORRENT_0_15
bool appendqBExtension;
#endif
QString defaultSavePath;
QString defaultTempPath;
// GeoIP
#ifndef DISABLE_GUI
bool resolve_countries;
bool geoipDBLoaded;
#endif
// ETA Computation
QPointer<QTimer> timerETA;
QHash<QString, QList<int> > ETA_samples;
// IP filtering
QPointer<FilterParserThread> filterParser;
QString filterPath;
// Web UI
QPointer<HttpServer> httpServer;
QList<QUrl> url_skippingDlg;
// Fast exit (async)
bool exiting;
protected:
QString getSavePath(QString hash);
bool initWebUi(QString username, QString password, int port);
public:
// Constructor / Destructor
Bittorrent();
......@@ -172,9 +119,6 @@ public:
public slots:
QTorrentHandle addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
QTorrentHandle addMagnetUri(QString magnet_uri, bool resumed=false);
void importOldTorrents();
void applyFormerAttributeFiles(QTorrentHandle h);
void importOldTempData(QString torrent_path);
void loadSessionState();
void saveSessionState();
void downloadFromUrl(QString url);
......@@ -182,6 +126,7 @@ public slots:
void startUpTorrents();
session_proxy asyncDeletion();
void recheckTorrent(QString hash);
void useAlternativeSpeedsLimit(bool alternative);
/* Needed by Web UI */
void pauseAllTorrents();
void pauseTorrent(QString hash);
......@@ -191,8 +136,6 @@ public slots:
void saveDHTEntry();
void preAllocateAllFiles(bool b);
void saveFastResumeData();
void enableDirectoryScanning(QString scan_dir);
void disableDirectoryScanning();
void enableIPFilter(QString filter);
void disableIPFilter();
void setQueueingEnabled(bool enable);
......@@ -208,9 +151,9 @@ public slots:
void setGlobalRatio(float ratio);
void setDeleteRatio(float ratio);
void setDHTPort(int dht_port);
void setPeerProxySettings(proxy_settings proxySettings);
void setHTTPProxySettings(proxy_settings proxySettings);
void setSessionSettings(session_settings sessionSettings);
void setPeerProxySettings(const proxy_settings &proxySettings);
void setHTTPProxySettings(const proxy_settings &proxySettings);
void setSessionSettings(const session_settings &sessionSettings);
void startTorrentsInPause(bool b);
void setDefaultTempPath(QString temppath);
void setAppendLabelToSavePath(bool append);
......@@ -239,11 +182,16 @@ public slots:
void configureSession();
void banIP(QString ip);
protected:
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString());
bool initWebUi(QString username, QString password, int port);
protected slots:
void addTorrentsFromScanFolder(QStringList&);
void readAlerts();
void deleteBigRatios();
void takeETASamples();
void exportTorrentFiles(QString path);
signals:
void addedTorrent(QTorrentHandle& h);
......@@ -261,6 +209,60 @@ signals:
void metadataReceived(QTorrentHandle &h);
void savePathChanged(QTorrentHandle &h);
void newConsoleMessage(QString msg);
void alternativeSpeedsModeChanged(bool alternative);
private: