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