Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TRemoteUpdateCheckDownloadParams = record

TRemoteUpdateCheck = class
private
FForce: Boolean;
FForce, FManualCheck: Boolean;
FRemoteResult: TRemoteUpdateCheckResult;
FErrorMessage: string;
FShowErrors: Boolean;
Expand All @@ -57,7 +57,7 @@ TRemoteUpdateCheck = class
function DoRun: TRemoteUpdateCheckResult;
public

constructor Create(AForce: Boolean);
constructor Create(AForce, AManualCheck: Boolean);
destructor Destroy; override;
function Run: TRemoteUpdateCheckResult;
property ShowErrors: Boolean read FShowErrors write FShowErrors;
Expand Down Expand Up @@ -95,14 +95,15 @@ implementation

{ TRemoteUpdateCheck }

constructor TRemoteUpdateCheck.Create(AForce: Boolean);
constructor TRemoteUpdateCheck.Create(AForce, AManualCheck: Boolean);
begin
inherited Create;

FShowErrors := True;
FRemoteResult := wucUnknown;

FForce := AForce;
FManualCheck := AManualCheck;

KL.Log('TRemoteUpdateCheck.Create');
end;
Expand Down Expand Up @@ -159,7 +160,7 @@ function TRemoteUpdateCheck.DoRun: TRemoteUpdateCheckResult;
http.Fields.Add('version', ansistring(CKeymanVersionInfo.Version));
http.Fields.Add('tier', ansistring(CKeymanVersionInfo.Tier));
http.Fields.Add('update', '1'); // This is checking for an update
if FForce then
if FManualCheck then
http.Fields.Add('manual', '1')
else
http.Fields.Add('manual', '0');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TState = class abstract
constructor Create(Context: TUpdateStateMachine);
procedure EnterState; virtual; abstract;
procedure ExitState; virtual; abstract;
procedure HandleCheck; virtual; abstract;
procedure HandleCheck(ManualCheck: Boolean); virtual; abstract;
function HandleKmShell: Integer; virtual; abstract;
procedure HandleDownload; virtual; abstract;
procedure HandleAbort; virtual; abstract;
Expand Down Expand Up @@ -80,7 +80,7 @@ TUpdateStateMachine = class
constructor Create(AForce: Boolean);
destructor Destroy; override;

procedure HandleCheck;
procedure HandleCheck(ManualCheck: Boolean);
function HandleKmShell: Integer;
procedure HandleDownload;
procedure HandleAbort;
Expand Down Expand Up @@ -166,7 +166,7 @@ IdleState = class(TState)
public
procedure EnterState; override;
procedure ExitState; override;
procedure HandleCheck; override;
procedure HandleCheck(ManualCheck: Boolean); override;
function HandleKmShell: Integer; override;
procedure HandleDownload; override;
procedure HandleAbort; override;
Expand All @@ -180,7 +180,7 @@ UpdateAvailableState = class(TState)
public
procedure EnterState; override;
procedure ExitState; override;
procedure HandleCheck; override;
procedure HandleCheck(ManualCheck: Boolean); override;
function HandleKmShell: Integer; override;
procedure HandleDownload; override;
procedure HandleAbort; override;
Expand All @@ -192,7 +192,7 @@ DownloadingState = class(TState)
function DownloadUpdatesBackground: Boolean;
procedure EnterState; override;
procedure ExitState; override;
procedure HandleCheck; override;
procedure HandleCheck(ManualCheck: Boolean); override;
function HandleKmShell: Integer; override;
procedure HandleDownload; override;
procedure HandleAbort; override;
Expand All @@ -203,7 +203,7 @@ WaitingRestartState = class(TState)
public
procedure EnterState; override;
procedure ExitState; override;
procedure HandleCheck; override;
procedure HandleCheck(ManualCheck: Boolean); override;
function HandleKmShell: Integer; override;
procedure HandleDownload; override;
procedure HandleAbort; override;
Expand Down Expand Up @@ -238,7 +238,7 @@ InstallingState = class(TState)
public
procedure EnterState; override;
procedure ExitState; override;
procedure HandleCheck; override;
procedure HandleCheck(ManualCheck: Boolean); override;
function HandleKmShell: Integer; override;
procedure HandleDownload; override;
procedure HandleAbort; override;
Expand Down Expand Up @@ -520,11 +520,11 @@ procedure TUpdateStateMachine.RemoveCachedFiles;
end;
end;

procedure TUpdateStateMachine.HandleCheck;
procedure TUpdateStateMachine.HandleCheck(ManualCheck: Boolean);
begin
if not IsCurrentStateAssigned then
Exit;
CurrentState.HandleCheck;
CurrentState.HandleCheck(ManualCheck);
end;

function TUpdateStateMachine.HandleKmShell: Integer;
Expand Down Expand Up @@ -639,13 +639,13 @@ procedure IdleState.ExitState;

end;

procedure IdleState.HandleCheck;
procedure IdleState.HandleCheck(ManualCheck: Boolean);
var
CheckForUpdates: TRemoteUpdateCheck;
Result: TRemoteUpdateCheckResult;
begin

CheckForUpdates := TRemoteUpdateCheck.Create(True);
CheckForUpdates := TRemoteUpdateCheck.Create(True, ManualCheck);
try
Result := CheckForUpdates.Run;
finally
Expand All @@ -669,7 +669,7 @@ function IdleState.HandleKmShell;
// Remote manages the last check time therefore
// we will allow it to return early if it hasn't reached
// the configured time between checks.
CheckForUpdates := TRemoteUpdateCheck.Create(False);
CheckForUpdates := TRemoteUpdateCheck.Create(False, False);
try
UpdateCheckResult := CheckForUpdates.Run;
finally
Expand Down Expand Up @@ -748,13 +748,13 @@ procedure UpdateAvailableState.ExitState;
// Exit UpdateAvailableState
end;

procedure UpdateAvailableState.HandleCheck;
procedure UpdateAvailableState.HandleCheck(ManualCheck: Boolean);
var
CheckForUpdates: TRemoteUpdateCheck;
Result: TRemoteUpdateCheckResult;
begin
// Check if new updates while in this state
CheckForUpdates := TRemoteUpdateCheck.Create(True);
CheckForUpdates := TRemoteUpdateCheck.Create(True, ManualCheck);
try
Result := CheckForUpdates.Run;
finally
Expand Down Expand Up @@ -866,7 +866,7 @@ procedure DownloadingState.ExitState;
// Exit DownloadingState
end;

procedure DownloadingState.HandleCheck;
procedure DownloadingState.HandleCheck(ManualCheck: Boolean);
begin

end;
Expand All @@ -887,7 +887,7 @@ function DownloadingState.HandleKmShell;
bucStateContext.RemoveCachedFiles;
FMutex.ReleaseOwnership; // Mutex must be freed before changing state
ChangeState(IdleState);
bucStateContext.CurrentState.HandleCheck;
bucStateContext.CurrentState.HandleCheck(False);
end;
finally
FreeAndNil(FMutex);
Expand All @@ -906,7 +906,7 @@ procedure DownloadingState.HandleDownload;
bucStateContext.RemoveCachedFiles;
FMutex.ReleaseOwnership; // Mutex must be freed before changing state
ChangeState(IdleState);
bucStateContext.CurrentState.HandleCheck;
bucStateContext.CurrentState.HandleCheck(False);
end;
finally
FreeAndNil(FMutex);
Expand Down Expand Up @@ -961,13 +961,13 @@ procedure WaitingRestartState.ExitState;
// Exit DownloadingState
end;

procedure WaitingRestartState.HandleCheck;
procedure WaitingRestartState.HandleCheck(ManualCheck: Boolean);
var
CheckForUpdates: TRemoteUpdateCheck;
Result: TRemoteUpdateCheckResult;
begin
// Check if new updates while in this state
CheckForUpdates := TRemoteUpdateCheck.Create(True);
CheckForUpdates := TRemoteUpdateCheck.Create(True, ManualCheck);
try
Result := CheckForUpdates.Run;
finally
Expand Down Expand Up @@ -996,7 +996,7 @@ function WaitingRestartState.HandleKmShell;
begin
// Return to Idle state and check for Updates state
ChangeState(IdleState);
bucStateContext.CurrentState.HandleCheck;
bucStateContext.CurrentState.HandleCheck(False);
Result := kmShellContinue;
end
else
Expand Down Expand Up @@ -1198,7 +1198,7 @@ procedure InstallingState.ExitState;

end;

procedure InstallingState.HandleCheck;
procedure InstallingState.HandleCheck(ManualCheck: Boolean);
begin

end;
Expand Down
3 changes: 2 additions & 1 deletion windows/src/desktop/kmshell/main/UfrmMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ procedure TfrmMain.Update_CheckNow;
begin
BUpdateSM := TUpdateStateMachine.Create(False);
try
BUpdateSM.HandleCheck;
// User initiated manual check
BUpdateSM.HandleCheck(True);
finally
BUpdateSM.Free;
end;
Expand Down
4 changes: 3 additions & 1 deletion windows/src/desktop/kmshell/main/initprog.pas
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,9 @@ function ProcessBackgroundUpdate(FMode: TKMShellMode; FSilent: Boolean) : Boolea
try
if (FMode = fmBackgroundUpdateCheck) then
begin
BUpdateSM.HandleCheck;
// -buc BackgroundUpdateCheck is designed to be called by a
// scheduled service therefore it is not a "manual" check
BUpdateSM.HandleCheck(False);
Result := True;
Exit;
end
Expand Down