From 13ecc147752620555e99aace87372558d538c9f6 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Tue, 30 Apr 2024 15:24:07 +0300 Subject: [PATCH] UI: Portable: Uninstall driver on exit If there is no installed Service or boot-filter. --- src/ui/fortmanager.cpp | 16 +++++++++++++++- src/ui/fortmanager.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index 83e07fc4..5e3747be 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -135,7 +135,7 @@ FortManager::FortManager(QObject *parent) : QObject(parent) { } FortManager::~FortManager() { if (m_initialized) { - closeDriver(); + closeOrRemoveDriver(); } deleteManagers(); @@ -334,6 +334,20 @@ void FortManager::closeDriver() QCoreApplication::sendPostedEvents(this); } +void FortManager::closeOrRemoveDriver() +{ + if (canInstallDriver() && !IoC()->hasService()) { + const FirewallConf *conf = IoC()->conf(); + + if (!conf->bootFilter()) { + removeDriver(); + return; + } + } + + closeDriver(); +} + bool FortManager::canInstallDriver() const { const auto settings = IoC(); diff --git a/src/ui/fortmanager.h b/src/ui/fortmanager.h index 047cb9ff..5ad3fb2f 100644 --- a/src/ui/fortmanager.h +++ b/src/ui/fortmanager.h @@ -44,7 +44,10 @@ private: bool setupDriver(); void closeDriver(); + void closeOrRemoveDriver(); + bool canInstallDriver() const; + void checkReinstallDriver(); void checkDriverOpened(); void checkStartService();