mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-11 12:51:03 +00:00
Further rewriting of the JSON-related code
This commit is contained in:
parent
122655758d
commit
a0d21ead18
@ -103,6 +103,10 @@ static const char KEY_FILE_PROGRESS[] = "progress";
|
||||
static const char KEY_FILE_PRIORITY[] = "priority";
|
||||
static const char KEY_FILE_IS_SEED[] = "is_seed";
|
||||
|
||||
// TransferInfo keys
|
||||
static const char KEY_TRANSFER_DLSPEED[] = "dl_info";
|
||||
static const char KEY_TRANSFER_UPSPEED[] = "up_info";
|
||||
|
||||
static JsonDict toJson(const QTorrentHandle& h)
|
||||
{
|
||||
JsonDict ret;
|
||||
@ -343,3 +347,20 @@ QString btjson::getFilesForTorrent(const QString& hash)
|
||||
|
||||
return file_list.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the global transfer information in JSON format.
|
||||
*
|
||||
* The return value is a JSON-formatted dictionary.
|
||||
* The dictionary keys are:
|
||||
* - "dl_info": Global download info
|
||||
* - "up_info": Global upload info
|
||||
*/
|
||||
QString btjson::getTransferInfo()
|
||||
{
|
||||
CACHED_VARIABLE(JsonDict, info, CACHE_DURATION_MS);
|
||||
session_status sessionStatus = QBtSession::instance()->getSessionStatus();
|
||||
info.add(KEY_TRANSFER_DLSPEED, tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download)));
|
||||
info.add(KEY_TRANSFER_UPSPEED, tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload)));
|
||||
return info.toString();
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
static QString getTrackersForTorrent(const QString& hash);
|
||||
static QString getPropertiesForTorrent(const QString& hash);
|
||||
static QString getFilesForTorrent(const QString& hash);
|
||||
static QString getTransferInfo();
|
||||
}; // class btjson
|
||||
|
||||
#endif // BTJSON_H
|
||||
|
@ -31,10 +31,9 @@
|
||||
|
||||
#include "httpconnection.h"
|
||||
#include "httpserver.h"
|
||||
#include "eventmanager.h"
|
||||
#include "preferences.h"
|
||||
#include "json.h"
|
||||
#include "btjson.h"
|
||||
#include "prefjson.h"
|
||||
#include "qbtsession.h"
|
||||
#include "misc.h"
|
||||
#ifndef DISABLE_GUI
|
||||
@ -160,7 +159,8 @@ void HttpConnection::translateDocument(QString& data) {
|
||||
QByteArray word = regex.cap(1).toLocal8Bit();
|
||||
|
||||
QString translation = word;
|
||||
if (m_httpserver->isTranslationNeeded()) {
|
||||
bool isTranslationNeeded = !Preferences().getLocale().startsWith("en");
|
||||
if (isTranslationNeeded) {
|
||||
int context_index = 0;
|
||||
do {
|
||||
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1);
|
||||
@ -367,23 +367,16 @@ void HttpConnection::respondFilesPropertiesJson(const QString& hash) {
|
||||
}
|
||||
|
||||
void HttpConnection::respondPreferencesJson() {
|
||||
EventManager* manager = m_httpserver->eventManager();
|
||||
QString string = json::toJson(manager->getGlobalPreferences());
|
||||
m_generator.setStatusLine(200, "OK");
|
||||
m_generator.setContentTypeByExt("js");
|
||||
m_generator.setMessage(string);
|
||||
m_generator.setMessage(prefjson::getPreferences());
|
||||
write();
|
||||
}
|
||||
|
||||
void HttpConnection::respondGlobalTransferInfoJson() {
|
||||
QVariantMap info;
|
||||
session_status sessionStatus = QBtSession::instance()->getSessionStatus();
|
||||
info["DlInfos"] = tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download));
|
||||
info["UpInfos"] = tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload));
|
||||
QString string = json::toJson(info);
|
||||
m_generator.setStatusLine(200, "OK");
|
||||
m_generator.setContentTypeByExt("js");
|
||||
m_generator.setMessage(string);
|
||||
m_generator.setMessage(btjson::getTransferInfo());
|
||||
write();
|
||||
}
|
||||
|
||||
@ -464,9 +457,7 @@ void HttpConnection::respondCommand(const QString& command) {
|
||||
return;
|
||||
}
|
||||
if (command == "setPreferences") {
|
||||
QString json_str = m_parser.post("json");
|
||||
EventManager* manager = m_httpserver->eventManager();
|
||||
manager->setGlobalPreferences(json::fromJson(json_str));
|
||||
prefjson::setPreferences(m_parser.post("json"));
|
||||
return;
|
||||
}
|
||||
if (command == "setFilePrio") {
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include "httpserver.h"
|
||||
#include "httpconnection.h"
|
||||
#include "eventmanager.h"
|
||||
#include "qbtsession.h"
|
||||
#include <QCryptographicHash>
|
||||
#include <QTime>
|
||||
@ -89,16 +88,14 @@ void HttpServer::resetNbFailedAttemptsForIp(const QString& ip) {
|
||||
m_clientFailedAttempts.remove(ip);
|
||||
}
|
||||
|
||||
HttpServer::HttpServer(QObject* parent) : QTcpServer(parent),
|
||||
m_eventManager(new EventManager(this)) {
|
||||
HttpServer::HttpServer(QObject* parent) : QTcpServer(parent)
|
||||
{
|
||||
|
||||
const Preferences pref;
|
||||
|
||||
m_username = pref.getWebUiUsername().toLocal8Bit();
|
||||
m_passwordSha1 = pref.getWebUiPassword().toLocal8Bit();
|
||||
m_localAuthEnabled = pref.isWebUiLocalAuthEnabled();
|
||||
m_needsTranslation = !Preferences().getLocale().startsWith("en");
|
||||
connect(m_eventManager, SIGNAL(localeChanged(QString)), SLOT(onLocaleChanged(QString)));
|
||||
|
||||
// HTTPS-related
|
||||
#ifndef QT_NO_OPENSSL
|
||||
@ -141,7 +138,6 @@ HttpServer::HttpServer(QObject* parent) : QTcpServer(parent),
|
||||
}
|
||||
|
||||
HttpServer::~HttpServer() {
|
||||
delete m_eventManager;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
@ -301,10 +297,6 @@ bool HttpServer::isAuthorized(const QByteArray& auth,
|
||||
return prop_response == response;
|
||||
}
|
||||
|
||||
EventManager* HttpServer::eventManager() const {
|
||||
return m_eventManager;
|
||||
}
|
||||
|
||||
void HttpServer::setlocalAuthEnabled(bool enabled) {
|
||||
m_localAuthEnabled = enabled;
|
||||
}
|
||||
@ -312,11 +304,3 @@ void HttpServer::setlocalAuthEnabled(bool enabled) {
|
||||
bool HttpServer::isLocalAuthEnabled() const {
|
||||
return m_localAuthEnabled;
|
||||
}
|
||||
|
||||
bool HttpServer::isTranslationNeeded() {
|
||||
return m_needsTranslation;
|
||||
}
|
||||
|
||||
void HttpServer::onLocaleChanged(const QString &locale) {
|
||||
m_needsTranslation = !locale.startsWith("en");
|
||||
}
|
||||
|
@ -64,12 +64,10 @@ public:
|
||||
bool isAuthorized(const QByteArray& auth, const QString& method) const;
|
||||
void setlocalAuthEnabled(bool enabled);
|
||||
bool isLocalAuthEnabled() const;
|
||||
EventManager *eventManager() const;
|
||||
QString generateNonce() const;
|
||||
int NbFailedAttemptsForIp(const QString& ip) const;
|
||||
void increaseNbFailedAttemptsForIp(const QString& ip);
|
||||
void resetNbFailedAttemptsForIp(const QString& ip);
|
||||
bool isTranslationNeeded();
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void enableHttps(const QSslCertificate &certificate, const QSslKey &key);
|
||||
@ -81,7 +79,6 @@ private:
|
||||
|
||||
private slots:
|
||||
void UnbanTimerEvent();
|
||||
void onLocaleChanged(const QString &locale);
|
||||
|
||||
private:
|
||||
void handleNewConnection(QTcpSocket *socket);
|
||||
@ -89,10 +86,8 @@ private:
|
||||
private:
|
||||
QByteArray m_username;
|
||||
QByteArray m_passwordSha1;
|
||||
EventManager *m_eventManager; // TODO: Remove
|
||||
QHash<QString, int> m_clientFailedAttempts;
|
||||
bool m_localAuthEnabled;
|
||||
bool m_needsTranslation;
|
||||
#ifndef QT_NO_OPENSSL
|
||||
bool m_https;
|
||||
QSslCertificate m_certificate;
|
||||
|
@ -94,16 +94,6 @@ QString json::toJson(const QVariant& v) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove
|
||||
QString json::toJson(const QVariantMap& m) {
|
||||
QStringList vlist;
|
||||
QVariantMap::ConstIterator it;
|
||||
for (it = m.constBegin(); it != m.constEnd(); it++) {
|
||||
vlist << toJson(it.key())+":"+toJson(it.value());
|
||||
}
|
||||
return "{"+vlist.join(",")+"}";
|
||||
}
|
||||
|
||||
QVariantMap json::fromJson(const QString& json) {
|
||||
qDebug("JSON is %s", qPrintable(json));
|
||||
QVariantMap m;
|
||||
@ -165,17 +155,3 @@ QVariantMap json::fromJson(const QString& json) {
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
// TODO: Remove
|
||||
QString json::toJson(const QList<QVariantMap>& v) {
|
||||
QStringList res;
|
||||
foreach (QVariantMap m, v) {
|
||||
QStringList vlist;
|
||||
QVariantMap::ConstIterator it;
|
||||
for (it = m.constBegin(); it != m.constEnd(); it++) {
|
||||
vlist << toJson(it.key())+":"+toJson(it.value());
|
||||
}
|
||||
res << "{"+vlist.join(",")+"}";
|
||||
}
|
||||
return "["+res.join(",")+"]";
|
||||
}
|
||||
|
@ -37,8 +37,6 @@
|
||||
namespace json {
|
||||
|
||||
QString toJson(const QVariant& v);
|
||||
QString toJson(const QVariantMap& m); // TODO: Remove
|
||||
QString toJson(const QList<QVariantMap>& v); // TODO: Remove
|
||||
QVariantMap fromJson(const QString& json);
|
||||
|
||||
} // namespace json
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
|
||||
* Copyright (C) 2006-2012 Ishan Arora and Christophe Dumez
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -28,30 +28,124 @@
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
|
||||
#include <libtorrent/version.hpp>
|
||||
#include "eventmanager.h"
|
||||
#include "prefjson.h"
|
||||
#include "jsondict.h"
|
||||
#include "preferences.h"
|
||||
#include "json.h"
|
||||
#include "qbtsession.h"
|
||||
#include "scannedfoldersmodel.h"
|
||||
#include "misc.h"
|
||||
#include "preferences.h"
|
||||
//#include "proplistdelegate.h"
|
||||
#include "torrentpersistentdata.h"
|
||||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <libtorrent/version.hpp>
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#include <QSslCertificate>
|
||||
#include <QSslKey>
|
||||
#endif
|
||||
#include <QTranslator>
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
EventManager::EventManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
prefjson::prefjson()
|
||||
{
|
||||
}
|
||||
|
||||
void EventManager::setGlobalPreferences(QVariantMap m) {
|
||||
QString prefjson::getPreferences()
|
||||
{
|
||||
const Preferences pref;
|
||||
JsonDict data;
|
||||
// UI
|
||||
data.add("locale", pref.getLocale());
|
||||
// Downloads
|
||||
data.add("save_path", pref.getSavePath());
|
||||
data.add("temp_path_enabled", pref.isTempPathEnabled());
|
||||
data.add("temp_path", pref.getTempPath());
|
||||
data.add("scan_dirs", pref.getScanDirs());
|
||||
QVariantList var_list;
|
||||
foreach (bool b, pref.getDownloadInScanDirs()) {
|
||||
var_list << b;
|
||||
}
|
||||
data.add("download_in_scan_dirs", var_list);
|
||||
data.add("export_dir_enabled", pref.isTorrentExportEnabled());
|
||||
data.add("export_dir", pref.getExportDir());
|
||||
data.add("mail_notification_enabled", pref.isMailNotificationEnabled());
|
||||
data.add("mail_notification_email", pref.getMailNotificationEmail());
|
||||
data.add("mail_notification_smtp", pref.getMailNotificationSMTP());
|
||||
data.add("mail_notification_ssl_enabled", pref.getMailNotificationSMTPSSL());
|
||||
data.add("mail_notification_auth_enabled", pref.getMailNotificationSMTPAuth());
|
||||
data.add("mail_notification_username", pref.getMailNotificationSMTPUsername());
|
||||
data.add("mail_notification_password", pref.getMailNotificationSMTPPassword());
|
||||
data.add("autorun_enabled", pref.isAutoRunEnabled());
|
||||
data.add("autorun_program", pref.getAutoRunProgram());
|
||||
data.add("preallocate_all", pref.preAllocateAllFiles());
|
||||
data.add("queueing_enabled", pref.isQueueingSystemEnabled());
|
||||
data.add("max_active_downloads", pref.getMaxActiveDownloads());
|
||||
data.add("max_active_torrents", pref.getMaxActiveTorrents());
|
||||
data.add("max_active_uploads", pref.getMaxActiveUploads());
|
||||
data.add("dont_count_slow_torrents", pref.ignoreSlowTorrentsForQueueing());
|
||||
data.add("incomplete_files_ext", pref.useIncompleteFilesExtension());
|
||||
// Connection
|
||||
data.add("listen_port", pref.getSessionPort());
|
||||
data.add("upnp", pref.isUPnPEnabled());
|
||||
data.add("dl_limit", pref.getGlobalDownloadLimit());
|
||||
data.add("up_limit", pref.getGlobalUploadLimit());
|
||||
data.add("max_connec", pref.getMaxConnecs());
|
||||
data.add("max_connec_per_torrent", pref.getMaxConnecsPerTorrent());
|
||||
data.add("max_uploads_per_torrent", pref.getMaxUploadsPerTorrent());
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
data.add("enable_utp", pref.isuTPEnabled());
|
||||
data.add("limit_utp_rate", pref.isuTPRateLimited());
|
||||
#endif
|
||||
data.add("limit_tcp_overhead", pref.includeOverheadInLimits());
|
||||
data.add("alt_dl_limit", pref.getAltGlobalDownloadLimit());
|
||||
data.add("alt_up_limit", pref.getAltGlobalUploadLimit());
|
||||
data.add("scheduler_enabled", pref.isSchedulerEnabled());
|
||||
const QTime start_time = pref.getSchedulerStartTime();
|
||||
data.add("schedule_from_hour", start_time.hour());
|
||||
data.add("schedule_from_min", start_time.minute());
|
||||
const QTime end_time = pref.getSchedulerEndTime();
|
||||
data.add("schedule_to_hour", end_time.hour());
|
||||
data.add("schedule_to_min", end_time.minute());
|
||||
data.add("scheduler_days", pref.getSchedulerDays());
|
||||
// Bittorrent
|
||||
data.add("dht", pref.isDHTEnabled());
|
||||
data.add("dhtSameAsBT", pref.isDHTPortSameAsBT());
|
||||
data.add("dht_port", pref.getDHTPort());
|
||||
data.add("pex", pref.isPeXEnabled());
|
||||
data.add("lsd", pref.isLSDEnabled());
|
||||
data.add("encryption", pref.getEncryptionSetting());
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
data.add("anonymous_mode", pref.isAnonymousModeEnabled());
|
||||
#endif
|
||||
// Proxy
|
||||
data.add("proxy_type", pref.getProxyType());
|
||||
data.add("proxy_ip", pref.getProxyIp());
|
||||
data.add("proxy_port", pref.getProxyPort());
|
||||
data.add("proxy_peer_connections", pref.proxyPeerConnections());
|
||||
data.add("proxy_auth_enabled", pref.isProxyAuthEnabled());
|
||||
data.add("proxy_username", pref.getProxyUsername());
|
||||
data.add("proxy_password", pref.getProxyPassword());
|
||||
// IP Filter
|
||||
data.add("ip_filter_enabled", pref.isFilteringEnabled());
|
||||
data.add("ip_filter_path", pref.getFilter());
|
||||
// Web UI
|
||||
data.add("web_ui_port", pref.getWebUiPort());
|
||||
data.add("web_ui_username", pref.getWebUiUsername());
|
||||
data.add("web_ui_password", pref.getWebUiPassword());
|
||||
data.add("bypass_local_auth", !pref.isWebUiLocalAuthEnabled());
|
||||
data.add("use_https", pref.isWebUiHttpsEnabled());
|
||||
data.add("ssl_key", QString::fromAscii(pref.getWebUiHttpsKey()));
|
||||
data.add("ssl_cert", QString::fromAscii(pref.getWebUiHttpsCertificate()));
|
||||
// DynDns
|
||||
data.add("dyndns_enabled", pref.isDynDNSEnabled());
|
||||
data.add("dyndns_service", pref.getDynDNSService());
|
||||
data.add("dyndns_username", pref.getDynDNSUsername());
|
||||
data.add("dyndns_password", pref.getDynDNSPassword());
|
||||
data.add("dyndns_domain", pref.getDynDomainName());
|
||||
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
void prefjson::setPreferences(const QString& json)
|
||||
{
|
||||
const QVariantMap m = json::fromJson(json);
|
||||
|
||||
// UI
|
||||
Preferences pref;
|
||||
if (m.contains("locale")) {
|
||||
@ -66,7 +160,6 @@ void EventManager::setGlobalPreferences(QVariantMap m) {
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
pref.setLocale(locale);
|
||||
emit localeChanged(locale);
|
||||
}
|
||||
}
|
||||
// Downloads
|
||||
@ -252,97 +345,3 @@ void EventManager::setGlobalPreferences(QVariantMap m) {
|
||||
// Reload preferences
|
||||
QBtSession::instance()->configureSession();
|
||||
}
|
||||
|
||||
QVariantMap EventManager::getGlobalPreferences() const {
|
||||
const Preferences pref;
|
||||
QVariantMap data;
|
||||
// UI
|
||||
data["locale"] = pref.getLocale();
|
||||
// Downloads
|
||||
data["save_path"] = pref.getSavePath();
|
||||
data["temp_path_enabled"] = pref.isTempPathEnabled();
|
||||
data["temp_path"] = pref.getTempPath();
|
||||
data["scan_dirs"] = pref.getScanDirs();
|
||||
QVariantList var_list;
|
||||
foreach (bool b, pref.getDownloadInScanDirs()) {
|
||||
var_list << b;
|
||||
}
|
||||
data["download_in_scan_dirs"] = var_list;
|
||||
data["export_dir_enabled"] = pref.isTorrentExportEnabled();
|
||||
data["export_dir"] = pref.getExportDir();
|
||||
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"] = 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();
|
||||
// Connection
|
||||
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();
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
data["enable_utp"] = pref.isuTPEnabled();
|
||||
data["limit_utp_rate"] = pref.isuTPRateLimited();
|
||||
#endif
|
||||
data["limit_tcp_overhead"] = pref.includeOverheadInLimits();
|
||||
data["alt_dl_limit"] = pref.getAltGlobalDownloadLimit();
|
||||
data["alt_up_limit"] = pref.getAltGlobalUploadLimit();
|
||||
data["scheduler_enabled"] = pref.isSchedulerEnabled();
|
||||
const QTime start_time = pref.getSchedulerStartTime();
|
||||
data["schedule_from_hour"] = start_time.hour();
|
||||
data["schedule_from_min"] = start_time.minute();
|
||||
const QTime end_time = pref.getSchedulerEndTime();
|
||||
data["schedule_to_hour"] = end_time.hour();
|
||||
data["schedule_to_min"] = end_time.minute();
|
||||
data["scheduler_days"] = pref.getSchedulerDays();
|
||||
// Bittorrent
|
||||
data["dht"] = pref.isDHTEnabled();
|
||||
data["dhtSameAsBT"] = pref.isDHTPortSameAsBT();
|
||||
data["dht_port"] = pref.getDHTPort();
|
||||
data["pex"] = pref.isPeXEnabled();
|
||||
data["lsd"] = pref.isLSDEnabled();
|
||||
data["encryption"] = pref.getEncryptionSetting();
|
||||
#if LIBTORRENT_VERSION_MINOR >= 16
|
||||
data["anonymous_mode"] = pref.isAnonymousModeEnabled();
|
||||
#endif
|
||||
// Proxy
|
||||
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();
|
||||
// IP Filter
|
||||
data["ip_filter_enabled"] = pref.isFilteringEnabled();
|
||||
data["ip_filter_path"] = pref.getFilter();
|
||||
// Web UI
|
||||
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::fromAscii(pref.getWebUiHttpsKey());
|
||||
data["ssl_cert"] = QString::fromAscii(pref.getWebUiHttpsCertificate());
|
||||
// DynDns
|
||||
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();
|
||||
return data;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
|
||||
* Copyright (C) 2006-2012 Ishan Arora and Christophe Dumez
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -28,30 +28,20 @@
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#ifndef PREFJSON_H
|
||||
#define PREFJSON_H
|
||||
|
||||
#ifndef EVENTMANAGER_H
|
||||
#define EVENTMANAGER_H
|
||||
#include <QString>
|
||||
|
||||
#include "qtorrenthandle.h"
|
||||
#include <QHash>
|
||||
#include <QVariant>
|
||||
|
||||
class EventManager : public QObject
|
||||
class prefjson
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(EventManager)
|
||||
|
||||
protected:
|
||||
void update(QVariantMap event);
|
||||
private:
|
||||
prefjson();
|
||||
|
||||
public:
|
||||
EventManager(QObject *parent);
|
||||
QList<QVariantMap> getPropFilesInfo(QString hash) const;
|
||||
QVariantMap getGlobalPreferences() const;
|
||||
void setGlobalPreferences(QVariantMap m);
|
||||
static QString getPreferences();
|
||||
static void setPreferences(const QString& json);
|
||||
|
||||
signals:
|
||||
void localeChanged(const QString &locale);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PREFJSON_H
|
@ -218,8 +218,8 @@ window.addEvent('load', function(){
|
||||
},
|
||||
onSuccess: function(info) {
|
||||
if(info) {
|
||||
$("DlInfos").set('html', info.DlInfos);
|
||||
$("UpInfos").set('html', info.UpInfos);
|
||||
$("DlInfos").set('html', info.dl_info);
|
||||
$("UpInfos").set('html', info.up_info);
|
||||
waitingTrInfo=false;
|
||||
loadTransferInfo.delay(3000);
|
||||
}
|
||||
|
@ -4,20 +4,20 @@ HEADERS += $$PWD/httpserver.h \
|
||||
$$PWD/httpconnection.h \
|
||||
$$PWD/httprequestparser.h \
|
||||
$$PWD/httpresponsegenerator.h \
|
||||
$$PWD/eventmanager.h \
|
||||
$$PWD/json.h \
|
||||
$$PWD/jsonlist.h \
|
||||
$$PWD/jsondict.h \
|
||||
$$PWD/btjson.h
|
||||
$$PWD/btjson.h \
|
||||
$$PWD/prefjson.h
|
||||
|
||||
SOURCES += $$PWD/httpserver.cpp \
|
||||
$$PWD/httpconnection.cpp \
|
||||
$$PWD/httprequestparser.cpp \
|
||||
$$PWD/httpresponsegenerator.cpp \
|
||||
$$PWD/eventmanager.cpp \
|
||||
$$PWD/jsonlist.cpp \
|
||||
$$PWD/jsondict.cpp \
|
||||
$$PWD/btjson.cpp \
|
||||
$$PWD/json.cpp
|
||||
$$PWD/json.cpp \
|
||||
$$PWD/prefjson.cpp
|
||||
|
||||
RESOURCES += $$PWD/webui.qrc
|
||||
|
Loading…
x
Reference in New Issue
Block a user