Skip to content

Commit

Permalink
Work on adding CreateExtractionPage and also make some other improvem…
Browse files Browse the repository at this point in the history
…ents. Some todos left as mentioned in the code and also didn't actually test the page yet.
  • Loading branch information
martijnlaan committed Nov 14, 2024
1 parent 5bf562b commit dc634c9
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 96 deletions.
9 changes: 9 additions & 0 deletions ISHelp/isxclasses.pas
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@ TDownloadWizardPage = class(TOutputProgressWizardPage)
property ShowBaseNameInsteadOfUrl: Boolean; read write;
end;

TExtractionWizardPage = class(TOutputProgressWizardPage)
property AbortButton: TNewButton; read;
property AbortedByUser: Boolean; read;
procedure Add(const ArchiveFileName, DestDir: String; const FullPaths: Boolean);
procedure Clear;
function Extract: Integer;
property ShowArchiveInsteadOfFile: Boolean; read write;
end;

TUIStateForm = class(TForm)
end;

Expand Down
43 changes: 23 additions & 20 deletions ISHelp/isxclasses_wordlists_generated.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ interface
'TComponent', 'TConstraintSize', 'TControl', 'TCursor', 'TCustomCheckBox', 'TCustomComboBox',
'TCustomControl', 'TCustomEdit', 'TCustomFolderTreeView', 'TCustomLabel', 'TCustomLinkLabel',
'TCustomListBox', 'TCustomMemo', 'TCustomPanel', 'TDownloadWizardPage', 'TDuplicates',
'TEdit', 'TEditCharCase', 'TEShiftState', 'TFileStream', 'TFolderRenameEvent', 'TFolderTreeView',
'TFont', 'TFontStyle', 'TFontStyles', 'TForm', 'TFormBorderStyle', 'TFormStyle', 'TGraphic',
'TGraphicControl', 'TGraphicsObject', 'THandleStream', 'TInputDirWizardPage', 'TInputFileWizardPage',
'TInputOptionWizardPage', 'TInputQueryWizardPage', 'TKeyEvent', 'TKeyPressEvent', 'TLabel',
'TLinkLabel', 'TListBox', 'TListBoxStyle', 'TMainForm', 'TMemo', 'TNewButton', 'TNewCheckBox',
'TNewCheckListBox', 'TNewComboBox', 'TNewEdit', 'TNewLinkLabel', 'TNewListBox', 'TNewMemo',
'TNewNotebook', 'TNewNotebookPage', 'TNewProgressBar', 'TNewProgressBarState', 'TNewProgressBarStyle',
'TNewRadioButton', 'TNewStaticText', 'TNotifyEvent', 'TObject', 'TOutputMarqueeProgressWizardPage',
'TOutputMsgMemoWizardPage', 'TOutputMsgWizardPage', 'TOutputProgressWizardPage', 'TPanel',
'TPanelBevel', 'TPasswordEdit', 'TPen', 'TPenMode', 'TPenStyle', 'TPersistent', 'TPosition',
'TRadioButton', 'TRichEditViewer', 'TScrollingWinControl', 'TScrollStyle', 'TSetupForm',
'TShiftState', 'TSizeConstraints', 'TStartMenuFolderTreeView', 'TStream', 'TStringList',
'TStrings', 'TStringStream', 'TSysLinkEvent', 'TSysLinkType', 'TUIStateForm', 'TUninstallProgressForm',
'TWinControl', 'TWizardForm', 'TWizardPage', 'TWizardPageButtonEvent', 'TWizardPageCancelEvent',
'TWizardPageNotifyEvent', 'TWizardPageShouldSkipEvent'
'TEdit', 'TEditCharCase', 'TEShiftState', 'TExtractionWizardPage', 'TFileStream', 'TFolderRenameEvent',
'TFolderTreeView', 'TFont', 'TFontStyle', 'TFontStyles', 'TForm', 'TFormBorderStyle',
'TFormStyle', 'TGraphic', 'TGraphicControl', 'TGraphicsObject', 'THandleStream', 'TInputDirWizardPage',
'TInputFileWizardPage', 'TInputOptionWizardPage', 'TInputQueryWizardPage', 'TKeyEvent',
'TKeyPressEvent', 'TLabel', 'TLinkLabel', 'TListBox', 'TListBoxStyle', 'TMainForm',
'TMemo', 'TNewButton', 'TNewCheckBox', 'TNewCheckListBox', 'TNewComboBox', 'TNewEdit',
'TNewLinkLabel', 'TNewListBox', 'TNewMemo', 'TNewNotebook', 'TNewNotebookPage', 'TNewProgressBar',
'TNewProgressBarState', 'TNewProgressBarStyle', 'TNewRadioButton', 'TNewStaticText',
'TNotifyEvent', 'TObject', 'TOutputMarqueeProgressWizardPage', 'TOutputMsgMemoWizardPage',
'TOutputMsgWizardPage', 'TOutputProgressWizardPage', 'TPanel', 'TPanelBevel', 'TPasswordEdit',
'TPen', 'TPenMode', 'TPenStyle', 'TPersistent', 'TPosition', 'TRadioButton', 'TRichEditViewer',
'TScrollingWinControl', 'TScrollStyle', 'TSetupForm', 'TShiftState', 'TSizeConstraints',
'TStartMenuFolderTreeView', 'TStream', 'TStringList', 'TStrings', 'TStringStream',
'TSysLinkEvent', 'TSysLinkType', 'TUIStateForm', 'TUninstallProgressForm', 'TWinControl',
'TWizardForm', 'TWizardPage', 'TWizardPageButtonEvent', 'TWizardPageCancelEvent', 'TWizardPageNotifyEvent',
'TWizardPageShouldSkipEvent'
];

PascalEnumValues_Isxclasses: array of AnsiString = [
Expand Down Expand Up @@ -89,6 +90,7 @@ interface
'function CheckItem(Index: Integer; AOperation: TCheckItemOperation): Boolean;',
'function CopyFrom(Source: TStream; ByteCount: Int64; BufferSize: Integer): Int64;',
'function Download: Int64;',
'function Extract: Integer;',
'function Find(S: String; var Index: Integer): Boolean;',
'function FindComponent(AName: String): TComponent;',
'function FindNextPage(CurPage: TNewNotebookPage; GoForward: Boolean): TNewNotebookPage;',
Expand All @@ -102,6 +104,7 @@ interface
'function TextHeight(Text: String): Integer;',
'function TextWidth(Text: String): Integer;',
'function Write(Buffer: AnyString; ByteCount: Longint): Longint;',
'procedure Add(ArchiveFileName, DestDir: String; FullPaths: Boolean);',
'procedure Add(Url, BaseName, RequiredSHA256OfFile: String);',
'procedure AddEx(Url, BaseName, RequiredSHA256OfFile, UserName, Password: String);',
'procedure AddStrings(Strings: TStrings);',
Expand Down Expand Up @@ -195,11 +198,11 @@ interface
'SelectComponentsPage', 'SelectDirBitmapImage', 'SelectDirBrowseLabel', 'SelectDirLabel',
'SelectDirPage', 'Selected', 'SelectedValueIndex', 'SelectGroupBitmapImage', 'SelectProgramGroupPage',
'SelectStartMenuFolderBrowseLabel', 'SelectStartMenuFolderLabel', 'SelectTasksLabel',
'SelectTasksPage', 'SelLength', 'SelStart', 'SelText', 'Shape', 'ShowAccelChar', 'ShowBaseNameInsteadOfUrl',
'ShowHint', 'Showing', 'ShowLines', 'Size', 'SizeAndCenterOnShow', 'Sorted', 'State',
'StatusLabel', 'Stretch', 'Strings', 'Style', 'SubCaptionLabel', 'SubItemFontStyle',
'Surface', 'SurfaceColor', 'SurfaceHeight', 'SurfaceWidth', 'TabOrder', 'TabStop',
'Tag', 'TasksList', 'Text', 'Top', 'TypesCombo', 'UseRichEdit', 'UserInfoNameEdit',
'SelectTasksPage', 'SelLength', 'SelStart', 'SelText', 'Shape', 'ShowAccelChar', 'ShowArchiveInsteadOfFile',
'ShowBaseNameInsteadOfUrl', 'ShowHint', 'Showing', 'ShowLines', 'Size', 'SizeAndCenterOnShow',
'Sorted', 'State', 'StatusLabel', 'Stretch', 'Strings', 'Style', 'SubCaptionLabel',
'SubItemFontStyle', 'Surface', 'SurfaceColor', 'SurfaceHeight', 'SurfaceWidth', 'TabOrder',
'TabStop', 'Tag', 'TasksList', 'Text', 'Top', 'TypesCombo', 'UseRichEdit', 'UserInfoNameEdit',
'UserInfoNameLabel', 'UserInfoOrgEdit', 'UserInfoOrgLabel', 'UserInfoPage', 'UserInfoSerialEdit',
'UserInfoSerialLabel', 'UseVisualStyle', 'Values', 'Visible', 'WantReturns', 'WantTabs',
'WelcomeLabel1', 'WelcomeLabel2', 'WelcomePage', 'Width', 'WizardBitmapImage', 'WizardBitmapImage2',
Expand Down
56 changes: 50 additions & 6 deletions ISHelp/isxfunc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,8 @@ end;</pre></example>
<link topic="isxfunc_DownloadTemporaryFileSize">DownloadTemporaryFileSize</link><br />
<link topic="isxfunc_DownloadTemporaryFileDate">DownloadTemporaryFileDate</link><br />
<link topic="isxfunc_CreateDownloadPage">CreateDownloadPage</link><br />
<link topic="isxfunc_ExtractTemporaryFile">ExtractTemporaryFile</link></p></seealso>
<link topic="isxfunc_ExtractTemporaryFile">ExtractTemporaryFile</link><br />
<link topic="isxfunc_Extract7ZipArchive">Extract7ZipArchive</link></p></seealso>
<example><pre>
[Code]
function OnDownloadProgress(const Url, Filename: String; const Progress, ProgressMax: Int64): Boolean;
Expand Down Expand Up @@ -1841,11 +1842,16 @@ end;</pre>
<p>See <link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link> for other considerations.</p></description>
</function>
<function>
<name>Extract7ZipFile</name>
<prototype>function Extract7ZipFile(const FileName, DestDir: String; const FullPaths: Boolean): Integer;</prototype>
<description><p>Extracts the specified 7-Zip archive to the specified directory, with or without using path names. Returns zero if successful, nonzero otherwise</p>
<p>The archive must not be encrypted.</p></description>
<remarks><p>Uses an embedded version of the &quot;7z ANSI-C Decoder&quot; from the LZMA SDK by Igor Pavlov, as-is, except that Unicode support and error messages were improved and that it outputs memory requirements.</p>
<name>Extract7ZipArchive</name>
<prototype>function Extract7ZipArchive(const ArchiveFileName, DestDir: String; const FullPaths: Boolean; const OnExtractionProgress: TOnExtractionProgress): Integer;</prototype>
<description><p>Extracts the specified 7-Zip archive to the specified directory, with or without using path names.</p>
<p>Returns zero if successful, nonzero otherwise</p>
<p>The archive must not be encrypted.</p>
<p>Set OnExtractionProgress to a function to be informed of progress, or <tt>nil</tt> otherwise.</p></description>
<remarks><p>TOnExtractionProgress is defined as:</p>
<p><tt>TOnExtractionProgress = function(const ArchiveFileName, FileName: string; const Progress, ProgressMax: Int64): Boolean;</tt></p>
<p>Return True to allow the extraction to continue, False otherwise.</p>
<p><tt>Extract7ZipArchive</tt> uses an embedded version of the &quot;7z ANSI-C Decoder&quot; from the LZMA SDK by Igor Pavlov, as-is, except that Unicode support and error messages were improved and that it outputs memory requirements.</p>
<p>All output of the decoder is logged if logging is enabled, including error messages but excluding empty lines.</p>
<p>The decoder has the following limitations, as written by Igor Pavlov in the LZMA SDK:<br /><br />
-It reads only &quot;FileName&quot;, &quot;Size&quot;, &quot;LastWriteTime&quot; and &quot;CRC&quot; information for each file in archive.<br />
Expand All @@ -1858,6 +1864,27 @@ You can create .7z archive with 7z.exe, 7za.exe or 7zr.exe:<br /><br />
If you have big number of files in archive, and you need fast extracting, you can use partly-solid archives:<br /><br />
7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K<br /><br />
In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only 512KB for extracting one file from such archive.</p></remarks>
<seealso><p><link topic="isxfunc_CreateExtractionPage">CreateExtractionPage</link><br />
<link topic="isxfunc_CreateDownloadPage">CreateDownloadPage</link><br />
<link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link><br />
<link topic="isxfunc_ExtractTemporaryFile">ExtractTemporaryFile</link></p></seealso>
<example><pre>
[Code]
function OnExtractionProgress(const ArchiveFileName, FileName: string; const Progress, ProgressMax: Int64): Boolean;
begin
Log(Format(' %s\%s: %d of %d bytes done.', [ArchiveFileName, FileName, Progress, ProgressMax]))
Result := True;
end;

function InitializeSetup: Boolean;
begin
try
Result := Extract7ZipArchive(ExpandConstant('{tmp}\Archive.7z'), ExpandConstant('{app}'), True, @OnExtractionProgress) = 0;
except
Log(GetExceptionMessage);
Result := False;
end;
end;</pre></example>
</function>
</subcategory>
<subcategory>
Expand Down Expand Up @@ -2621,6 +2648,23 @@ Page := CreateOutputMsgMemoPage(wpWelcome,
<example><p>See <i>CodeDownloadFiles.iss</i> for an example.</p></example>
<seealso><p><link topic="scriptclasses" anchor="TDownloadWizardPage">TDownloadWizardPage</link><br />
<link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link><br />
<link topic="isxfunc_CreateOutputProgressPage">CreateOutputProgressPage</link></p></seealso>
</function>
<function>
<name>CreateExtractionPage</name>
<prototype>function CreateExtractionPage(const ACaption, ADescription: String; const OnExtractionProgress: TOnExtractionProgress): ExtractionWizardPage;</prototype>
<description><p>Creates a wizard page to extract 7-Zip archives and show progress.</p>
<p>Set OnExtractionProgress to a function to be informed of progress, or <tt>nil</tt> otherwise.</p>
<p>Unlike the other types of wizard pages, progress pages are not displayed as part of the normal page sequence (note that there is no <tt>AfterID</tt> parameter). A progress page can only be displayed programmatically by calling its <tt>Show</tt> method.</p></description>
<remarks><p>Call the <tt>Show</tt> method to activate and show the page. When you're finished with it, call the <tt>Hide</tt> method to revert to the previous page.</p>
<p>Always put the <tt>Hide</tt> call inside the <tt>finally</tt> part of a <tt>try..finally</tt> language construct, as demonstrated in <i>CodeDownloadFiles.iss</i>. Not calling <tt>Hide</tt> will result in the wizard being permanently stuck on the progress page.</p>
<p>To add a new archive to extract, call the <tt>Add</tt> method. Always call the <tt>Clear</tt> method before adding the first file.</p>
<p>To start the extraction, call the <tt>Extract</tt> method. An exception will be raised if there was an error. Otherwise, <tt>Extract</tt> returns the number of archives extracted.</p>
<p>Set the <tt>ShowArchiveInsteadFile</tt> property to <tt>True</tt> to show the name of the archive which is being extracted to the user instead of the names of the files inside the archive.</p>
<p>See <link topic="isxfunc_Extract7ZipArchive">Extract7ZipArchive</link> for other considerations and the definition of <tt>TOnExtractionProgress</tt>.</p></remarks>
<example><p>See <i>CodeDownloadFiles.iss</i> for an example of <tt>CreateDownloadPage</tt> which works very similar to <tt>CreateExtractionPage</tt>.</p></example>
<seealso><p><link topic="scriptclasses" anchor="TExtractionWizardPage">TExtractionWizardPage</link><br />
<link topic="isxfunc_Extract7ZipArchive">Extract7ZipArchive</link><br />
<link topic="isxfunc_CreateOutputProgressPage">CreateOutputProgressPage</link></p></seealso>
</function>
<function>
Expand Down
15 changes: 15 additions & 0 deletions Projects/Src/Compiler.ScriptClasses.pas
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,20 @@ procedure RegisterDownloadWizardPage_C(Cl: TPSPascalCompiler);
end;
end;

procedure RegisterExtractionWizardPage_C(Cl: TPSPascalCompiler);
begin
with CL.AddClassN(Cl.FindClass('TOutputProgressWizardPage'),'TExtractionWizardPage') do
begin
RegisterProperty('AbortButton', 'TNewButton', iptr);
RegisterProperty('AbortedByUser', 'Boolean', iptr);
RegisterProperty('ShowArchiveInsteadOfFile', 'Boolean', iptrw);
RegisterMethod('procedure Add(const ArchiveFileName, DestDir: String; const FullPaths: Boolean)');
RegisterMethod('procedure Clear');
RegisterMethod('function Extract: Integer');
RegisterMethod('procedure Show'); { Without this TOutputProgressWizardPage's Show will be called }
end;
end;

procedure RegisterHandCursor_C(Cl: TPSPascalCompiler);
begin
cl.AddConstantN('crHand', 'Integer').Value.ts32 := crHand;
Expand Down Expand Up @@ -675,6 +689,7 @@ procedure ScriptClassesLibraryRegister_C(Cl: TPSPascalCompiler);
RegisterOutputProgressWizardPage_C(Cl);
RegisterOutputMarqueeProgressWizardPage_C(Cl);
RegisterDownloadWizardPage_C(Cl);
RegisterExtractionWizardPage_C(Cl);

RegisterHandCursor_C(Cl);

Expand Down
1 change: 1 addition & 0 deletions Projects/Src/Compiler.ScriptFunc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ procedure ScriptFuncLibraryRegister_C(ScriptCompiler: TPSPascalCompiler;
'end');

RegisterType('TOnDownloadProgress', 'function(const Url, FileName: string; const Progress, ProgressMax: Int64): Boolean;');
RegisterType('TOnExtractionProgress', 'function(const ArchiveFileName, FileName: string; const Progress, ProgressMax: Int64): Boolean;');
RegisterType('TOnLog', 'procedure(const S: String; const Error, FirstLine: Boolean);');

for var ScriptFuncTable in ScriptFuncTables do
Expand Down
Loading

0 comments on commit dc634c9

Please sign in to comment.