mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:25:18 +00:00
UI: Store log flags in the .ini
This commit is contained in:
parent
74e09b3a43
commit
c89daf2d96
@ -7,6 +7,7 @@ FirewallConf::FirewallConf(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_provBoot(false),
|
||||
m_filterEnabled(true),
|
||||
m_resolveAddress(false),
|
||||
m_logBlocked(false),
|
||||
m_logStat(false),
|
||||
m_appBlockAll(true),
|
||||
@ -32,6 +33,14 @@ void FirewallConf::setFilterEnabled(bool filterEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
void FirewallConf::setResolveAddress(bool resolveAddress)
|
||||
{
|
||||
if (m_resolveAddress != resolveAddress) {
|
||||
m_resolveAddress = resolveAddress;
|
||||
emit resolveAddressChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void FirewallConf::setLogBlocked(bool logBlocked)
|
||||
{
|
||||
if (m_logBlocked != logBlocked) {
|
||||
@ -131,16 +140,18 @@ void FirewallConf::copyFlags(const FirewallConf &o)
|
||||
{
|
||||
setProvBoot(o.provBoot());
|
||||
setFilterEnabled(o.filterEnabled());
|
||||
setLogStat(o.logStat());
|
||||
ipInclude()->setUseAll(o.ipInclude()->useAll());
|
||||
ipExclude()->setUseAll(o.ipExclude()->useAll());
|
||||
setAppBlockAll(o.appBlockAll());
|
||||
setAppAllowAll(o.appAllowAll());
|
||||
setAppGroupBits(o.appGroupBits());
|
||||
|
||||
copyImmediateFlags(o);
|
||||
}
|
||||
|
||||
void FirewallConf::copyTempFlags(const FirewallConf &o)
|
||||
void FirewallConf::copyImmediateFlags(const FirewallConf &o)
|
||||
{
|
||||
setResolveAddress(o.resolveAddress());
|
||||
setLogBlocked(o.logBlocked());
|
||||
setLogStat(o.logStat());
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ class FirewallConf : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool provBoot READ provBoot WRITE setProvBoot NOTIFY provBootChanged)
|
||||
Q_PROPERTY(bool filterEnabled READ filterEnabled WRITE setFilterEnabled NOTIFY filterEnabledChanged)
|
||||
Q_PROPERTY(bool resolveAddress READ resolveAddress WRITE setResolveAddress NOTIFY resolveAddressChanged)
|
||||
Q_PROPERTY(bool logBlocked READ logBlocked WRITE setLogBlocked NOTIFY logBlockedChanged)
|
||||
Q_PROPERTY(bool logStat READ logStat WRITE setLogStat NOTIFY logStatChanged)
|
||||
Q_PROPERTY(bool appBlockAll READ appBlockAll WRITE setAppBlockAll NOTIFY appBlockAllChanged)
|
||||
@ -31,6 +32,9 @@ public:
|
||||
bool filterEnabled() const { return m_filterEnabled; }
|
||||
void setFilterEnabled(bool filterEnabled);
|
||||
|
||||
bool resolveAddress() const { return m_resolveAddress; }
|
||||
void setResolveAddress(bool resolveAddress);
|
||||
|
||||
bool logBlocked() const { return m_logBlocked; }
|
||||
void setLogBlocked(bool logBlocked);
|
||||
|
||||
@ -53,7 +57,7 @@ public:
|
||||
QQmlListProperty<AppGroup> appGroups();
|
||||
|
||||
void copyFlags(const FirewallConf &o);
|
||||
void copyTempFlags(const FirewallConf &o);
|
||||
void copyImmediateFlags(const FirewallConf &o);
|
||||
|
||||
QVariant toVariant() const;
|
||||
void fromVariant(const QVariant &v);
|
||||
@ -61,6 +65,7 @@ public:
|
||||
signals:
|
||||
void provBootChanged();
|
||||
void filterEnabledChanged();
|
||||
void resolveAddressChanged();
|
||||
void logBlockedChanged();
|
||||
void logStatChanged();
|
||||
void appBlockAllChanged();
|
||||
@ -77,7 +82,9 @@ private:
|
||||
uint m_provBoot : 1;
|
||||
uint m_filterEnabled : 1;
|
||||
|
||||
uint m_logBlocked : 1; // transient
|
||||
uint m_resolveAddress : 1;
|
||||
|
||||
uint m_logBlocked : 1;
|
||||
uint m_logStat : 1;
|
||||
|
||||
uint m_appBlockAll : 1;
|
||||
|
@ -226,11 +226,18 @@ bool FortManager::applyConf(bool onlyFlags)
|
||||
|
||||
FirewallConf *newConf = cloneConf(*m_firewallConfToEdit);
|
||||
|
||||
newConf->copyTempFlags(*m_firewallConf);
|
||||
|
||||
return saveSettings(newConf, onlyFlags);
|
||||
}
|
||||
|
||||
bool FortManager::applyConfImmediateFlags()
|
||||
{
|
||||
Q_ASSERT(m_firewallConfToEdit != nullConf());
|
||||
|
||||
m_firewallConf->copyImmediateFlags(*m_firewallConfToEdit);
|
||||
|
||||
return saveSettings(m_firewallConf, true, true);
|
||||
}
|
||||
|
||||
void FortManager::setFirewallConfToEdit(FirewallConf *conf)
|
||||
{
|
||||
if (m_firewallConfToEdit != nullConf()
|
||||
@ -252,7 +259,8 @@ bool FortManager::loadSettings(FirewallConf *conf)
|
||||
return updateDriverConf(conf);
|
||||
}
|
||||
|
||||
bool FortManager::saveSettings(FirewallConf *newConf, bool onlyFlags)
|
||||
bool FortManager::saveSettings(FirewallConf *newConf, bool onlyFlags,
|
||||
bool immediateFlags)
|
||||
{
|
||||
if (!(onlyFlags ? m_fortSettings->writeConfFlags(*newConf)
|
||||
: m_fortSettings->writeConf(*newConf))) {
|
||||
@ -265,7 +273,9 @@ bool FortManager::saveSettings(FirewallConf *newConf, bool onlyFlags)
|
||||
m_firewallConf = newConf;
|
||||
}
|
||||
|
||||
updateTrayMenu();
|
||||
if (!immediateFlags) {
|
||||
updateTrayMenu();
|
||||
}
|
||||
|
||||
return onlyFlags ? updateDriverConfFlags(m_firewallConf)
|
||||
: updateDriverConf(m_firewallConf);
|
||||
@ -299,20 +309,6 @@ bool FortManager::updateDriverConfFlags(FirewallConf *conf)
|
||||
return true;
|
||||
}
|
||||
|
||||
void FortManager::setLogBlocked(bool enable)
|
||||
{
|
||||
m_firewallConf->setLogBlocked(enable);
|
||||
|
||||
updateDriverConfFlags(m_firewallConf);
|
||||
}
|
||||
|
||||
void FortManager::setLogStat(bool enable)
|
||||
{
|
||||
m_firewallConf->setLogStat(enable);
|
||||
|
||||
updateDriverConfFlags(m_firewallConf);
|
||||
}
|
||||
|
||||
void FortManager::setLanguage(int language)
|
||||
{
|
||||
if (!TranslationManager::instance()->switchLanguage(language))
|
||||
|
@ -53,9 +53,7 @@ public slots:
|
||||
bool saveOriginConf(const QString &message);
|
||||
bool saveConf(bool onlyFlags = false);
|
||||
bool applyConf(bool onlyFlags = false);
|
||||
|
||||
void setLogBlocked(bool enable);
|
||||
void setLogStat(bool enable);
|
||||
bool applyConfImmediateFlags();
|
||||
|
||||
void setLanguage(int language);
|
||||
|
||||
@ -76,7 +74,8 @@ private:
|
||||
bool setupEngine();
|
||||
|
||||
bool loadSettings(FirewallConf *conf);
|
||||
bool saveSettings(FirewallConf *newConf, bool onlyFlags = false);
|
||||
bool saveSettings(FirewallConf *newConf, bool onlyFlags = false,
|
||||
bool immediateFlags = false);
|
||||
|
||||
bool updateDriverConf(FirewallConf *conf);
|
||||
bool updateDriverConfFlags(FirewallConf *conf);
|
||||
|
@ -204,6 +204,8 @@ bool FortSettings::readConfFlags(FirewallConf &conf) const
|
||||
m_ini->beginGroup("confFlags");
|
||||
conf.setProvBoot(iniBool("provBoot"));
|
||||
conf.setFilterEnabled(iniBool("filterEnabled", true));
|
||||
conf.setResolveAddress(iniBool("resolveAddress"));
|
||||
conf.setLogBlocked(iniBool("logBlocked"));
|
||||
conf.setLogStat(iniBool("logStat"));
|
||||
conf.ipInclude()->setUseAll(iniBool("ipIncludeAll"));
|
||||
conf.ipExclude()->setUseAll(iniBool("ipExcludeAll"));
|
||||
@ -220,6 +222,8 @@ bool FortSettings::writeConfFlags(const FirewallConf &conf)
|
||||
m_ini->beginGroup("confFlags");
|
||||
setIniValue("provBoot", conf.provBoot());
|
||||
setIniValue("filterEnabled", conf.filterEnabled());
|
||||
setIniValue("resolveAddress", conf.resolveAddress());
|
||||
setIniValue("logBlocked", conf.logBlocked());
|
||||
setIniValue("logStat", conf.logStat());
|
||||
setIniValue("ipIncludeAll", conf.ipInclude()->useAll());
|
||||
setIniValue("ipExcludeAll", conf.ipExclude()->useAll());
|
||||
|
Binary file not shown.
@ -19,17 +19,17 @@
|
||||
<translation>Конфигурация слишком большая</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/confutil.cpp" line="112"/>
|
||||
<location filename="../util/confutil.cpp" line="113"/>
|
||||
<source>Number of Application Groups must be < %1</source>
|
||||
<translation>Количество групп приложений должно быть < %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/confutil.cpp" line="124"/>
|
||||
<location filename="../util/confutil.cpp" line="125"/>
|
||||
<source>Length of Application Group's Name must be < %1</source>
|
||||
<translation>Длина наименования группы приложения должна быть < %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/confutil.cpp" line="166"/>
|
||||
<location filename="../util/confutil.cpp" line="167"/>
|
||||
<source>Length of Application's Path must be < %1</source>
|
||||
<translation>Длина пути приложения должна быть < %1</translation>
|
||||
</message>
|
||||
@ -37,17 +37,17 @@
|
||||
<context>
|
||||
<name>FortManager</name>
|
||||
<message>
|
||||
<location filename="../fortmanager.cpp" line="337"/>
|
||||
<location filename="../fortmanager.cpp" line="358"/>
|
||||
<source>Options</source>
|
||||
<translation>Опции</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../fortmanager.cpp" line="342"/>
|
||||
<location filename="../fortmanager.cpp" line="363"/>
|
||||
<source>Filter Enabled</source>
|
||||
<translation>Фильтр включен</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../fortmanager.cpp" line="357"/>
|
||||
<location filename="../fortmanager.cpp" line="378"/>
|
||||
<source>Quit</source>
|
||||
<translation>Выйти</translation>
|
||||
</message>
|
||||
@ -83,33 +83,33 @@
|
||||
<context>
|
||||
<name>Ip4Range</name>
|
||||
<message>
|
||||
<location filename="../util/ip4range.cpp" line="32"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="32"/>
|
||||
<source>Error at line %1: %2</source>
|
||||
<translation>Ошибка в строке %1: %2</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/ip4range.cpp" line="92"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="92"/>
|
||||
<source>Bad format</source>
|
||||
<translation>Некорректный формат</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/ip4range.cpp" line="110"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="110"/>
|
||||
<source>Bad IP address</source>
|
||||
<translation>Некорректный IP адрес</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/ip4range.cpp" line="117"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="117"/>
|
||||
<source>Bad second IP address</source>
|
||||
<translation>Некорректный второй IP адрес</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/ip4range.cpp" line="121"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="121"/>
|
||||
<source>Bad range</source>
|
||||
<translation>Некорректный диапазон</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../util/ip4range.cpp" line="102"/>
|
||||
<location filename="../util/ip4range.cpp" line="129"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="102"/>
|
||||
<location filename="../util/net/ip4range.cpp" line="129"/>
|
||||
<source>Bad mask</source>
|
||||
<translation>Некорректная маска</translation>
|
||||
</message>
|
||||
@ -166,17 +166,17 @@
|
||||
<translation>Выделить всЁ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/BlockedPage.qml" line="179"/>
|
||||
<location filename="../qml/pages/BlockedPage.qml" line="34"/>
|
||||
<source>Clear</source>
|
||||
<translation>Очистить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/BlockedPage.qml" line="185"/>
|
||||
<location filename="../qml/pages/BlockedPage.qml" line="40"/>
|
||||
<source>Resolve Addresses</source>
|
||||
<translation>Преобразовать адреса</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/BlockedPage.qml" line="197"/>
|
||||
<location filename="../qml/pages/BlockedPage.qml" line="59"/>
|
||||
<source>Log Blocked Applications</source>
|
||||
<translation>Показ блокированных приложений</translation>
|
||||
</message>
|
||||
@ -281,22 +281,27 @@
|
||||
<translation>Блокировано</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/MainPage.qml" line="91"/>
|
||||
<location filename="../qml/pages/MainPage.qml" line="73"/>
|
||||
<source>Statistics</source>
|
||||
<translation>Статистика</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/MainPage.qml" line="97"/>
|
||||
<source>OK</source>
|
||||
<translation>OK</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/MainPage.qml" line="105"/>
|
||||
<location filename="../qml/pages/MainPage.qml" line="111"/>
|
||||
<source>Apply</source>
|
||||
<translation>Применить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/MainPage.qml" line="118"/>
|
||||
<location filename="../qml/pages/MainPage.qml" line="124"/>
|
||||
<source>Cancel</source>
|
||||
<translation>Отмена</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/MainPage.qml" line="123"/>
|
||||
<location filename="../qml/pages/MainPage.qml" line="129"/>
|
||||
<source>Quit</source>
|
||||
<translation>Выйти</translation>
|
||||
</message>
|
||||
@ -370,5 +375,10 @@
|
||||
<source>Last Success</source>
|
||||
<translation>Успешный запуск</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/StatisticsPage.qml" line="24"/>
|
||||
<source>Collect Traffic Statistics</source>
|
||||
<translation>Собирать статистику трафика</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -9,43 +9,16 @@ BasePage {
|
||||
readonly property LogManager logManager: fortManager.logManager
|
||||
readonly property AppBlockedModel appBlockedModel: logManager.appBlockedModel
|
||||
|
||||
property bool logBlockedEnabled: false
|
||||
property bool addressResolvingEnabled: false
|
||||
|
||||
readonly property string currentAppPath:
|
||||
(appListView.currentIndex >= 0 && appListView.currentItem)
|
||||
? appListView.currentItem.appPath : ""
|
||||
|
||||
function switchLogBlocked(enable) {
|
||||
if (logBlockedEnabled === enable)
|
||||
return;
|
||||
|
||||
logBlockedEnabled = enable;
|
||||
|
||||
fortManager.setLogBlocked(enable);
|
||||
}
|
||||
|
||||
function switchResolveAddresses(enable) {
|
||||
if (addressResolvingEnabled === enable)
|
||||
return;
|
||||
|
||||
addressResolvingEnabled = enable;
|
||||
}
|
||||
|
||||
function clearAppPaths() {
|
||||
appListView.currentIndex = -1;
|
||||
|
||||
logManager.clearModels();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: mainPage
|
||||
onClosed: {
|
||||
switchResolveAddresses(false);
|
||||
switchLogBlocked(false);
|
||||
}
|
||||
}
|
||||
|
||||
HostInfoCache {
|
||||
id: hostInfoCache
|
||||
}
|
||||
@ -65,7 +38,15 @@ BasePage {
|
||||
CheckBox {
|
||||
text: translationManager.dummyBool
|
||||
&& qsTranslate("qml", "Resolve Addresses")
|
||||
onToggled: switchResolveAddresses(checked)
|
||||
checked: firewallConf.resolveAddress
|
||||
onToggled: {
|
||||
if (firewallConf.resolveAddress === checked)
|
||||
return;
|
||||
|
||||
firewallConf.resolveAddress = checked;
|
||||
|
||||
fortManager.applyConfImmediateFlags();
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -73,11 +54,18 @@ BasePage {
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: cbShowBlockedApps
|
||||
font.weight: Font.DemiBold
|
||||
text: translationManager.dummyBool
|
||||
&& qsTranslate("qml", "Log Blocked Applications")
|
||||
onToggled: switchLogBlocked(checked)
|
||||
checked: firewallConf.logBlocked
|
||||
onToggled: {
|
||||
if (firewallConf.logBlocked === checked)
|
||||
return;
|
||||
|
||||
firewallConf.logBlocked = checked;
|
||||
|
||||
fortManager.applyConfImmediateFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +143,8 @@ BasePage {
|
||||
delegate: Label {
|
||||
width: ipListView.width
|
||||
elide: Text.ElideRight
|
||||
text: (addressResolvingEnabled && hostInfoCache.dummyBool
|
||||
text: (firewallConf.resolveAddress
|
||||
&& hostInfoCache.dummyBool
|
||||
&& hostInfoCache.hostName(ipText)) || ipText
|
||||
|
||||
readonly property string ipText: display
|
||||
|
@ -8,24 +8,6 @@ BasePage {
|
||||
|
||||
readonly property LogManager logManager: fortManager.logManager
|
||||
|
||||
property bool logStatisticsEnabled: false
|
||||
|
||||
function switchLogStatistics(enable) {
|
||||
if (logStatisticsEnabled === enable)
|
||||
return;
|
||||
|
||||
logStatisticsEnabled = enable;
|
||||
|
||||
fortManager.setLogStat(enable);
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: mainPage
|
||||
onClosed: {
|
||||
switchLogStatistics(false);
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
@ -39,8 +21,16 @@ BasePage {
|
||||
id: cbShowBlockedApps
|
||||
font.weight: Font.DemiBold
|
||||
text: translationManager.dummyBool
|
||||
&& qsTranslate("qml", "Collect Usage Statistics")
|
||||
onToggled: switchLogStatistics(checked)
|
||||
&& qsTranslate("qml", "Collect Traffic Statistics")
|
||||
checked: firewallConf.logStat
|
||||
onToggled: {
|
||||
if (firewallConf.logStat === checked)
|
||||
return;
|
||||
|
||||
firewallConf.logStat = checked;
|
||||
|
||||
fortManager.applyConfImmediateFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user