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
|
|
|
|
|
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-11-20 18:59:17 +03:00
|
|
|
#include <QDebug>
|
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-07-16 19:03:18 +04:00
|
|
|
#include "qinisettings.h"
|
2010-06-05 22:59:05 +04:00
|
|
|
|
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-10-24 01:46:05 +04:00
|
|
|
namespace Proxy {
|
2010-11-13 13:49:22 +03:00
|
|
|
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
|
2010-10-24 01:46:05 +04:00
|
|
|
}
|
2011-03-27 12:34:51 +04:00
|
|
|
namespace TrayIcon {
|
|
|
|
enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT };
|
|
|
|
}
|
2011-04-15 17:02:39 +04:00
|
|
|
namespace DNS {
|
2011-06-05 20:08:30 +04:00
|
|
|
enum Service { DYNDNS, NOIP, NONE = -1 };
|
2011-04-17 18:42:38 +04:00
|
|
|
}
|
2010-01-15 17:20:20 +03:00
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
class Preferences : public QIniSettings {
|
|
|
|
Q_DISABLE_COPY(Preferences);
|
|
|
|
|
|
|
|
public:
|
2010-11-20 18:59:17 +03:00
|
|
|
Preferences() : QIniSettings("qBittorrent", "qBittorrent") {
|
|
|
|
qDebug() << "Preferences constructor";
|
|
|
|
}
|
2010-10-31 15:35:07 +03:00
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
public:
|
|
|
|
// General options
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getLocale() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/Locale"), "en_GB").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setLocale(const QString &locale) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool useProgramNotification() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/ProgramNotification"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void useProgramNotification(bool use) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/ProgramNotification"), use);
|
2010-01-31 20:30:17 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool deleteTorrentFilesAsDefault() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setDeleteTorrentFilesAsDefault(bool del) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/DeleteTorrentsFilesAsDefault"), del);
|
2010-07-22 13:39:51 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setConfirmOnExit(bool confirm) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/ExitConfirm"), confirm);
|
2010-07-22 13:39:51 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool confirmOnExit() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool();
|
2010-05-21 19:42:17 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void showSpeedInTitleBar(bool show) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/SpeedInTitleBar"), show);
|
2010-05-21 19:42:17 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool speedInTitleBar() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/SpeedInTitleBar"), false).toBool();
|
2010-06-21 19:53:42 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool useAlternatingRowColors() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/AlternatingRowColors"), true).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setAlternatingRowColors(bool b) {
|
|
|
|
setValue("Preferences/General/AlternatingRowColors", b);
|
2010-06-21 22:32:01 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool systrayIntegration() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSystrayIntegration(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/SystrayEnabled"), enabled);
|
2009-12-22 17:06:36 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setToolbarDisplayed(bool displayed) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/ToolbarDisplayed"), displayed);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isToolbarDisplayed() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/ToolbarDisplayed"), true).toBool();
|
2009-11-18 21:45:06 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool minimizeToTray() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool();
|
2010-06-21 22:32:01 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMinimizeToTray(bool b) {
|
|
|
|
setValue("Preferences/General/MinimizeToTray", b);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool closeToTray() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setCloseToTray(bool b) {
|
|
|
|
setValue("Preferences/General/CloseToTray", b);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool startMinimized() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setStartMinimized(bool b) {
|
|
|
|
setValue("Preferences/General/StartMinimized", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSlashScreenDisabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/NoSplashScreen"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSplashScreenDisabled(bool b) {
|
|
|
|
setValue("Preferences/General/NoSplashScreen", b);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2011-02-06 17:27:34 +03:00
|
|
|
// Preventing from system suspend while active torrents are presented.
|
|
|
|
bool preventFromSuspend() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/PreventFromSuspend"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPreventFromSuspend(bool b) {
|
|
|
|
setValue("Preferences/General/PreventFromSuspend", b);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Downloads
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getSavePath() const {
|
2010-06-03 02:31:49 +04:00
|
|
|
#ifdef Q_WS_WIN
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/SavePath"),
|
2010-11-20 18:59:17 +03:00
|
|
|
QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath("Downloads")).toString();
|
2010-06-03 02:31:49 +04:00
|
|
|
#else
|
2010-11-16 23:34:31 +03:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSavePath(const QString &save_path) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/SavePath"), save_path);
|
* 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-11-16 23:34:31 +03:00
|
|
|
bool isTempPathEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setTempPathEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getTempPath() const {
|
|
|
|
const QString temp = QDir(getSavePath()).absoluteFilePath("temp");
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/TempPath"), temp).toString();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setTempPath(const QString &path) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path);
|
* 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-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
2010-11-16 23:34:31 +03:00
|
|
|
bool useIncompleteFilesExtension() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
|
2009-12-17 23:28:30 +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
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void useIncompleteFilesExtension(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), 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
|
|
|
}
|
2009-12-18 16:36:47 +03:00
|
|
|
#endif
|
2009-12-17 23:28:30 +03:00
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool appendTorrentLabel() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AppendLabel"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAppendTorrentLabel(bool b) {
|
|
|
|
setValue("Preferences/Downloads/AppendLabel", b);
|
|
|
|
}
|
|
|
|
|
2011-09-06 23:13:02 +04:00
|
|
|
QString lastLocationPath() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setLastLocationPath(const QString &path) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), path);
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool preAllocateAllFiles() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool();
|
2009-12-17 23:28:30 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void preAllocateAllFiles(bool enabled) {
|
|
|
|
return setValue(QString::fromUtf8("Preferences/Downloads/PreAllocation"), enabled);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool useAdditionDialog() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void useAdditionDialog(bool b) {
|
|
|
|
setValue("Preferences/Downloads/AdditionDialog", b);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool addTorrentsInPause() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/StartInPause"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void addTorrentsInPause(bool b) {
|
|
|
|
setValue("Preferences/Downloads/StartInPause", b);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList getScanDirs() const {
|
|
|
|
return 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
|
2010-11-16 23:34:31 +03:00
|
|
|
void setScanDirs(const QStringList &dirs) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), dirs);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QList<bool> getDownloadInScanDirs() const {
|
|
|
|
return misc::boolListfromStringList(value(QString::fromUtf8("Preferences/Downloads/DownloadInScanDirs")).toStringList());
|
2010-02-28 18:15:00 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setDownloadInScanDirs(const QList<bool> &list) {
|
|
|
|
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-11-16 23:34:31 +03:00
|
|
|
bool isTorrentExportEnabled() const {
|
|
|
|
return !value(QString::fromUtf8("Preferences/Downloads/TorrentExport"), QString()).toString().isEmpty();
|
2010-01-31 16:09:46 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getExportDir() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/TorrentExport"), QString()).toString();
|
2010-01-31 16:09:46 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setExportDir(QString path) {
|
2010-01-31 16:09:46 +03:00
|
|
|
path = path.trimmed();
|
|
|
|
if(path.isEmpty())
|
|
|
|
path = QString();
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/TorrentExport"), path);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMailNotificationEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/enabled"), false).toBool();
|
2010-01-31 16:09:46 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMailNotificationEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/enabled"), enabled);
|
2010-08-19 22:47:57 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getMailNotificationEmail() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/email"), "").toString();
|
2010-08-19 22:47:57 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMailNotificationEmail(const QString &mail) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/email"), mail);
|
2010-08-19 22:47:57 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getMailNotificationSMTP() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/smtp_server"), "smtp.changeme.com").toString();
|
2010-08-19 22:47:57 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMailNotificationSMTP(const QString &smtp_server) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/smtp_server"), smtp_server);
|
2010-08-19 22:47:57 +04:00
|
|
|
}
|
|
|
|
|
2011-04-09 21:39:51 +04:00
|
|
|
bool getMailNotificationSMTPSSL() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/req_ssl"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPSSL(bool use) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/req_ssl"), use);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getMailNotificationSMTPAuth() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/req_auth"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPAuth(bool use) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/req_auth"), use);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getMailNotificationSMTPUsername() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/username")).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPUsername(const QString &username) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/username"), username);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getMailNotificationSMTPPassword() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/MailNotification/password")).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setMailNotificationSMTPPassword(const QString &password) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/MailNotification/password"), password);
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getActionOnDblClOnTorrentDl() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DblClOnTorDl"), 0).toInt();
|
2010-08-19 22:47:57 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setActionOnDblClOnTorrentDl(int act) {
|
|
|
|
setValue("Preferences/Downloads/DblClOnTorDl", act);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getActionOnDblClOnTorrentFn() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DblClOnTorFn"), 1).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setActionOnDblClOnTorrentFn(int act) {
|
|
|
|
setValue("Preferences/Downloads/DblClOnTorFn", act);
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Connection options
|
2010-11-16 23:34:31 +03:00
|
|
|
int getSessionPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/PortRangeMin"), 6881).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSessionPort(int port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/PortRangeMin"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isUPnPEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/UPnP"), true).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setUPnPEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/UPnP"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getGlobalDownloadLimit() const {
|
2010-12-02 20:17:50 +03:00
|
|
|
return value("Preferences/Connection/GlobalDLLimit", -1).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setGlobalDownloadLimit(int limit) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("Preferences/Connection/GlobalDLLimit", limit);
|
2009-11-17 16:11:32 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getGlobalUploadLimit() const {
|
2010-12-02 20:17:50 +03:00
|
|
|
return value("Preferences/Connection/GlobalUPLimit", 50).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setGlobalUploadLimit(int limit) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("Preferences/Connection/GlobalUPLimit", limit);
|
2009-11-17 16:11:32 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getAltGlobalDownloadLimit() const {
|
|
|
|
int ret = value(QString::fromUtf8("Preferences/Connection/GlobalDLLimitAlt"), 10).toInt();
|
2010-06-25 01:34:31 +04:00
|
|
|
if(ret <= 0)
|
|
|
|
ret = 10;
|
|
|
|
return ret;
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setAltGlobalDownloadLimit(int limit) {
|
2010-01-23 23:44:09 +03:00
|
|
|
if(limit <= 0) limit = -1;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("Preferences/Connection/GlobalDLLimitAlt", limit);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getAltGlobalUploadLimit() const {
|
|
|
|
int ret = value(QString::fromUtf8("Preferences/Connection/GlobalUPLimitAlt"), 10).toInt();
|
2010-06-25 01:34:31 +04:00
|
|
|
if(ret <= 0)
|
|
|
|
ret = 10;
|
|
|
|
return ret;
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setAltGlobalUploadLimit(int limit) {
|
2010-01-23 23:44:09 +03:00
|
|
|
if(limit <= 0) limit = -1;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("Preferences/Connection/GlobalUPLimitAlt", limit);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isAltBandwidthEnabled() const {
|
|
|
|
return value("Preferences/Connection/alt_speeds_on", false).toBool();
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setAltBandwidthEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/Connection/alt_speeds_on", enabled);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSchedulerEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/Enabled"), enabled);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isSchedulerEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Scheduler/Enabled"), false).toBool();
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QTime getSchedulerStartTime() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Scheduler/start_time"), QTime(8,0)).toTime();
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSchedulerStartTime(const QTime &time) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/start_time"), time);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QTime getSchedulerEndTime() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Scheduler/end_time"), QTime(20,0)).toTime();
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSchedulerEndTime(const QTime &time) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/end_time"), time);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
scheduler_days getSchedulerDays() const {
|
|
|
|
return (scheduler_days)value(QString::fromUtf8("Preferences/Scheduler/days"), EVERY_DAY).toInt();
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSchedulerDays(scheduler_days days) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Scheduler/days"), (int)days);
|
2010-01-23 23:44:09 +03:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Proxy options
|
2010-11-18 23:05:56 +03:00
|
|
|
bool isProxyEnabled() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt() > 0;
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
bool isProxyAuthEnabled() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
void setProxyAuthEnabled(bool enabled) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), 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
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
QString getProxyIp() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
void setProxyIp(const QString &ip) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/IP"), 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
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
unsigned short getProxyPort() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
void setProxyPort(unsigned short port) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 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
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
QString getProxyUsername() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
void setProxyUsername(const QString &username) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Username"), 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
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
QString getProxyPassword() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
void setProxyPassword(const QString &password) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Password"), 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
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
int getProxyType() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-18 23:05:56 +03:00
|
|
|
void setProxyType(int type) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ProxyType"), 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
|
|
|
}
|
|
|
|
|
2011-05-01 15:22:17 +04:00
|
|
|
void setProxyPeerConnections(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ProxyPeerConnections"), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool proxyPeerConnections() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ProxyPeerConnections"), false).toBool();
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Bittorrent options
|
2010-11-16 23:34:31 +03:00
|
|
|
int getMaxConnecs() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), 500).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxConnecs(int val) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), val);
|
2009-11-26 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getMaxConnecsPerTorrent() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), 100).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxConnecsPerTorrent(int val) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), val);
|
2009-11-26 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getMaxUploadsPerTorrent() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), 4).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxUploadsPerTorrent(int val) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), val);
|
2009-11-26 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
2011-04-17 22:11:03 +04:00
|
|
|
bool isuTPEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/uTP"), true).toBool();
|
2011-04-17 18:42:38 +04:00
|
|
|
}
|
|
|
|
|
2011-04-17 22:11:03 +04:00
|
|
|
void setuTPEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/Bittorrent/uTP", enabled);
|
2011-04-17 18:42:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isuTPRateLimited() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/uTP_rate_limiting"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setuTPRateLimited(bool enabled) {
|
|
|
|
setValue("Preferences/Bittorrent/uTP_rate_limiting", enabled);
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isDHTEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/DHT"), true).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setDHTEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/DHT"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isPeXEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/PeX"), true).toBool();
|
2009-12-17 21:00:21 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setPeXEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/PeX"), enabled);
|
2009-11-26 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isDHTPortSameAsBT() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), true).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setDHTPortSameAsBT(bool same) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/sameDHTPortAsBT"), same);
|
2010-03-22 23:34:12 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getDHTPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), 6881).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setDHTPort(int port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/DHTPort"), port);
|
2010-03-22 23:34:12 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isLSDEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setLSDEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/LSD"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getEncryptionSetting() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/Encryption"), 0).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setEncryptionSetting(int val) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
|
* 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
|
|
|
}
|
|
|
|
|
2011-03-07 22:26:44 +03:00
|
|
|
qreal getGlobalMaxRatio() const {
|
2010-11-16 23:34:31 +03:00
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2011-03-07 22:26:44 +03:00
|
|
|
void setGlobalMaxRatio(qreal ratio) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio);
|
2010-06-22 21:06:11 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxRatioAction(int act) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatioAction"), act);
|
2010-06-22 21:06:11 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getMaxRatioAction() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatioAction"), PAUSE_ACTION).toInt();
|
2010-06-22 21:06:11 +04:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// IP Filter
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isFilteringEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/IPFilter/Enabled"), false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setFilteringEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/IPFilter/Enabled"), 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getFilter() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/IPFilter/File"), QString()).toString();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setFilter(const QString &path) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/IPFilter/File"), path);
|
* 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-11-16 23:34:31 +03:00
|
|
|
void banIP(const QString &ip) {
|
|
|
|
QStringList banned_ips = value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
|
2009-11-17 19:02:35 +03:00
|
|
|
if(!banned_ips.contains(ip)) {
|
|
|
|
banned_ips << ip;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("Preferences/IPFilter/BannedIPs", banned_ips);
|
2009-11-17 19:02:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QStringList bannedIPs() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
|
2009-11-17 19:02:35 +03:00
|
|
|
}
|
|
|
|
|
2010-06-22 17:58:22 +04:00
|
|
|
// Search
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isSearchEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Search/SearchEnabled"), true).toBool();
|
2010-06-22 17:58:22 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setSearchEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Search/SearchEnabled"), enabled);
|
2010-06-22 17:58:22 +04:00
|
|
|
}
|
|
|
|
|
2010-12-20 21:07:36 +03:00
|
|
|
// Execution Log
|
|
|
|
|
|
|
|
bool isExecutionLogEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/ExecutionLog/enabled"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setExecutionLogEnabled(bool b) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/ExecutionLog/enabled"), b);
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:08:28 +03:00
|
|
|
// Queueing system
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isQueueingSystemEnabled() const {
|
|
|
|
return value("Preferences/Queueing/QueueingEnabled", false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setQueueingSystemEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/Queueing/QueueingEnabled", 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getMaxActiveDownloads() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), 3).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxActiveDownloads(int val) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), val);
|
* 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-11-16 23:34:31 +03:00
|
|
|
int getMaxActiveUploads() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), 3).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxActiveUploads(int val) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), val);
|
* 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-11-16 23:34:31 +03:00
|
|
|
int getMaxActiveTorrents() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), 5).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxActiveTorrents(int val) {
|
* 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;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), val);
|
* 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
|
|
|
}
|
|
|
|
|
2011-09-18 20:34:29 +04:00
|
|
|
void setIgnoreSlowTorrentsForQueueing(bool ignore) {
|
|
|
|
setValue("Preferences/Queueing/IgnoreSlowTorrents", ignore);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ignoreSlowTorrentsForQueueing() const {
|
|
|
|
return value("Preferences/Queueing/IgnoreSlowTorrents", false).toBool();
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isWebUiEnabled() const {
|
|
|
|
return value("Preferences/WebUI/Enabled", false).toBool();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setWebUiEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/Enabled", enabled);
|
2009-12-15 14:59:48 +03:00
|
|
|
}
|
2009-11-14 22:08:28 +03:00
|
|
|
|
2011-02-27 12:34:42 +03:00
|
|
|
void setWebUiLocalAuthEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/LocalHostAuth", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isWebUiLocalAuthEnabled() const {
|
|
|
|
return value("Preferences/WebUI/LocalHostAuth", true).toBool();
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
quint16 getWebUiPort() const {
|
|
|
|
return value("Preferences/WebUI/Port", 8080).toInt();
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setWebUiPort(quint16 port) {
|
|
|
|
setValue("Preferences/WebUI/Port", 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
|
|
|
}
|
|
|
|
|
2011-04-12 23:50:05 +04:00
|
|
|
bool useUPnPForWebUIPort() const {
|
|
|
|
return value("Preferences/WebUI/UseUPnP", true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUPnPForWebUIPort(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/UseUPnP", enabled);
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getWebUiUsername() const {
|
|
|
|
return value("Preferences/WebUI/Username", "admin").toString();
|
2009-12-10 22:19:19 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setWebUiUsername(const QString &username) {
|
|
|
|
setValue("Preferences/WebUI/Username", 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
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setWebUiPassword(const QString &new_password) {
|
2009-12-10 22:19:19 +03:00
|
|
|
// 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());
|
2010-11-16 23:34:31 +03:00
|
|
|
|
|
|
|
setValue("Preferences/WebUI/Password_ha1", md5.result().toHex());
|
2009-11-14 22:08:28 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getWebUiPassword() const {
|
|
|
|
QString pass_ha1 = value("Preferences/WebUI/Password_ha1", "").toString();
|
2010-01-15 17:20:20 +03:00
|
|
|
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
|
|
|
|
2011-05-07 17:48:42 +04:00
|
|
|
bool isWebUiHttpsEnabled() const {
|
|
|
|
return value("Preferences/WebUI/HTTPS/Enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWebUiHttpsEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/WebUI/HTTPS/Enabled", enabled);
|
|
|
|
}
|
|
|
|
|
2011-06-05 20:08:30 +04:00
|
|
|
QByteArray getWebUiHttpsCertificate() const {
|
|
|
|
return value("Preferences/WebUI/HTTPS/Certificate").toByteArray();
|
2011-05-07 17:48:42 +04:00
|
|
|
}
|
|
|
|
|
2011-06-05 20:08:30 +04:00
|
|
|
void setWebUiHttpsCertificate(const QByteArray &data) {
|
|
|
|
setValue("Preferences/WebUI/HTTPS/Certificate", data);
|
2011-05-07 17:48:42 +04:00
|
|
|
}
|
|
|
|
|
2011-06-05 20:08:30 +04:00
|
|
|
QByteArray getWebUiHttpsKey() const {
|
|
|
|
return value("Preferences/WebUI/HTTPS/Key").toByteArray();
|
2011-05-07 17:48:42 +04:00
|
|
|
}
|
|
|
|
|
2011-06-05 20:08:30 +04:00
|
|
|
void setWebUiHttpsKey(const QByteArray &data) {
|
|
|
|
setValue("Preferences/WebUI/HTTPS/Key", data);
|
2011-05-07 17:48:42 +04:00
|
|
|
}
|
|
|
|
|
2011-04-15 17:02:39 +04:00
|
|
|
bool isDynDNSEnabled() const {
|
|
|
|
return value("Preferences/DynDNS/Enabled", false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDNSEnabled(bool enabled) {
|
|
|
|
setValue("Preferences/DynDNS/Enabled", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
DNS::Service getDynDNSService() const {
|
|
|
|
return DNS::Service(value("Preferences/DynDNS/Service", DNS::DYNDNS).toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDNSService(int service) {
|
|
|
|
setValue("Preferences/DynDNS/Service", service);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getDynDomainName() const {
|
|
|
|
return value("Preferences/DynDNS/DomainName", "changeme.dyndns.org").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDomainName(const QString name) {
|
|
|
|
setValue("Preferences/DynDNS/DomainName", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getDynDNSUsername() const {
|
|
|
|
return value("Preferences/DynDNS/Username").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDNSUsername(const QString username) {
|
|
|
|
setValue("Preferences/DynDNS/Username", username);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getDynDNSPassword() const {
|
|
|
|
return value("Preferences/DynDNS/Password").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDynDNSPassword(const QString password) {
|
|
|
|
setValue("Preferences/DynDNS/Password", password);
|
|
|
|
}
|
|
|
|
|
2010-01-31 18:27:54 +03:00
|
|
|
// Advanced settings
|
2010-08-16 21:35:32 +04:00
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setUILockPassword(const QString &clear_password) {
|
2010-08-19 20:30:13 +04:00
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
|
|
|
md5.addData(clear_password.toLocal8Bit());
|
|
|
|
QString md5_password = md5.result().toHex();
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("Locking/password", md5_password);
|
2010-08-19 20:30:13 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getUILockPasswordMD5() const {
|
|
|
|
return value("Locking/password", QString()).toString();
|
2010-08-19 20:30:13 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isUILocked() const {
|
|
|
|
return value("Locking/locked", false).toBool();
|
2010-08-19 20:30:13 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setUILocked(bool locked) {
|
|
|
|
return setValue("Locking/locked", locked);
|
2010-08-19 20:30:13 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isAutoRunEnabled() const {
|
|
|
|
return value("AutoRun/enabled", false).toBool();
|
2010-08-20 17:20:23 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setAutoRunEnabled(bool enabled) {
|
|
|
|
return setValue("AutoRun/enabled", enabled);
|
2010-08-20 17:20:23 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setAutoRunProgram(const QString &program) {
|
|
|
|
setValue("AutoRun/program", program);
|
2010-08-20 17:20:23 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getAutoRunProgram() const {
|
|
|
|
return value("AutoRun/program", QString()).toString();
|
2010-08-20 17:20:23 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool shutdownWhenDownloadsComplete() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AutoShutDownOnCompletion"), false).toBool();
|
2010-08-16 21:35:32 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setShutdownWhenDownloadsComplete(bool shutdown) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownOnCompletion"), shutdown);
|
2010-08-16 21:35:32 +04:00
|
|
|
}
|
|
|
|
|
2010-12-31 16:36:32 +03:00
|
|
|
bool suspendWhenDownloadsComplete() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AutoSuspendOnCompletion"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSuspendWhenDownloadsComplete(bool suspend) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/AutoSuspendOnCompletion"), suspend);
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool shutdownqBTWhenDownloadsComplete() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/AutoShutDownqBTOnCompletion"), false).toBool();
|
2010-10-09 18:57:41 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setShutdownqBTWhenDownloadsComplete(bool shutdown) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownqBTOnCompletion"), shutdown);
|
2010-10-09 18:57:41 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
uint diskCacheSize() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt();
|
2010-01-31 18:27:54 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setDiskCacheSize(uint size) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Downloads/DiskCache"), size);
|
2010-01-31 18:27:54 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
uint outgoingPortsMin() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), 0).toUInt();
|
2010-01-31 18:27:54 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setOutgoingPortsMin(uint val) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), val);
|
2010-01-31 18:27:54 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
uint outgoingPortsMax() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), 0).toUInt();
|
2010-01-31 18:27:54 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setOutgoingPortsMax(uint val) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), val);
|
2010-01-31 18:27:54 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool ignoreLimitsOnLAN() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), true).toBool();
|
2010-01-31 18:42:24 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void ignoreLimitsOnLAN(bool ignore) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), ignore);
|
2010-01-31 18:42:24 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool includeOverheadInLimits() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), false).toBool();
|
2010-01-31 18:57:07 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void includeOverheadInLimits(bool include) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), include);
|
2010-01-31 18:57:07 +03:00
|
|
|
}
|
|
|
|
|
2011-06-05 20:08:30 +04:00
|
|
|
bool trackerExchangeEnabled() const {
|
2011-09-21 19:48:10 +04:00
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/LtTrackerExchange"), false).toBool();
|
2011-06-05 20:08:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTrackerExchangeEnabled(bool enable) {
|
2011-09-21 19:48:10 +04:00
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/LtTrackerExchange"), enable);
|
2011-06-05 20:08:30 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool recheckTorrentsOnCompletion() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), false).toBool();
|
2010-01-31 19:14:56 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void recheckTorrentsOnCompletion(bool recheck) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), recheck);
|
2010-01-31 19:14:56 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
unsigned int getRefreshInterval() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/General/RefreshInterval"), 1500).toUInt();
|
2010-01-31 19:25:04 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setRefreshInterval(uint interval) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/General/RefreshInterval"), interval);
|
2010-01-31 19:25:04 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool resolvePeerCountries() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool();
|
2010-01-31 19:43:19 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void resolvePeerCountries(bool resolve) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), resolve);
|
2010-01-31 19:43:19 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool resolvePeerHostNames() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), false).toBool();
|
2010-01-31 19:43:19 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void resolvePeerHostNames(bool resolve) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/ResolvePeerHostNames"), resolve);
|
2010-01-31 19:43:19 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getMaxHalfOpenConnections() const {
|
|
|
|
const int val = value(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), 50).toInt();
|
2010-03-25 22:16:43 +03:00
|
|
|
if(val <= 0) return -1;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setMaxHalfOpenConnections(int value) {
|
2010-03-25 22:16:43 +03:00
|
|
|
if(value <= 0) value = -1;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), value);
|
2010-03-25 22:16:43 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setNetworkInterface(const QString& iface) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/Interface"), iface);
|
2010-05-11 19:53:14 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QString getNetworkInterface() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString();
|
2010-05-11 19:53:14 +04:00
|
|
|
}
|
|
|
|
|
2011-02-05 18:44:48 +03:00
|
|
|
void setNetworkAddress(const QString& addr) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Connection/InetAddress"), addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getNetworkAddress() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Connection/InetAddress"), QString()).toString();
|
|
|
|
}
|
|
|
|
|
2011-09-20 21:15:47 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 15
|
|
|
|
bool isAnonymousModeEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void enableAnonymousMode(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), enabled);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-06-07 12:32:41 +04:00
|
|
|
#if LIBTORRENT_VERSION_MINOR > 14
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isSuperSeedingEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool();
|
2010-03-25 22:31:48 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void enableSuperSeeding(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), enabled);
|
2010-03-25 22:31:48 +03:00
|
|
|
}
|
2011-09-18 21:05:30 +04:00
|
|
|
|
|
|
|
bool announceToAllTrackers() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAnnounceToAllTrackers(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), enabled);
|
|
|
|
}
|
2010-03-25 22:31:48 +03:00
|
|
|
#endif
|
|
|
|
|
2011-01-01 16:05:28 +03:00
|
|
|
#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0))
|
|
|
|
bool useSystemIconTheme() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void useSystemIconTheme(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), enabled);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
QStringList getTorrentLabels() const {
|
|
|
|
return value("TransferListFilters/customLabels").toStringList();
|
2010-11-13 13:49:22 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void addTorrentLabel(const QString& label) {
|
|
|
|
QStringList labels = value("TransferListFilters/customLabels").toStringList();
|
2010-11-13 13:49:22 +03:00
|
|
|
if(!labels.contains(label))
|
|
|
|
labels << label;
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("TransferListFilters/customLabels", labels);
|
2010-11-13 13:49:22 +03:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void removeTorrentLabel(const QString& label) {
|
|
|
|
QStringList labels = value("TransferListFilters/customLabels").toStringList();
|
2010-11-13 13:49:22 +03:00
|
|
|
if(labels.contains(label))
|
|
|
|
labels.removeOne(label);
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue("TransferListFilters/customLabels", labels);
|
2010-05-17 18:57:45 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool recursiveDownloadDisabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), false).toBool();
|
2010-06-14 21:46:33 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void disableRecursiveDownload(bool disable=true) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), disable);
|
2010-06-14 21:46:33 +04:00
|
|
|
}
|
|
|
|
|
2010-05-30 21:51:40 +04:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
static QString getPythonPath() {
|
2010-07-22 01:45:32 +04:00
|
|
|
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
|
2010-06-02 02:47:14 +04:00
|
|
|
QStringList versions = reg_python.childGroups();
|
|
|
|
qDebug("Python versions nb: %d", versions.size());
|
2011-09-11 21:22:54 +04:00
|
|
|
//versions = versions.filter(QRegExp("2\\..*"));
|
2010-06-02 02:47:14 +04:00
|
|
|
versions.sort();
|
|
|
|
while(!versions.empty()) {
|
|
|
|
const QString version = versions.takeLast();
|
|
|
|
qDebug("Detected possible Python v%s location", qPrintable(version));
|
2010-07-22 01:45:32 +04:00
|
|
|
QString path = reg_python.value(version+"/InstallPath/Default", "").toString().replace("/", "\\");
|
2010-06-02 02:47:14 +04:00
|
|
|
if(!path.isEmpty() && QDir(path).exists("python.exe")) {
|
|
|
|
qDebug("Found python.exe at %s", qPrintable(path));
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
2011-09-11 21:22:54 +04:00
|
|
|
// Fallback: Detect python from default locations
|
|
|
|
QStringList supported_versions;
|
|
|
|
supported_versions << "32" << "31" << "30" << "27" << "26" << "25";
|
2011-09-15 23:00:48 +04:00
|
|
|
foreach(const QString &v, supported_versions) {
|
2011-09-11 21:22:54 +04:00
|
|
|
if(QFile::exists("C:/Python"+v+"/python.exe")) {
|
2011-09-15 23:00:48 +04:00
|
|
|
reg_python.setValue(v[0]+"."+v[1]+"/InstallPath/Default", QString("C:\\Python"+v));
|
2011-09-11 21:22:54 +04:00
|
|
|
return "C:\\Python"+v;
|
|
|
|
}
|
2010-06-02 02:47:14 +04:00
|
|
|
}
|
|
|
|
return QString::null;
|
2010-05-31 16:48:00 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool neverCheckFileAssoc() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Win32/NeverCheckFileAssocation"), false).toBool();
|
2010-05-31 16:48:00 +04:00
|
|
|
}
|
|
|
|
|
2011-09-18 17:42:50 +04:00
|
|
|
void setNeverCheckFileAssoc(bool check = true) {
|
2010-11-16 23:34:31 +03:00
|
|
|
setValue(QString::fromUtf8("Preferences/Win32/NeverCheckFileAssocation"), check);
|
2010-05-30 21:51:40 +04:00
|
|
|
}
|
2010-05-31 01:45:55 +04:00
|
|
|
|
2011-09-18 17:42:50 +04:00
|
|
|
static bool isTorrentFileAssocSet() {
|
2010-07-22 01:45:32 +04:00
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
2010-11-22 23:27:57 +03: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-11-22 23:27:57 +03: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;
|
2010-07-22 01:45:32 +04:00
|
|
|
// Icon
|
|
|
|
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
2010-11-22 23:27:57 +03:00
|
|
|
if(settings.value("qBittorrent/DefaultIcon/Default", icon_str).toString().compare(icon_str, Qt::CaseInsensitive) != 0)
|
2010-07-22 01:45:32 +04:00
|
|
|
return false;
|
2011-09-18 17:42:50 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isMagnetLinkAssocSet() {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
|
|
|
|
2010-05-31 16:48:00 +04:00
|
|
|
// Check magnet link assoc
|
2011-09-18 17:42:50 +04:00
|
|
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
|
|
|
QString 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;
|
2011-09-18 17:42:50 +04:00
|
|
|
QString assoc_exe = exe_reg.cap(1);
|
2010-05-31 16:48:00 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-09-18 17:42:50 +04:00
|
|
|
static void setTorrentFileAssoc(bool set) {
|
2010-07-22 01:45:32 +04:00
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
2011-09-18 17:42:50 +04:00
|
|
|
|
2010-05-31 16:48:00 +04:00
|
|
|
// .Torrent association
|
2011-09-18 17:42:50 +04:00
|
|
|
if (set) {
|
|
|
|
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
|
|
|
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
|
|
|
|
|
|
|
settings.setValue(".torrent/Default", "qBittorrent");
|
|
|
|
settings.setValue(".torrent/Content Type", "application/x-bittorrent");
|
|
|
|
settings.setValue("qBittorrent/shell/Default", "open");
|
|
|
|
settings.setValue("qBittorrent/shell/open/command/Default", command_str);
|
|
|
|
settings.setValue("qBittorrent/Content Type/Default", "application/x-bittorrent");
|
|
|
|
settings.setValue("qBittorrent/DefaultIcon/Default", icon_str);
|
|
|
|
} else {
|
|
|
|
settings.remove(".torrent/Default");
|
|
|
|
settings.remove(".torrent/Content Type");
|
|
|
|
settings.remove("qBittorrent/shell/Default");
|
|
|
|
settings.remove("qBittorrent/shell/open/command/Default");
|
|
|
|
settings.remove("qBittorrent/Content Type/Default");
|
|
|
|
settings.remove("qBittorrent/DefaultIcon/Default");
|
|
|
|
}
|
2010-05-31 01:45:55 +04:00
|
|
|
}
|
|
|
|
|
2011-09-18 17:42:50 +04:00
|
|
|
static void setMagnetLinkAssoc(bool set) {
|
|
|
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
|
|
|
|
|
|
|
// Magnet association
|
|
|
|
if (set) {
|
|
|
|
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
|
|
|
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
|
|
|
|
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
settings.remove("Magnet/Default");
|
|
|
|
settings.remove("Magnet/Content Type");
|
|
|
|
settings.remove("Magnet/URL Protocol");
|
|
|
|
settings.remove("Magnet/DefaultIcon/Default");
|
|
|
|
settings.remove("Magnet/shell/Default");
|
|
|
|
settings.remove("Magnet/shell/open/command/Default");
|
|
|
|
}
|
|
|
|
}
|
2010-05-30 21:51:40 +04:00
|
|
|
#endif
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
bool isTrackerEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/trackerEnabled"), false).toBool();
|
2010-10-16 01:55:56 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setTrackerEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/trackerEnabled"), enabled);
|
2010-10-16 01:55:56 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
int getTrackerPort() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/trackerPort"), 9000).toInt();
|
2010-10-16 01:55:56 +04:00
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:31 +03:00
|
|
|
void setTrackerPort(int port) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/trackerPort"), port);
|
2010-10-16 01:55:56 +04:00
|
|
|
}
|
|
|
|
|
2010-12-21 20:52:49 +03:00
|
|
|
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
2010-12-21 20:41:11 +03:00
|
|
|
bool isUpdateCheckEnabled() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/updateCheck"), true).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUpdateCheckEnabled(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/updateCheck"), enabled);
|
|
|
|
}
|
|
|
|
#endif
|
2011-01-16 18:29:44 +03:00
|
|
|
bool confirmTorrentDeletion() const {
|
|
|
|
return value(QString::fromUtf8("Preferences/Advanced/confirmTorrentDeletion"), true).toBool();
|
|
|
|
}
|
|
|
|
void setConfirmTorrentDeletion(bool enabled) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/confirmTorrentDeletion"), enabled);
|
|
|
|
}
|
2011-03-12 23:59:44 +03:00
|
|
|
|
2011-03-27 12:34:51 +04:00
|
|
|
TrayIcon::Style trayIconStyle() const {
|
|
|
|
return TrayIcon::Style(value(QString::fromUtf8("Preferences/Advanced/TrayIconStyle"), TrayIcon::NORMAL).toInt());
|
2011-03-12 23:59:44 +03:00
|
|
|
}
|
2011-03-27 12:34:51 +04:00
|
|
|
void setTrayIconStyle(TrayIcon::Style style) {
|
|
|
|
setValue(QString::fromUtf8("Preferences/Advanced/TrayIconStyle"), style);
|
2011-03-12 23:59:44 +03:00
|
|
|
}
|
2009-11-14 22:08:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PREFERENCES_H
|