mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:25:56 +00:00
UI: Fix driver setup.
This commit is contained in:
parent
a8b742feda
commit
1983b0b7b9
@ -25,7 +25,9 @@ FortManager::FortManager(QObject *parent) :
|
||||
m_firewallConfToEdit(nullConf()),
|
||||
m_driverManager(new DriverManager(this))
|
||||
{
|
||||
m_fortSettings->readConf(*m_firewallConf);
|
||||
setupDriver();
|
||||
|
||||
loadSettings(m_firewallConf);
|
||||
|
||||
registerQmlTypes();
|
||||
|
||||
@ -50,6 +52,16 @@ void FortManager::registerQmlTypes()
|
||||
qmlRegisterType<LogEntry>("com.fortfirewall", 1, 0, "LogEntry");
|
||||
}
|
||||
|
||||
bool FortManager::setupDriver()
|
||||
{
|
||||
if (!m_driverManager->openDevice()) {
|
||||
showErrorBox(m_driverManager->errorMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FortManager::setupTrayIcon()
|
||||
{
|
||||
m_trayIcon->setToolTip(qApp->applicationDisplayName());
|
||||
@ -75,16 +87,6 @@ void FortManager::setupEngine()
|
||||
Q_ASSERT(m_appWindow);
|
||||
}
|
||||
|
||||
bool FortManager::setupDriver()
|
||||
{
|
||||
if (!m_driverManager->openDevice()) {
|
||||
showErrorBox(m_driverManager->errorMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FortManager::showTrayIcon()
|
||||
{
|
||||
m_trayIcon->show();
|
||||
@ -140,6 +142,16 @@ void FortManager::setFirewallConfToEdit(FirewallConf *conf)
|
||||
emit firewallConfToEditChanged();
|
||||
}
|
||||
|
||||
bool FortManager::loadSettings(FirewallConf *conf)
|
||||
{
|
||||
if (!m_fortSettings->readConf(*conf)) {
|
||||
showErrorBox(m_fortSettings->errorMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return updateDriverConf(conf);
|
||||
}
|
||||
|
||||
bool FortManager::saveSettings(FirewallConf *newConf)
|
||||
{
|
||||
if (!m_fortSettings->writeConf(*newConf)) {
|
||||
@ -152,8 +164,13 @@ bool FortManager::saveSettings(FirewallConf *newConf)
|
||||
|
||||
updateTrayMenu();
|
||||
|
||||
return updateDriverConf(m_firewallConf);
|
||||
}
|
||||
|
||||
bool FortManager::updateDriverConf(FirewallConf *conf)
|
||||
{
|
||||
// Update driver
|
||||
if (!m_driverManager->writeConf(*m_firewallConf)) {
|
||||
if (!m_driverManager->writeConf(*conf)) {
|
||||
showErrorBox(m_driverManager->errorMessage());
|
||||
return false;
|
||||
}
|
||||
@ -161,7 +178,7 @@ bool FortManager::saveSettings(FirewallConf *newConf)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FortManager::updateDriverFlags(FirewallConf *conf)
|
||||
bool FortManager::updateDriverConfFlags(FirewallConf *conf)
|
||||
{
|
||||
// Update driver
|
||||
if (!m_driverManager->writeConfFlags(*conf)) {
|
||||
@ -176,7 +193,7 @@ void FortManager::setAppLogBlocked(bool enable)
|
||||
{
|
||||
m_firewallConf->setAppLogBlocked(enable);
|
||||
|
||||
updateDriverFlags(m_firewallConf);
|
||||
updateDriverConfFlags(m_firewallConf);
|
||||
}
|
||||
|
||||
void FortManager::saveTrayFlags()
|
||||
@ -197,7 +214,7 @@ void FortManager::saveTrayFlags()
|
||||
|
||||
m_fortSettings->writeConfFlags(*m_firewallConf);
|
||||
|
||||
updateDriverFlags(m_firewallConf);
|
||||
updateDriverConfFlags(m_firewallConf);
|
||||
}
|
||||
|
||||
FirewallConf *FortManager::cloneConf(const FirewallConf &conf)
|
||||
|
@ -34,8 +34,6 @@ signals:
|
||||
void firewallConfToEditChanged();
|
||||
|
||||
public slots:
|
||||
bool setupDriver();
|
||||
|
||||
void showTrayIcon();
|
||||
|
||||
void showWindow();
|
||||
@ -58,11 +56,15 @@ private:
|
||||
|
||||
static void registerQmlTypes();
|
||||
|
||||
bool setupDriver();
|
||||
void setupTrayIcon();
|
||||
void setupEngine();
|
||||
|
||||
bool loadSettings(FirewallConf *conf);
|
||||
bool saveSettings(FirewallConf *newConf);
|
||||
bool updateDriverFlags(FirewallConf *conf);
|
||||
|
||||
bool updateDriverConf(FirewallConf *conf);
|
||||
bool updateDriverConfFlags(FirewallConf *conf);
|
||||
|
||||
FirewallConf *cloneConf(const FirewallConf &conf);
|
||||
|
||||
|
@ -22,11 +22,6 @@ int main(int argc, char *argv[])
|
||||
return FortCommon::provRegister(true);
|
||||
}
|
||||
|
||||
// Open the driver device
|
||||
if (!fortManager.setupDriver()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fortManager.showTrayIcon();
|
||||
|
||||
return app.exec();
|
||||
|
Loading…
Reference in New Issue
Block a user