2009-11-14 22:08:28 +03:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2006 Christophe Dumez
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
|
|
|
* Contact : chris@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PREFERENCES_H
|
|
|
|
#define PREFERENCES_H
|
|
|
|
|
|
|
|
#include <QSettings>
|
2009-12-10 22:19:19 +03:00
|
|
|
#include <QCryptographicHash>
|
2009-11-14 22:08:28 +03:00
|
|
|
#include <QPair>
|
2009-11-26 11:10:23 +03:00
|
|
|
#include <QDir>
|
2010-01-23 23:44:09 +03:00
|
|
|
#include <QTime>
|
2010-06-05 22:59:05 +04:00
|
|
|
#include <QList>
|
2010-06-07 12:32:41 +04:00
|
|
|
#include <libtorrent/version.hpp>
|
2009-11-14 22:08:28 +03:00
|
|
|
|
2010-05-31 01:45:55 +04:00
|
|
|
#ifndef DISABLE_GUI
|
|
|
|
#include <QApplication>
|
|
|
|
#else
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#endif
|
|
|
|
|
2010-06-03 02:31:49 +04:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#endif
|
|
|
|
|
2010-06-05 22:59:05 +04:00
|
|
|
#include "misc.h"
|
|
|
|
|
2010-01-15 17:20:20 +03:00
|
|
|
#define QBT_REALM "Web UI Access"
|
2010-01-23 23:44:09 +03:00
|
|
|
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
|
2010-06-22 21:06:11 +04:00
|
|
|
enum maxRatioAction {PAUSE_ACTION, REMOVE_ACTION};
|
2010-01-15 17:20:20 +03:00
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
class Preferences {
|
|
|
|
public:
|
|
|
|
// General options
|
|
|
|
static QString getLocale() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/Locale"), "en_GB").toString();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setLocale(QString locale) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:46:21 +03:00
|
|
|
static QString getStyle() {
|
2010-01-31 20:30:17 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-01-31 20:46:21 +03:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/Style"), "").toString();
|
2010-01-31 20:30:17 +03:00
|
|
|
}
|
|
|
|
|
2010-01-31 20:46:21 +03:00
|
|
|
static void setStyle(QString style) {
|
2010-01-31 20:30:17 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-01-31 20:46:21 +03:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/Style"), style);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-05-21 19:42:17 +04:00
|
|
|
static bool deleteTorrentFilesAsDefault() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setDeleteTorrentFilesAsDefault(bool del) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), del);
|
|
|
|
}
|
|
|
|
|
2010-06-21 19:53:42 +04:00
|
|
|
static void setConfirmOnExit(bool confirm) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/ExitConfirm"), confirm);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool confirmOnExit() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool();
|
|
|
|
}
|
|
|
|
|
2010-06-21 22:32:01 +04:00
|
|
|
static void showSpeedInTitleBar(bool show) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/SpeedInTitleBar"), show);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool speedInTitleBar() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/SpeedInTitleBar"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2009-12-22 17:06:36 +03:00
|
|
|
static bool useAlternatingRowColors() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/AlternatingRowColors"), true).toBool();
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool systrayIntegration() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
|
|
|
|
}
|
|
|
|
|
2009-11-18 21:45:06 +03:00
|
|
|
static void setSystrayIntegration(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/SystrayEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
2010-06-21 22:32:01 +04:00
|
|
|
static void setToolbarDisplayed(bool displayed) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/ToolbarDisplayed"), displayed);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isToolbarDisplayed() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/ToolbarDisplayed"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool minimizeToTray() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool closeToTray() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool startMinimized() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isSlashScreenDisabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/NoSplashScreen"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Downloads
|
|
|
|
static QString getSavePath() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-06-03 02:31:49 +04:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/SavePath"),
|
|
|
|
QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath("Downloads")).toString();
|
|
|
|
#else
|
2010-03-07 00:11:47 +03:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/SavePath"), QDir::home().absoluteFilePath("qBT_dir")).toString();
|
2010-06-03 02:31:49 +04:00
|
|
|
#endif
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setSavePath(QString save_path) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/SavePath"), save_path);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isTempPathEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setTempPathEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static QString getTempPath() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-03-07 00:11:47 +03:00
|
|
|
QString temp = QDir::home().absoluteFilePath("qBT_dir")+QDir::separator()+"temp";
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPath"), temp).toString();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setTempPath(QString path) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path);
|
|
|
|
}
|
|
|
|
|
2010-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
2009-12-17 23:28:30 +03:00
|
|
|
static bool useIncompleteFilesExtension() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
|
|
|
|
}
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
|
|
|
|
static void useIncompleteFilesExtension(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), enabled);
|
|
|
|
}
|
2009-12-18 16:36:47 +03:00
|
|
|
#endif
|
2009-12-17 23:28:30 +03:00
|
|
|
|
|
|
|
static bool appendTorrentLabel() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/AppendLabel"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool preAllocateAllFiles() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void preAllocateAllFiles(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.setValue(QString::fromUtf8("Preferences/Downloads/PreAllocation"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool useAdditionDialog() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-06-01 20:29:40 +04:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool addTorrentsInPause() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/StartInPause"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2010-02-28 18:15:00 +03:00
|
|
|
static QStringList getScanDirs() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-02-28 18:15:00 +03:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/ScanDirs"), QStringList()).toStringList();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-02-28 18:15:00 +03:00
|
|
|
// This must be called somewhere with data from the model
|
|
|
|
static void setScanDirs(const QStringList &dirs) {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-02-28 18:15:00 +03:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), dirs);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-06-05 22:59:05 +04:00
|
|
|
static QList<bool> getDownloadInScanDirs() {
|
2010-02-28 18:15:00 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-06-05 22:59:05 +04:00
|
|
|
return misc::boolListfromStringList(settings.value(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs")).toStringList());
|
2010-02-28 18:15:00 +03:00
|
|
|
}
|
|
|
|
|
2010-06-05 22:59:05 +04:00
|
|
|
static void setDownloadInScanDirs(const QList<bool> &list) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-06-05 22:59:05 +04:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs"), misc::toStringList(list));
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
}
|
|
|
|
|
2010-01-31 16:09:46 +03:00
|
|
|
static bool isTorrentExportEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return !settings.value(QString::fromUtf8("Preferences/Downloads/TorrentExport"), QString()).toString().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getExportDir() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/TorrentExport"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setExportDir(QString path) {
|
|
|
|
path = path.trimmed();
|
|
|
|
if(path.isEmpty())
|
|
|
|
path = QString();
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/TorrentExport"), path);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getActionOnDblClOnTorrentDl() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/DblClOnTorDl"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int getActionOnDblClOnTorrentFn() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/DblClOnTorFn"), 1).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Connection options
|
|
|
|
static int getSessionPort() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/PortRangeMin"), 6881).toInt();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setSessionPort(int port) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/PortRangeMin"), port);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isUPnPEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/UPnP"), true).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setUPnPEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/UPnP"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isNATPMPEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/NAT-PMP"), true).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setNATPMPEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/NAT-PMP"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getGlobalDownloadLimit() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimit"), -1).toInt();
|
|
|
|
}
|
|
|
|
|
2009-11-17 16:11:32 +03:00
|
|
|
static void setGlobalDownloadLimit(int limit) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(limit <= 0) limit = -1;
|
2009-11-17 16:11:32 +03:00
|
|
|
settings.setValue("Preferences/Connection/GlobalDLLimit", limit);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getGlobalUploadLimit() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-01-23 23:44:09 +03:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), 50).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2009-11-17 16:11:32 +03:00
|
|
|
static void setGlobalUploadLimit(int limit) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(limit <= 0) limit = -1;
|
2009-11-17 16:11:32 +03:00
|
|
|
settings.setValue("Preferences/Connection/GlobalUPLimit", limit);
|
|
|
|
}
|
|
|
|
|
2010-01-23 23:44:09 +03:00
|
|
|
static int getAltGlobalDownloadLimit() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimitAlt"), 10).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setAltGlobalDownloadLimit(int limit) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
if(limit <= 0) limit = -1;
|
|
|
|
settings.setValue("Preferences/Connection/GlobalDLLimitAlt", limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int getAltGlobalUploadLimit() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimitAlt"), 10).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setAltGlobalUploadLimit(int limit) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
if(limit <= 0) limit = -1;
|
2010-01-25 22:54:46 +03:00
|
|
|
settings.setValue("Preferences/Connection/GlobalUPLimitAlt", limit);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool isAltBandwidthEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value("Preferences/Connection/alt_speeds_on", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setAltBandwidthEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue("Preferences/Connection/alt_speeds_on", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setSchedulerEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Scheduler/Enabled"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isSchedulerEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Scheduler/Enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static QTime getSchedulerStartTime() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Scheduler/start_time"), QTime(8,0)).toTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setSchedulerStartTime(QTime time) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Scheduler/start_time"), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
static QTime getSchedulerEndTime() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Scheduler/end_time"), QTime(20,0)).toTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setSchedulerEndTime(QTime time) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Scheduler/end_time"), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
static scheduler_days getSchedulerDays() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return (scheduler_days)settings.value(QString::fromUtf8("Preferences/Scheduler/days"), EVERY_DAY).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setSchedulerDays(scheduler_days days) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Scheduler/days"), (int)days);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Proxy options
|
|
|
|
static bool isHTTPProxyEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isHTTPProxyAuthEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Authentication"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setHTTPProxyAuthEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Authentication"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static QString getHTTPProxyIp() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setHTTPProxyIp(QString ip) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), ip);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static unsigned short getHTTPProxyPort() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toInt();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setHTTPProxyPort(unsigned short port) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), port);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static QString getHTTPProxyUsername() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setHTTPProxyUsername(QString username) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), username);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static QString getHTTPProxyPassword() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setHTTPProxyPassword(QString password) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), password);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getHTTPProxyType() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setHTTPProxyType(int type) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isPeerProxyEnabled() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt() > 0;
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static bool isPeerProxyAuthEnabled() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setPeerProxyAuthEnabled(bool enabled) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static QString getPeerProxyIp() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setPeerProxyIp(QString ip) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/IP"), ip);
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static unsigned short getPeerProxyPort() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setPeerProxyPort(unsigned short port) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Port"), port);
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static QString getPeerProxyUsername() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setPeerProxyUsername(QString username) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Username"), username);
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static QString getPeerProxyPassword() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setPeerProxyPassword(QString password) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Password"), password);
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static int getPeerProxyType() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
2009-12-30 13:53:58 +03:00
|
|
|
static void setPeerProxyType(int type) {
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/ProxyType"), type);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Bittorrent options
|
|
|
|
static int getMaxConnecs() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), 500).toInt();
|
|
|
|
}
|
|
|
|
|
2009-11-26 11:10:23 +03:00
|
|
|
static void setMaxConnecs(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(val <= 0) val = -1;
|
2009-11-26 11:10:23 +03:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), val);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getMaxConnecsPerTorrent() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), 100).toInt();
|
|
|
|
}
|
|
|
|
|
2009-11-26 11:10:23 +03:00
|
|
|
static void setMaxConnecsPerTorrent(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(val <= 0) val = -1;
|
2009-11-26 11:10:23 +03:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), val);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getMaxUploadsPerTorrent() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), 4).toInt();
|
|
|
|
}
|
|
|
|
|
2009-11-26 11:10:23 +03:00
|
|
|
static void setMaxUploadsPerTorrent(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
if(val <= 0) val = -1;
|
2009-11-26 11:10:23 +03:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), val);
|
|
|
|
}
|
|
|
|
|
2009-12-30 16:10:06 +03:00
|
|
|
static QString getPeerID() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/PeerID"), "qB").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setPeerID(QString peer_id) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/PeerID"), peer_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getDefaultClientVersion(QString peer_id) {
|
2009-12-30 20:47:10 +03:00
|
|
|
if(peer_id == "UT") {
|
|
|
|
// uTorrent
|
|
|
|
return "1.8.5";
|
2009-12-30 16:10:06 +03:00
|
|
|
}
|
2010-01-01 23:29:03 +03:00
|
|
|
// Azureus
|
|
|
|
if(peer_id == "AZ") {
|
|
|
|
return "4.3.0.4";
|
|
|
|
}
|
|
|
|
// KTorrent
|
|
|
|
if(peer_id == "KT") {
|
|
|
|
return "3.3.2";
|
|
|
|
}
|
|
|
|
// qBittorrent
|
|
|
|
return QString(VERSION);
|
2009-12-30 16:10:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static QString getDefaultClientBuild(QString peer_id) {
|
|
|
|
if(peer_id == "UT") {
|
|
|
|
return "17414";
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getClientVersion() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
QString peer_id = getPeerID();
|
|
|
|
if(peer_id == "qB")
|
|
|
|
return QString(VERSION);
|
|
|
|
QString version = settings.value(QString::fromUtf8("Preferences/Bittorrent/PeerVersion"), QString()).toString();
|
|
|
|
if(version.isEmpty()) {
|
|
|
|
version = getDefaultClientVersion(peer_id);
|
|
|
|
}
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setClientVersion(QString version) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/PeerVersion"), version);
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getClientBuild() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
QString peer_id = getPeerID();
|
|
|
|
if(peer_id != "UT")
|
|
|
|
return "";
|
|
|
|
QString build = settings.value(QString::fromUtf8("Preferences/Bittorrent/PeerBuild"), QString()).toString();
|
|
|
|
if(build.isEmpty()) {
|
|
|
|
build = getDefaultClientBuild(peer_id);
|
|
|
|
}
|
|
|
|
return build;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setClientBuild(QString build) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/PeerBuild"), build);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isDHTEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/DHT"), true).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setDHTEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/DHT"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-12-17 21:00:21 +03:00
|
|
|
static bool isPeXEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/PeX"), true).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setPeXEnabled(bool enabled) {
|
2009-11-26 11:10:23 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/PeX"), enabled);
|
2009-11-26 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isDHTPortSameAsBT() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), true).toBool();
|
|
|
|
}
|
|
|
|
|
2010-03-22 23:34:12 +03:00
|
|
|
static void setDHTPortSameAsBT(bool same) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), same);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getDHTPort() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-01-20 12:54:51 +03:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), 6881).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-03-22 23:34:12 +03:00
|
|
|
static void setDHTPort(int port) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), port);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isLSDEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setLSDEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/LSD"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getEncryptionSetting() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/Encryption"), 0).toInt();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setEncryptionSetting(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
|
|
|
|
}
|
|
|
|
|
2010-06-22 21:06:11 +04:00
|
|
|
static float getMaxRatio() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();
|
|
|
|
}
|
|
|
|
|
2010-06-22 21:06:11 +04:00
|
|
|
static void setMaxRatio(float ratio) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setMaxRatioAction(int act) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatioAction"), act);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int getMaxRatioAction() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxRatioAction"), PAUSE_ACTION).toInt();
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// IP Filter
|
|
|
|
static bool isFilteringEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/IPFilter/Enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setFilteringEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/IPFilter/Enabled"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static QString getFilter() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/IPFilter/File"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setFilter(QString path) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/IPFilter/File"), path);
|
|
|
|
}
|
|
|
|
|
2009-11-17 19:02:35 +03:00
|
|
|
static void banIP(QString ip) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
QStringList banned_ips = settings.value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
|
|
|
|
if(!banned_ips.contains(ip)) {
|
|
|
|
banned_ips << ip;
|
|
|
|
settings.setValue("Preferences/IPFilter/BannedIPs", banned_ips);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static QStringList bannedIPs() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
|
|
|
|
}
|
|
|
|
|
2010-06-22 17:58:22 +04:00
|
|
|
// Search
|
|
|
|
static bool isSearchEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Search/SearchEnabled"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setSearchEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Search/SearchEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// RSS
|
|
|
|
static bool isRSSEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/RSS/RSSEnabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2010-06-22 17:58:22 +04:00
|
|
|
static void setRSSEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/RSS/RSSEnabled"), enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-15 11:53:33 +03:00
|
|
|
static unsigned int getRSSRefreshInterval() {
|
2009-11-14 22:08:28 +03:00
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2009-11-15 11:53:33 +03:00
|
|
|
return settings.value(QString::fromUtf8("Preferences/RSS/RSSRefresh"), 5).toUInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-06-22 17:39:49 +04:00
|
|
|
static void setRSSRefreshInterval(uint interval) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/RSS/RSSRefresh"), interval);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getRSSMaxArticlesPerFeed() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), 50).toInt();
|
|
|
|
}
|
|
|
|
|
2010-06-22 17:39:49 +04:00
|
|
|
static void setRSSMaxArticlesPerFeed(int nb) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/RSS/RSSMaxArticlesPerFeed"), nb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Queueing system
|
|
|
|
static bool isQueueingSystemEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value("Preferences/Queueing/QueueingEnabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setQueueingSystemEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue("Preferences/Queueing/QueueingEnabled", enabled);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getMaxActiveDownloads() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), 3).toInt();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setMaxActiveDownloads(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
if(val < 0) val = -1;
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), val);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getMaxActiveUploads() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), 3).toInt();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setMaxActiveUploads(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
if(val < 0) val = -1;
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), val);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static int getMaxActiveTorrents() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), 5).toInt();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setMaxActiveTorrents(int val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
if(val < 0) val = -1;
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), val);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static bool isWebUiEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value("Preferences/WebUI/Enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
2009-12-15 14:59:48 +03:00
|
|
|
static void setWebUiEnabled(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue("Preferences/WebUI/Enabled", enabled);
|
|
|
|
}
|
2009-11-14 22:08:28 +03:00
|
|
|
|
|
|
|
static quint16 getWebUiPort() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value("Preferences/WebUI/Port", 8080).toInt();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setWebUiPort(quint16 port) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue("Preferences/WebUI/Port", port);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
static QString getWebUiUsername() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2009-12-10 22:19:19 +03:00
|
|
|
return settings.value("Preferences/WebUI/Username", "admin").toString();
|
|
|
|
}
|
|
|
|
|
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
|
|
|
static void setWebUiUsername(QString username) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue("Preferences/WebUI/Username", username);
|
|
|
|
}
|
|
|
|
|
2009-12-10 22:19:19 +03:00
|
|
|
static void setWebUiPassword(QString new_password) {
|
|
|
|
// Get current password md5
|
|
|
|
QString current_pass_md5 = getWebUiPassword();
|
|
|
|
// Check if password did not change
|
|
|
|
if(current_pass_md5 == new_password) return;
|
|
|
|
// Encode to md5 and save
|
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
2010-01-15 17:20:20 +03:00
|
|
|
md5.addData(getWebUiUsername().toLocal8Bit()+":"+QBT_REALM+":");
|
2009-12-10 22:19:19 +03:00
|
|
|
md5.addData(new_password.toLocal8Bit());
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2010-01-15 17:20:20 +03:00
|
|
|
settings.setValue("Preferences/WebUI/Password_ha1", md5.result().toHex());
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static QString getWebUiPassword() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
2009-12-10 22:19:19 +03:00
|
|
|
// Here for backward compatiblity
|
|
|
|
if(settings.contains("Preferences/WebUI/Password")) {
|
|
|
|
QString clear_pass = settings.value("Preferences/WebUI/Password", "adminadmin").toString();
|
|
|
|
settings.remove("Preferences/WebUI/Password");
|
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
2010-01-15 17:20:20 +03:00
|
|
|
md5.addData(getWebUiUsername().toLocal8Bit()+":"+QBT_REALM+":");
|
2009-12-10 22:19:19 +03:00
|
|
|
md5.addData(clear_pass.toLocal8Bit());
|
|
|
|
QString pass_md5(md5.result().toHex());
|
2010-01-15 17:20:20 +03:00
|
|
|
settings.setValue("Preferences/WebUI/Password_ha1", pass_md5);
|
2009-12-10 22:19:19 +03:00
|
|
|
return pass_md5;
|
|
|
|
}
|
2010-01-15 17:20:20 +03:00
|
|
|
QString pass_ha1 = settings.value("Preferences/WebUI/Password_ha1", "").toString();
|
|
|
|
if(pass_ha1.isEmpty()) {
|
2009-12-10 22:19:19 +03:00
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
2010-01-15 17:20:20 +03:00
|
|
|
md5.addData(getWebUiUsername().toLocal8Bit()+":"+QBT_REALM+":");
|
2009-12-10 22:19:19 +03:00
|
|
|
md5.addData("adminadmin");
|
2010-01-15 17:20:20 +03:00
|
|
|
pass_ha1 = md5.result().toHex();
|
2009-12-10 22:19:19 +03:00
|
|
|
}
|
2010-01-15 17:20:20 +03:00
|
|
|
return pass_ha1;
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
2009-11-17 19:02:35 +03:00
|
|
|
|
2010-01-31 18:27:54 +03:00
|
|
|
// Advanced settings
|
|
|
|
static uint diskCacheSize() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setDiskCacheSize(uint size) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Downloads/DiskCache"), size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint outgoingPortsMin() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), 0).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setOutgoingPortsMin(uint val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint outgoingPortsMax() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), 0).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setOutgoingPortsMax(uint val) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), val);
|
|
|
|
}
|
|
|
|
|
2010-01-31 18:42:24 +03:00
|
|
|
static bool ignoreLimitsOnLAN() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ignoreLimitsOnLAN(bool ignore) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), ignore);
|
|
|
|
}
|
|
|
|
|
2010-01-31 18:57:07 +03:00
|
|
|
static bool includeOverheadInLimits() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void includeOverheadInLimits(bool include) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), include);
|
|
|
|
}
|
|
|
|
|
2010-01-31 19:14:56 +03:00
|
|
|
static bool recheckTorrentsOnCompletion() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void recheckTorrentsOnCompletion(bool recheck) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), recheck);
|
|
|
|
}
|
|
|
|
|
2010-01-31 19:25:04 +03:00
|
|
|
static unsigned int getRefreshInterval() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/General/RefreshInterval"), 1500).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setRefreshInterval(uint interval) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/General/RefreshInterval"), interval);
|
|
|
|
}
|
|
|
|
|
2010-01-31 19:43:19 +03:00
|
|
|
static bool resolvePeerCountries() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void resolvePeerCountries(bool resolve) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), resolve);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool resolvePeerHostNames() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void resolvePeerHostNames(bool resolve) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), resolve);
|
|
|
|
}
|
|
|
|
|
2010-03-25 22:16:43 +03:00
|
|
|
static int getMaxHalfOpenConnections() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
const int val = settings.value(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), 50).toInt();
|
|
|
|
if(val <= 0) return -1;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setMaxHalfOpenConnections(int value) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
if(value <= 0) value = -1;
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), value);
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:53:14 +04:00
|
|
|
static void setNetworkInterface(QString iface) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Connection/Interface"), iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getNetworkInterface() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
2010-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
2010-03-25 22:31:48 +03:00
|
|
|
static bool isSuperSeedingEnabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void enableSuperSeeding(bool enabled) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), enabled);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-17 18:57:45 +04:00
|
|
|
static QList<QByteArray> getHostNameCookies(QString host_name) {
|
|
|
|
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
|
|
|
QList<QByteArray> ret;
|
|
|
|
QMap<QString, QVariant> hosts_table = qBTRSS.value("hosts_cookies", QMap<QString, QVariant>()).toMap();
|
|
|
|
if(!hosts_table.contains(host_name)) return ret;
|
|
|
|
QByteArray raw_cookies = hosts_table.value(host_name).toByteArray();
|
|
|
|
return raw_cookies.split(':');
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setHostNameCookies(QString host_name, const QList<QByteArray> &cookies) {
|
|
|
|
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
|
|
|
QMap<QString, QVariant> hosts_table = qBTRSS.value("hosts_cookies", QMap<QString, QVariant>()).toMap();
|
|
|
|
QByteArray raw_cookies = "";
|
|
|
|
foreach(const QByteArray& cookie, cookies) {
|
|
|
|
raw_cookies += cookie + ":";
|
|
|
|
}
|
|
|
|
if(raw_cookies.endsWith(":"))
|
|
|
|
raw_cookies.chop(1);
|
|
|
|
hosts_table.insert(host_name, raw_cookies);
|
|
|
|
qBTRSS.setValue("hosts_cookies", hosts_table);
|
|
|
|
}
|
|
|
|
|
2010-06-14 21:46:33 +04:00
|
|
|
static bool recursiveDownloadDisabled() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void disableRecursiveDownload(bool disable=true) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), disable);
|
|
|
|
}
|
|
|
|
|
2010-05-30 21:51:40 +04:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
static QString getPythonPath() {
|
2010-06-02 02:47:14 +04:00
|
|
|
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QSettings::NativeFormat);
|
|
|
|
QStringList versions = reg_python.childGroups();
|
|
|
|
qDebug("Python versions nb: %d", versions.size());
|
|
|
|
versions = versions.filter(QRegExp("2\\..*"));
|
|
|
|
versions.sort();
|
|
|
|
while(!versions.empty()) {
|
|
|
|
const QString version = versions.takeLast();
|
|
|
|
qDebug("Detected possible Python v%s location", qPrintable(version));
|
|
|
|
QString path = reg_python.value(version+"/InstallPath/Default", "").toString().replace("/", "\\");
|
|
|
|
if(!path.isEmpty() && QDir(path).exists("python.exe")) {
|
|
|
|
qDebug("Found python.exe at %s", qPrintable(path));
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(QFile::exists("C:/Python26/python.exe")) {
|
|
|
|
reg_python.setValue("2.6/InstallPath/Default", "C:\\Python26");
|
|
|
|
return "C:\\Python26";
|
|
|
|
}
|
|
|
|
if(QFile::exists("C:/Python25/python.exe")) {
|
|
|
|
reg_python.setValue("2.5/InstallPath/Default", "C:\\Python26");
|
|
|
|
return "C:\\Python25";
|
|
|
|
}
|
|
|
|
return QString::null;
|
2010-05-31 16:48:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool neverCheckFileAssoc() {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
return settings.value(QString::fromUtf8("Preferences/Win32/NeverCheckFileAssocation"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setNeverCheckFileAssoc(bool check=true) {
|
|
|
|
QSettings settings("qBittorrent", "qBittorrent");
|
|
|
|
settings.setValue(QString::fromUtf8("Preferences/Win32/NeverCheckFileAssocation"), check);
|
2010-05-30 21:51:40 +04:00
|
|
|
}
|
2010-05-31 01:45:55 +04:00
|
|
|
|
|
|
|
static bool isFileAssocOk() {
|
2010-05-31 16:48:00 +04:00
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
2010-06-14 16:51:07 +04:00
|
|
|
if(settings.value(".torrent\\Default").toString() != "qBittorrent") {
|
2010-05-31 16:48:00 +04:00
|
|
|
qDebug(".torrent != qBittorrent");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
qDebug("Checking shell command");
|
2010-06-14 16:51:07 +04:00
|
|
|
QString shell_command = settings.value("qBittorrent\\shell\\open\\command\\Default", "").toString();
|
2010-05-31 16:48:00 +04:00
|
|
|
qDebug("Shell command is: %s", qPrintable(shell_command));
|
|
|
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
|
|
|
if(exe_reg.indexIn(shell_command) < 0)
|
|
|
|
return false;
|
|
|
|
QString assoc_exe = exe_reg.cap(1);
|
|
|
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
|
|
|
if(assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) != 0)
|
|
|
|
return false;
|
|
|
|
// Check magnet link assoc
|
2010-06-14 16:51:07 +04:00
|
|
|
shell_command = settings.value("Magnet\\shell\\open\\command\\Default", "").toString();
|
2010-05-31 16:48:00 +04:00
|
|
|
if(exe_reg.indexIn(shell_command) < 0)
|
|
|
|
return false;
|
|
|
|
assoc_exe = exe_reg.cap(1);
|
|
|
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
|
|
|
if(assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) != 0)
|
|
|
|
return false;
|
|
|
|
return true;
|
2010-05-31 01:45:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setFileAssoc() {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
2010-05-31 16:48:00 +04:00
|
|
|
// .Torrent association
|
2010-06-14 16:51:07 +04:00
|
|
|
settings.setValue(".torrent\\Default", "qBittorrent");
|
|
|
|
settings.setValue(".torrent\\Content Type", "application/x-bittorrent");
|
|
|
|
settings.setValue("qBittorrent\\shell\\Default", "open");
|
2010-05-31 01:45:55 +04:00
|
|
|
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
2010-06-14 16:51:07 +04:00
|
|
|
settings.setValue("qBittorrent\\shell\\open\\command\\Default", command_str);
|
|
|
|
settings.setValue("qBittorrent\\Content Type\\Default", "application/x-bittorrent");
|
2010-05-31 01:45:55 +04:00
|
|
|
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",0";
|
2010-06-14 16:51:07 +04:00
|
|
|
settings.setValue("qBittorrent\\DefaultIcon\\Default", icon_str);
|
2010-05-31 16:48:00 +04:00
|
|
|
// Magnet association
|
2010-06-14 16:51:07 +04:00
|
|
|
settings.setValue("Magnet\\Default", "Magnet URI");
|
|
|
|
settings.setValue("Magnet\\Content Type", "application/x-magnet");
|
|
|
|
settings.setValue("Magnet\\URL Protocol", "");
|
|
|
|
settings.setValue("Magnet\\DefaultIcon\\Default", icon_str);
|
|
|
|
settings.setValue("Magnet\\shell\\Default", "open");
|
|
|
|
settings.setValue("Magnet\\shell\\open\\command\\Default", command_str);
|
2010-05-31 01:45:55 +04:00
|
|
|
}
|
|
|
|
|
2010-05-30 21:51:40 +04:00
|
|
|
#endif
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PREFERENCES_H
|