UI: AutoUpdateManager: Run Installer via Service

This commit is contained in:
Nodir Temirkhodjaev 2024-04-28 07:52:01 +03:00
parent f97f307b52
commit beeb294476
11 changed files with 47 additions and 13 deletions

View File

@ -87,7 +87,8 @@ Name: "{commondesktop}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"
[Run]
; 1. Uninstall -> 2. Install Driver -> 3. Portable -> 4. Service
Filename: "{#APP_EXE}"; Parameters: "-u"
Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver"
Filename: "{app}\driver\scripts\reinstall.bat"; Parameters: {code:DriverInstallArgs}; \
Description: "Re-install driver"
Filename: "{#APP_EXE}"; Parameters: "-i portable"; Tasks: portable
Filename: "{#APP_EXE}"; Parameters: "-i service"; Tasks: service
@ -138,6 +139,14 @@ begin
end;
end;
function DriverInstallArgs(Value: string): string;
begin
if ParamExists('/VERYSILENT') then
begin
Result := '/SILENT';
end;
end;
function ShouldLaunch: Boolean;
begin
Result := ParamExists('/LAUNCH') or not (ParamExists('/SILENT') or ParamExists('/VERYSILENT'));

View File

@ -51,7 +51,8 @@ sc start %DRIVERSVC%
:EXIT
@echo End execution... Result Code = %RCODE%
@if %RCODE% neq 0 (
@if %RCODE% neq 0 if "%1" neq "/SILENT" (
@echo ARGS: %*
@pause
)
@exit /b %RCODE%

View File

@ -5,4 +5,4 @@
%COMSPEC% /C "%~dp0uninstall.bat"
"%~dp0install.bat"
"%~dp0install.bat" %*

View File

@ -23,6 +23,7 @@ const char *const commandString(Command cmd)
CASE_STRING(Rpc_AppInfoManager_checkLookupInfoFinished)
CASE_STRING(Rpc_AutoUpdateManager_startDownload)
CASE_STRING(Rpc_AutoUpdateManager_runInstaller)
CASE_STRING(Rpc_AutoUpdateManager_updateState)
CASE_STRING(Rpc_AutoUpdateManager_restartClients)
@ -129,6 +130,7 @@ RpcManager managerByCommand(Command cmd)
Rpc_AppInfoManager, // Rpc_AppInfoManager_checkLookupFinished,
Rpc_AutoUpdateManager, // Rpc_AutoUpdateManager_startDownload,
Rpc_AutoUpdateManager, // Rpc_AutoUpdateManager_runInstaller,
Rpc_AutoUpdateManager, // Rpc_AutoUpdateManager_updateState,
Rpc_AutoUpdateManager, // Rpc_AutoUpdateManager_restartClients,
@ -214,6 +216,7 @@ bool commandRequiresValidation(Command cmd)
0, // Rpc_AppInfoManager_checkLookupFinished,
true, // Rpc_AutoUpdateManager_startDownload,
true, // Rpc_AutoUpdateManager_runInstaller,
0, // Rpc_AutoUpdateManager_updateState,
0, // Rpc_AutoUpdateManager_restartClients,

View File

@ -23,6 +23,7 @@ enum Command : qint8 {
Rpc_AppInfoManager_checkLookupInfoFinished,
Rpc_AutoUpdateManager_startDownload,
Rpc_AutoUpdateManager_runInstaller,
Rpc_AutoUpdateManager_updateState,
Rpc_AutoUpdateManager_restartClients,

View File

@ -8,6 +8,7 @@
#include <form/controls/controlutil.h>
#include <form/home/homecontroller.h>
#include <fortsettings.h>
#include <manager/autoupdatemanager.h>
#include <task/taskinfoupdatechecker.h>
#include <task/taskmanager.h>
@ -99,6 +100,8 @@ QLayout *AboutPage::setupButtonsLayout()
m_btDownload = ControlUtil::createFlatToolButton(
":/icons/download.png", [&] { autoUpdateManager()->startDownload(); });
m_btDownload->setEnabled(!settings()->isPortable());
// Install
m_btInstall = ControlUtil::createFlatToolButton(
":/icons/tick.png", [&] { autoUpdateManager()->runInstaller(); });

View File

@ -180,23 +180,25 @@ bool AutoUpdateManager::runInstaller()
return false;
}
qCDebug(LC) << "Run Installer:" << installerPath << args;
if (settings->hasService()) {
emit restartClients(installerPath);
} else {
OsUtil::quit("new version install");
}
qCDebug(LC) << "Run Installer:" << installerPath << args;
if (settings->isMaster()) {
OsUtil::quit("new version install");
}
return true;
}
QStringList AutoUpdateManager::installerArgs(FortSettings *settings)
{
QStringList args;
QStringList args = { "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NOCANCEL" };
if (!settings->isPortable()) {
args << "/SILENT";
if (settings->forceDebug()) {
args << "/LOG";
}
if (!settings->hasService()) {

View File

@ -51,7 +51,7 @@ public:
public slots:
virtual bool startDownload();
bool runInstaller();
virtual bool runInstaller();
signals:
void flagsChanged();
@ -66,6 +66,7 @@ protected:
void setupDownloader() override;
QString installerPath() const { return m_updatePath + m_fileName; }
QString installerLogPath() const { return m_updatePath + "log.txt"; }
protected slots:
void downloadFinished(const QByteArray &data, bool success) override;

View File

@ -23,6 +23,8 @@ ServiceManager::ServiceManager(QObject *parent) : QObject(parent) { }
void ServiceManager::setUp()
{
qApp->connect(qApp, &QObject::destroyed, [] { reportStatus(SERVICE_STOPPED); });
setupControlManager();
setupConfManager();
}
@ -110,8 +112,6 @@ void ServiceManager::processControl(quint32 code, quint32 eventType)
Q_FALLTHROUGH();
case FORT_SERVICE_CONTROL_UNINSTALL:
case SERVICE_CONTROL_SHUTDOWN: {
qApp->connect(qApp, &QObject::destroyed, [] { reportStatus(SERVICE_STOPPED); });
OsUtil::quit("service control"); // it's threadsafe
state = SERVICE_STOP_PENDING;

View File

@ -36,11 +36,18 @@ bool processAutoUpdateManager_startDownload(AutoUpdateManager *autoUpdateManager
return autoUpdateManager->startDownload();
}
bool processAutoUpdateManager_runInstaller(AutoUpdateManager *autoUpdateManager,
const ProcessCommandArgs & /*p*/, QVariantList & /*resArgs*/)
{
return autoUpdateManager->runInstaller();
}
using processAutoUpdateManager_func = bool (*)(
AutoUpdateManager *autoUpdateManager, const ProcessCommandArgs &p, QVariantList &resArgs);
static processAutoUpdateManager_func processAutoUpdateManager_funcList[] = {
&processAutoUpdateManager_startDownload, // Rpc_AutoUpdateManager_startDownload,
&processAutoUpdateManager_runInstaller, // Rpc_AutoUpdateManager_runInstaller,
};
inline bool processAutoUpdateManagerRpcResult(
@ -48,7 +55,7 @@ inline bool processAutoUpdateManagerRpcResult(
{
const processAutoUpdateManager_func func = RpcManager::getProcessFunc(p.command,
processAutoUpdateManager_funcList, Control::Rpc_AutoUpdateManager_startDownload,
Control::Rpc_AutoUpdateManager_startDownload);
Control::Rpc_AutoUpdateManager_runInstaller);
return func ? func(autoUpdateManager, p, resArgs) : false;
}
@ -137,6 +144,11 @@ bool AutoUpdateManagerRpc::startDownload()
return IoC<RpcManager>()->doOnServer(Control::Rpc_AutoUpdateManager_startDownload);
}
bool AutoUpdateManagerRpc::runInstaller()
{
return IoC<RpcManager>()->doOnServer(Control::Rpc_AutoUpdateManager_runInstaller);
}
void AutoUpdateManagerRpc::setupManager()
{
setupClientSignals();

View File

@ -32,6 +32,8 @@ public:
public slots:
bool startDownload() override;
bool runInstaller() override;
protected:
void setupManager() override;