2008-05-17 17:23:37 +04:00
|
|
|
/*
|
2009-04-05 22:48:45 +04:00
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
2012-05-26 23:58:53 +04:00
|
|
|
* Copyright (C) 2006-2012 Ishan Arora and Christophe Dumez
|
2008-05-17 17:23:37 +04:00
|
|
|
*
|
2009-04-05 22:48:45 +04:00
|
|
|
* 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.
|
2008-05-17 17:23:37 +04:00
|
|
|
*
|
2009-04-05 22:48:45 +04:00
|
|
|
* 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.
|
2008-05-17 17:23:37 +04:00
|
|
|
*
|
2009-04-05 22:48:45 +04:00
|
|
|
* 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
|
2008-05-17 17:23:37 +04:00
|
|
|
*/
|
|
|
|
|
2012-05-26 23:58:53 +04:00
|
|
|
#include "prefjson.h"
|
|
|
|
#include "preferences.h"
|
2010-10-09 18:06:35 +04:00
|
|
|
#include "qbtsession.h"
|
2010-03-18 22:25:16 +03:00
|
|
|
#include "scannedfoldersmodel.h"
|
2012-05-26 23:58:53 +04:00
|
|
|
|
|
|
|
#include <libtorrent/version.hpp>
|
2011-06-05 20:08:30 +04:00
|
|
|
#ifndef QT_NO_OPENSSL
|
|
|
|
#include <QSslCertificate>
|
|
|
|
#include <QSslKey>
|
|
|
|
#endif
|
2012-05-26 23:58:53 +04:00
|
|
|
#include <QTranslator>
|
2014-06-04 10:11:38 +04:00
|
|
|
#include "jsonutils.h"
|
2008-05-17 17:23:37 +04:00
|
|
|
|
2012-05-26 23:58:53 +04:00
|
|
|
prefjson::prefjson()
|
|
|
|
{
|
|
|
|
}
|
2010-11-23 00:55:32 +03:00
|
|
|
|
2014-06-04 10:11:38 +04:00
|
|
|
QByteArray prefjson::getPreferences()
|
2008-05-17 17:23:37 +04:00
|
|
|
{
|
2012-05-26 23:58:53 +04:00
|
|
|
const Preferences pref;
|
2014-06-04 10:11:38 +04:00
|
|
|
QVariantMap data;
|
2012-05-26 23:58:53 +04:00
|
|
|
// UI
|
2014-06-04 10:11:38 +04:00
|
|
|
data["locale"] = pref.getLocale();
|
2012-05-26 23:58:53 +04:00
|
|
|
// Downloads
|
2014-06-04 10:11:38 +04:00
|
|
|
data["save_path"] = fsutils::toNativePath(pref.getSavePath());
|
|
|
|
data["temp_path_enabled"] = pref.isTempPathEnabled();
|
|
|
|
data["temp_path"] = fsutils::toNativePath(pref.getTempPath());
|
|
|
|
QVariantList l;
|
2013-11-10 18:29:17 +04:00
|
|
|
foreach (const QString& s, pref.getScanDirs()) {
|
|
|
|
l << fsutils::toNativePath(s);
|
|
|
|
}
|
2014-06-04 10:11:38 +04:00
|
|
|
data["scan_dirs"] = l;
|
2012-05-26 23:58:53 +04:00
|
|
|
QVariantList var_list;
|
|
|
|
foreach (bool b, pref.getDownloadInScanDirs()) {
|
|
|
|
var_list << b;
|
|
|
|
}
|
2014-06-04 10:11:38 +04:00
|
|
|
data["download_in_scan_dirs"] = var_list;
|
|
|
|
data["export_dir_enabled"] = pref.isTorrentExportEnabled();
|
|
|
|
data["export_dir"] = fsutils::toNativePath(pref.getTorrentExportDir());
|
|
|
|
data["mail_notification_enabled"] = pref.isMailNotificationEnabled();
|
|
|
|
data["mail_notification_email"] = pref.getMailNotificationEmail();
|
|
|
|
data["mail_notification_smtp"] = pref.getMailNotificationSMTP();
|
|
|
|
data["mail_notification_ssl_enabled"] = pref.getMailNotificationSMTPSSL();
|
|
|
|
data["mail_notification_auth_enabled"] = pref.getMailNotificationSMTPAuth();
|
|
|
|
data["mail_notification_username"] = pref.getMailNotificationSMTPUsername();
|
|
|
|
data["mail_notification_password"] = pref.getMailNotificationSMTPPassword();
|
|
|
|
data["autorun_enabled"] = pref.isAutoRunEnabled();
|
|
|
|
data["autorun_program"] = fsutils::toNativePath(pref.getAutoRunProgram());
|
|
|
|
data["preallocate_all"] = pref.preAllocateAllFiles();
|
|
|
|
data["queueing_enabled"] = pref.isQueueingSystemEnabled();
|
|
|
|
data["max_active_downloads"] = pref.getMaxActiveDownloads();
|
|
|
|
data["max_active_torrents"] = pref.getMaxActiveTorrents();
|
|
|
|
data["max_active_uploads"] = pref.getMaxActiveUploads();
|
|
|
|
data["dont_count_slow_torrents"] = pref.ignoreSlowTorrentsForQueueing();
|
|
|
|
data["incomplete_files_ext"] = pref.useIncompleteFilesExtension();
|
2012-05-26 23:58:53 +04:00
|
|
|
// Connection
|
2014-06-04 10:11:38 +04:00
|
|
|
data["listen_port"] = pref.getSessionPort();
|
|
|
|
data["upnp"] = pref.isUPnPEnabled();
|
|
|
|
data["dl_limit"] = pref.getGlobalDownloadLimit();
|
|
|
|
data["up_limit"] = pref.getGlobalUploadLimit();
|
|
|
|
data["max_connec"] = pref.getMaxConnecs();
|
|
|
|
data["max_connec_per_torrent"] = pref.getMaxConnecsPerTorrent();
|
|
|
|
data["max_uploads_per_torrent"] = pref.getMaxUploadsPerTorrent();
|
|
|
|
data["enable_utp"] = pref.isuTPEnabled();
|
|
|
|
data["limit_utp_rate"] = pref.isuTPRateLimited();
|
|
|
|
data["limit_tcp_overhead"] = pref.includeOverheadInLimits();
|
|
|
|
data["alt_dl_limit"] = pref.getAltGlobalDownloadLimit();
|
|
|
|
data["alt_up_limit"] = pref.getAltGlobalUploadLimit();
|
|
|
|
data["scheduler_enabled"] = pref.isSchedulerEnabled();
|
2012-05-26 23:58:53 +04:00
|
|
|
const QTime start_time = pref.getSchedulerStartTime();
|
2014-06-04 10:11:38 +04:00
|
|
|
data["schedule_from_hour"] = start_time.hour();
|
|
|
|
data["schedule_from_min"] = start_time.minute();
|
2012-05-26 23:58:53 +04:00
|
|
|
const QTime end_time = pref.getSchedulerEndTime();
|
2014-06-04 10:11:38 +04:00
|
|
|
data["schedule_to_hour"] = end_time.hour();
|
|
|
|
data["schedule_to_min"] = end_time.minute();
|
|
|
|
data["scheduler_days"] = pref.getSchedulerDays();
|
2012-05-26 23:58:53 +04:00
|
|
|
// Bittorrent
|
2014-06-04 10:11:38 +04:00
|
|
|
data["dht"] = pref.isDHTEnabled();
|
|
|
|
data["pex"] = pref.isPeXEnabled();
|
|
|
|
data["lsd"] = pref.isLSDEnabled();
|
|
|
|
data["encryption"] = pref.getEncryptionSetting();
|
|
|
|
data["anonymous_mode"] = pref.isAnonymousModeEnabled();
|
2012-05-26 23:58:53 +04:00
|
|
|
// Proxy
|
2014-06-04 10:11:38 +04:00
|
|
|
data["proxy_type"] = pref.getProxyType();
|
|
|
|
data["proxy_ip"] = pref.getProxyIp();
|
|
|
|
data["proxy_port"] = pref.getProxyPort();
|
|
|
|
data["proxy_peer_connections"] = pref.proxyPeerConnections();
|
|
|
|
data["proxy_auth_enabled"] = pref.isProxyAuthEnabled();
|
|
|
|
data["proxy_username"] = pref.getProxyUsername();
|
|
|
|
data["proxy_password"] = pref.getProxyPassword();
|
2012-05-26 23:58:53 +04:00
|
|
|
// IP Filter
|
2014-06-04 10:11:38 +04:00
|
|
|
data["ip_filter_enabled"] = pref.isFilteringEnabled();
|
|
|
|
data["ip_filter_path"] = fsutils::toNativePath(pref.getFilter());
|
2012-05-26 23:58:53 +04:00
|
|
|
// Web UI
|
2014-06-04 10:11:38 +04:00
|
|
|
data["web_ui_port"] = pref.getWebUiPort();
|
|
|
|
data["web_ui_username"] = pref.getWebUiUsername();
|
|
|
|
data["web_ui_password"] = pref.getWebUiPassword();
|
|
|
|
data["bypass_local_auth"] = !pref.isWebUiLocalAuthEnabled();
|
|
|
|
data["use_https"] = pref.isWebUiHttpsEnabled();
|
|
|
|
data["ssl_key"] = QString::fromLatin1(pref.getWebUiHttpsKey());
|
|
|
|
data["ssl_cert"] = QString::fromLatin1(pref.getWebUiHttpsCertificate());
|
2012-05-26 23:58:53 +04:00
|
|
|
// DynDns
|
2014-06-04 10:11:38 +04:00
|
|
|
data["dyndns_enabled"] = pref.isDynDNSEnabled();
|
|
|
|
data["dyndns_service"] = pref.getDynDNSService();
|
|
|
|
data["dyndns_username"] = pref.getDynDNSUsername();
|
|
|
|
data["dyndns_password"] = pref.getDynDNSPassword();
|
|
|
|
data["dyndns_domain"] = pref.getDynDomainName();
|
2012-05-26 23:58:53 +04:00
|
|
|
|
2014-06-04 10:11:38 +04:00
|
|
|
return json::toJson(data);
|
2008-05-17 17:23:37 +04:00
|
|
|
}
|
|
|
|
|
2012-05-26 23:58:53 +04:00
|
|
|
void prefjson::setPreferences(const QString& json)
|
|
|
|
{
|
2014-06-04 10:11:38 +04:00
|
|
|
const QVariantMap m = json::fromJson(json).toMap();
|
2012-05-26 23:58:53 +04: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
|
|
|
// UI
|
2010-11-16 23:34:31 +03:00
|
|
|
Preferences pref;
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("locale")) {
|
2010-09-25 16:42:19 +04:00
|
|
|
QString locale = m["locale"].toString();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (pref.getLocale() != locale) {
|
2010-09-25 16:42:19 +04:00
|
|
|
QTranslator *translator = new QTranslator;
|
2012-02-20 21:56:07 +04:00
|
|
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
2010-09-25 16:42:19 +04:00
|
|
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
|
|
|
}else{
|
2013-10-20 20:31:01 +04:00
|
|
|
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
|
2010-09-25 16:42:19 +04:00
|
|
|
}
|
|
|
|
qApp->installTranslator(translator);
|
|
|
|
|
2011-09-29 21:47:51 +04:00
|
|
|
pref.setLocale(locale);
|
|
|
|
}
|
2010-09-25 16:42:19 +04: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
|
|
|
// Downloads
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("save_path"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setSavePath(m["save_path"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("temp_path_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setTempPathEnabled(m["temp_path_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("temp_path"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setTempPath(m["temp_path"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
|
2010-06-05 22:59:05 +04:00
|
|
|
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
|
|
|
|
QList<bool> download_at_path;
|
2012-02-20 21:30:53 +04:00
|
|
|
foreach (QVariant var, download_at_path_tmp) {
|
2010-06-05 22:59:05 +04:00
|
|
|
download_at_path << var.toBool();
|
|
|
|
}
|
2010-11-16 23:34:31 +03:00
|
|
|
QStringList old_folders = pref.getScanDirs();
|
2010-03-18 22:25:16 +03:00
|
|
|
QStringList new_folders = m["scan_dirs"].toStringList();
|
2012-02-20 21:30:53 +04:00
|
|
|
if (download_at_path.size() == new_folders.size()) {
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setScanDirs(new_folders);
|
|
|
|
pref.setDownloadInScanDirs(download_at_path);
|
2012-02-20 21:30:53 +04:00
|
|
|
foreach (const QString &old_folder, old_folders) {
|
2010-03-22 21:50:04 +03:00
|
|
|
// Update deleted folders
|
2012-02-20 21:30:53 +04:00
|
|
|
if (!new_folders.contains(old_folder)) {
|
2010-11-14 00:15:52 +03:00
|
|
|
QBtSession::instance()->getScanFoldersModel()->removePath(old_folder);
|
2010-03-22 21:50:04 +03:00
|
|
|
}
|
2010-03-18 22:25:16 +03:00
|
|
|
}
|
2010-03-22 21:50:04 +03:00
|
|
|
int i = 0;
|
2012-02-20 21:30:53 +04:00
|
|
|
foreach (const QString &new_folder, new_folders) {
|
2010-06-29 12:44:56 +04:00
|
|
|
qDebug("New watched folder: %s", qPrintable(new_folder));
|
2010-03-22 21:50:04 +03:00
|
|
|
// Update new folders
|
2013-11-10 18:29:17 +04:00
|
|
|
if (!old_folders.contains(fsutils::fromNativePath(new_folder))) {
|
2010-11-14 00:15:52 +03:00
|
|
|
QBtSession::instance()->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
|
2010-03-22 21:50:04 +03:00
|
|
|
}
|
|
|
|
++i;
|
2010-03-18 22:25:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("export_dir"))
|
2012-08-21 11:16:49 +04:00
|
|
|
pref.setTorrentExportDir(m["export_dir"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_email"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMailNotificationEmail(m["mail_notification_email"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_smtp"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMailNotificationSMTP(m["mail_notification_smtp"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_ssl_enabled"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setMailNotificationSMTPSSL(m["mail_notification_ssl_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_auth_enabled"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setMailNotificationSMTPAuth(m["mail_notification_auth_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_username"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setMailNotificationSMTPUsername(m["mail_notification_username"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("mail_notification_password"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setMailNotificationSMTPPassword(m["mail_notification_password"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("autorun_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setAutoRunEnabled(m["autorun_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("autorun_program"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setAutoRunProgram(m["autorun_program"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("preallocate_all"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.preAllocateAllFiles(m["preallocate_all"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("queueing_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setQueueingSystemEnabled(m["queueing_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("max_active_downloads"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxActiveDownloads(m["max_active_downloads"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("max_active_torrents"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxActiveTorrents(m["max_active_torrents"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("max_active_uploads"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxActiveUploads(m["max_active_uploads"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dont_count_slow_torrents"))
|
2011-09-18 20:34:29 +04:00
|
|
|
pref.setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("incomplete_files_ext"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.useIncompleteFilesExtension(m["incomplete_files_ext"].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
|
|
|
// Connection
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("listen_port"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setSessionPort(m["listen_port"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("upnp"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setUPnPEnabled(m["upnp"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dl_limit"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setGlobalDownloadLimit(m["dl_limit"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("up_limit"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setGlobalUploadLimit(m["up_limit"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("max_connec"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxConnecs(m["max_connec"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("max_connec_per_torrent"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("max_uploads_per_torrent"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("enable_utp"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setuTPEnabled(m["enable_utp"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("limit_utp_rate"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setuTPRateLimited(m["limit_utp_rate"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("limit_tcp_overhead"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.includeOverheadInLimits(m["limit_tcp_overhead"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("alt_dl_limit"))
|
2011-10-19 20:55:11 +04:00
|
|
|
pref.setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("alt_up_limit"))
|
2011-10-19 20:55:11 +04:00
|
|
|
pref.setAltGlobalUploadLimit(m["alt_up_limit"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("scheduler_enabled"))
|
2011-10-19 20:55:11 +04:00
|
|
|
pref.setSchedulerEnabled(m["scheduler_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) {
|
2011-10-19 20:55:11 +04:00
|
|
|
pref.setSchedulerStartTime(QTime(m["schedule_from_hour"].toInt(),
|
|
|
|
m["schedule_from_min"].toInt()));
|
|
|
|
}
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) {
|
2011-10-19 20:55:11 +04:00
|
|
|
pref.setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(),
|
|
|
|
m["schedule_to_min"].toInt()));
|
|
|
|
}
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("scheduler_days"))
|
2011-10-19 20:55:11 +04:00
|
|
|
pref.setSchedulerDays(scheduler_days(m["scheduler_days"].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
|
|
|
// Bittorrent
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dht"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setDHTEnabled(m["dht"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("pex"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setPeXEnabled(m["pex"].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
|
|
|
qDebug("Pex support: %d", (int)m["pex"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("lsd"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setLSDEnabled(m["lsd"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("encryption"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setEncryptionSetting(m["encryption"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("anonymous_mode"))
|
2011-09-20 21:15:47 +04:00
|
|
|
pref.enableAnonymousMode(m["anonymous_mode"].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
|
|
|
// Proxy
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_type"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyType(m["proxy_type"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_ip"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyIp(m["proxy_ip"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_port"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyPort(m["proxy_port"].toUInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_peer_connections"))
|
2011-05-01 16:00:23 +04:00
|
|
|
pref.setProxyPeerConnections(m["proxy_peer_connections"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_auth_enabled"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_username"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyUsername(m["proxy_username"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("proxy_password"))
|
2010-11-18 23:05:56 +03:00
|
|
|
pref.setProxyPassword(m["proxy_password"].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
|
|
|
// IP Filter
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("ip_filter_enabled"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setFilteringEnabled(m["ip_filter_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("ip_filter_path"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setFilter(m["ip_filter_path"].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
|
|
|
// Web UI
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("web_ui_port"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setWebUiPort(m["web_ui_port"].toUInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("web_ui_username"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setWebUiUsername(m["web_ui_username"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("web_ui_password"))
|
2010-11-16 23:34:31 +03:00
|
|
|
pref.setWebUiPassword(m["web_ui_password"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("bypass_local_auth"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("use_https"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setWebUiHttpsEnabled(m["use_https"].toBool());
|
|
|
|
#ifndef QT_NO_OPENSSL
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("ssl_key")) {
|
2013-09-21 11:59:58 +04:00
|
|
|
QByteArray raw_key = m["ssl_key"].toString().toLatin1();
|
2011-06-05 20:08:30 +04:00
|
|
|
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
|
|
|
|
pref.setWebUiHttpsKey(raw_key);
|
|
|
|
}
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("ssl_cert")) {
|
2013-09-21 11:59:58 +04:00
|
|
|
QByteArray raw_cert = m["ssl_cert"].toString().toLatin1();
|
2011-06-05 20:08:30 +04:00
|
|
|
if (!QSslCertificate(raw_cert).isNull())
|
|
|
|
pref.setWebUiHttpsCertificate(raw_cert);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// Dyndns
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dyndns_enabled"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setDynDNSEnabled(m["dyndns_enabled"].toBool());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dyndns_service"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setDynDNSService(m["dyndns_service"].toInt());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dyndns_username"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setDynDNSUsername(m["dyndns_username"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dyndns_password"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setDynDNSPassword(m["dyndns_password"].toString());
|
2012-02-20 21:30:53 +04:00
|
|
|
if (m.contains("dyndns_domain"))
|
2011-06-05 20:08:30 +04:00
|
|
|
pref.setDynDomainName(m["dyndns_domain"].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
|
|
|
// Reload preferences
|
2010-11-14 00:15:52 +03:00
|
|
|
QBtSession::instance()->configureSession();
|
* 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
|
|
|
}
|