Skip to content

Commit

Permalink
Merge pull request #12079 from keymanapp/feat/windows/add-apply-now-u…
Browse files Browse the repository at this point in the history
…pdate

feat(windows): add state machine to control installation including apply now update  💽
  • Loading branch information
rc-swag authored Nov 12, 2024
2 parents dba05b1 + ab3227f commit e58e690
Show file tree
Hide file tree
Showing 29 changed files with 1,822 additions and 269 deletions.
52 changes: 52 additions & 0 deletions common/windows/delphi/general/Keyman.System.ExecutionHistory.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
Keyman is copyright (C) SIL Global. MIT License.
This module provides functionality to track the execution state of the Keyman
engine. It uses a global atom to record whether Keyman has started during the
current session and checks if it has previously run.
}
unit Keyman.System.ExecutionHistory;


interface

const
AtomName = 'KeymanSessionFlag';

function RecordKeymanStarted : Boolean;
function HasKeymanRun : Boolean;

implementation

uses
System.SysUtils,
Winapi.Windows,
KLog;

function RecordKeymanStarted : Boolean;
var
atom: WORD;
begin
atom := GlobalAddAtom(AtomName);
if atom = 0 then
begin
// TODO-WINDOWS-UPDATES: #10210 log to sentry
Result := False;
end
else
Result := True;
end;

function HasKeymanRun : Boolean;
begin
Result := GlobalFindAtom(AtomName) <> 0;
if not Result then
begin
if GetLastError <> ERROR_FILE_NOT_FOUND then
begin
// TODO-WINDOWS-UPDATES: log to Sentry
end;
end;
end;

end.
8 changes: 6 additions & 2 deletions common/windows/delphi/general/RegistryKeys.pas
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ interface

SRegValue_CharMapSourceData = 'charmap source data'; // LM

SRegValue_AvailableLanguages = 'available languages'; //CU
SRegValue_CurrentLanguage = 'current language'; //CU
SRegValue_AvailableLanguages = 'available languages'; // CU
SRegValue_CurrentLanguage = 'current language'; // CU

SRegValue_Update_State = 'update state'; // CU

{ Privacy }

Expand Down Expand Up @@ -312,8 +314,10 @@ interface
SRegValue_ActiveProject_Filename = 'project filename';
SRegValue_ActiveProject_SourcePath = 'source path';

SRegValue_AutomaticUpdates = 'automatic updates'; //CU
SRegValue_CheckForUpdates = 'check for updates'; // CU
SRegValue_LastUpdateCheckTime = 'last update check time'; // CU
SRegValue_ApplyNow = 'apply now'; // CU Start the install now even though it will require an restart

SRegValue_UpdateCheck_UseProxy = 'update check use proxy'; // CU
SRegValue_UpdateCheck_ProxyHost = 'update check proxy host'; // CU
Expand Down
5 changes: 5 additions & 0 deletions oem/firstvoices/windows/src/xml/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@
<!-- Introduced: 7.0.230.0 -->
<string name="koShowWelcome" comment="Startup options - show/hide welcome screen">Show welcome screen</string>

<!-- Context: Configuration Dialog - Options tab -->
<!-- String Type: FormatString -->
<!-- Introduced: 18.0.96.0 -->
<string name="koAutomaticUpdate" comment="Automatically download updates in the background, for installation later">Automatically download updates in the background, for installation later</string>

<!-- Context: Configuration Dialog - Options tab -->
<!-- String Type: FormatString -->
<!-- Introduced: 7.0.230.0 -->
Expand Down
7 changes: 6 additions & 1 deletion windows/src/desktop/kmshell/kmshell.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ uses
Keyman.Configuration.System.Main in 'main\Keyman.Configuration.System.Main.pas',
UpdateXMLRenderer in 'render\UpdateXMLRenderer.pas',
Keyman.System.UpdateCheckStorage in 'main\Keyman.System.UpdateCheckStorage.pas',
Keyman.System.RemoteUpdateCheck in 'main\Keyman.System.RemoteUpdateCheck.pas';
Keyman.System.RemoteUpdateCheck in 'main\Keyman.System.RemoteUpdateCheck.pas',
Keyman.System.UpdateStateMachine in 'main\Keyman.System.UpdateStateMachine.pas',
Keyman.System.DownloadUpdate in 'main\Keyman.System.DownloadUpdate.pas',
Keyman.System.ExecutionHistory in '..\..\..\..\common\windows\delphi\general\Keyman.System.ExecutionHistory.pas',
Keyman.Configuration.UI.UfrmStartInstallNow in 'main\Keyman.Configuration.UI.UfrmStartInstallNow.pas' {frmInstallNow},
Keyman.Configuration.UI.UfrmStartInstall in 'main\Keyman.Configuration.UI.UfrmStartInstall.pas' {frmStartInstall};

{$R VERSION.RES}
{$R manifest.res}
Expand Down
20 changes: 16 additions & 4 deletions windows/src/desktop/kmshell/kmshell.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@
<DCCReference Include="render\UpdateXMLRenderer.pas"/>
<DCCReference Include="main\Keyman.System.UpdateCheckStorage.pas"/>
<DCCReference Include="main\Keyman.System.RemoteUpdateCheck.pas"/>
<DCCReference Include="main\Keyman.System.UpdateStateMachine.pas"/>
<DCCReference Include="main\Keyman.System.DownloadUpdate.pas"/>
<DCCReference Include="..\..\..\..\common\windows\delphi\general\Keyman.System.ExecutionHistory.pas"/>
<DCCReference Include="main\Keyman.Configuration.UI.UfrmStartInstallNow.pas">
<Form>frmInstallNow</Form>
<FormType>dfm</FormType>
</DCCReference>
<DCCReference Include="main\Keyman.Configuration.UI.UfrmStartInstall.pas">
<Form>frmStartInstall</Form>
<FormType>dfm</FormType>
</DCCReference>
<None Include="Profiling\AQtimeModule1.aqt"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
Expand Down Expand Up @@ -418,21 +429,21 @@
<Platform value="Win64">False</Platform>
</Platforms>
<Deployment Version="3">
<DeployFile LocalName="bin\Win32\Debug\kmshell.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile LocalName="bin\Win32\Debug\kmshell.rsm" Configuration="Debug" Class="DebugSymbols">
<Platform Name="Win32">
<RemoteName>kmshell.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="kmshell.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile LocalName="bin\Win32\Debug\kmshell.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>kmshell.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="bin\Win32\Debug\kmshell.rsm" Configuration="Debug" Class="DebugSymbols">
<DeployFile LocalName="kmshell.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>kmshell.rsm</RemoteName>
<RemoteName>kmshell.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
Expand Down Expand Up @@ -1231,6 +1242,7 @@
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
</Deployment>
<ModelSupport>False</ModelSupport>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
Expand Down
Binary file added windows/src/desktop/kmshell/kmshell.res
Binary file not shown.
11 changes: 11 additions & 0 deletions windows/src/desktop/kmshell/main/BackgroundUpdateStateDiagram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
``` mermaid
stateDiagram
[*] --> Idle
Idle --> UpdateAvailable
UpdateAvailable --> Downloading
Downloading --> Installing
Downloading --> WaitingRestart
WaitingRestart --> Installing
Installing --> PostInstall
PostInstall --> Idle
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
object frmStartInstall: TfrmStartInstall
Left = 0
Top = 0
Caption = 'Keyman Update'
ClientHeight = 225
ClientWidth = 425
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object lblInstallUpdate: TLabel
Left = 128
Top = 96
Width = 175
Height = 19
Caption = 'Keyman update available'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object cmdInstall: TButton
Left = 228
Top = 184
Width = 75
Height = 25
Caption = 'Install'
ModalResult = 1
TabOrder = 0
end
object cmdLater: TButton
Left = 336
Top = 184
Width = 75
Height = 25
Caption = 'Close'
ModalResult = 8
TabOrder = 1
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
Keyman is copyright (C) SIL Global. MIT License.
// TODO-WINDOWS-UPDATES: Localise all the labels and captions.
}
unit Keyman.Configuration.UI.UfrmStartInstall;
interface

uses
System.Classes,
System.SysUtils,
System.Variants,
Vcl.Controls,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.Forms,
Vcl.Graphics,
Vcl.StdCtrls,
Winapi.Messages,
Winapi.Windows,
UfrmKeymanBase,
UserMessages;

type
TfrmStartInstall = class(TfrmKeymanBase)
cmdInstall: TButton;
cmdLater: TButton;
lblInstallUpdate: TLabel;
private
public
end;


implementation

{$R *.dfm}


end.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
object frmStartInstallNow: TfrmStartInstallNow
Left = 0
Top = 0
Caption = 'Keyman Update'
ClientHeight = 225
ClientWidth = 425
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object lblUpdateMessage: TLabel
Left = 56
Top = 88
Width = 274
Height = 19
Caption = 'Keyman and Windows will be restarted'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
WordWrap = True
end
object lblUpdateNow: TLabel
Left = 56
Top = 40
Width = 115
Height = 25
Caption = 'Update Now'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object cmdInstall: TButton
Left = 228
Top = 184
Width = 75
Height = 25
Caption = 'Update'
ModalResult = 1
TabOrder = 0
end
object cmdLater: TButton
Left = 336
Top = 184
Width = 75
Height = 25
Caption = 'Close'
ModalResult = 8
TabOrder = 1
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
Keyman is copyright (C) SIL Global. MIT License.
// TODO-WINDOWS-UPDATES: Localise all the labels and captions.
}
unit Keyman.Configuration.UI.UfrmStartInstallNow;
interface

uses
System.Classes,
System.SysUtils,
System.Variants,
Vcl.Controls,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.Forms,
Vcl.Graphics,
Vcl.StdCtrls,
Winapi.Messages,
Winapi.Windows,
UfrmKeymanBase,
UserMessages;

type
TfrmStartInstallNow = class(TfrmKeymanBase)
cmdInstall: TButton;
cmdLater: TButton;
lblUpdateMessage: TLabel;
lblUpdateNow: TLabel;
private
public
end;

implementation

{$R *.dfm}



end.
Loading

0 comments on commit e58e690

Please sign in to comment.