Skip to content

Commit

Permalink
HTTPS support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Oleynikov committed Nov 27, 2019
1 parent 77b18b6 commit d224768
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions NightscoutWatcher.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="2"/>
<MinorVersionNr Value="1"/>
<MinorVersionNr Value="2"/>
<RevisionNr Value="5"/>
<BuildNr Value="106"/>
<BuildNr Value="109"/>
</VersionInfo>
<BuildModes Count="3">
<Item1 Name="Default" Default="True"/>
Expand Down
22 changes: 9 additions & 13 deletions forms/ufMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,23 @@ procedure TfMain.actSetNightscoutSiteExecute(Sender: TObject);
TimerIntervalSecs := -1;
if WasConnected then
TimerIntervalSecs := 20;
DialogResult := TfTimerDialog.Execute(Self, 'Nighscout site', 'Type URL of Nightscout site', Url, [pbOK, pbCancel], TimerIntervalSecs);
Msg := 'Type in URL of Nightscout site.' + #13#10 +
'If there is an error appeare try to change protocol to HTTP instead of HTTPS in URL.';
DialogResult := TfTimerDialog.Execute(Self, 'Nighscout site', Msg, Url, [pbOK, pbCancel], TimerIntervalSecs);
if DialogResult = mrOK then
begin
if (Url <> '') and (SetNightscoutUrl(Url)) then
tmrTimer(tmr)
else
begin
actSetNightscoutSiteExecute(Sender);
end;
end
else if (DialogResult = mrCancel) and not WasConnected then
begin
Msg := 'To obtain CGM data you have to type full URL of your Nightscout site.' + #13#10 +
'Only HTTP protocol is supported.' + #13#10 +
Msg := 'To obtain CGM data you have to type in full URL of your Nightscout site.' + #13#10 +
'To support HTTPS you have to download libeay32.dll and ssleay32.dll and put it to the project directory.' + #13#10 +
'Otherwise only HTTP protocol is supported. Try to change protocol to HTTP instead of HTTPS in URL.' + #13#10#13#10 +
'Do you want to try again?';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetNightscoutSiteExecute(Sender);
Expand Down Expand Up @@ -1255,18 +1260,9 @@ procedure TfMain.HardInvalidate();
function TfMain.SetNightscoutUrl(Url: string): Boolean;
begin
Result := False;
Url := Trim(Url);
if Url = '' then
if Trim(Url) = '' then
Exit;

Url := ReplaceText(Url, 'https://', 'http://');
Url := ReplaceText(Url, 'http://', 'http://');
if Url[Length(Url)] = '/' then
Url := Copy(Url, 1, Length(Url) - 1);

if Pos('http://', Url) < 1 then
Url := 'http://' + Url;

Settings.NightscoutUrl := Url;
Result := True;
end;
Expand Down
10 changes: 5 additions & 5 deletions forms/uftimerdialog.lfm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
object fTimerDialog: TfTimerDialog
Left = 394
Height = 130
Top = 577
Left = 806
Height = 135
Top = 264
Width = 525
BorderStyle = bsDialog
Caption = 'fTimerDialog'
ClientHeight = 130
ClientHeight = 135
ClientWidth = 525
Constraints.MinHeight = 130
Constraints.MinWidth = 400
Expand All @@ -24,7 +24,7 @@ object fTimerDialog: TfTimerDialog
object pb: TButtonPanel
Left = 6
Height = 34
Top = 90
Top = 95
Width = 513
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
Expand Down

0 comments on commit d224768

Please sign in to comment.