ADD: FTP - Options: to enable/disable hidden items query, send keep alive during transfer

This commit is contained in:
Alexander Koblov 2018-05-06 07:56:21 +00:00
commit 3188fbfbea
4 changed files with 127 additions and 78 deletions

View file

@ -1,6 +1,6 @@
object DialogBox: TDialogBox
Left = 431
Height = 345
Height = 436
Top = 141
Width = 420
AutoSize = True
@ -9,19 +9,19 @@ object DialogBox: TDialogBox
Caption = 'FTP'
ChildSizing.LeftRightSpacing = 10
ChildSizing.TopBottomSpacing = 10
ClientHeight = 345
ClientHeight = 436
ClientWidth = 420
OnShow = DialogBoxShow
Position = poScreenCenter
LCLVersion = '1.6.4.0'
LCLVersion = '1.8.2.0'
object lblName: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = edtName
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 15
Width = 102
Height = 18
Top = 16
Width = 112
BorderSpacing.Left = 12
Caption = 'Connection name:'
ParentColor = False
@ -31,8 +31,8 @@ object DialogBox: TDialogBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Left = 142
Height = 26
Top = 12
Width = 260
BorderSpacing.Left = 18
@ -45,9 +45,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = edtHost
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 44
Width = 64
Height = 18
Top = 48
Width = 70
BorderSpacing.Left = 12
Caption = 'Host[:Port]:'
ParentColor = False
@ -58,9 +58,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtName
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Top = 41
Left = 142
Height = 26
Top = 44
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -71,9 +71,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = edtUserName
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 104
Width = 66
Height = 18
Top = 111
Width = 71
BorderSpacing.Left = 12
Caption = 'User name:'
ParentColor = False
@ -84,9 +84,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnAnonymous
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Top = 101
Left = 142
Height = 26
Top = 107
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -98,9 +98,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtHost
AnchorSideRight.Side = asrBottom
Left = 132
Left = 142
Height = 25
Top = 70
Top = 76
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -114,22 +114,22 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtPassword
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Top = 219
Left = 142
Height = 26
Top = 235
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
TabOrder = 9
TabOrder = 10
end
object lblRemoteDir: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = edtRemoteDir
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 222
Width = 65
Height = 18
Top = 239
Width = 71
BorderSpacing.Left = 12
Caption = 'Remote dir:'
ParentColor = False
@ -139,46 +139,46 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = edtInitCommands
AnchorSideTop.Side = asrBottom
Left = 12
Height = 22
Top = 289
Width = 325
Height = 24
Top = 311
Width = 350
BorderSpacing.Left = 12
BorderSpacing.Top = 18
Caption = 'Use passive mode for transfers (like a WWW browser)'
Checked = True
State = cbChecked
TabOrder = 11
TabOrder = 12
end
object btnCancel: TButton
AnchorSideTop.Control = chkPassiveMode
AnchorSideTop.Control = chkKeepAliveTransfer
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtRemoteDir
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 317
Left = 327
Height = 25
Top = 323
Top = 395
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Top = 12
Caption = 'Cancel'
ModalResult = 2
OnClick = ButtonClick
TabOrder = 13
TabOrder = 16
end
object btnOK: TButton
AnchorSideTop.Control = btnCancel
AnchorSideRight.Control = btnCancel
AnchorSideBottom.Side = asrBottom
Left = 230
Left = 240
Height = 25
Top = 323
Top = 395
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 12
Caption = '&OK'
OnClick = ButtonClick
TabOrder = 12
TabOrder = 15
end
object edtPassword: TEdit
AnchorSideLeft.Control = edtUserName
@ -186,9 +186,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtUserName
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Top = 130
Left = 142
Height = 26
Top = 139
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -201,9 +201,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = edtPassword
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 133
Width = 58
Height = 18
Top = 143
Width = 63
BorderSpacing.Left = 12
Caption = 'Password:'
ParentColor = False
@ -213,9 +213,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = lblPassword
AnchorSideTop.Side = asrBottom
Left = 12
Height = 22
Top = 162
Width = 282
Height = 24
Top = 173
Width = 306
BorderSpacing.Left = 12
BorderSpacing.Top = 12
Caption = 'Use master password to protect the password'
@ -228,9 +228,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtUserName
AnchorSideRight.Side = asrBottom
Left = 132
Left = 142
Height = 25
Top = 130
Top = 139
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -245,22 +245,22 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtRemoteDir
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Top = 248
Left = 142
Height = 26
Top = 267
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
TabOrder = 10
TabOrder = 11
end
object lblInitCommands: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = edtInitCommands
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 251
Width = 87
Height = 18
Top = 271
Width = 96
BorderSpacing.Left = 12
Caption = 'Init commands:'
ParentColor = False
@ -270,9 +270,9 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = btnAnonymous
AnchorSideTop.Side = asrCenter
Left = 12
Height = 22
Top = 71
Width = 45
Height = 24
Top = 76
Width = 47
BorderSpacing.Left = 12
Caption = 'TLS'
OnChange = CheckBoxChange
@ -285,10 +285,10 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblName
AnchorSideRight.Side = asrBottom
Left = 61
Height = 22
Top = 71
Width = 53
Left = 63
Height = 24
Top = 76
Width = 61
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 4
Caption = 'SSH'
@ -301,13 +301,13 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtPassword
AnchorSideRight.Side = asrBottom
Left = 132
Height = 23
Top = 190
Left = 142
Height = 26
Top = 203
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
ItemHeight = 17
ItemHeight = 18
ItemIndex = 0
Items.Strings = (
'Auto'
@ -336,7 +336,7 @@ object DialogBox: TDialogBox
'ISO-8859-15'
)
Style = csDropDownList
TabOrder = 14
TabOrder = 9
Text = 'Auto'
end
object lblEncoding: TLabel
@ -344,11 +344,33 @@ object DialogBox: TDialogBox
AnchorSideTop.Control = cmbEncoding
AnchorSideTop.Side = asrCenter
Left = 12
Height = 17
Top = 193
Width = 55
Height = 18
Top = 207
Width = 61
BorderSpacing.Left = 12
Caption = 'Encoding:'
ParentColor = False
end
object chkShowHidden: TCheckBox
AnchorSideLeft.Control = chkPassiveMode
AnchorSideTop.Control = chkPassiveMode
AnchorSideTop.Side = asrBottom
Left = 12
Height = 24
Top = 335
Width = 306
Caption = 'Use ''LIST -la'' command to reveal hidden items'
TabOrder = 13
end
object chkKeepAliveTransfer: TCheckBox
AnchorSideLeft.Control = chkPassiveMode
AnchorSideTop.Control = chkShowHidden
AnchorSideTop.Side = asrBottom
Left = 12
Height = 24
Top = 359
Width = 224
Caption = 'Send keepalive during a transfer'
TabOrder = 14
end
end

View file

@ -119,6 +119,14 @@ begin
SendDlgMsg(pDlg, 'chkAutoTLS', DM_SETCHECK, Data, 0);
Data:= PtrInt(gConnection.OpenSSH);
SendDlgMsg(pDlg, 'chkOpenSSH', DM_SETCHECK, Data, 0);
Data:= PtrInt(gConnection.ShowHiddenItems);
SendDlgMsg(pDlg, 'chkShowHidden', DM_SETCHECK, Data, 0);
Data:= PtrInt(gConnection.KeepAliveTransfer);
SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_SETCHECK, Data, 0);
SendDlgMsg(pDlg, 'chkShowHidden', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
SendDlgMsg(pDlg, 'chkPassiveMode', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
end;
DN_CHANGE:
begin
@ -150,8 +158,13 @@ begin
gConnection.OpenSSH:= Boolean(Data);
if gConnection.OpenSSH then
begin
if libssh2 = NilHandle then
if libssh2 <> NilHandle then
begin
SendDlgMsg(pDlg, 'chkShowHidden', DM_SETCHECK, 0, 0);
SendDlgMsg(pDlg, 'chkPassiveMode', DM_SETCHECK, 0, 0);
SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_SETCHECK, 0, 0);
end
else begin
ShowWarningSSH;
gConnection.OpenSSH:= False;
Data:= PtrInt(gConnection.OpenSSH);
@ -159,6 +172,9 @@ begin
end;
SendDlgMsg(pDlg, 'chkAutoTLS', DM_SETCHECK, 0, 0);
end;
SendDlgMsg(pDlg, 'chkShowHidden', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
SendDlgMsg(pDlg, 'chkPassiveMode', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
end;
end;
DN_CLICK:
@ -221,6 +237,10 @@ begin
gConnection.PassiveMode:= Boolean(Data);
Data:= SendDlgMsg(pDlg, 'chkAutoTLS', DM_GETCHECK, 0, 0);
gConnection.AutoTLS:= Boolean(Data);
Data:= SendDlgMsg(pDlg, 'chkShowHidden', DM_GETCHECK, 0, 0);
gConnection.ShowHiddenItems:= Boolean(Data);
Data:= SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_GETCHECK, 0, 0);
gConnection.KeepAliveTransfer:= Boolean(Data);
if gConnection.FullSSL and (InitSSLInterface = False) then
begin;
ShowWarningSSL;

View file

@ -84,7 +84,8 @@ type
FUnicode: Boolean;
FSetTime: Boolean;
FMachine: Boolean;
FShowHidden: String;
FShowHidden: Boolean;
FShowHiddenText: String;
FUseAllocate: Boolean;
FTcpKeepAlive: Boolean;
FKeepAliveTransfer: Boolean;
@ -121,6 +122,7 @@ type
public
property UseAllocate: Boolean write FUseAllocate;
property TcpKeepAlive: Boolean write FTcpKeepAlive;
property ShowHidden: Boolean read FShowHidden write FShowHidden;
property KeepAliveTransfer: Boolean read FKeepAliveTransfer write FKeepAliveTransfer;
end;
@ -597,10 +599,10 @@ begin
FTPCommand('OPTS UTF8 ON');
end;
end;
if not FMachine then
if (not FMachine) and FShowHidden then
begin
if inherited List('-la', False) then
FShowHidden:= '-la'
FShowHiddenText:= '-la'
else begin
DoStatus(False, 'Server does not seem to support LIST -a');
end;
@ -673,7 +675,7 @@ begin
if FMachine then
Result:= ListMachine(EmptyStr)
else begin
Result:= inherited List(FShowHidden, NameList);
Result:= inherited List(FShowHiddenText, NameList);
end;
if (Result = False) and (FSock.WaitingData > 0) then
begin

View file

@ -49,6 +49,7 @@ type
UseAllocate: Boolean;
Encoding: AnsiString;
InitCommands: AnsiString;
ShowHiddenItems: Boolean;
PasswordChanged: Boolean;
KeepAliveTransfer: Boolean;
public
@ -168,6 +169,7 @@ begin
Connection.OpenSSH:= IniFile.ReadBool('FTP', 'Connection' + sIndex + 'OpenSSH', False);
Connection.UseAllocate:= IniFile.ReadBool('FTP', 'Connection' + sIndex + 'UseAllocate', False);
Connection.InitCommands := IniFile.ReadString('FTP', 'Connection' + sIndex + 'InitCommands', EmptyStr);
Connection.ShowHiddenItems := IniFile.ReadBool('FTP', 'Connection' + sIndex + 'ShowHiddenItems', True);
Connection.KeepAliveTransfer := IniFile.ReadBool('FTP', 'Connection' + sIndex + 'KeepAliveTransfer', False);
// add connection to connection list
ConnectionList.AddObject(Connection.ConnectionName, Connection);
@ -204,6 +206,7 @@ begin
IniFile.WriteBool('FTP', 'Connection' + sIndex + 'OpenSSH', Connection.OpenSSH);
IniFile.WriteBool('FTP', 'Connection' + sIndex + 'UseAllocate', Connection.UseAllocate);
IniFile.WriteString('FTP', 'Connection' + sIndex + 'InitCommands', Connection.InitCommands);
IniFile.WriteBool('FTP', 'Connection' + sIndex + 'ShowHiddenItems', Connection.ShowHiddenItems);
IniFile.WriteBool('FTP', 'Connection' + sIndex + 'KeepAliveTransfer', Connection.KeepAliveTransfer);
end;
IniFile.UpdateFile;
@ -314,6 +317,7 @@ begin
FtpSend := TSftpSend.Create(Connection.Encoding)
else begin
FtpSend := TFTPSendEx.Create(Connection.Encoding);
FtpSend.ShowHidden := Connection.ShowHiddenItems;
FtpSend.KeepAliveTransfer := Connection.KeepAliveTransfer;
end;
FtpSend.TcpKeepAlive := TcpKeepAlive;
@ -1115,6 +1119,7 @@ begin
MasterPassword:= Connection.MasterPassword;
ConnectionName:= Connection.ConnectionName;
PasswordChanged:= Connection.PasswordChanged;
ShowHiddenItems:= Connection.ShowHiddenItems;
KeepAliveTransfer:= Connection.KeepAliveTransfer;
end;