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