Add option for restricting non-printer connections
This commit is contained in:
parent
f30f40683e
commit
b4aaa85a2d
12 changed files with 98 additions and 4 deletions
|
@ -160,5 +160,12 @@ ApplicationWindow
|
||||||
defaultValue: SeaPrintSettings.debugLogDefault
|
defaultValue: SeaPrintSettings.debugLogDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigurationValue
|
||||||
|
{
|
||||||
|
id: allowExternalConnectionsSetting
|
||||||
|
key: SeaPrintSettings.allowExternalConnectionsPath
|
||||||
|
defaultValue: SeaPrintSettings.allowExternalConnectionsDefault
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,14 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextSwitch {
|
||||||
|
text: qsTr("Allow external connections")
|
||||||
|
description: qsTr("Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.")
|
||||||
|
checked: allowExternalConnectionsSetting.value
|
||||||
|
onCheckedChanged: {
|
||||||
|
allowExternalConnectionsSetting.value = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,9 +126,12 @@ void IppPrinter::MaybeGetStrings()
|
||||||
if(_attrs.contains("printer-strings-uri") && _strings.empty())
|
if(_attrs.contains("printer-strings-uri") && _strings.empty())
|
||||||
{
|
{
|
||||||
QUrl url(_attrs["printer-strings-uri"].toObject()["value"].toString());
|
QUrl url(_attrs["printer-strings-uri"].toObject()["value"].toString());
|
||||||
|
if(isAllowedAddress(url))
|
||||||
|
{
|
||||||
IppDiscovery::instance()->resolve(url);
|
IppDiscovery::instance()->resolve(url);
|
||||||
emit doGetStrings(url);
|
emit doGetStrings(url);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IppPrinter::MaybeGetIcon(bool retry)
|
void IppPrinter::MaybeGetIcon(bool retry)
|
||||||
|
@ -157,7 +160,7 @@ void IppPrinter::MaybeGetIcon(bool retry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!url.isEmpty())
|
if(isAllowedAddress(url))
|
||||||
{
|
{
|
||||||
IppDiscovery::instance()->resolve(url);
|
IppDiscovery::instance()->resolve(url);
|
||||||
emit doGetImage(url);
|
emit doGetImage(url);
|
||||||
|
@ -821,6 +824,13 @@ void IppPrinter::setProgress(qint64 sent, qint64 total)
|
||||||
emit progressChanged();
|
emit progressChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IppPrinter::isAllowedAddress(QUrl url)
|
||||||
|
{
|
||||||
|
bool allowed = ((url.host() == _url.host()) || Settings::instance()->allowExternalConnections());
|
||||||
|
qDebug() << url << " is allowed: " << allowed;
|
||||||
|
return allowed;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonValue IppPrinter::getAttrOrDefault(QJsonObject jobAttrs, QString name, QString subkey)
|
QJsonValue IppPrinter::getAttrOrDefault(QJsonObject jobAttrs, QString name, QString subkey)
|
||||||
{
|
{
|
||||||
if(subkey == "")
|
if(subkey == "")
|
||||||
|
|
|
@ -106,6 +106,8 @@ private:
|
||||||
void setBusyMessage(QString msg);
|
void setBusyMessage(QString msg);
|
||||||
void setProgress(qint64 sent, qint64 total);
|
void setProgress(qint64 sent, qint64 total);
|
||||||
|
|
||||||
|
bool isAllowedAddress(QUrl addr);
|
||||||
|
|
||||||
QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name, QString subkey = "");
|
QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name, QString subkey = "");
|
||||||
|
|
||||||
IppMsg mk_msg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject());
|
IppMsg mk_msg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject());
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
|
|
||||||
Settings::Settings() : _ignoreSslErrorsSetting("/apps/harbour-seaprint/settings/ignore-ssl-errors", this),
|
Settings::Settings() : _ignoreSslErrorsSetting("/apps/harbour-seaprint/settings/ignore-ssl-errors", this),
|
||||||
_debugLogSetting("/apps/harbour-seaprint/settings/debug-log", this)
|
_debugLogSetting("/apps/harbour-seaprint/settings/debug-log", this),
|
||||||
|
_allowExternalConnectionsSetting("/apps/harbour-seaprint/settings/allow-external-connections", this)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,3 +49,13 @@ QString Settings::debugLogPath()
|
||||||
{
|
{
|
||||||
return _debugLogSetting.key();
|
return _debugLogSetting.key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::allowExternalConnections()
|
||||||
|
{
|
||||||
|
return _allowExternalConnectionsSetting.value(_allowExternalConnectionsDefault).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Settings::allowExternalConnectionsPath()
|
||||||
|
{
|
||||||
|
return _allowExternalConnectionsSetting.key();
|
||||||
|
}
|
||||||
|
|
|
@ -10,14 +10,19 @@ public:
|
||||||
|
|
||||||
Q_PROPERTY(QString ignoreSslErrorsPath READ ignoreSslErrorsPath CONSTANT)
|
Q_PROPERTY(QString ignoreSslErrorsPath READ ignoreSslErrorsPath CONSTANT)
|
||||||
Q_PROPERTY(bool ignoreSslErrorsDefault MEMBER _ignoreSslErrorsDefault CONSTANT)
|
Q_PROPERTY(bool ignoreSslErrorsDefault MEMBER _ignoreSslErrorsDefault CONSTANT)
|
||||||
|
|
||||||
Q_PROPERTY(QString debugLogPath READ debugLogPath CONSTANT)
|
Q_PROPERTY(QString debugLogPath READ debugLogPath CONSTANT)
|
||||||
Q_PROPERTY(bool debugLogDefault MEMBER _debugLogDefault CONSTANT)
|
Q_PROPERTY(bool debugLogDefault MEMBER _debugLogDefault CONSTANT)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString allowExternalConnectionsPath READ allowExternalConnectionsPath CONSTANT)
|
||||||
|
Q_PROPERTY(bool allowExternalConnectionsDefault MEMBER _allowExternalConnectionsDefault CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Settings* instance();
|
static Settings* instance();
|
||||||
|
|
||||||
bool ignoreSslErrors();
|
bool ignoreSslErrors();
|
||||||
bool debugLog();
|
bool debugLog();
|
||||||
|
bool allowExternalConnections();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings();
|
Settings();
|
||||||
|
@ -29,12 +34,15 @@ private:
|
||||||
|
|
||||||
MGConfItem _ignoreSslErrorsSetting;
|
MGConfItem _ignoreSslErrorsSetting;
|
||||||
MGConfItem _debugLogSetting;
|
MGConfItem _debugLogSetting;
|
||||||
|
MGConfItem _allowExternalConnectionsSetting;
|
||||||
|
|
||||||
QString ignoreSslErrorsPath();
|
QString ignoreSslErrorsPath();
|
||||||
QString debugLogPath();
|
QString debugLogPath();
|
||||||
|
QString allowExternalConnectionsPath();
|
||||||
|
|
||||||
bool _ignoreSslErrorsDefault = true;
|
bool _ignoreSslErrorsDefault = true;
|
||||||
bool _debugLogDefault = false;
|
bool _debugLogDefault = false;
|
||||||
|
bool _allowExternalConnectionsDefault = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -569,6 +569,14 @@ auf diesem Drucker</translation>
|
||||||
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
||||||
<translation>Druckt das Debug-Protokoll in die Konsole (falls von hier ausgeführt) oder journal wenn normal gestartet wurde. Wird erst nach einem Neustart der App wirksam.</translation>
|
<translation>Druckt das Debug-Protokoll in die Konsole (falls von hier ausgeführt) oder journal wenn normal gestartet wurde. Wird erst nach einem Neustart der App wirksam.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow external connections</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SupplyItem</name>
|
<name>SupplyItem</name>
|
||||||
|
|
|
@ -568,6 +568,14 @@
|
||||||
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow external connections</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SupplyItem</name>
|
<name>SupplyItem</name>
|
||||||
|
|
|
@ -569,6 +569,14 @@ sur cette imprimante</translation>
|
||||||
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
||||||
<translation>Afficher les messages du journal de débogage vers le terminal (si exécuté à partir de là) ou dans le journal si exécuté normalement. Nécessite de (re)démarrer l'application.</translation>
|
<translation>Afficher les messages du journal de débogage vers le terminal (si exécuté à partir de là) ou dans le journal si exécuté normalement. Nécessite de (re)démarrer l'application.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow external connections</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SupplyItem</name>
|
<name>SupplyItem</name>
|
||||||
|
|
|
@ -568,6 +568,14 @@
|
||||||
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow external connections</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SupplyItem</name>
|
<name>SupplyItem</name>
|
||||||
|
|
|
@ -568,6 +568,14 @@
|
||||||
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow external connections</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SupplyItem</name>
|
<name>SupplyItem</name>
|
||||||
|
|
|
@ -568,6 +568,14 @@
|
||||||
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
<source>Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow external connections</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SupplyItem</name>
|
<name>SupplyItem</name>
|
||||||
|
|
Loading…
Reference in a new issue