mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:25:18 +00:00
UI: Update driver on services started
This commit is contained in:
parent
23695146eb
commit
322a4e44e3
@ -1151,7 +1151,7 @@ bool ConfManager::validateDriver()
|
||||
return driverManager->validate(buf, verSize);
|
||||
}
|
||||
|
||||
void ConfManager::updateDriverServices()
|
||||
void ConfManager::updateServices()
|
||||
{
|
||||
auto serviceInfoManager = IoC<ServiceInfoManager>();
|
||||
|
||||
@ -1162,9 +1162,14 @@ void ConfManager::updateDriverServices()
|
||||
|
||||
serviceInfoManager->monitorServices(services);
|
||||
|
||||
if (runningServicesCount == 0)
|
||||
return;
|
||||
if (runningServicesCount > 0) {
|
||||
updateDriverServices(services, runningServicesCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfManager::updateDriverServices(
|
||||
const QVector<ServiceInfo> &services, int runningServicesCount)
|
||||
{
|
||||
ConfUtil confUtil;
|
||||
QByteArray buf;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <util/classhelpers.h>
|
||||
#include <util/conf/confappswalker.h>
|
||||
#include <util/ioc/iocservice.h>
|
||||
#include <util/service/serviceinfo.h>
|
||||
#include <util/triggertimer.h>
|
||||
|
||||
class App;
|
||||
@ -85,8 +86,12 @@ public:
|
||||
virtual bool checkPassword(const QString &password);
|
||||
|
||||
bool validateDriver();
|
||||
void updateDriverServices();
|
||||
|
||||
void updateServices();
|
||||
void updateDriverServices(const QVector<ServiceInfo> &services, int runningServicesCount);
|
||||
|
||||
virtual bool updateDriverConf(bool onlyFlags = false);
|
||||
|
||||
void updateDriverZones(quint32 zonesMask, quint32 enabledMask, quint32 dataSize,
|
||||
const QList<QByteArray> &zonesData);
|
||||
|
||||
|
@ -88,6 +88,7 @@ void FortManager::initialize()
|
||||
setupConfManager();
|
||||
setupQuotaManager();
|
||||
setupTaskManager();
|
||||
setupServiceInfoManager();
|
||||
|
||||
setupDriver();
|
||||
loadConf();
|
||||
@ -252,7 +253,7 @@ bool FortManager::setupDriver()
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
confManager->updateDriverServices();
|
||||
confManager->updateServices();
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -329,6 +330,14 @@ void FortManager::setupTaskManager()
|
||||
});
|
||||
}
|
||||
|
||||
void FortManager::setupServiceInfoManager()
|
||||
{
|
||||
auto serviceInfoManager = IoC<ServiceInfoManager>();
|
||||
|
||||
connect(serviceInfoManager, &ServiceInfoManager::servicesStarted, IoC<ConfManager>(),
|
||||
&ConfManager::updateDriverServices);
|
||||
}
|
||||
|
||||
void FortManager::setupTranslationManager()
|
||||
{
|
||||
IoC<TranslationManager>()->switchLanguageByName(IoC<UserSettings>()->iniUser().language());
|
||||
|
@ -47,6 +47,7 @@ private:
|
||||
void setupConfManager();
|
||||
void setupQuotaManager();
|
||||
void setupTaskManager();
|
||||
void setupServiceInfoManager();
|
||||
|
||||
void setupTranslationManager();
|
||||
|
||||
|
@ -90,9 +90,8 @@ QVector<ServiceInfo> getServiceInfoList(SC_HANDLE mngr, DWORD serviceType = SERV
|
||||
for (int infoIndex = infoList.size(); serviceCount > 0;
|
||||
--serviceCount, ++service, ++infoIndex) {
|
||||
|
||||
const auto originalServiceName =
|
||||
QString::fromUtf16((const char16_t *) service->lpServiceName);
|
||||
const auto serviceName = resolveSvcHostServiceName(servicesReg, originalServiceName);
|
||||
auto serviceName = QString::fromUtf16((const char16_t *) service->lpServiceName);
|
||||
serviceName = resolveSvcHostServiceName(servicesReg, serviceName);
|
||||
|
||||
const RegKey svcReg(servicesReg, serviceName);
|
||||
|
||||
@ -251,7 +250,16 @@ void ServiceInfoManager::stopServiceMonitor(ServiceMonitor *serviceMonitor)
|
||||
|
||||
void ServiceInfoManager::onServicesCreated(const QStringList &serviceNames)
|
||||
{
|
||||
for (const QString &serviceName : serviceNames) {
|
||||
const RegKey servicesReg(RegKey::HKLM, servicesSubKey);
|
||||
|
||||
for (const QString &name : serviceNames) {
|
||||
const QString serviceName = resolveSvcHostServiceName(servicesReg, name);
|
||||
|
||||
const RegKey svcReg(servicesReg, serviceName);
|
||||
|
||||
if (!checkIsSvcHostService(svcReg))
|
||||
continue;
|
||||
|
||||
setupServiceMonitor(serviceName);
|
||||
}
|
||||
}
|
||||
@ -262,10 +270,24 @@ void ServiceInfoManager::onServiceStateChanged(ServiceMonitor *serviceMonitor)
|
||||
case ServiceMonitor::ServiceStateUnknown: {
|
||||
} break;
|
||||
case ServiceMonitor::ServiceRunning: {
|
||||
emit serviceStarted(serviceMonitor->serviceName(), serviceMonitor->processId());
|
||||
onServiceStarted(serviceMonitor);
|
||||
} break;
|
||||
case ServiceMonitor::ServiceDeleting: {
|
||||
stopServiceMonitor(serviceMonitor);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceInfoManager::onServiceStarted(ServiceMonitor *serviceMonitor)
|
||||
{
|
||||
constexpr int servicesCount = 1;
|
||||
|
||||
QVector<ServiceInfo> services(servicesCount);
|
||||
|
||||
ServiceInfo &info = services[0];
|
||||
info.isRunning = true;
|
||||
info.processId = serviceMonitor->processId();
|
||||
info.serviceName = serviceMonitor->serviceName();
|
||||
|
||||
emit servicesStarted(services, servicesCount);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
static QString getSvcHostServiceDll(const QString &serviceName);
|
||||
|
||||
signals:
|
||||
void serviceStarted(const QString &serviceName, qint32 processId);
|
||||
void servicesStarted(const QVector<ServiceInfo> &services, int runningServicesCount);
|
||||
|
||||
public slots:
|
||||
virtual void trackService(const QString &serviceName);
|
||||
@ -45,6 +45,7 @@ protected:
|
||||
private:
|
||||
void onServicesCreated(const QStringList &serviceNames);
|
||||
void onServiceStateChanged(ServiceMonitor *serviceMonitor);
|
||||
void onServiceStarted(ServiceMonitor *serviceMonitor);
|
||||
|
||||
private:
|
||||
ServiceListMonitor *m_serviceListMonitor = nullptr;
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
bool isTracked() const { return trackFlags != 0; }
|
||||
|
||||
bool isRunning = 0;
|
||||
bool isRunning = false;
|
||||
quint32 trackFlags = 0;
|
||||
quint32 processId = 0;
|
||||
QString serviceName;
|
||||
|
Loading…
Reference in New Issue
Block a user