mirror of
https://github.com/tnodir/fort
synced 2024-11-15 14:56:05 +00:00
UI: Store "passwordHash" in .ini
This commit is contained in:
parent
a044ebf087
commit
0daa695b38
@ -190,14 +190,6 @@ void FirewallConf::setQuotaMonthMb(quint32 quotaMonthMb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirewallConf::setPasswordHash(const QString &passwordHash)
|
|
||||||
{
|
|
||||||
if (m_passwordHash != passwordHash) {
|
|
||||||
m_passwordHash = passwordHash;
|
|
||||||
emit passwordHashChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
quint32 FirewallConf::appGroupBits() const
|
quint32 FirewallConf::appGroupBits() const
|
||||||
{
|
{
|
||||||
quint32 groupBits = 0;
|
quint32 groupBits = 0;
|
||||||
@ -284,7 +276,6 @@ void FirewallConf::copyFlags(const FirewallConf &o)
|
|||||||
setStopInetTraffic(o.stopInetTraffic());
|
setStopInetTraffic(o.stopInetTraffic());
|
||||||
setAppBlockAll(o.appBlockAll());
|
setAppBlockAll(o.appBlockAll());
|
||||||
setAppAllowAll(o.appAllowAll());
|
setAppAllowAll(o.appAllowAll());
|
||||||
setPasswordHash(o.passwordHash());
|
|
||||||
setAppGroupBits(o.appGroupBits());
|
setAppGroupBits(o.appGroupBits());
|
||||||
|
|
||||||
setActivePeriodEnabled(o.activePeriodEnabled());
|
setActivePeriodEnabled(o.activePeriodEnabled());
|
||||||
@ -314,8 +305,6 @@ QVariant FirewallConf::toVariant() const
|
|||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
|
|
||||||
map["passwordHash"] = m_passwordHash;
|
|
||||||
|
|
||||||
QVariantList addresses;
|
QVariantList addresses;
|
||||||
for (const AddressGroup *addressGroup : addressGroupsList()) {
|
for (const AddressGroup *addressGroup : addressGroupsList()) {
|
||||||
addresses.append(addressGroup->toVariant());
|
addresses.append(addressGroup->toVariant());
|
||||||
@ -335,8 +324,6 @@ void FirewallConf::fromVariant(const QVariant &v)
|
|||||||
{
|
{
|
||||||
const QVariantMap map = v.toMap();
|
const QVariantMap map = v.toMap();
|
||||||
|
|
||||||
m_passwordHash = map["passwordHash"].toString();
|
|
||||||
|
|
||||||
const QVariantList addresses = map["addressGroups"].toList();
|
const QVariantList addresses = map["addressGroups"].toList();
|
||||||
int addrGroupIndex = 0;
|
int addrGroupIndex = 0;
|
||||||
for (const QVariant &av : addresses) {
|
for (const QVariant &av : addresses) {
|
||||||
|
@ -37,8 +37,6 @@ class FirewallConf : public QObject
|
|||||||
Q_PROPERTY(int trafUnit READ trafUnit WRITE setTrafUnit NOTIFY trafUnitChanged)
|
Q_PROPERTY(int trafUnit READ trafUnit WRITE setTrafUnit NOTIFY trafUnitChanged)
|
||||||
Q_PROPERTY(quint32 quotaDayMb READ quotaDayMb WRITE setQuotaDayMb NOTIFY quotaDayMbChanged)
|
Q_PROPERTY(quint32 quotaDayMb READ quotaDayMb WRITE setQuotaDayMb NOTIFY quotaDayMbChanged)
|
||||||
Q_PROPERTY(quint32 quotaMonthMb READ quotaMonthMb WRITE setQuotaMonthMb NOTIFY quotaMonthMbChanged)
|
Q_PROPERTY(quint32 quotaMonthMb READ quotaMonthMb WRITE setQuotaMonthMb NOTIFY quotaMonthMbChanged)
|
||||||
Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY passwordHashChanged)
|
|
||||||
Q_PROPERTY(QString passwordHash READ passwordHash WRITE setPasswordHash NOTIFY passwordHashChanged)
|
|
||||||
Q_PROPERTY(AddressGroup *inetAddressGroup READ inetAddressGroup NOTIFY addressGroupsChanged)
|
Q_PROPERTY(AddressGroup *inetAddressGroup READ inetAddressGroup NOTIFY addressGroupsChanged)
|
||||||
Q_PROPERTY(QQmlListProperty<AddressGroup> addressGroups READ addressGroups NOTIFY addressGroupsChanged)
|
Q_PROPERTY(QQmlListProperty<AddressGroup> addressGroups READ addressGroups NOTIFY addressGroupsChanged)
|
||||||
Q_PROPERTY(QQmlListProperty<AppGroup> appGroups READ appGroups NOTIFY appGroupsChanged)
|
Q_PROPERTY(QQmlListProperty<AppGroup> appGroups READ appGroups NOTIFY appGroupsChanged)
|
||||||
@ -117,11 +115,6 @@ public:
|
|||||||
quint32 quotaMonthMb() const { return m_quotaMonthMb; }
|
quint32 quotaMonthMb() const { return m_quotaMonthMb; }
|
||||||
void setQuotaMonthMb(quint32 quotaMonthMb);
|
void setQuotaMonthMb(quint32 quotaMonthMb);
|
||||||
|
|
||||||
bool hasPassword() const { return !m_passwordHash.isEmpty(); }
|
|
||||||
|
|
||||||
QString passwordHash() const { return m_passwordHash; }
|
|
||||||
void setPasswordHash(const QString &passwordHash);
|
|
||||||
|
|
||||||
quint32 appGroupBits() const;
|
quint32 appGroupBits() const;
|
||||||
void setAppGroupBits(quint32 groupBits);
|
void setAppGroupBits(quint32 groupBits);
|
||||||
|
|
||||||
@ -164,7 +157,6 @@ signals:
|
|||||||
void trafUnitChanged();
|
void trafUnitChanged();
|
||||||
void quotaDayMbChanged();
|
void quotaDayMbChanged();
|
||||||
void quotaMonthMbChanged();
|
void quotaMonthMbChanged();
|
||||||
void passwordHashChanged();
|
|
||||||
void addressGroupsChanged();
|
void addressGroupsChanged();
|
||||||
void appGroupsChanged();
|
void appGroupsChanged();
|
||||||
|
|
||||||
@ -205,8 +197,6 @@ private:
|
|||||||
QString m_activePeriodFrom;
|
QString m_activePeriodFrom;
|
||||||
QString m_activePeriodTo;
|
QString m_activePeriodTo;
|
||||||
|
|
||||||
QString m_passwordHash;
|
|
||||||
|
|
||||||
QList<AddressGroup *> m_addressGroups;
|
QList<AddressGroup *> m_addressGroups;
|
||||||
QList<AppGroup *> m_appGroups;
|
QList<AppGroup *> m_appGroups;
|
||||||
};
|
};
|
||||||
|
@ -433,7 +433,7 @@ void FortManager::exit(int retcode)
|
|||||||
|
|
||||||
bool FortManager::checkPassword()
|
bool FortManager::checkPassword()
|
||||||
{
|
{
|
||||||
const QString passwordHash = firewallConf()->passwordHash();
|
const QString passwordHash = fortSettings()->passwordHash();
|
||||||
if (passwordHash.isEmpty())
|
if (passwordHash.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -687,7 +687,7 @@ void FortManager::updateTrayMenu()
|
|||||||
addHotKey(m_graphWindowAction, fortSettings()->hotKeyGraph(),
|
addHotKey(m_graphWindowAction, fortSettings()->hotKeyGraph(),
|
||||||
conf.logStat());
|
conf.logStat());
|
||||||
|
|
||||||
if (!conf.hasPassword() && !m_firewallConfToEdit) {
|
if (!fortSettings()->hasPassword() && !m_firewallConfToEdit) {
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
m_filterEnabledAction = addAction(
|
m_filterEnabledAction = addAction(
|
||||||
@ -730,7 +730,7 @@ void FortManager::updateTrayMenu()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!conf.hasPassword()) {
|
if (!fortSettings()->hasPassword()) {
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
QAction *quitAction = addAction(
|
QAction *quitAction = addAction(
|
||||||
menu, QIcon(":/images/cross.png"), tr("Quit"),
|
menu, QIcon(":/images/cross.png"), tr("Quit"),
|
||||||
|
@ -18,6 +18,8 @@ class FortSettings : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool debug READ debug WRITE setDebug NOTIFY iniChanged)
|
Q_PROPERTY(bool debug READ debug WRITE setDebug NOTIFY iniChanged)
|
||||||
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY iniChanged)
|
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY iniChanged)
|
||||||
|
Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY iniChanged)
|
||||||
|
Q_PROPERTY(QString passwordHash READ passwordHash WRITE setPasswordHash NOTIFY iniChanged)
|
||||||
Q_PROPERTY(qreal windowAddrSplit READ windowAddrSplit WRITE setWindowAddrSplit NOTIFY iniChanged)
|
Q_PROPERTY(qreal windowAddrSplit READ windowAddrSplit WRITE setWindowAddrSplit NOTIFY iniChanged)
|
||||||
Q_PROPERTY(qreal windowAppsSplit READ windowAppsSplit WRITE setWindowAppsSplit NOTIFY iniChanged)
|
Q_PROPERTY(qreal windowAppsSplit READ windowAppsSplit WRITE setWindowAppsSplit NOTIFY iniChanged)
|
||||||
Q_PROPERTY(bool graphWindowVisible READ graphWindowVisible WRITE setGraphWindowVisible NOTIFY iniChanged)
|
Q_PROPERTY(bool graphWindowVisible READ graphWindowVisible WRITE setGraphWindowVisible NOTIFY iniChanged)
|
||||||
@ -59,6 +61,11 @@ public:
|
|||||||
QString language() const { return iniText("base/language", "en"); }
|
QString language() const { return iniText("base/language", "en"); }
|
||||||
void setLanguage(const QString &v) { setIniValue("base/language", v); }
|
void setLanguage(const QString &v) { setIniValue("base/language", v); }
|
||||||
|
|
||||||
|
bool hasPassword() const { return !passwordHash().isEmpty(); }
|
||||||
|
|
||||||
|
QString passwordHash() const { return iniText("base/passwordHash"); }
|
||||||
|
void setPasswordHash(const QString &v) { setIniValue("base/passwordHash", v); }
|
||||||
|
|
||||||
int iniVersion() const { return iniInt("base/version"); }
|
int iniVersion() const { return iniInt("base/version"); }
|
||||||
void setIniVersion(int v) { setIniValue("base/version", v); }
|
void setIniVersion(int v) { setIniValue("base/version", v); }
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ BasePage {
|
|||||||
function onAboutToSave() { // override
|
function onAboutToSave() { // override
|
||||||
const password = editPassword.text;
|
const password = editPassword.text;
|
||||||
if (password) {
|
if (password) {
|
||||||
firewallConf.passwordHash = stringUtil.cryptoHash(password);
|
fortSettings.passwordHash = stringUtil.cryptoHash(password);
|
||||||
editPassword.text = "";
|
editPassword.text = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,10 +133,10 @@ BasePage {
|
|||||||
id: cbPassword
|
id: cbPassword
|
||||||
text: translationManager.trTrigger
|
text: translationManager.trTrigger
|
||||||
&& qsTranslate("qml", "Password:")
|
&& qsTranslate("qml", "Password:")
|
||||||
checked: firewallConf.hasPassword
|
checked: fortSettings.hasPassword
|
||||||
onToggled: {
|
onToggled: {
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
firewallConf.passwordHash =
|
fortSettings.passwordHash =
|
||||||
editPassword.text = "";
|
editPassword.text = "";
|
||||||
} else {
|
} else {
|
||||||
editPassword.forceActiveFocus();
|
editPassword.forceActiveFocus();
|
||||||
@ -150,9 +150,9 @@ BasePage {
|
|||||||
width: 180
|
width: 180
|
||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
passwordMaskDelay: 300
|
passwordMaskDelay: 300
|
||||||
readOnly: firewallConf.hasPassword || !cbPassword.checked
|
readOnly: fortSettings.hasPassword || !cbPassword.checked
|
||||||
placeholderText: translationManager.trTrigger
|
placeholderText: translationManager.trTrigger
|
||||||
&& (firewallConf.hasPassword
|
&& (fortSettings.hasPassword
|
||||||
? qsTranslate("qml", "Installed")
|
? qsTranslate("qml", "Installed")
|
||||||
: qsTranslate("qml", "Not Installed"))
|
: qsTranslate("qml", "Not Installed"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user