mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
bc97208516
commit
ff10eafcbc
@ -48,293 +48,293 @@ prefjson::prefjson()
|
|||||||
|
|
||||||
QByteArray prefjson::getPreferences()
|
QByteArray prefjson::getPreferences()
|
||||||
{
|
{
|
||||||
const Preferences* const pref = Preferences::instance();
|
const Preferences* const pref = Preferences::instance();
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
// UI
|
// UI
|
||||||
data["locale"] = pref->getLocale();
|
data["locale"] = pref->getLocale();
|
||||||
// Downloads
|
// Downloads
|
||||||
data["save_path"] = Utils::Fs::toNativePath(pref->getSavePath());
|
data["save_path"] = Utils::Fs::toNativePath(pref->getSavePath());
|
||||||
data["temp_path_enabled"] = pref->isTempPathEnabled();
|
data["temp_path_enabled"] = pref->isTempPathEnabled();
|
||||||
data["temp_path"] = Utils::Fs::toNativePath(pref->getTempPath());
|
data["temp_path"] = Utils::Fs::toNativePath(pref->getTempPath());
|
||||||
QVariantList l;
|
QVariantList l;
|
||||||
foreach (const QString& s, pref->getScanDirs()) {
|
foreach (const QString& s, pref->getScanDirs()) {
|
||||||
l << Utils::Fs::toNativePath(s);
|
l << Utils::Fs::toNativePath(s);
|
||||||
}
|
}
|
||||||
data["scan_dirs"] = l;
|
data["scan_dirs"] = l;
|
||||||
QVariantList var_list;
|
QVariantList var_list;
|
||||||
foreach (bool b, pref->getDownloadInScanDirs()) {
|
foreach (bool b, pref->getDownloadInScanDirs()) {
|
||||||
var_list << b;
|
var_list << b;
|
||||||
}
|
}
|
||||||
data["download_in_scan_dirs"] = var_list;
|
data["download_in_scan_dirs"] = var_list;
|
||||||
data["export_dir_enabled"] = pref->isTorrentExportEnabled();
|
data["export_dir_enabled"] = pref->isTorrentExportEnabled();
|
||||||
data["export_dir"] = Utils::Fs::toNativePath(pref->getTorrentExportDir());
|
data["export_dir"] = Utils::Fs::toNativePath(pref->getTorrentExportDir());
|
||||||
data["mail_notification_enabled"] = pref->isMailNotificationEnabled();
|
data["mail_notification_enabled"] = pref->isMailNotificationEnabled();
|
||||||
data["mail_notification_email"] = pref->getMailNotificationEmail();
|
data["mail_notification_email"] = pref->getMailNotificationEmail();
|
||||||
data["mail_notification_smtp"] = pref->getMailNotificationSMTP();
|
data["mail_notification_smtp"] = pref->getMailNotificationSMTP();
|
||||||
data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL();
|
data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL();
|
||||||
data["mail_notification_auth_enabled"] = pref->getMailNotificationSMTPAuth();
|
data["mail_notification_auth_enabled"] = pref->getMailNotificationSMTPAuth();
|
||||||
data["mail_notification_username"] = pref->getMailNotificationSMTPUsername();
|
data["mail_notification_username"] = pref->getMailNotificationSMTPUsername();
|
||||||
data["mail_notification_password"] = pref->getMailNotificationSMTPPassword();
|
data["mail_notification_password"] = pref->getMailNotificationSMTPPassword();
|
||||||
data["autorun_enabled"] = pref->isAutoRunEnabled();
|
data["autorun_enabled"] = pref->isAutoRunEnabled();
|
||||||
data["autorun_program"] = Utils::Fs::toNativePath(pref->getAutoRunProgram());
|
data["autorun_program"] = Utils::Fs::toNativePath(pref->getAutoRunProgram());
|
||||||
data["preallocate_all"] = pref->preAllocateAllFiles();
|
data["preallocate_all"] = pref->preAllocateAllFiles();
|
||||||
data["queueing_enabled"] = pref->isQueueingSystemEnabled();
|
data["queueing_enabled"] = pref->isQueueingSystemEnabled();
|
||||||
data["max_active_downloads"] = pref->getMaxActiveDownloads();
|
data["max_active_downloads"] = pref->getMaxActiveDownloads();
|
||||||
data["max_active_torrents"] = pref->getMaxActiveTorrents();
|
data["max_active_torrents"] = pref->getMaxActiveTorrents();
|
||||||
data["max_active_uploads"] = pref->getMaxActiveUploads();
|
data["max_active_uploads"] = pref->getMaxActiveUploads();
|
||||||
data["dont_count_slow_torrents"] = pref->ignoreSlowTorrentsForQueueing();
|
data["dont_count_slow_torrents"] = pref->ignoreSlowTorrentsForQueueing();
|
||||||
data["incomplete_files_ext"] = pref->useIncompleteFilesExtension();
|
data["incomplete_files_ext"] = pref->useIncompleteFilesExtension();
|
||||||
// Connection
|
// Connection
|
||||||
data["listen_port"] = pref->getSessionPort();
|
data["listen_port"] = pref->getSessionPort();
|
||||||
data["upnp"] = pref->isUPnPEnabled();
|
data["upnp"] = pref->isUPnPEnabled();
|
||||||
data["dl_limit"] = pref->getGlobalDownloadLimit();
|
data["dl_limit"] = pref->getGlobalDownloadLimit();
|
||||||
data["up_limit"] = pref->getGlobalUploadLimit();
|
data["up_limit"] = pref->getGlobalUploadLimit();
|
||||||
data["max_connec"] = pref->getMaxConnecs();
|
data["max_connec"] = pref->getMaxConnecs();
|
||||||
data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent();
|
data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent();
|
||||||
data["max_uploads"] = pref->getMaxUploads();
|
data["max_uploads"] = pref->getMaxUploads();
|
||||||
data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent();
|
data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent();
|
||||||
data["enable_utp"] = pref->isuTPEnabled();
|
data["enable_utp"] = pref->isuTPEnabled();
|
||||||
data["limit_utp_rate"] = pref->isuTPRateLimited();
|
data["limit_utp_rate"] = pref->isuTPRateLimited();
|
||||||
data["limit_tcp_overhead"] = pref->includeOverheadInLimits();
|
data["limit_tcp_overhead"] = pref->includeOverheadInLimits();
|
||||||
data["alt_dl_limit"] = pref->getAltGlobalDownloadLimit();
|
data["alt_dl_limit"] = pref->getAltGlobalDownloadLimit();
|
||||||
data["alt_up_limit"] = pref->getAltGlobalUploadLimit();
|
data["alt_up_limit"] = pref->getAltGlobalUploadLimit();
|
||||||
data["scheduler_enabled"] = pref->isSchedulerEnabled();
|
data["scheduler_enabled"] = pref->isSchedulerEnabled();
|
||||||
const QTime start_time = pref->getSchedulerStartTime();
|
const QTime start_time = pref->getSchedulerStartTime();
|
||||||
data["schedule_from_hour"] = start_time.hour();
|
data["schedule_from_hour"] = start_time.hour();
|
||||||
data["schedule_from_min"] = start_time.minute();
|
data["schedule_from_min"] = start_time.minute();
|
||||||
const QTime end_time = pref->getSchedulerEndTime();
|
const QTime end_time = pref->getSchedulerEndTime();
|
||||||
data["schedule_to_hour"] = end_time.hour();
|
data["schedule_to_hour"] = end_time.hour();
|
||||||
data["schedule_to_min"] = end_time.minute();
|
data["schedule_to_min"] = end_time.minute();
|
||||||
data["scheduler_days"] = pref->getSchedulerDays();
|
data["scheduler_days"] = pref->getSchedulerDays();
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
data["dht"] = pref->isDHTEnabled();
|
data["dht"] = pref->isDHTEnabled();
|
||||||
data["pex"] = pref->isPeXEnabled();
|
data["pex"] = pref->isPeXEnabled();
|
||||||
data["lsd"] = pref->isLSDEnabled();
|
data["lsd"] = pref->isLSDEnabled();
|
||||||
data["encryption"] = pref->getEncryptionSetting();
|
data["encryption"] = pref->getEncryptionSetting();
|
||||||
data["anonymous_mode"] = pref->isAnonymousModeEnabled();
|
data["anonymous_mode"] = pref->isAnonymousModeEnabled();
|
||||||
// Proxy
|
// Proxy
|
||||||
data["proxy_type"] = pref->getProxyType();
|
data["proxy_type"] = pref->getProxyType();
|
||||||
data["proxy_ip"] = pref->getProxyIp();
|
data["proxy_ip"] = pref->getProxyIp();
|
||||||
data["proxy_port"] = pref->getProxyPort();
|
data["proxy_port"] = pref->getProxyPort();
|
||||||
data["proxy_peer_connections"] = pref->proxyPeerConnections();
|
data["proxy_peer_connections"] = pref->proxyPeerConnections();
|
||||||
data["proxy_auth_enabled"] = pref->isProxyAuthEnabled();
|
data["proxy_auth_enabled"] = pref->isProxyAuthEnabled();
|
||||||
data["proxy_username"] = pref->getProxyUsername();
|
data["proxy_username"] = pref->getProxyUsername();
|
||||||
data["proxy_password"] = pref->getProxyPassword();
|
data["proxy_password"] = pref->getProxyPassword();
|
||||||
// IP Filter
|
// IP Filter
|
||||||
data["ip_filter_enabled"] = pref->isFilteringEnabled();
|
data["ip_filter_enabled"] = pref->isFilteringEnabled();
|
||||||
data["ip_filter_path"] = Utils::Fs::toNativePath(pref->getFilter());
|
data["ip_filter_path"] = Utils::Fs::toNativePath(pref->getFilter());
|
||||||
// Web UI
|
// Web UI
|
||||||
data["web_ui_port"] = pref->getWebUiPort();
|
data["web_ui_port"] = pref->getWebUiPort();
|
||||||
data["web_ui_username"] = pref->getWebUiUsername();
|
data["web_ui_username"] = pref->getWebUiUsername();
|
||||||
data["web_ui_password"] = pref->getWebUiPassword();
|
data["web_ui_password"] = pref->getWebUiPassword();
|
||||||
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
|
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
|
||||||
data["use_https"] = pref->isWebUiHttpsEnabled();
|
data["use_https"] = pref->isWebUiHttpsEnabled();
|
||||||
data["ssl_key"] = QString::fromLatin1(pref->getWebUiHttpsKey());
|
data["ssl_key"] = QString::fromLatin1(pref->getWebUiHttpsKey());
|
||||||
data["ssl_cert"] = QString::fromLatin1(pref->getWebUiHttpsCertificate());
|
data["ssl_cert"] = QString::fromLatin1(pref->getWebUiHttpsCertificate());
|
||||||
// DynDns
|
// DynDns
|
||||||
data["dyndns_enabled"] = pref->isDynDNSEnabled();
|
data["dyndns_enabled"] = pref->isDynDNSEnabled();
|
||||||
data["dyndns_service"] = pref->getDynDNSService();
|
data["dyndns_service"] = pref->getDynDNSService();
|
||||||
data["dyndns_username"] = pref->getDynDNSUsername();
|
data["dyndns_username"] = pref->getDynDNSUsername();
|
||||||
data["dyndns_password"] = pref->getDynDNSPassword();
|
data["dyndns_password"] = pref->getDynDNSPassword();
|
||||||
data["dyndns_domain"] = pref->getDynDomainName();
|
data["dyndns_domain"] = pref->getDynDomainName();
|
||||||
|
|
||||||
return json::toJson(data);
|
return json::toJson(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prefjson::setPreferences(const QString& json)
|
void prefjson::setPreferences(const QString& json)
|
||||||
{
|
{
|
||||||
const QVariantMap m = json::fromJson(json).toMap();
|
const QVariantMap m = json::fromJson(json).toMap();
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
if (m.contains("locale")) {
|
if (m.contains("locale")) {
|
||||||
QString locale = m["locale"].toString();
|
QString locale = m["locale"].toString();
|
||||||
if (pref->getLocale() != locale) {
|
if (pref->getLocale() != locale) {
|
||||||
QTranslator *translator = new QTranslator;
|
QTranslator *translator = new QTranslator;
|
||||||
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
}else{
|
||||||
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
|
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
|
||||||
}
|
}
|
||||||
qApp->installTranslator(translator);
|
qApp->installTranslator(translator);
|
||||||
|
|
||||||
pref->setLocale(locale);
|
pref->setLocale(locale);
|
||||||
}
|
|
||||||
}
|
|
||||||
// Downloads
|
|
||||||
if (m.contains("save_path"))
|
|
||||||
pref->setSavePath(m["save_path"].toString());
|
|
||||||
if (m.contains("temp_path_enabled"))
|
|
||||||
pref->setTempPathEnabled(m["temp_path_enabled"].toBool());
|
|
||||||
if (m.contains("temp_path"))
|
|
||||||
pref->setTempPath(m["temp_path"].toString());
|
|
||||||
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
|
|
||||||
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
|
|
||||||
QList<bool> download_at_path;
|
|
||||||
foreach (QVariant var, download_at_path_tmp) {
|
|
||||||
download_at_path << var.toBool();
|
|
||||||
}
|
|
||||||
QStringList old_folders = pref->getScanDirs();
|
|
||||||
QStringList new_folders = m["scan_dirs"].toStringList();
|
|
||||||
if (download_at_path.size() == new_folders.size()) {
|
|
||||||
pref->setScanDirs(new_folders);
|
|
||||||
pref->setDownloadInScanDirs(download_at_path);
|
|
||||||
foreach (const QString &old_folder, old_folders) {
|
|
||||||
// Update deleted folders
|
|
||||||
if (!new_folders.contains(old_folder)) {
|
|
||||||
ScanFoldersModel::instance()->removePath(old_folder);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
foreach (const QString &new_folder, new_folders) {
|
|
||||||
qDebug("New watched folder: %s", qPrintable(new_folder));
|
|
||||||
// Update new folders
|
|
||||||
if (!old_folders.contains(Utils::Fs::fromNativePath(new_folder))) {
|
|
||||||
ScanFoldersModel::instance()->addPath(new_folder, download_at_path.at(i));
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
// Downloads
|
||||||
if (m.contains("export_dir"))
|
if (m.contains("save_path"))
|
||||||
pref->setTorrentExportDir(m["export_dir"].toString());
|
pref->setSavePath(m["save_path"].toString());
|
||||||
if (m.contains("mail_notification_enabled"))
|
if (m.contains("temp_path_enabled"))
|
||||||
pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
|
pref->setTempPathEnabled(m["temp_path_enabled"].toBool());
|
||||||
if (m.contains("mail_notification_email"))
|
if (m.contains("temp_path"))
|
||||||
pref->setMailNotificationEmail(m["mail_notification_email"].toString());
|
pref->setTempPath(m["temp_path"].toString());
|
||||||
if (m.contains("mail_notification_smtp"))
|
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
|
||||||
pref->setMailNotificationSMTP(m["mail_notification_smtp"].toString());
|
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
|
||||||
if (m.contains("mail_notification_ssl_enabled"))
|
QList<bool> download_at_path;
|
||||||
pref->setMailNotificationSMTPSSL(m["mail_notification_ssl_enabled"].toBool());
|
foreach (QVariant var, download_at_path_tmp) {
|
||||||
if (m.contains("mail_notification_auth_enabled"))
|
download_at_path << var.toBool();
|
||||||
pref->setMailNotificationSMTPAuth(m["mail_notification_auth_enabled"].toBool());
|
}
|
||||||
if (m.contains("mail_notification_username"))
|
QStringList old_folders = pref->getScanDirs();
|
||||||
pref->setMailNotificationSMTPUsername(m["mail_notification_username"].toString());
|
QStringList new_folders = m["scan_dirs"].toStringList();
|
||||||
if (m.contains("mail_notification_password"))
|
if (download_at_path.size() == new_folders.size()) {
|
||||||
pref->setMailNotificationSMTPPassword(m["mail_notification_password"].toString());
|
pref->setScanDirs(new_folders);
|
||||||
if (m.contains("autorun_enabled"))
|
pref->setDownloadInScanDirs(download_at_path);
|
||||||
pref->setAutoRunEnabled(m["autorun_enabled"].toBool());
|
foreach (const QString &old_folder, old_folders) {
|
||||||
if (m.contains("autorun_program"))
|
// Update deleted folders
|
||||||
pref->setAutoRunProgram(m["autorun_program"].toString());
|
if (!new_folders.contains(old_folder)) {
|
||||||
if (m.contains("preallocate_all"))
|
ScanFoldersModel::instance()->removePath(old_folder);
|
||||||
pref->preAllocateAllFiles(m["preallocate_all"].toBool());
|
}
|
||||||
if (m.contains("queueing_enabled"))
|
}
|
||||||
pref->setQueueingSystemEnabled(m["queueing_enabled"].toBool());
|
int i = 0;
|
||||||
if (m.contains("max_active_downloads"))
|
foreach (const QString &new_folder, new_folders) {
|
||||||
pref->setMaxActiveDownloads(m["max_active_downloads"].toInt());
|
qDebug("New watched folder: %s", qPrintable(new_folder));
|
||||||
if (m.contains("max_active_torrents"))
|
// Update new folders
|
||||||
pref->setMaxActiveTorrents(m["max_active_torrents"].toInt());
|
if (!old_folders.contains(Utils::Fs::fromNativePath(new_folder))) {
|
||||||
if (m.contains("max_active_uploads"))
|
ScanFoldersModel::instance()->addPath(new_folder, download_at_path.at(i));
|
||||||
pref->setMaxActiveUploads(m["max_active_uploads"].toInt());
|
}
|
||||||
if (m.contains("dont_count_slow_torrents"))
|
++i;
|
||||||
pref->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
|
}
|
||||||
if (m.contains("incomplete_files_ext"))
|
}
|
||||||
pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
|
}
|
||||||
// Connection
|
if (m.contains("export_dir"))
|
||||||
if (m.contains("listen_port"))
|
pref->setTorrentExportDir(m["export_dir"].toString());
|
||||||
pref->setSessionPort(m["listen_port"].toInt());
|
if (m.contains("mail_notification_enabled"))
|
||||||
if (m.contains("upnp"))
|
pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
|
||||||
pref->setUPnPEnabled(m["upnp"].toBool());
|
if (m.contains("mail_notification_email"))
|
||||||
if (m.contains("dl_limit"))
|
pref->setMailNotificationEmail(m["mail_notification_email"].toString());
|
||||||
pref->setGlobalDownloadLimit(m["dl_limit"].toInt());
|
if (m.contains("mail_notification_smtp"))
|
||||||
if (m.contains("up_limit"))
|
pref->setMailNotificationSMTP(m["mail_notification_smtp"].toString());
|
||||||
pref->setGlobalUploadLimit(m["up_limit"].toInt());
|
if (m.contains("mail_notification_ssl_enabled"))
|
||||||
if (m.contains("max_connec"))
|
pref->setMailNotificationSMTPSSL(m["mail_notification_ssl_enabled"].toBool());
|
||||||
pref->setMaxConnecs(m["max_connec"].toInt());
|
if (m.contains("mail_notification_auth_enabled"))
|
||||||
if (m.contains("max_connec_per_torrent"))
|
pref->setMailNotificationSMTPAuth(m["mail_notification_auth_enabled"].toBool());
|
||||||
pref->setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
|
if (m.contains("mail_notification_username"))
|
||||||
if (m.contains("max_uploads"))
|
pref->setMailNotificationSMTPUsername(m["mail_notification_username"].toString());
|
||||||
pref->setMaxUploads(m["max_uploads"].toInt());
|
if (m.contains("mail_notification_password"))
|
||||||
if (m.contains("max_uploads_per_torrent"))
|
pref->setMailNotificationSMTPPassword(m["mail_notification_password"].toString());
|
||||||
pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
|
if (m.contains("autorun_enabled"))
|
||||||
if (m.contains("enable_utp"))
|
pref->setAutoRunEnabled(m["autorun_enabled"].toBool());
|
||||||
pref->setuTPEnabled(m["enable_utp"].toBool());
|
if (m.contains("autorun_program"))
|
||||||
if (m.contains("limit_utp_rate"))
|
pref->setAutoRunProgram(m["autorun_program"].toString());
|
||||||
pref->setuTPRateLimited(m["limit_utp_rate"].toBool());
|
if (m.contains("preallocate_all"))
|
||||||
if (m.contains("limit_tcp_overhead"))
|
pref->preAllocateAllFiles(m["preallocate_all"].toBool());
|
||||||
pref->includeOverheadInLimits(m["limit_tcp_overhead"].toBool());
|
if (m.contains("queueing_enabled"))
|
||||||
if (m.contains("alt_dl_limit"))
|
pref->setQueueingSystemEnabled(m["queueing_enabled"].toBool());
|
||||||
pref->setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt());
|
if (m.contains("max_active_downloads"))
|
||||||
if (m.contains("alt_up_limit"))
|
pref->setMaxActiveDownloads(m["max_active_downloads"].toInt());
|
||||||
pref->setAltGlobalUploadLimit(m["alt_up_limit"].toInt());
|
if (m.contains("max_active_torrents"))
|
||||||
if (m.contains("scheduler_enabled"))
|
pref->setMaxActiveTorrents(m["max_active_torrents"].toInt());
|
||||||
pref->setSchedulerEnabled(m["scheduler_enabled"].toBool());
|
if (m.contains("max_active_uploads"))
|
||||||
if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) {
|
pref->setMaxActiveUploads(m["max_active_uploads"].toInt());
|
||||||
pref->setSchedulerStartTime(QTime(m["schedule_from_hour"].toInt(),
|
if (m.contains("dont_count_slow_torrents"))
|
||||||
m["schedule_from_min"].toInt()));
|
pref->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
|
||||||
}
|
if (m.contains("incomplete_files_ext"))
|
||||||
if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) {
|
pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
|
||||||
pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(),
|
// Connection
|
||||||
m["schedule_to_min"].toInt()));
|
if (m.contains("listen_port"))
|
||||||
}
|
pref->setSessionPort(m["listen_port"].toInt());
|
||||||
if (m.contains("scheduler_days"))
|
if (m.contains("upnp"))
|
||||||
pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt()));
|
pref->setUPnPEnabled(m["upnp"].toBool());
|
||||||
// Bittorrent
|
if (m.contains("dl_limit"))
|
||||||
if (m.contains("dht"))
|
pref->setGlobalDownloadLimit(m["dl_limit"].toInt());
|
||||||
pref->setDHTEnabled(m["dht"].toBool());
|
if (m.contains("up_limit"))
|
||||||
if (m.contains("pex"))
|
pref->setGlobalUploadLimit(m["up_limit"].toInt());
|
||||||
pref->setPeXEnabled(m["pex"].toBool());
|
if (m.contains("max_connec"))
|
||||||
qDebug("Pex support: %d", (int)m["pex"].toBool());
|
pref->setMaxConnecs(m["max_connec"].toInt());
|
||||||
if (m.contains("lsd"))
|
if (m.contains("max_connec_per_torrent"))
|
||||||
pref->setLSDEnabled(m["lsd"].toBool());
|
pref->setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
|
||||||
if (m.contains("encryption"))
|
if (m.contains("max_uploads"))
|
||||||
pref->setEncryptionSetting(m["encryption"].toInt());
|
pref->setMaxUploads(m["max_uploads"].toInt());
|
||||||
if (m.contains("anonymous_mode"))
|
if (m.contains("max_uploads_per_torrent"))
|
||||||
pref->enableAnonymousMode(m["anonymous_mode"].toBool());
|
pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
|
||||||
// Proxy
|
if (m.contains("enable_utp"))
|
||||||
if (m.contains("proxy_type"))
|
pref->setuTPEnabled(m["enable_utp"].toBool());
|
||||||
pref->setProxyType(m["proxy_type"].toInt());
|
if (m.contains("limit_utp_rate"))
|
||||||
if (m.contains("proxy_ip"))
|
pref->setuTPRateLimited(m["limit_utp_rate"].toBool());
|
||||||
pref->setProxyIp(m["proxy_ip"].toString());
|
if (m.contains("limit_tcp_overhead"))
|
||||||
if (m.contains("proxy_port"))
|
pref->includeOverheadInLimits(m["limit_tcp_overhead"].toBool());
|
||||||
pref->setProxyPort(m["proxy_port"].toUInt());
|
if (m.contains("alt_dl_limit"))
|
||||||
if (m.contains("proxy_peer_connections"))
|
pref->setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt());
|
||||||
pref->setProxyPeerConnections(m["proxy_peer_connections"].toBool());
|
if (m.contains("alt_up_limit"))
|
||||||
if (m.contains("proxy_auth_enabled"))
|
pref->setAltGlobalUploadLimit(m["alt_up_limit"].toInt());
|
||||||
pref->setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
|
if (m.contains("scheduler_enabled"))
|
||||||
if (m.contains("proxy_username"))
|
pref->setSchedulerEnabled(m["scheduler_enabled"].toBool());
|
||||||
pref->setProxyUsername(m["proxy_username"].toString());
|
if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) {
|
||||||
if (m.contains("proxy_password"))
|
pref->setSchedulerStartTime(QTime(m["schedule_from_hour"].toInt(),
|
||||||
pref->setProxyPassword(m["proxy_password"].toString());
|
m["schedule_from_min"].toInt()));
|
||||||
// IP Filter
|
}
|
||||||
if (m.contains("ip_filter_enabled"))
|
if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) {
|
||||||
pref->setFilteringEnabled(m["ip_filter_enabled"].toBool());
|
pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(),
|
||||||
if (m.contains("ip_filter_path"))
|
m["schedule_to_min"].toInt()));
|
||||||
pref->setFilter(m["ip_filter_path"].toString());
|
}
|
||||||
// Web UI
|
if (m.contains("scheduler_days"))
|
||||||
if (m.contains("web_ui_port"))
|
pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt()));
|
||||||
pref->setWebUiPort(m["web_ui_port"].toUInt());
|
// Bittorrent
|
||||||
if (m.contains("web_ui_username"))
|
if (m.contains("dht"))
|
||||||
pref->setWebUiUsername(m["web_ui_username"].toString());
|
pref->setDHTEnabled(m["dht"].toBool());
|
||||||
if (m.contains("web_ui_password"))
|
if (m.contains("pex"))
|
||||||
pref->setWebUiPassword(m["web_ui_password"].toString());
|
pref->setPeXEnabled(m["pex"].toBool());
|
||||||
if (m.contains("bypass_local_auth"))
|
qDebug("Pex support: %d", (int)m["pex"].toBool());
|
||||||
pref->setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool());
|
if (m.contains("lsd"))
|
||||||
if (m.contains("use_https"))
|
pref->setLSDEnabled(m["lsd"].toBool());
|
||||||
pref->setWebUiHttpsEnabled(m["use_https"].toBool());
|
if (m.contains("encryption"))
|
||||||
|
pref->setEncryptionSetting(m["encryption"].toInt());
|
||||||
|
if (m.contains("anonymous_mode"))
|
||||||
|
pref->enableAnonymousMode(m["anonymous_mode"].toBool());
|
||||||
|
// Proxy
|
||||||
|
if (m.contains("proxy_type"))
|
||||||
|
pref->setProxyType(m["proxy_type"].toInt());
|
||||||
|
if (m.contains("proxy_ip"))
|
||||||
|
pref->setProxyIp(m["proxy_ip"].toString());
|
||||||
|
if (m.contains("proxy_port"))
|
||||||
|
pref->setProxyPort(m["proxy_port"].toUInt());
|
||||||
|
if (m.contains("proxy_peer_connections"))
|
||||||
|
pref->setProxyPeerConnections(m["proxy_peer_connections"].toBool());
|
||||||
|
if (m.contains("proxy_auth_enabled"))
|
||||||
|
pref->setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
|
||||||
|
if (m.contains("proxy_username"))
|
||||||
|
pref->setProxyUsername(m["proxy_username"].toString());
|
||||||
|
if (m.contains("proxy_password"))
|
||||||
|
pref->setProxyPassword(m["proxy_password"].toString());
|
||||||
|
// IP Filter
|
||||||
|
if (m.contains("ip_filter_enabled"))
|
||||||
|
pref->setFilteringEnabled(m["ip_filter_enabled"].toBool());
|
||||||
|
if (m.contains("ip_filter_path"))
|
||||||
|
pref->setFilter(m["ip_filter_path"].toString());
|
||||||
|
// Web UI
|
||||||
|
if (m.contains("web_ui_port"))
|
||||||
|
pref->setWebUiPort(m["web_ui_port"].toUInt());
|
||||||
|
if (m.contains("web_ui_username"))
|
||||||
|
pref->setWebUiUsername(m["web_ui_username"].toString());
|
||||||
|
if (m.contains("web_ui_password"))
|
||||||
|
pref->setWebUiPassword(m["web_ui_password"].toString());
|
||||||
|
if (m.contains("bypass_local_auth"))
|
||||||
|
pref->setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool());
|
||||||
|
if (m.contains("use_https"))
|
||||||
|
pref->setWebUiHttpsEnabled(m["use_https"].toBool());
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
if (m.contains("ssl_key")) {
|
if (m.contains("ssl_key")) {
|
||||||
QByteArray raw_key = m["ssl_key"].toString().toLatin1();
|
QByteArray raw_key = m["ssl_key"].toString().toLatin1();
|
||||||
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
|
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
|
||||||
pref->setWebUiHttpsKey(raw_key);
|
pref->setWebUiHttpsKey(raw_key);
|
||||||
}
|
}
|
||||||
if (m.contains("ssl_cert")) {
|
if (m.contains("ssl_cert")) {
|
||||||
QByteArray raw_cert = m["ssl_cert"].toString().toLatin1();
|
QByteArray raw_cert = m["ssl_cert"].toString().toLatin1();
|
||||||
if (!QSslCertificate(raw_cert).isNull())
|
if (!QSslCertificate(raw_cert).isNull())
|
||||||
pref->setWebUiHttpsCertificate(raw_cert);
|
pref->setWebUiHttpsCertificate(raw_cert);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Dyndns
|
// Dyndns
|
||||||
if (m.contains("dyndns_enabled"))
|
if (m.contains("dyndns_enabled"))
|
||||||
pref->setDynDNSEnabled(m["dyndns_enabled"].toBool());
|
pref->setDynDNSEnabled(m["dyndns_enabled"].toBool());
|
||||||
if (m.contains("dyndns_service"))
|
if (m.contains("dyndns_service"))
|
||||||
pref->setDynDNSService(m["dyndns_service"].toInt());
|
pref->setDynDNSService(m["dyndns_service"].toInt());
|
||||||
if (m.contains("dyndns_username"))
|
if (m.contains("dyndns_username"))
|
||||||
pref->setDynDNSUsername(m["dyndns_username"].toString());
|
pref->setDynDNSUsername(m["dyndns_username"].toString());
|
||||||
if (m.contains("dyndns_password"))
|
if (m.contains("dyndns_password"))
|
||||||
pref->setDynDNSPassword(m["dyndns_password"].toString());
|
pref->setDynDNSPassword(m["dyndns_password"].toString());
|
||||||
if (m.contains("dyndns_domain"))
|
if (m.contains("dyndns_domain"))
|
||||||
pref->setDynDomainName(m["dyndns_domain"].toString());
|
pref->setDynDomainName(m["dyndns_domain"].toString());
|
||||||
// Save preferences
|
// Save preferences
|
||||||
pref->apply();
|
pref->apply();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user