UPD: Ftp plugin (Send init commands)

This commit is contained in:
Alexander Koblov 2009-10-20 20:34:55 +00:00
commit a2dfd1ec53
3 changed files with 53 additions and 12 deletions

View file

@ -1,12 +1,12 @@
object DialogBox: TDialogBox
Left = 290
Height = 341
Height = 357
Top = 144
Width = 400
BorderIcons = [biSystemMenu]
BorderStyle = bsDialog
Caption = 'FTP'
ClientHeight = 341
ClientHeight = 357
ClientWidth = 400
OnShow = DialogBoxShow
LCLVersion = '0.9.29'
@ -100,6 +100,7 @@ object DialogBox: TDialogBox
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Caption = 'Anonymous login (e-mail address as password)'
OnClick = ButtonClick
TabOrder = 3
end
object edtRemoteDir: TEdit
@ -130,11 +131,11 @@ object DialogBox: TDialogBox
end
object chkPassiveMode: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = edtRemoteDir
AnchorSideTop.Control = edtInitCommands
AnchorSideTop.Side = asrBottom
Left = 12
Height = 17
Top = 215
Top = 238
Width = 273
BorderSpacing.Left = 12
BorderSpacing.Top = 18
@ -147,7 +148,7 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 17
Top = 238
Top = 261
Width = 213
BorderSpacing.Left = 12
BorderSpacing.Top = 6
@ -161,7 +162,7 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrCenter
Left = 18
Height = 14
Top = 264
Top = 287
Width = 52
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -175,7 +176,7 @@ object DialogBox: TDialogBox
AnchorSideTop.Side = asrBottom
Left = 80
Height = 21
Top = 261
Top = 284
Width = 100
BorderSpacing.Left = 10
BorderSpacing.Top = 6
@ -196,7 +197,7 @@ object DialogBox: TDialogBox
AnchorSideRight.Control = edtInterval
Left = 212
Height = 14
Top = 264
Top = 287
Width = 84
Anchors = [akTop, akRight]
BorderSpacing.Right = 12
@ -210,7 +211,7 @@ object DialogBox: TDialogBox
AnchorSideRight.Side = asrBottom
Left = 308
Height = 21
Top = 261
Top = 284
Width = 80
Alignment = taRightJustify
Anchors = [akTop, akRight]
@ -226,7 +227,7 @@ object DialogBox: TDialogBox
AnchorSideBottom.Side = asrBottom
Left = 313
Height = 25
Top = 304
Top = 320
Width = 75
Anchors = [akRight, akBottom]
BorderSpacing.Bottom = 12
@ -241,7 +242,7 @@ object DialogBox: TDialogBox
AnchorSideBottom.Side = asrBottom
Left = 226
Height = 25
Top = 304
Top = 320
Width = 75
Anchors = [akRight, akBottom]
BorderSpacing.Right = 12
@ -308,4 +309,30 @@ object DialogBox: TDialogBox
TabOrder = 13
Visible = False
end
object edtInitCommands: TEdit
AnchorSideLeft.Control = edtRemoteDir
AnchorSideTop.Control = edtRemoteDir
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtRemoteDir
AnchorSideRight.Side = asrBottom
Left = 128
Height = 21
Top = 203
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
TabOrder = 14
end
object lblInitCommands: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = edtInitCommands
AnchorSideTop.Side = asrCenter
Left = 12
Height = 14
Top = 206
Width = 74
BorderSpacing.Left = 12
Caption = 'Init commands:'
ParentColor = False
end
end

View file

@ -71,6 +71,9 @@ begin
wsText:= gConnection.Path;
Data:= PtrInt(PWideChar(wsText));
SendDlgMsg(pDlg, 'edtRemoteDir', DM_SETTEXT, Data, 0);
wsText:= gConnection.InitCommands;
Data:= PtrInt(PWideChar(wsText));
SendDlgMsg(pDlg, 'edtInitCommands', DM_SETTEXT, Data, 0);
Data:= PtrInt(gConnection.PassiveMode);
SendDlgMsg(pDlg, 'chkPassiveMode', DM_SETCHECK, Data, 0);
end;
@ -106,6 +109,9 @@ begin
Data:= SendDlgMsg(pDlg, 'edtRemoteDir', DM_GETTEXT, 0, 0);
wsText:= PWideChar(Data);
gConnection.Path:= wsText;
Data:= SendDlgMsg(pDlg, 'edtInitCommands', DM_GETTEXT, 0, 0);
wsText:= PWideChar(Data);
gConnection.InitCommands:= wsText;
Data:= SendDlgMsg(pDlg, 'chkPassiveMode', DM_GETCHECK, 0, 0);
gConnection.PassiveMode:= Boolean(Data);
// close dialog

View file

@ -49,6 +49,7 @@ type
Password: AnsiString;
MasterPassword: Boolean;
PassiveMode: Boolean;
InitCommands: AnsiString;
end;
function FsInit(PluginNr: Integer; pProgressProc: TProgressProc;
@ -87,7 +88,7 @@ var
implementation
uses
IniFiles, FtpUtils, FtpConfDlg;
IniFiles, StrUtils, FtpUtils, FtpConfDlg;
var
ActiveConnectionList, ConnectionList: TStringList;
@ -135,6 +136,7 @@ begin
else
Connection.Password := DecodeBase64(IniFile.ReadString('FTP', 'Connection' + sIndex + 'Password', EmptyStr));
Connection.PassiveMode:= IniFile.ReadBool('FTP', 'Connection' + sIndex + 'PassiveMode', True);
Connection.InitCommands := IniFile.ReadString('FTP', 'Connection' + sIndex + 'InitCommands', EmptyStr);
// add connection to connection list
ConnectionList.AddObject(Connection.ConnectionName, Connection);
end;
@ -164,6 +166,7 @@ begin
else
IniFile.WriteString('FTP', 'Connection' + sIndex + 'Password', EncodeBase64(Connection.Password));
IniFile.WriteBool('FTP', 'Connection' + sIndex + 'PassiveMode', Connection.PassiveMode);
IniFile.WriteString('FTP', 'Connection' + sIndex + 'InitCommands', Connection.InitCommands);
end;
end;
@ -206,6 +209,7 @@ function FtpConnect(const ConnectionName: AnsiString; out FtpSend: TFTPSendEx):
var
I: Integer;
Connection: TConnection;
sTemp: AnsiString;
begin
Result:= False;
if ActiveConnectionList.IndexOf(ConnectionName) < 0 then
@ -241,6 +245,10 @@ begin
if FtpSend.Login then
begin
LogProc(PluginNumber, MSGTYPE_CONNECT, PAnsiChar('CONNECT ' + ConnectionName));
sTemp:= Connection.InitCommands;
repeat
FtpSend.FTPCommand(Copy2SymbDel(sTemp, ';'));
until sTemp = EmptyStr;
ActiveConnectionList.AddObject(ConnectionName, FtpSend);
Result:= True;
end