|
@@ -13,7 +13,7 @@ interface
|
|
|
|
|
|
uses
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, Contnrs, Generics.Collections,
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, Contnrs, Generics.Collections,
|
|
- Shared.Struct, Setup.WizardForm, Setup.Install, Compression.SevenZipDecoder,
|
|
|
|
|
|
+ Shared.Struct, Setup.WizardForm, Setup.Install, Setup.ScriptFunc.HelperFunc, Compression.SevenZipDecoder,
|
|
NewCheckListBox, NewStaticText, NewProgressBar, PasswordEdit, RichEditViewer,
|
|
NewCheckListBox, NewStaticText, NewProgressBar, PasswordEdit, RichEditViewer,
|
|
BidiCtrls, TaskbarProgressFunc;
|
|
BidiCtrls, TaskbarProgressFunc;
|
|
|
|
|
|
@@ -190,12 +190,14 @@ type
|
|
FShowBaseNameInsteadOfUrl: Boolean;
|
|
FShowBaseNameInsteadOfUrl: Boolean;
|
|
FAbortButton: TNewButton;
|
|
FAbortButton: TNewButton;
|
|
FShowProgressControlsOnNextProgress, FAbortedByUser: Boolean;
|
|
FShowProgressControlsOnNextProgress, FAbortedByUser: Boolean;
|
|
|
|
+ FThrottler: TProgressThrottler;
|
|
FLastBaseNameOrUrl: String;
|
|
FLastBaseNameOrUrl: String;
|
|
function DoAdd(const Url, BaseName, RequiredSHA256OfFile: String;
|
|
function DoAdd(const Url, BaseName, RequiredSHA256OfFile: String;
|
|
const UserName, Password: String; const ISSigVerify: Boolean;
|
|
const UserName, Password: String; const ISSigVerify: Boolean;
|
|
const ISSigAllowedKeys: AnsiString; const DotISSigEntry: Boolean; const Data: NativeUInt): Integer;
|
|
const ISSigAllowedKeys: AnsiString; const DotISSigEntry: Boolean; const Data: NativeUInt): Integer;
|
|
procedure AbortButtonClick(Sender: TObject);
|
|
procedure AbortButtonClick(Sender: TObject);
|
|
function InternalOnDownloadProgress(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
function InternalOnDownloadProgress(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
|
|
+ function InternalThrottledOnDownloadProgress(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
procedure ShowProgressControls(const AVisible: Boolean);
|
|
procedure ShowProgressControls(const AVisible: Boolean);
|
|
public
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
@@ -234,8 +236,10 @@ type
|
|
FShowArchiveInsteadOfFile: Boolean;
|
|
FShowArchiveInsteadOfFile: Boolean;
|
|
FAbortButton: TNewButton;
|
|
FAbortButton: TNewButton;
|
|
FShowProgressControlsOnNextProgress, FAbortedByUser: Boolean;
|
|
FShowProgressControlsOnNextProgress, FAbortedByUser: Boolean;
|
|
|
|
+ FThrottler: TProgressThrottler;
|
|
procedure AbortButtonClick(Sender: TObject);
|
|
procedure AbortButtonClick(Sender: TObject);
|
|
function InternalOnExtractionProgress(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
function InternalOnExtractionProgress(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
|
|
+ function InternalThrottledOnExtractionProgress(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
procedure ShowProgressControls(const AVisible: Boolean);
|
|
procedure ShowProgressControls(const AVisible: Boolean);
|
|
public
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
@@ -991,11 +995,6 @@ begin
|
|
Log('Need to abort download.');
|
|
Log('Need to abort download.');
|
|
Result := False;
|
|
Result := False;
|
|
end else begin
|
|
end else begin
|
|
- if ProgressMax > 0 then
|
|
|
|
- Log(Format(' %d of %d bytes done.', [Progress, ProgressMax]))
|
|
|
|
- else
|
|
|
|
- Log(Format(' %d bytes done.', [Progress]));
|
|
|
|
-
|
|
|
|
FMsg2Label.Caption := IfThen(FShowBaseNameInsteadOfUrl, PathExtractName(BaseName), Url);
|
|
FMsg2Label.Caption := IfThen(FShowBaseNameInsteadOfUrl, PathExtractName(BaseName), Url);
|
|
if ProgressMax > MaxLongInt then begin
|
|
if ProgressMax > MaxLongInt then begin
|
|
Progress32 := Round((Progress / ProgressMax) * MaxLongInt);
|
|
Progress32 := Round((Progress / ProgressMax) * MaxLongInt);
|
|
@@ -1012,13 +1011,28 @@ begin
|
|
ProcessMsgs;
|
|
ProcessMsgs;
|
|
end;
|
|
end;
|
|
|
|
|
|
- if Assigned(FOnDownloadProgress) then
|
|
|
|
- Result := FOnDownloadProgress(Url, BaseName, Progress, ProgressMax)
|
|
|
|
- else
|
|
|
|
- Result := True;
|
|
|
|
|
|
+ { This will call InternalThrottledOnDownloadProgress, which will log progress and call the script's FOnDownloadProgress, but throttled }
|
|
|
|
+ if FThrottler = nil then begin
|
|
|
|
+ const OnDownloadProgress: TOnDownloadProgress = InternalThrottledOnDownloadProgress;
|
|
|
|
+ FThrottler := TProgressThrottler.Create(OnDownloadProgress);
|
|
|
|
+ end;
|
|
|
|
+ Result := FThrottler.OnDownloadProgress(Url, BaseName, Progress, ProgressMax);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TDownloadWizardPage.InternalThrottledOnDownloadProgress(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
|
|
+begin
|
|
|
|
+ if ProgressMax > 0 then
|
|
|
|
+ Log(Format(' %d of %d bytes done.', [Progress, ProgressMax]))
|
|
|
|
+ else
|
|
|
|
+ Log(Format(' %d bytes done.', [Progress]));
|
|
|
|
+
|
|
|
|
+ if Assigned(FOnDownloadProgress) then
|
|
|
|
+ Result := FOnDownloadProgress(Url, BaseName, Progress, ProgressMax)
|
|
|
|
+ else
|
|
|
|
+ Result := True;
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TDownloadWizardPage.Create(AOwner: TComponent);
|
|
constructor TDownloadWizardPage.Create(AOwner: TComponent);
|
|
begin
|
|
begin
|
|
inherited;
|
|
inherited;
|
|
@@ -1028,6 +1042,7 @@ end;
|
|
|
|
|
|
destructor TDownloadWizardPage.Destroy;
|
|
destructor TDownloadWizardPage.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ FThrottler.Free;
|
|
FFiles.Free;
|
|
FFiles.Free;
|
|
inherited;
|
|
inherited;
|
|
end;
|
|
end;
|
|
@@ -1210,13 +1225,27 @@ begin
|
|
ProcessMsgs;
|
|
ProcessMsgs;
|
|
end;
|
|
end;
|
|
|
|
|
|
- if Assigned(FOnExtractionProgress) then
|
|
|
|
- Result := FOnExtractionProgress(ArchiveName, FileName, Progress, ProgressMax)
|
|
|
|
- else
|
|
|
|
|
|
+ { This will call InternalThrottledOnExtractionProgress, which will call the script's FOnExtractionProgress, but throttled
|
|
|
|
+ Because it does nothing else we first check if FOnExtractionProgress is actually assigned }
|
|
|
|
+ if Assigned(FOnExtractionProgress) then begin
|
|
|
|
+ if FThrottler = nil then begin
|
|
|
|
+ const OnExtractionProgress: TOnExtractionProgress = InternalThrottledOnExtractionProgress;
|
|
|
|
+ FThrottler := TProgressThrottler.Create(OnExtractionProgress);
|
|
|
|
+ end;
|
|
|
|
+ Result := FThrottler.OnExtractionProgress(ArchiveName, FileName, Progress, ProgressMax);
|
|
|
|
+ end else
|
|
Result := True;
|
|
Result := True;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TExtractionWizardPage.InternalThrottledOnExtractionProgress(const ArchiveName, FileName: string; const Progress, ProgressMax: Int64): Boolean;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(FOnExtractionProgress) then { Always True, see above }
|
|
|
|
+ Result := FOnExtractionProgress(ArchiveName, FileName, Progress, ProgressMax)
|
|
|
|
+ else
|
|
|
|
+ Result := True;
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TExtractionWizardPage.Create(AOwner: TComponent);
|
|
constructor TExtractionWizardPage.Create(AOwner: TComponent);
|
|
begin
|
|
begin
|
|
inherited;
|
|
inherited;
|
|
@@ -1226,6 +1255,7 @@ end;
|
|
|
|
|
|
destructor TExtractionWizardPage.Destroy;
|
|
destructor TExtractionWizardPage.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ FThrottler.Free;
|
|
FArchives.Free;
|
|
FArchives.Free;
|
|
inherited;
|
|
inherited;
|
|
end;
|
|
end;
|