Skip to content

Commit

Permalink
Logging consent dialog implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
LongDirtyAnimAlf committed Dec 7, 2017
1 parent 98fb318 commit 1e743ef
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
6 changes: 2 additions & 4 deletions extrasettings.lfm
Expand Up @@ -345,14 +345,12 @@ object Form2: TForm2
Height = 19
Hint = 'Location and install info will be send to public central fpcupdeluxe server.'
Top = 279
Width = 246
Width = 243
BorderSpacing.Left = 4
BorderSpacing.Top = 6
Caption = 'Send location and install info (default=yes)'
Checked = True
Caption = 'Send location and install info (default=no)'
ParentShowHint = False
ShowHint = True
State = cbChecked
TabOrder = 11
end
end
Expand Down
11 changes: 7 additions & 4 deletions extrasettings.pas
Expand Up @@ -143,6 +143,7 @@ TForm2 = class(TForm)
procedure SetAutoSwitchURL(value:boolean);

function GetSendInfo:boolean;
procedure SetSendInfo(value:boolean);

function GetHTTPProxyHost:string;
function GetHTTPProxyPort:integer;
Expand Down Expand Up @@ -190,7 +191,7 @@ TForm2 = class(TForm)
property UseWget:boolean read GetUseWget write SetUseWget;
property ExtraVerbose:boolean read GetExtraVerbose write SetExtraVerbose;
property AutoSwitchURL:boolean read GetAutoSwitchURL write SetAutoSwitchURL;
property SendInfo:boolean read GetSendInfo;
property SendInfo:boolean read GetSendInfo write SetSendInfo;

property HTTPProxyHost:string read GetHTTPProxyHost;
property HTTPProxyPort:integer read GetHTTPProxyPort;
Expand Down Expand Up @@ -282,8 +283,6 @@ procedure TForm2.FormCreate(Sender: TObject);

{$ifdef RemoteLog}
CheckSendInfo.Checked:=ReadBool('General','SendInfo',True);
{$else}
CheckSendInfo.Checked:=ReadBool('General','SendInfo',False);
{$endif}

EditHTTPProxyHost.Text:=ReadString('ProxySettings','HTTPProxyURL','');
Expand Down Expand Up @@ -328,9 +327,9 @@ procedure TForm2.FormCreate(Sender: TObject);
{$endif CPUARM}

{$ifndef RemoteLog}
CheckSendInfo.Checked:=False;
CheckSendInfo.Enabled:=false;
{$endif}

end;

procedure TForm2.SetInstallDir(const aInstallDir:string='');
Expand Down Expand Up @@ -744,6 +743,10 @@ function TForm2.GetSendInfo:boolean;
begin
result:=CheckSendInfo.Checked;
end;
procedure TForm2.SetSendInfo(value:boolean);
begin
CheckSendInfo.Checked:=value;
end;

function TForm2.GetFPCOptions:string;
begin
Expand Down
37 changes: 32 additions & 5 deletions fpcupdeluxemainform.pas
Expand Up @@ -101,6 +101,7 @@ TForm1 = class(TForm)
MissingTools:boolean;
InternalError:string;
{$ifdef RemoteLog}
sConsentWarning:boolean;
aDataClient:TDataClient;
{$endif}
function InstallCrossCompiler(Sender: TObject):boolean;
Expand Down Expand Up @@ -264,6 +265,9 @@ procedure TForm1.FormCreate(Sender: TObject);
with TIniFile.Create(SafeGetApplicationPath+DELUXEFILENAME) do
try
sInstallDir:=ReadString('General','InstallDirectory',sInstallDir);
{$ifdef RemoteLog}
sConsentWarning:=ReadBool('General','ConsentWarning',true);
{$endif}
CheckAutoClear.Checked:=ReadBool('General','AutoClear',True);
SynEdit1.Font.Size := ReadInteger('General','CommandFontSize',SynEdit1.Font.Size);
if ReadBool('General','Maximized',False) then
Expand Down Expand Up @@ -1305,6 +1309,8 @@ procedure TForm1.QuickBtnClick(Sender: TObject);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
aModalResult:TModalResult;
begin
TTimer(Sender).Enabled:=false;
// only run once !!
Expand All @@ -1317,6 +1323,28 @@ procedure TForm1.Timer1Timer(Sender: TObject);
// This must only be called once.
If Not Alternate_ui_created then alternateui_Create_Controls;
{$endif}
{$ifdef RemoteLog}
if (sConsentWarning) OR (Form2.SendInfo) then
begin
AddMessage('Fpcupdeluxe logging info:');
AddMessage('http://54.194.211.233:8880/root/getinfohtml',true);
AddMessage('http://54.194.211.233:8880/root/getinfohtml?ShowErrors=yes');
if (sConsentWarning) then
begin
aModalResult:=(MessageDlg(
'Attention !'+sLineBreak+
sLineBreak +
'Fpcupdeluxe is able to log some install info.' + sLineBreak +
'This data is send towards a server,' + sLineBreak +
'where it is available to anybody.' + sLineBreak +
'(see URL shown in screen and statusbar)' + sLineBreak +
sLineBreak +
'Do you want logging info to be gathered ?'
,mtConfirmation,[mbYes, mbNo],0));
if aModalResult=mrYes then Form2.SendInfo:=True;;
end;
end;
{$endif}
end;

procedure TForm1.BitBtnFPCandLazarusClick(Sender: TObject);
Expand Down Expand Up @@ -2359,14 +2387,13 @@ procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
if Assigned(FPCupManager) then
begin
Application.MainForm.Cursor:=crHourGlass;
with TIniFile.Create(SafeGetApplicationPath+DELUXEFILENAME) do
try
WriteString('General','InstallDirectory',sInstallDir);

WriteBool('General','AutoClear',CheckAutoClear.Checked);

Application.MainForm.Cursor:=crHourGlass;

{$ifdef RemoteLog}
WriteBool('General','ConsentWarning',false);
{$endif}
WriteString('ProxySettings','HTTPProxyURL',FPCupManager.HTTPProxyHost);
WriteInteger('ProxySettings','HTTPProxyPort',FPCupManager.HTTPProxyPort);
WriteString('ProxySettings','HTTPProxyUser',FPCupManager.HTTPProxyUser);
Expand Down

0 comments on commit 1e743ef

Please sign in to comment.