mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-07 22:47:29 +00:00
feat(windows): Add a installNow event to SM
Added an event for install now when the user wants to manual start the install process straight away.
This commit is contained in:
parent
486586dc8d
commit
2eab485c76
2 changed files with 114 additions and 3 deletions
|
|
@ -180,6 +180,7 @@ const
|
|||
|
||||
SRegValue_Install_Update = 'install update';
|
||||
SRegValue_Update_State = 'update state';
|
||||
SRegValue_Install_Mode = 'install mode';
|
||||
|
||||
{ Privacy }
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ type
|
|||
procedure HandleInstall; virtual; abstract;
|
||||
procedure HandleMSIInstallComplete; virtual; abstract;
|
||||
procedure HandleAbort; virtual; abstract;
|
||||
procedure HandleInstallNow; virtual; abstract;
|
||||
|
||||
// For convenience
|
||||
function StateName: string; virtual; abstract;
|
||||
|
|
@ -111,10 +112,11 @@ type
|
|||
procedure Exit; override;
|
||||
procedure HandleCheck; override;
|
||||
procedure HandleDownload; override;
|
||||
function HandleKmShell : Integer; override;
|
||||
function HandleKmShell : Integer; override;
|
||||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -124,10 +126,11 @@ type
|
|||
procedure Exit; override;
|
||||
procedure HandleCheck; override;
|
||||
procedure HandleDownload; override;
|
||||
function HandleKmShell : Integer; override;
|
||||
function HandleKmShell : Integer; override;
|
||||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -143,6 +146,7 @@ type
|
|||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -156,6 +160,7 @@ type
|
|||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -181,6 +186,7 @@ type
|
|||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -194,6 +200,7 @@ type
|
|||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -207,6 +214,7 @@ type
|
|||
procedure HandleInstall; override;
|
||||
procedure HandleMSIInstallComplete; override;
|
||||
procedure HandleAbort; override;
|
||||
procedure HandleInstallNow; override;
|
||||
function StateName: string; override;
|
||||
end;
|
||||
|
||||
|
|
@ -254,6 +262,7 @@ type
|
|||
function checkUpdateSchedule : Boolean;
|
||||
|
||||
function SetRegistryState (Update : TUpdateState): Boolean;
|
||||
function SetRegistryInstallMode (InstallMode : Boolean): Boolean;
|
||||
|
||||
protected
|
||||
property State: TStateClass read GetState write SetState;
|
||||
|
|
@ -268,10 +277,12 @@ type
|
|||
procedure HandleInstall;
|
||||
procedure HandleMSIInstallComplete;
|
||||
procedure HandleAbort;
|
||||
procedure HandleInstallNow;
|
||||
function CurrentStateName: string;
|
||||
|
||||
property ShowErrors: Boolean read FShowErrors write FShowErrors;
|
||||
function CheckRegistryState : TUpdateState;
|
||||
function CheckRegistryInstallMode : Boolean;
|
||||
|
||||
end;
|
||||
|
||||
|
|
@ -459,6 +470,57 @@ begin
|
|||
Result := UpdateState;
|
||||
end;
|
||||
|
||||
function TBackgroundUpdate.SetRegistryInstallMode (InstallMode : Boolean): Boolean;
|
||||
var
|
||||
InstallModeStr : string;
|
||||
begin
|
||||
|
||||
Result := False;
|
||||
with TRegistryErrorControlled.Create do
|
||||
try
|
||||
RootKey := HKEY_LOCAL_MACHINE;
|
||||
KL.Log('SetRegistryState State Entry');
|
||||
if OpenKey(SRegKey_KeymanEngine_LM, True) then
|
||||
begin
|
||||
InstallModeStr := BoolToStr(InstallMode, True);
|
||||
WriteString(SRegValue_Install_Mode, InstallModeStr);
|
||||
KL.Log('SetRegistryInstallMode is:[' + InstallModeStr + ']');
|
||||
end;
|
||||
Result := True;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function TBackgroundUpdate.CheckRegistryInstallMode : Boolean;
|
||||
var
|
||||
InstallMode : Boolean;
|
||||
|
||||
begin
|
||||
// We will use a registry flag to maintain the install mode background/foreground
|
||||
|
||||
InstallMode := False;
|
||||
// check the registry value
|
||||
with TRegistryErrorControlled.Create do // I2890
|
||||
try
|
||||
RootKey := HKEY_LOCAL_MACHINE;
|
||||
if OpenKeyReadOnly(SRegKey_KeymanEngine_LM) and ValueExists(SRegValue_Install_Mode) then
|
||||
begin
|
||||
InstallMode := StrToBool(ReadString(SRegValue_Install_Mode));
|
||||
KL.Log('CheckRegistryState State is:[' + ReadString(SRegValue_Update_State) + ']');
|
||||
end
|
||||
else
|
||||
begin
|
||||
InstallMode := False; // default to background
|
||||
KL.Log('CheckRegistryInstallMode reg value not found default:[ False ]');
|
||||
end
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
Result := InstallMode;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
//function TBackgroundUpdate.IsKeymanRunning: Boolean; // I2329
|
||||
|
|
@ -612,6 +674,11 @@ begin
|
|||
CurrentState.HandleAbort;
|
||||
end;
|
||||
|
||||
procedure TBackgroundUpdate.HandleInstallNow;
|
||||
begin
|
||||
CurrentState.HandleInstallNow;
|
||||
end;
|
||||
|
||||
function TBackgroundUpdate.CurrentStateName: string;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -699,6 +766,12 @@ begin
|
|||
// Implement your logic here
|
||||
end;
|
||||
|
||||
procedure IdleState.HandleInstallNow;
|
||||
begin
|
||||
bucStateContext.SetRegistryInstallMode(True);
|
||||
bucStateContext.CurrentState.HandleCheck;
|
||||
end;
|
||||
|
||||
function IdleState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -713,7 +786,7 @@ begin
|
|||
bucStateContext.SetRegistryState(usUpdateAvailable);
|
||||
if bucStateContext.FAuto then
|
||||
begin
|
||||
bucStateContext.CurrentState.HandleDownload ;
|
||||
bucStateContext.CurrentState.HandleDownload;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -756,6 +829,12 @@ begin
|
|||
// Implement your logic here
|
||||
end;
|
||||
|
||||
procedure UpdateAvailableState.HandleInstallNow;
|
||||
begin
|
||||
bucStateContext.SetRegistryInstallMode(True);
|
||||
ChangeState(DownloadingState);
|
||||
end;
|
||||
|
||||
function UpdateAvailableState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -831,6 +910,12 @@ begin
|
|||
// Implement your logic here
|
||||
end;
|
||||
|
||||
procedure DownloadingState.HandleInstallNow;
|
||||
begin
|
||||
bucStateContext.SetRegistryInstallMode(True);
|
||||
// Continue downloading
|
||||
end;
|
||||
|
||||
function DownloadingState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -939,6 +1024,14 @@ begin
|
|||
// Implement your logic here
|
||||
end;
|
||||
|
||||
procedure WaitingRestartState.HandleInstallNow;
|
||||
begin
|
||||
bucStateContext.SetRegistryInstallMode(True);
|
||||
// Notify User to install
|
||||
ChangeState(InstallingState);
|
||||
|
||||
end;
|
||||
|
||||
function WaitingRestartState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -1080,6 +1173,11 @@ begin
|
|||
ChangeState(IdleState);
|
||||
end;
|
||||
|
||||
procedure InstallingState.HandleInstallNow;
|
||||
begin
|
||||
// Do Nothing. Need the UI to let user know installation in progress OR
|
||||
end;
|
||||
|
||||
function InstallingState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -1130,6 +1228,13 @@ begin
|
|||
// Implement your logic here
|
||||
end;
|
||||
|
||||
procedure RetryState.HandleInstallNow;
|
||||
begin
|
||||
bucStateContext.SetRegistryInstallMode(True);
|
||||
// TODO: #10038 handle retry counts
|
||||
ChangeState(InstallingState);
|
||||
end;
|
||||
|
||||
function RetryState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
@ -1198,6 +1303,11 @@ begin
|
|||
// Handle Abort
|
||||
end;
|
||||
|
||||
procedure WaitingPostInstallState.HandleInstallNow;
|
||||
begin
|
||||
// Do nothing as files will be cleaned via HandleKmShell
|
||||
end;
|
||||
|
||||
function WaitingPostInstallState.StateName;
|
||||
begin
|
||||
// Implement your logic here
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue