Browse Source

Merge pull request #3384 from ngosang/webui_upnp

[Web UI] New option Web UI port UPNP. Closes #3358
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
c1e2ddc843
  1. 3
      src/webui/prefjson.cpp
  2. 2
      src/webui/webapplication.cpp
  3. 29
      src/webui/www/public/preferences_content.html

3
src/webui/prefjson.cpp

@ -150,6 +150,7 @@ QByteArray prefjson::getPreferences()
data["locale"] = pref->getLocale(); data["locale"] = pref->getLocale();
// HTTP Server // HTTP Server
data["web_ui_port"] = pref->getWebUiPort(); data["web_ui_port"] = pref->getWebUiPort();
data["web_ui_upnp"] = pref->useUPnPForWebUIPort();
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());
@ -361,6 +362,8 @@ void prefjson::setPreferences(const QString& json)
// HTTP Server // HTTP Server
if (m.contains("web_ui_port")) if (m.contains("web_ui_port"))
pref->setWebUiPort(m["web_ui_port"].toUInt()); pref->setWebUiPort(m["web_ui_port"].toUInt());
if (m.contains("web_ui_upnp"))
pref->setUPnPForWebUIPort(m["web_ui_upnp"].toBool());
if (m.contains("use_https")) if (m.contains("use_https"))
pref->setWebUiHttpsEnabled(m["use_https"].toBool()); pref->setWebUiHttpsEnabled(m["use_https"].toBool());
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL

2
src/webui/webapplication.cpp

@ -46,7 +46,7 @@
#include "websessiondata.h" #include "websessiondata.h"
#include "webapplication.h" #include "webapplication.h"
static const int API_VERSION = 3; static const int API_VERSION = 4;
static const int API_VERSION_MIN = 2; static const int API_VERSION_MIN = 2;
const QString WWW_FOLDER = ":/www/public/"; const QString WWW_FOLDER = ":/www/public/";

29
src/webui/www/public/preferences_content.html

@ -343,18 +343,21 @@
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(HTTP Server)QBT_TR</legend> <legend>QBT_TR(HTTP Server)QBT_TR</legend>
<label for="webui_port_value">QBT_TR(Port:)QBT_TR</label><input type="text" id="webui_port_value" style="width: 4em;"/><br/> <label for="webui_port_value">QBT_TR(Port:)QBT_TR</label><input type="text" id="webui_port_value" style="width: 4em;"/><br/>
<input type="checkbox" id="webui_upnp_checkbox"/>
<input type="checkbox" id="use_https_checkbox" onclick="updateHttpsSettings();" /> <label for="webui_upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP to forward the port from my router)QBT_TR</label><br/>
<label for="use_https_checkbox">QBT_TR(Use HTTPS instead of HTTP)QBT_TR</label><br/> <fieldset class="settings">
<div class="formRow"> <legend><input type="checkbox" id="use_https_checkbox" onclick="updateHttpsSettings();" />
<label for="ssl_key_textarea" style="margin-left: 20px;">QBT_TR(Key:)QBT_TR</label> <label for="use_https_checkbox">QBT_TR(Use HTTPS instead of HTTP)QBT_TR</label></legend>
<textarea id="ssl_key_textarea" rows="5" cols="70"></textarea> <div class="formRow">
</div> <label for="ssl_key_textarea" style="margin-left: 20px;">QBT_TR(Key:)QBT_TR</label>
<div class="formRow"> <textarea id="ssl_key_textarea" rows="5" cols="70"></textarea>
<label for="ssl_cert_textarea" style="margin-left: 20px;">QBT_TR(Certificate:)QBT_TR</label> </div>
<textarea id="ssl_cert_textarea" rows="5" cols="70"></textarea> <div class="formRow">
</div> <label for="ssl_cert_textarea" style="margin-left: 20px;">QBT_TR(Certificate:)QBT_TR</label>
<div style="padding-left: 10px;"><a href=http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#aboutcerts>Information about certificates</a></div> <textarea id="ssl_cert_textarea" rows="5" cols="70"></textarea>
</div>
<div style="padding-left: 10px;"><a href=http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#aboutcerts>Information about certificates</a></div>
</fieldset>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
@ -912,6 +915,7 @@ loadPreferences = function() {
// HTTP Server // HTTP Server
$('webui_port_value').setProperty('value', pref.web_ui_port); $('webui_port_value').setProperty('value', pref.web_ui_port);
$('webui_upnp_checkbox').setProperty('checked', pref.web_ui_upnp);
$('use_https_checkbox').setProperty('checked', pref.use_https); $('use_https_checkbox').setProperty('checked', pref.use_https);
$('ssl_key_textarea').setProperty('value', pref.ssl_key); $('ssl_key_textarea').setProperty('value', pref.ssl_key);
$('ssl_cert_textarea').setProperty('value', pref.ssl_cert); $('ssl_cert_textarea').setProperty('value', pref.ssl_cert);
@ -1168,6 +1172,7 @@ applyPreferences = function() {
return; return;
} }
settings.set('web_ui_port', web_ui_port); settings.set('web_ui_port', web_ui_port);
settings.set('web_ui_upnp', $('webui_upnp_checkbox').getProperty('checked'));
settings.set('use_https', $('use_https_checkbox').getProperty('checked')); settings.set('use_https', $('use_https_checkbox').getProperty('checked'));
settings.set('ssl_key', $('ssl_key_textarea').getProperty('value')); settings.set('ssl_key', $('ssl_key_textarea').getProperty('value'));
settings.set('ssl_cert', $('ssl_cert_textarea').getProperty('value')); settings.set('ssl_cert', $('ssl_cert_textarea').getProperty('value'));

Loading…
Cancel
Save