ADD: Execute calculate checksum in queue

This commit is contained in:
Alexander Koblov 2015-08-25 18:52:49 +00:00
commit fdff5e400f
7 changed files with 422 additions and 121 deletions

205
src/fbuttonform.lfm Normal file
View file

@ -0,0 +1,205 @@
object frmButtonForm: TfrmButtonForm
Left = 634
Height = 402
Top = 161
Width = 609
ChildSizing.LeftRightSpacing = 8
ChildSizing.TopBottomSpacing = 8
ClientHeight = 402
ClientWidth = 609
LCLVersion = '1.4.3.0'
object pnlContent: TPanel
Left = 8
Height = 348
Top = 8
Width = 593
Align = alClient
AutoSize = True
BevelOuter = bvNone
Color = clForm
ParentColor = False
TabOrder = 0
end
object pnlButtons: TPanel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 34
Top = 360
Width = 593
Align = alBottom
Anchors = [akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 4
BevelOuter = bvNone
ClientHeight = 34
ClientWidth = 593
Color = clForm
ParentColor = False
TabOrder = 1
object btnAddToQueue: TBitBtn
Left = 0
Height = 34
Top = 0
Width = 127
Align = alLeft
AutoSize = True
BorderSpacing.InnerBorder = 2
Caption = 'A&dd To Queue'
Constraints.MinHeight = 34
Constraints.MinWidth = 88
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
000004733AFF21824FFF638272FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF7ACFA4FF2C8C5AFF3D7659FFAEAEAEFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF82D8ACFF76D6A6FF3C9D6AFF27744CFFACAEADFF000000000000
0000000000000000000000000000000000000000000000000000000000000000
000009773FFF83DBAEFF1FC671FF72DEA7FF4BB27FFF177445FFA8ADAAFF0000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF83DCAFFF11C369FF1ACC73FF69DFA3FF5AC28DFF137643FF9EA7
A3FF000000000000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF10BD65FF11C167FF13C269FF59D395FF67C998FF167C
47FF889C92FF0000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF0DB35EFF0EB660FF0EB660FF0DB45FFF47C484FF70CA
9CFF1D824DFF678C79FF00000000000000000000000000000000000000000000
000004733AFFA9DCC1FF0CAA58FF12AE5EFF15AF60FF16AD61FF13AA5DFF3AB6
77FF75C79DFF288957FF4E8367FF000000000000000000000000000000000000
000004733AFFA9DCC1FF2EAD6BFF2BAD6AFF27AB68FF22A964FF1CA55FFF41B2
78FF78C69FFF298858FF678C79FF000000000000000000000000000000000000
000004733AFFA9DCC1FF36AD70FF32AC6DFF2DAA6AFF28A866FF58BC89FF78C5
9DFF1F804EFF839A8EFF00000000000000000000000000000000000000000000
000004733AFFA9DCC1FF3EB176FF3AAF73FF36AE70FF6FC598FF71BF97FF187B
49FFA6B0ABFF0000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF45B47BFF47B47CFF82CCA6FF67B68CFF177745FFC1C5
C3FF000000000000000000000000000000000000000000000000000000000000
000004733AFFA5DABFFF57BB87FF90D2B0FF5BAB82FF23774CFFD4D5D4FF0000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF9BD5B7FF4C9F73FF3D7D5CFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFFA4D9BEFF3D9366FF5F8873FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF2D8859FF859C90FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
}
ModalResult = 1
OnClick = btnAddToQueueClick
TabOrder = 0
end
object btnCreateSpecialQueue: TBitBtn
Left = 127
Height = 34
Top = 0
Width = 23
Align = alLeft
BorderSpacing.Right = 12
Glyph.Data = {
72000000424D7200000000000000360000002800000005000000030000000100
2000000000003C00000064000000640000000000000000000000000000000000
0000000000FF000000000000000000000000000000FF000000FF000000FF0000
0000000000FF000000FF000000FF000000FF000000FF
}
Layout = blGlyphBottom
OnClick = btnCreateSpecialQueueClick
PopupMenu = pmQueuePopup
TabOrder = 1
end
object btnCancel: TBitBtn
Left = 411
Height = 34
Top = 0
Width = 86
Align = alRight
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Right = 8
BorderSpacing.InnerBorder = 2
Cancel = True
Caption = '&Cancel'
Kind = bkCancel
ModalResult = 2
TabOrder = 2
end
object btnOK: TBitBtn
Left = 505
Height = 34
Top = 0
Width = 88
Align = alRight
AutoSize = True
BorderSpacing.InnerBorder = 2
Caption = '&OK'
Constraints.MinHeight = 34
Constraints.MinWidth = 88
Default = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
000004733AFF21824FFF638272FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF7ACFA4FF2C8C5AFF3D7659FFAEAEAEFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF82D8ACFF76D6A6FF3C9D6AFF27744CFFACAEADFF000000000000
0000000000000000000000000000000000000000000000000000000000000000
000009773FFF83DBAEFF1FC671FF72DEA7FF4BB27FFF177445FFA8ADAAFF0000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF83DCAFFF11C369FF1ACC73FF69DFA3FF5AC28DFF137643FF9EA7
A3FF000000000000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF10BD65FF11C167FF13C269FF59D395FF67C998FF167C
47FF889C92FF0000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF0DB35EFF0EB660FF0EB660FF0DB45FFF47C484FF70CA
9CFF1D824DFF678C79FF00000000000000000000000000000000000000000000
000004733AFFA9DCC1FF0CAA58FF12AE5EFF15AF60FF16AD61FF13AA5DFF3AB6
77FF75C79DFF288957FF4E8367FF000000000000000000000000000000000000
000004733AFFA9DCC1FF2EAD6BFF2BAD6AFF27AB68FF22A964FF1CA55FFF41B2
78FF78C69FFF298858FF678C79FF000000000000000000000000000000000000
000004733AFFA9DCC1FF36AD70FF32AC6DFF2DAA6AFF28A866FF58BC89FF78C5
9DFF1F804EFF839A8EFF00000000000000000000000000000000000000000000
000004733AFFA9DCC1FF3EB176FF3AAF73FF36AE70FF6FC598FF71BF97FF187B
49FFA6B0ABFF0000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF45B47BFF47B47CFF82CCA6FF67B68CFF177745FFC1C5
C3FF000000000000000000000000000000000000000000000000000000000000
000004733AFFA5DABFFF57BB87FF90D2B0FF5BAB82FF23774CFFD4D5D4FF0000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFFA9DCC1FF9BD5B7FF4C9F73FF3D7D5CFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFFA4D9BEFF3D9366FF5F8873FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000004733AFF2D8859FF859C90FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
}
ModalResult = 1
OnClick = btnOKClick
TabOrder = 3
end
end
object pmQueuePopup: TPopupMenu
left = 280
top = 280
object mnuNewQueue: TMenuItem
Caption = 'New queue'
OnClick = mnuNewQueueClick
end
object mnuQueue1: TMenuItem
Caption = 'Queue 1'
OnClick = mnuQueueNumberClick
end
object mnuQueue2: TMenuItem
Caption = 'Queue 2'
OnClick = mnuQueueNumberClick
end
object mnuQueue3: TMenuItem
Caption = 'Queue 3'
OnClick = mnuQueueNumberClick
end
object mnuQueue4: TMenuItem
Caption = 'Queue 4'
OnClick = mnuQueueNumberClick
end
object mnuQueue5: TMenuItem
Caption = 'Queue 5'
OnClick = mnuQueueNumberClick
end
end
end

9
src/fbuttonform.lrt Normal file
View file

@ -0,0 +1,9 @@
TFRMBUTTONFORM.BTNADDTOQUEUE.CAPTION=A&dd To Queue
TFRMBUTTONFORM.BTNCANCEL.CAPTION=&Cancel
TFRMBUTTONFORM.BTNOK.CAPTION=&OK
TFRMBUTTONFORM.MNUNEWQUEUE.CAPTION=New queue
TFRMBUTTONFORM.MNUQUEUE1.CAPTION=Queue 1
TFRMBUTTONFORM.MNUQUEUE2.CAPTION=Queue 2
TFRMBUTTONFORM.MNUQUEUE3.CAPTION=Queue 3
TFRMBUTTONFORM.MNUQUEUE4.CAPTION=Queue 4
TFRMBUTTONFORM.MNUQUEUE5.CAPTION=Queue 5

109
src/fbuttonform.pas Normal file
View file

@ -0,0 +1,109 @@
unit fButtonForm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Buttons, Menus, uOperationsManager;
type
{ TfrmButtonForm }
TfrmButtonForm = class(TForm)
btnAddToQueue: TBitBtn;
btnCancel: TBitBtn;
btnCreateSpecialQueue: TBitBtn;
btnOK: TBitBtn;
mnuNewQueue: TMenuItem;
mnuQueue1: TMenuItem;
mnuQueue2: TMenuItem;
mnuQueue3: TMenuItem;
mnuQueue4: TMenuItem;
mnuQueue5: TMenuItem;
pmQueuePopup: TPopupMenu;
pnlContent: TPanel;
pnlButtons: TPanel;
procedure btnAddToQueueClick(Sender: TObject);
procedure btnCreateSpecialQueueClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure mnuNewQueueClick(Sender: TObject);
procedure mnuQueueNumberClick(Sender: TObject);
private
function GetQueueIdentifier: TOperationsManagerQueueIdentifier;
public
constructor Create(TheOwner: TComponent); override;
property QueueIdentifier: TOperationsManagerQueueIdentifier read GetQueueIdentifier;
end;
var
frmButtonForm: TfrmButtonForm;
implementation
{$R *.lfm}
var
FQueueIdentifier: TOperationsManagerQueueIdentifier = SingleQueueId;
{ TfrmButtonForm }
procedure TfrmButtonForm.btnCreateSpecialQueueClick(Sender: TObject);
begin
btnCreateSpecialQueue.PopupMenu.PopUp;
end;
procedure TfrmButtonForm.btnAddToQueueClick(Sender: TObject);
begin
ModalResult := btnAddToQueue.ModalResult;
end;
procedure TfrmButtonForm.btnOKClick(Sender: TObject);
begin
FQueueIdentifier := FreeOperationsQueueId;
end;
procedure TfrmButtonForm.mnuNewQueueClick(Sender: TObject);
var
NewQueueId: TOperationsManagerQueueIdentifier;
begin
for NewQueueId := Succ(FreeOperationsQueueId) to MaxInt do
with OperationsManager do
begin
if not Assigned(QueueByIdentifier[NewQueueId]) then
begin
FQueueIdentifier := NewQueueId;
ModalResult := btnAddToQueue.ModalResult;
Break;
end;
end;
end;
procedure TfrmButtonForm.mnuQueueNumberClick(Sender: TObject);
var
NewQueueNumber: TOperationsManagerQueueIdentifier;
begin
if TryStrToInt(Copy((Sender as TMenuItem).Name, 9, 1), NewQueueNumber) then
begin
FQueueIdentifier := NewQueueNumber;
ModalResult := btnAddToQueue.ModalResult;
end;
end;
function TfrmButtonForm.GetQueueIdentifier: TOperationsManagerQueueIdentifier;
begin
Result:= FQueueIdentifier;
end;
constructor TfrmButtonForm.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
if FQueueIdentifier = FreeOperationsQueueId then FQueueIdentifier:= SingleQueueId;
btnAddToQueue.Caption:= btnAddToQueue.Caption + ' #' + IntToStr(FQueueIdentifier);
end;
end.

View file

@ -1,4 +1,4 @@
object frmCheckSumCalc: TfrmCheckSumCalc
inherited frmCheckSumCalc: TfrmCheckSumCalc
Left = 321
Height = 400
Top = 59
@ -6,8 +6,6 @@ object frmCheckSumCalc: TfrmCheckSumCalc
AutoSize = True
BorderIcons = [biSystemMenu]
Caption = 'Calculate checksum...'
ChildSizing.LeftRightSpacing = 8
ChildSizing.TopBottomSpacing = 8
ClientHeight = 400
ClientWidth = 400
Constraints.MinHeight = 400
@ -16,112 +14,89 @@ object frmCheckSumCalc: TfrmCheckSumCalc
OnShow = FormShow
Position = poScreenCenter
SessionProperties = 'cbOpenAfterJobIsComplete.Checked;cbSeparateFile.Checked;lbHashAlgorithm.ItemIndex'
LCLVersion = '1.2.6.0'
object lblSaveTo: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 10
Height = 15
Top = 8
Width = 130
BorderSpacing.Left = 10
BorderSpacing.Top = 8
Caption = '&Save checksum file(s) to:'
FocusControl = edtSaveTo
ParentColor = False
inherited pnlContent: TPanel
Height = 346
Width = 384
ClientHeight = 346
ClientWidth = 384
ParentColor = True
object lblSaveTo: TLabel[0]
Left = 0
Height = 15
Top = 0
Width = 130
Caption = '&Save checksum file(s) to:'
FocusControl = edtSaveTo
ParentColor = False
end
object edtSaveTo: TEdit[1]
AnchorSideLeft.Control = pnlContent
AnchorSideTop.Control = lblSaveTo
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlContent
AnchorSideRight.Side = asrBottom
Left = 0
Height = 23
Top = 21
Width = 384
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
TabOrder = 0
end
object cbSeparateFile: TCheckBox[2]
AnchorSideLeft.Control = edtSaveTo
AnchorSideTop.Control = edtSaveTo
AnchorSideTop.Side = asrBottom
Left = 0
Height = 19
Top = 50
Width = 242
BorderSpacing.Top = 6
Caption = 'C&reate separate checksum file for each file'
OnChange = cbSeparateFileChange
TabOrder = 1
end
object lbHashAlgorithm: TListBox[3]
AnchorSideLeft.Control = edtSaveTo
AnchorSideTop.Control = cbOpenAfterJobIsComplete
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtSaveTo
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 244
Top = 100
Width = 384
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
ItemHeight = 0
OnSelectionChange = lbHashAlgorithmSelectionChange
ScrollWidth = 150
TabOrder = 3
end
object cbOpenAfterJobIsComplete: TCheckBox[4]
AnchorSideLeft.Control = edtSaveTo
AnchorSideTop.Control = cbSeparateFile
AnchorSideTop.Side = asrBottom
Left = 0
Height = 19
Top = 75
Width = 243
BorderSpacing.Top = 6
Caption = 'Open checksum file after job is completed'
OnChange = cbSeparateFileChange
TabOrder = 2
end
end
object edtSaveTo: TEdit
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = lblSaveTo
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 10
Height = 23
Top = 29
Width = 380
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 10
BorderSpacing.Top = 6
BorderSpacing.Right = 10
TabOrder = 0
end
object cbSeparateFile: TCheckBox
AnchorSideLeft.Control = edtSaveTo
AnchorSideTop.Control = edtSaveTo
AnchorSideTop.Side = asrBottom
Left = 10
Height = 19
Top = 58
Width = 242
BorderSpacing.Top = 6
Caption = 'C&reate separate checksum file for each file'
OnChange = cbSeparateFileChange
TabOrder = 1
end
object btnOK: TBitBtn
AnchorSideTop.Control = btnCancel
AnchorSideRight.Control = btnCancel
AnchorSideBottom.Side = asrBottom
Left = 184
Height = 32
Top = 356
Width = 100
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = '&OK'
Default = True
Kind = bkOK
ModalResult = 1
TabOrder = 2
end
object btnCancel: TBitBtn
AnchorSideTop.Control = lbHashAlgorithm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtSaveTo
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 290
Height = 32
Top = 356
Width = 100
Anchors = [akTop, akRight]
BorderSpacing.Top = 12
Cancel = True
Caption = '&Cancel'
Kind = bkCancel
ModalResult = 2
TabOrder = 3
end
object lbHashAlgorithm: TListBox
AnchorSideLeft.Control = edtSaveTo
AnchorSideTop.Control = cbOpenAfterJobIsComplete
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtSaveTo
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 10
Height = 236
Top = 108
Width = 380
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
ItemHeight = 0
OnSelectionChange = lbHashAlgorithmSelectionChange
ScrollWidth = 150
TabOrder = 4
end
object cbOpenAfterJobIsComplete: TCheckBox
AnchorSideLeft.Control = edtSaveTo
AnchorSideTop.Control = cbSeparateFile
AnchorSideTop.Side = asrBottom
Left = 10
Height = 19
Top = 83
Width = 243
BorderSpacing.Top = 6
Caption = 'Open checksum file after job is completed'
OnChange = cbSeparateFileChange
TabOrder = 5
inherited pnlButtons: TPanel
Top = 358
Width = 384
ClientWidth = 384
inherited btnCancel: TBitBtn
Left = 202
end
inherited btnOK: TBitBtn
Left = 296
end
end
end

View file

@ -1,6 +1,4 @@
TFRMCHECKSUMCALC.CAPTION=Calculate checksum...
TFRMCHECKSUMCALC.LBLSAVETO.CAPTION=&Save checksum file(s) to:
TFRMCHECKSUMCALC.CBSEPARATEFILE.CAPTION=C&reate separate checksum file for each file
TFRMCHECKSUMCALC.BTNOK.CAPTION=&OK
TFRMCHECKSUMCALC.BTNCANCEL.CAPTION=&Cancel
TFRMCHECKSUMCALC.CBOPENAFTERJOBISCOMPLETE.CAPTION=Open checksum file after job is completed

View file

@ -28,15 +28,14 @@ unit fCheckSumCalc;
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, Buttons, uHash;
Classes, SysUtils, Forms, Controls, StdCtrls, Buttons, fButtonForm, uHash,
uOperationsManager;
type
{ TfrmCheckSumCalc }
TfrmCheckSumCalc = class(TForm)
btnOK: TBitBtn;
btnCancel: TBitBtn;
TfrmCheckSumCalc = class(TfrmButtonForm)
cbSeparateFile: TCheckBox;
cbOpenAfterJobIsComplete: TCheckBox;
edtSaveTo: TEdit;
@ -55,7 +54,8 @@ type
end;
function ShowCalcCheckSum(var sFileName: UTF8String; out SeparateFile: Boolean;
out HashAlgorithm: THashAlgorithm; out OpenFileAfterJobCompleted: Boolean): Boolean;
out HashAlgorithm: THashAlgorithm; out OpenFileAfterJobCompleted: Boolean;
out QueueId: TOperationsManagerQueueIdentifier): Boolean;
function ShowCalcVerifyCheckSum(out Hash: String;
out HashAlgorithm: THashAlgorithm): Boolean;
@ -68,7 +68,8 @@ uses
uGlobs, uLng;
function ShowCalcCheckSum(var sFileName: UTF8String; out SeparateFile: Boolean;
out HashAlgorithm: THashAlgorithm; out OpenFileAfterJobCompleted: Boolean): Boolean;
out HashAlgorithm: THashAlgorithm; out OpenFileAfterJobCompleted: Boolean;
out QueueId: TOperationsManagerQueueIdentifier): Boolean;
begin
with TfrmCheckSumCalc.Create(Application) do
try
@ -81,6 +82,7 @@ begin
SeparateFile:= cbSeparateFile.Checked;
OpenFileAfterJobCompleted:=(cbOpenAfterJobIsComplete.Checked AND cbOpenAfterJobIsComplete.Enabled);
HashAlgorithm:= FAlgorithm;
QueueId:= QueueIdentifier
end;
finally
Free;
@ -97,6 +99,8 @@ begin
SessionProperties:= EmptyStr;
Caption:= rsCheckSumVerifyTitle;
cbSeparateFile.Visible:= False;
btnAddToQueue.Visible:= False;
btnCreateSpecialQueue.Visible:= False;
cbOpenAfterJobIsComplete.Visible:= False;
lbHashAlgorithm.OnSelectionChange:= nil;
edtSaveTo.OnChange:= @edtSaveToChange;

View file

@ -2030,11 +2030,12 @@ end;
procedure TMainCommands.cm_CheckSumCalc(const Params: array of string);
var
I: Integer;
bSeparateFile, bOpenFileAfterJobCompleted: Boolean;
HashAlgorithm: THashAlgorithm;
sFileName: UTF8String;
SelectedFiles: TFiles;
HashAlgorithm: THashAlgorithm;
QueueId: TOperationsManagerQueueIdentifier;
Operation: TFileSourceCalcChecksumOperation;
bSeparateFile, bOpenFileAfterJobCompleted: Boolean;
begin
// This will work only for filesystem.
// For other file sources use temp file system when it's done.
@ -2072,7 +2073,7 @@ begin
else
sFileName:= ActiveFrame.CurrentPath + SelectedFiles[0].Name;
if ShowCalcCheckSum(sFileName, bSeparateFile, HashAlgorithm, bOpenFileAfterJobCompleted) then
if ShowCalcCheckSum(sFileName, bSeparateFile, HashAlgorithm, bOpenFileAfterJobCompleted, QueueId) then
begin
Operation := ActiveFrame.FileSource.CreateCalcChecksumOperation(
SelectedFiles, ActiveFrame.CurrentPath, sFileName) as TFileSourceCalcChecksumOperation;
@ -2085,7 +2086,7 @@ begin
Operation.Algorithm := HashAlgorithm;
// Start operation.
OperationsManager.AddOperation(Operation);
OperationsManager.AddOperation(Operation, QueueId, False);
end
else
begin