mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-09 10:25:32 +00:00
feat(windows): address review comments
This commit is contained in:
parent
740f787a9b
commit
fc40aa7c8e
2 changed files with 11 additions and 58 deletions
|
|
@ -56,8 +56,6 @@ type
|
|||
property ShowErrors: Boolean read FShowErrors write FShowErrors;
|
||||
end;
|
||||
|
||||
procedure LogMessage(LogMessage: string);
|
||||
|
||||
(**
|
||||
* This function checks if a week or CheckPeriod time has passed since the last
|
||||
* update check.
|
||||
|
|
@ -73,11 +71,13 @@ uses
|
|||
System.Win.Registry,
|
||||
Winapi.Windows,
|
||||
Winapi.WinINet,
|
||||
Sentry.Client,
|
||||
|
||||
GlobalProxySettings,
|
||||
KLog,
|
||||
keymanapi_TLB,
|
||||
KeymanVersion,
|
||||
Keyman.System.KeymanSentryClient,
|
||||
Keyman.System.UpdateCheckStorage,
|
||||
kmint,
|
||||
ErrorControlledRegistry,
|
||||
|
|
@ -103,7 +103,8 @@ end;
|
|||
destructor TRemoteUpdateCheck.Destroy;
|
||||
begin
|
||||
if (FErrorMessage <> '') and FShowErrors then
|
||||
LogMessage(FErrorMessage);
|
||||
TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR,
|
||||
'"+FErrorMessage+"');
|
||||
|
||||
KL.Log('TRemoteUpdateCheck.Destroy: FErrorMessage = ' + FErrorMessage);
|
||||
KL.Log('TRemoteUpdateCheck.Destroy: FRemoteResult = ' +
|
||||
|
|
@ -223,13 +224,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
// temp wrapper for converting showmessage to logs don't know where
|
||||
// if nt using klog
|
||||
procedure LogMessage(LogMessage: string);
|
||||
begin
|
||||
KL.Log(LogMessage);
|
||||
end;
|
||||
|
||||
function ConfigCheckContinue: Boolean;
|
||||
var
|
||||
Registry: TRegistryErrorControlled;
|
||||
|
|
@ -260,7 +254,8 @@ begin
|
|||
on E: ERegistryException do
|
||||
begin
|
||||
Result := False;
|
||||
LogMessage(E.Message);
|
||||
TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR,
|
||||
E.Message);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ var
|
|||
FResult: Boolean;
|
||||
RootPath: string;
|
||||
begin
|
||||
// call seperate process
|
||||
// call separate process
|
||||
RootPath := ExtractFilePath(ParamStr(0));
|
||||
FResult := TUtilExecute.ShellCurrentUser(0, ParamStr(0),
|
||||
IncludeTrailingPathDelimiter(RootPath), '-bd');
|
||||
|
|
@ -746,8 +746,10 @@ begin
|
|||
|
||||
if (not DownloadResult) then
|
||||
begin
|
||||
// Failed three times in this process return to the
|
||||
// IdleState to wait 7 days before trying again
|
||||
// Failed three times in this process; return to the
|
||||
// IdleState to wait 'CheckPeriod' before trying again
|
||||
TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR,
|
||||
'Error Updates not downloaded after 3 attempts');
|
||||
ChangeState(IdleState);
|
||||
end
|
||||
else
|
||||
|
|
@ -1016,48 +1018,4 @@ begin
|
|||
// Result := kmShellContinue;
|
||||
end;
|
||||
|
||||
// Private Functions:
|
||||
function ConfigCheckContinue: Boolean;
|
||||
var
|
||||
Registry: TRegistryErrorControlled;
|
||||
begin
|
||||
{ Verify that it has been at least CheckPeriod days since last update check }
|
||||
Result := False;
|
||||
try
|
||||
Registry := TRegistryErrorControlled.Create; // I2890
|
||||
try
|
||||
if Registry.OpenKeyReadOnly(SRegKey_KeymanDesktop_CU) then
|
||||
begin
|
||||
if Registry.ValueExists(SRegValue_CheckForUpdates) and
|
||||
not Registry.ReadBool(SRegValue_CheckForUpdates) then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
if Registry.ValueExists(SRegValue_LastUpdateCheckTime) and
|
||||
(Now - Registry.ReadDateTime(SRegValue_LastUpdateCheckTime) >
|
||||
CheckPeriod) then
|
||||
begin
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
Exit;
|
||||
end;
|
||||
finally
|
||||
Registry.Free;
|
||||
end;
|
||||
except
|
||||
{ we will not run the check if an error occurs reading the settings }
|
||||
on E: Exception do
|
||||
begin
|
||||
Result := False;
|
||||
LogMessage(E.Message);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue