From 02fe64b0e71cf728e70082641e1e06452008fae8 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Tue, 10 Apr 2018 10:37:17 -0400 Subject: [PATCH 1/5] Compensate for Windows Locale settings issue Sometime decimal separator may be`,` instead of `.`. Conversion from string to float requires separator to be `.` as the value being converted comes with a `.` separator, regardless of Locale settings. --- Delphi/Project/Source/uInstallLocationFrm.pas | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index ccf545f..f3aa382 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -172,8 +172,8 @@ procedure TfrmInstallLocation.FormCreate(Sender: TObject); constructor TCheckTLS.Create(aRESTRequest: TRestRequest; aRESTResponse: TRESTResponse); var - splitVersion: TArray; actualVersion: double; + lFormatSettings: TFormatSettings; begin aRESTRequest.Execute; fStatusCode := aRESTResponse.StatusCode; @@ -182,14 +182,19 @@ constructor TCheckTLS.Create(aRESTRequest: TRestRequest; aRESTResponse: TRESTRes fTLSVersion := ''; if fStatusCode = 200 then begin - fTLSVersion := aRESTResponse.JSONText.Replace('"',''); - splitVersion := fTLSVersion.Split([' ']); - actualVersion := splitVersion[1].ToDouble; + lFormatSettings := TFormatSettings.Create; + lformatSettings.ThousandSeparator := ','; + lFormatSettings.DecimalSeparator := '.'; + fTLSVersion := aRESTResponse.JSONText.Replace('"TLS ',''); + fTLSVersion := fTLSVersion + .Replace('"','') + .Replace(' ',''); + actualVersion := StrToFloat(fTLSVersion, lFormatSettings); fTLSOK := actualVersion >= cDesiredVersion; if not fTLSOK then fMessageStr := format('TLS Version = %s, must be %0.1f or greater.'+#13#10+ 'GitHub requires at least version 1.2'+#13#10+ - 'Please follow the link to Microsoft for instructions on updating Windows.',[splitVersion[1],cDesiredVersion]); + 'Please follow the link to Microsoft for instructions on updating Windows.',[fTLSVersion,cDesiredVersion]); end else begin From 84675b3e7cd806642beaf4a562dc8ae72bcb4e4d Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Tue, 10 Apr 2018 10:37:58 -0400 Subject: [PATCH 2/5] Bump internal version --- Delphi/Project/ExercismCLIInstaller.dproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index 5926f87..21968f5 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -93,8 +93,8 @@ true true true - CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.1.15;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.1.0;Comments= - 15 + CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.1.17;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.1.0;Comments= + 17 1 @@ -109,9 +109,9 @@ true 2 true - CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.14;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= + CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.16;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= img\ExercismCLIInstaller_Icon.ico - 14 + 16 2 From aff17c3b9e0626601addd913f7d5a870368ff0e2 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Tue, 10 Apr 2018 21:37:54 -0400 Subject: [PATCH 3/5] Fix case. --- Delphi/Project/Source/uInstallLocationFrm.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index f3aa382..a5d03d3 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -183,7 +183,7 @@ constructor TCheckTLS.Create(aRESTRequest: TRestRequest; aRESTResponse: TRESTRes if fStatusCode = 200 then begin lFormatSettings := TFormatSettings.Create; - lformatSettings.ThousandSeparator := ','; + lFormatSettings.ThousandSeparator := ','; lFormatSettings.DecimalSeparator := '.'; fTLSVersion := aRESTResponse.JSONText.Replace('"TLS ',''); fTLSVersion := fTLSVersion From 16b313966c6952719a74242bdb3acd72c4116cfa Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Tue, 10 Apr 2018 21:43:38 -0400 Subject: [PATCH 4/5] trigger TLS check from timer Moved TLS to a timer event instead of Form Activate event. The form would delay painting while waiting for TLS check to complete. Effect is corrected when TLS check is triggered from timer event. --- Delphi/Project/Source/uInstallLocationFrm.dfm | 7 +++++++ Delphi/Project/Source/uInstallLocationFrm.pas | 20 +++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index 885ffb2..79d2fee 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -259,4 +259,11 @@ object frmInstallLocation: TfrmInstallLocation Left = 416 Top = 48 end + object tmrCheckTLS: TTimer + Enabled = False + Interval = 200 + OnTimer = tmrCheckTLSTimer + Left = 76 + Top = 200 + end end diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index a5d03d3..7a91070 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -59,11 +59,13 @@ TfrmInstallLocation = class(TForm) rrCheckTLSVersion: TRESTRequest; rResponseCheckTLSVersion: TRESTResponse; lblUpdateTLS: TOvcURL; + tmrCheckTLS: TTimer; procedure btnCancelClick(Sender: TObject); procedure btnNextClick(Sender: TObject); procedure btnBrowseClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); + procedure tmrCheckTLSTimer(Sender: TObject); private { Private declarations } public @@ -150,9 +152,21 @@ procedure TfrmInstallLocation.btnNextClick(Sender: TObject); end; procedure TfrmInstallLocation.FormActivate(Sender: TObject); +begin + tmrCheckTLS.Enabled := true; +end; + +procedure TfrmInstallLocation.FormCreate(Sender: TObject); +begin + NextClicked := false; + SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW); +end; + +procedure TfrmInstallLocation.tmrCheckTLSTimer(Sender: TObject); var CheckTLS: ICheckTLS; begin + tmrCheckTLS.Enabled := false; CheckTLS := TCheckTLS.Create(rrCheckTLSVersion, rResponseCheckTLSVersion); btnNext.Enabled := CheckTLS.TLSok; if not btnNext.Enabled then @@ -162,12 +176,6 @@ procedure TfrmInstallLocation.FormActivate(Sender: TObject); end; end; -procedure TfrmInstallLocation.FormCreate(Sender: TObject); -begin - NextClicked := false; - SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW); -end; - { TCheckTLS } constructor TCheckTLS.Create(aRESTRequest: TRestRequest; aRESTResponse: TRESTResponse); From eaae4b1c2ee8a8886b4a60be99004025c2d24257 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Tue, 10 Apr 2018 21:56:38 -0400 Subject: [PATCH 5/5] Bump Internal Version --- Delphi/Project/ExercismCLIInstaller.dproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index 21968f5..452252c 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -109,9 +109,9 @@ true 2 true - CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.16;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= + CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.18;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= img\ExercismCLIInstaller_Icon.ico - 16 + 18 2