mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:32:56 +00:00
UIL RpcManager: Add AutoUpdateManager
This commit is contained in:
parent
30c2e7bfa4
commit
6041c6773e
@ -17,11 +17,12 @@ const char *const commandString(Command cmd)
|
||||
CASE_STRING(Rpc_Result_Error)
|
||||
|
||||
CASE_STRING(Rpc_RpcManager_initClient)
|
||||
CASE_STRING(Rpc_RpcManager_restartClient)
|
||||
|
||||
CASE_STRING(Rpc_AppInfoManager_lookupAppInfo)
|
||||
CASE_STRING(Rpc_AppInfoManager_checkLookupInfoFinished)
|
||||
|
||||
CASE_STRING(Rpc_AutoUpdateManager_restartClients)
|
||||
|
||||
CASE_STRING(Rpc_ConfManager_saveVariant)
|
||||
CASE_STRING(Rpc_ConfManager_exportMasterBackup)
|
||||
CASE_STRING(Rpc_ConfManager_importMasterBackup)
|
||||
@ -91,6 +92,7 @@ const char *const rpcManagerString(RpcManager rpcManager)
|
||||
switch (rpcManager) {
|
||||
CASE_STRING(Rpc_NoneManager)
|
||||
CASE_STRING(Rpc_AppInfoManager)
|
||||
CASE_STRING(Rpc_AutoUpdateManager)
|
||||
CASE_STRING(Rpc_ConfManager)
|
||||
CASE_STRING(Rpc_ConfAppManager)
|
||||
CASE_STRING(Rpc_ConfRuleManager)
|
||||
@ -117,11 +119,12 @@ RpcManager managerByCommand(Command cmd)
|
||||
Rpc_NoneManager, // Rpc_Result_Error,
|
||||
|
||||
Rpc_NoneManager, // Rpc_RpcManager_initClient,
|
||||
Rpc_NoneManager, // Rpc_RpcManager_restartClient,
|
||||
|
||||
Rpc_AppInfoManager, // Rpc_AppInfoManager_lookupAppInfo,
|
||||
Rpc_AppInfoManager, // Rpc_AppInfoManager_checkLookupFinished,
|
||||
|
||||
Rpc_AutoUpdateManager, // Rpc_AutoUpdateManager_restartClients,
|
||||
|
||||
Rpc_ConfManager, // Rpc_ConfManager_saveVariant,
|
||||
Rpc_ConfManager, // Rpc_ConfManager_exportMasterBackup,
|
||||
Rpc_ConfManager, // Rpc_ConfManager_importMasterBackup,
|
||||
@ -197,11 +200,12 @@ bool commandRequiresValidation(Command cmd)
|
||||
0, // Rpc_Result_Error,
|
||||
|
||||
0, // Rpc_RpcManager_initClient,
|
||||
0, // Rpc_RpcManager_restartClient,
|
||||
|
||||
true, // Rpc_AppInfoManager_lookupAppInfo,
|
||||
0, // Rpc_AppInfoManager_checkLookupFinished,
|
||||
|
||||
0, // Rpc_AutoUpdateManager_restartClients,
|
||||
|
||||
true, // Rpc_ConfManager_saveVariant,
|
||||
true, // Rpc_ConfManager_exportMasterBackup,
|
||||
true, // Rpc_ConfManager_importMasterBackup,
|
||||
|
@ -17,11 +17,12 @@ enum Command : qint8 {
|
||||
Rpc_Result_Error,
|
||||
|
||||
Rpc_RpcManager_initClient,
|
||||
Rpc_RpcManager_restartClient,
|
||||
|
||||
Rpc_AppInfoManager_lookupAppInfo,
|
||||
Rpc_AppInfoManager_checkLookupInfoFinished,
|
||||
|
||||
Rpc_AutoUpdateManager_restartClients,
|
||||
|
||||
Rpc_ConfManager_saveVariant,
|
||||
Rpc_ConfManager_exportMasterBackup,
|
||||
Rpc_ConfManager_importMasterBackup,
|
||||
@ -86,6 +87,7 @@ enum Command : qint8 {
|
||||
enum RpcManager : qint8 {
|
||||
Rpc_NoneManager = 0,
|
||||
Rpc_AppInfoManager,
|
||||
Rpc_AutoUpdateManager,
|
||||
Rpc_ConfManager,
|
||||
Rpc_ConfAppManager,
|
||||
Rpc_ConfRuleManager,
|
||||
|
@ -82,7 +82,7 @@ bool AutoUpdateManager::runInstaller()
|
||||
return false;
|
||||
|
||||
QStringList args;
|
||||
fillInstallerArgs(args);
|
||||
prepareInstaller(args);
|
||||
|
||||
if (!QProcess::startDetached(exePath, args))
|
||||
return false;
|
||||
@ -90,7 +90,7 @@ bool AutoUpdateManager::runInstaller()
|
||||
return true;
|
||||
}
|
||||
|
||||
void AutoUpdateManager::fillInstallerArgs(QStringList &args) const
|
||||
void AutoUpdateManager::prepareInstaller(QStringList &args)
|
||||
{
|
||||
auto settings = IoC<FortSettings>();
|
||||
|
||||
@ -101,6 +101,6 @@ void AutoUpdateManager::fillInstallerArgs(QStringList &args) const
|
||||
if (!settings->hasService()) {
|
||||
args << "/AUTORUN";
|
||||
} else if (settings->isService()) {
|
||||
IoC<RpcManager>()->invokeOnClients(Control::Rpc_RpcManager_restartClient);
|
||||
emit restartClients();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ public:
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
signals:
|
||||
void restartClients();
|
||||
|
||||
protected:
|
||||
void setupDownloader() override;
|
||||
|
||||
@ -29,7 +32,7 @@ protected slots:
|
||||
void clearUpdateDir();
|
||||
|
||||
bool runInstaller();
|
||||
void fillInstallerArgs(QStringList &args) const;
|
||||
void prepareInstaller(QStringList &args);
|
||||
|
||||
private:
|
||||
static QString getDownloadUrl();
|
||||
|
@ -1,6 +1,33 @@
|
||||
#include "autoupdatemanagerrpc.h"
|
||||
|
||||
#include <rpc/rpcmanager.h>
|
||||
#include <util/ioc/ioccontainer.h>
|
||||
#include <util/osutil.h>
|
||||
|
||||
AutoUpdateManagerRpc::AutoUpdateManagerRpc(const QString &cachePath, QObject *parent) :
|
||||
AutoUpdateManager(cachePath, parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool AutoUpdateManagerRpc::processServerCommand(const ProcessCommandArgs &p,
|
||||
QVariantList & /*resArgs*/, bool & /*ok*/, bool & /*isSendResult*/)
|
||||
{
|
||||
auto autoUpdateManager = IoC<AutoUpdateManager>();
|
||||
|
||||
switch (p.command) {
|
||||
case Control::Rpc_AutoUpdateManager_restartClients:
|
||||
QMetaObject::invokeMethod(
|
||||
autoUpdateManager, [] { OsUtil::restartClient(); }, Qt::QueuedConnection);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void AutoUpdateManagerRpc::setupServerSignals(RpcManager *rpcManager)
|
||||
{
|
||||
auto autoUpdateManager = IoC<AutoUpdateManager>();
|
||||
|
||||
connect(autoUpdateManager, &AutoUpdateManager::restartClients, rpcManager,
|
||||
[&] { rpcManager->invokeOnClients(Control::Rpc_AutoUpdateManager_restartClients); });
|
||||
}
|
||||
|
@ -5,12 +5,19 @@
|
||||
|
||||
class RpcManager;
|
||||
|
||||
struct ProcessCommandArgs;
|
||||
|
||||
class AutoUpdateManagerRpc : public AutoUpdateManager
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutoUpdateManagerRpc(const QString &cachePath, QObject *parent = nullptr);
|
||||
|
||||
static bool processServerCommand(
|
||||
const ProcessCommandArgs &p, QVariantList &resArgs, bool &ok, bool &isSendResult);
|
||||
|
||||
static void setupServerSignals(RpcManager *rpcManager);
|
||||
};
|
||||
|
||||
#endif // AUTOUPDATEMANAGERRPC_H
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <fortsettings.h>
|
||||
#include <manager/windowmanager.h>
|
||||
#include <rpc/appinfomanagerrpc.h>
|
||||
#include <rpc/autoupdatemanagerrpc.h>
|
||||
#include <rpc/confappmanagerrpc.h>
|
||||
#include <rpc/confmanagerrpc.h>
|
||||
#include <rpc/confrulemanagerrpc.h>
|
||||
@ -79,6 +80,7 @@ void RpcManager::tearDown()
|
||||
void RpcManager::setupServerSignals()
|
||||
{
|
||||
AppInfoManagerRpc::setupServerSignals(this);
|
||||
AutoUpdateManagerRpc::setupServerSignals(this);
|
||||
ConfManagerRpc::setupServerSignals(this);
|
||||
ConfAppManagerRpc::setupServerSignals(this);
|
||||
ConfRuleManagerRpc::setupServerSignals(this);
|
||||
@ -210,11 +212,6 @@ bool RpcManager::processCommandRpc(const ProcessCommandArgs &p)
|
||||
return true;
|
||||
}
|
||||
|
||||
case Control::Rpc_RpcManager_restartClient: {
|
||||
QMetaObject::invokeMethod(this, [] { OsUtil::restartClient(); }, Qt::QueuedConnection);
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return processManagerRpc(p);
|
||||
}
|
||||
@ -222,6 +219,7 @@ bool RpcManager::processCommandRpc(const ProcessCommandArgs &p)
|
||||
|
||||
static processManager_func processManager_funcList[] = {
|
||||
&AppInfoManagerRpc::processServerCommand, // Control::Rpc_AppInfoManager,
|
||||
&AutoUpdateManagerRpc::processServerCommand, // Control::Rpc_AutoUpdateManager,
|
||||
&ConfManagerRpc::processServerCommand, // Control::Rpc_ConfManager,
|
||||
&ConfAppManagerRpc::processServerCommand, // Control::Rpc_ConfAppManager,
|
||||
&ConfRuleManagerRpc::processServerCommand, // Control::Rpc_ConfRuleManager,
|
||||
|
Loading…
Reference in New Issue
Block a user