mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Ftp plugin (Save/Load passive mode)
This commit is contained in:
parent
d816a5bb38
commit
ffee13f819
3 changed files with 54 additions and 38 deletions
|
|
@ -99,7 +99,7 @@ object DialogBox: TDialogBox
|
|||
Width = 260
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Anonymous'
|
||||
Caption = 'Anonymous login (e-mail address as password)'
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtRemoteDir: TEdit
|
||||
|
|
@ -110,7 +110,7 @@ object DialogBox: TDialogBox
|
|||
AnchorSideRight.Side = asrBottom
|
||||
Left = 128
|
||||
Height = 21
|
||||
Top = 174
|
||||
Top = 176
|
||||
Width = 260
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
|
|
@ -122,7 +122,7 @@ object DialogBox: TDialogBox
|
|||
AnchorSideTop.Side = asrCenter
|
||||
Left = 12
|
||||
Height = 14
|
||||
Top = 177
|
||||
Top = 179
|
||||
Width = 57
|
||||
BorderSpacing.Left = 12
|
||||
Caption = 'Remote dir:'
|
||||
|
|
@ -134,7 +134,7 @@ object DialogBox: TDialogBox
|
|||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 17
|
||||
Top = 213
|
||||
Top = 215
|
||||
Width = 273
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Top = 18
|
||||
|
|
@ -147,7 +147,7 @@ object DialogBox: TDialogBox
|
|||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 17
|
||||
Top = 236
|
||||
Top = 238
|
||||
Width = 213
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Top = 6
|
||||
|
|
@ -161,7 +161,7 @@ object DialogBox: TDialogBox
|
|||
AnchorSideTop.Side = asrCenter
|
||||
Left = 18
|
||||
Height = 14
|
||||
Top = 262
|
||||
Top = 264
|
||||
Width = 52
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
|
|
@ -175,18 +175,20 @@ object DialogBox: TDialogBox
|
|||
AnchorSideTop.Side = asrBottom
|
||||
Left = 80
|
||||
Height = 21
|
||||
Top = 259
|
||||
Top = 261
|
||||
Width = 100
|
||||
BorderSpacing.Left = 10
|
||||
BorderSpacing.Top = 6
|
||||
Enabled = False
|
||||
ItemHeight = 13
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'NOOP'
|
||||
'PWD'
|
||||
'SYST'
|
||||
)
|
||||
TabOrder = 7
|
||||
Text = 'NOOP'
|
||||
end
|
||||
object lblInterval: TLabel
|
||||
AnchorSideTop.Control = edtInterval
|
||||
|
|
@ -194,7 +196,7 @@ object DialogBox: TDialogBox
|
|||
AnchorSideRight.Control = edtInterval
|
||||
Left = 212
|
||||
Height = 14
|
||||
Top = 262
|
||||
Top = 264
|
||||
Width = 84
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Right = 12
|
||||
|
|
@ -208,12 +210,14 @@ object DialogBox: TDialogBox
|
|||
AnchorSideRight.Side = asrBottom
|
||||
Left = 308
|
||||
Height = 21
|
||||
Top = 259
|
||||
Top = 261
|
||||
Width = 80
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
Enabled = False
|
||||
TabOrder = 8
|
||||
Text = '90'
|
||||
end
|
||||
object btnCancel: TButton
|
||||
AnchorSideRight.Control = edtRemoteDir
|
||||
|
|
@ -275,14 +279,14 @@ object DialogBox: TDialogBox
|
|||
end
|
||||
object chkMasterPassword: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = edtPassword
|
||||
AnchorSideTop.Control = lblPassword
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 17
|
||||
Top = 151
|
||||
Top = 153
|
||||
Width = 240
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Top = 12
|
||||
Caption = 'Use master password to protect the password'
|
||||
OnChange = CheckBoxChange
|
||||
TabOrder = 12
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ begin
|
|||
if gConnection.MasterPassword then
|
||||
begin
|
||||
SendDlgMsg(pDlg, 'chkMasterPassword', DM_SETCHECK, 1, 0);
|
||||
SendDlgMsg(pDlg, 'chkMasterPassword', DM_ENABLE, 0, 0);
|
||||
SendDlgMsg(pDlg, 'edtPassword', DM_SHOWITEM, 0, 0);
|
||||
SendDlgMsg(pDlg, 'btnChangePassword', DM_SHOWITEM, 1, 0);
|
||||
end
|
||||
|
|
@ -70,6 +71,8 @@ begin
|
|||
wsText:= gConnection.Path;
|
||||
Data:= PtrInt(PWideChar(wsText));
|
||||
SendDlgMsg(pDlg, 'edtRemoteDir', DM_SETTEXT, Data, 0);
|
||||
Data:= PtrInt(gConnection.PassiveMode);
|
||||
SendDlgMsg(pDlg, 'chkPassiveMode', DM_SETCHECK, Data, 0);
|
||||
end;
|
||||
DN_CHANGE:
|
||||
if DlgItemName = 'chkSendCommand' then
|
||||
|
|
@ -78,7 +81,13 @@ begin
|
|||
SendDlgMsg(pDlg, 'edtInterval', DM_ENABLE, wParam, 0);
|
||||
end;
|
||||
DN_CLICK:
|
||||
if DlgItemName = 'btnOK' then
|
||||
if DlgItemName = 'btnAnonymous' then
|
||||
begin
|
||||
wsText:= 'anonymous';
|
||||
Data:= PtrInt(PWideChar(wsText));
|
||||
SendDlgMsg(pDlg, 'edtUserName', DM_SETTEXT, Data, 0);
|
||||
end
|
||||
else if DlgItemName = 'btnOK' then
|
||||
begin
|
||||
Data:= SendDlgMsg(pDlg, 'edtName', DM_GETTEXT, 0, 0);
|
||||
wsText:= PWideChar(Data);
|
||||
|
|
@ -97,6 +106,8 @@ begin
|
|||
Data:= SendDlgMsg(pDlg, 'edtRemoteDir', DM_GETTEXT, 0, 0);
|
||||
wsText:= PWideChar(Data);
|
||||
gConnection.Path:= wsText;
|
||||
Data:= SendDlgMsg(pDlg, 'chkPassiveMode', DM_GETCHECK, 0, 0);
|
||||
gConnection.PassiveMode:= Boolean(Data);
|
||||
// close dialog
|
||||
SendDlgMsg(pDlg, DlgItemName, DM_CLOSE, 1, 0);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ uses
|
|||
type
|
||||
TFTPSendEx = class(TFTPSend)
|
||||
public
|
||||
procedure FTPStatus(Sender: TObject; Response: Boolean;
|
||||
const Value: string);
|
||||
procedure FTPStatus(Sender: TObject; Response: Boolean; const Value: String);
|
||||
end;
|
||||
|
||||
TConnection = class
|
||||
|
|
@ -49,18 +48,17 @@ type
|
|||
UserName: AnsiString;
|
||||
Password: AnsiString;
|
||||
MasterPassword: Boolean;
|
||||
PassiveMode: Boolean;
|
||||
end;
|
||||
|
||||
function FsInit(PluginNr: Integer; pProgressProc: TProgressProc;
|
||||
pLogProc: TLogProc; pRequestProc: TRequestProc): Integer; stdcall;
|
||||
|
||||
function FsFindFirst(Path: PAnsiChar; var FindData: TWin32FindData): THandle;
|
||||
stdcall;
|
||||
function FsFindFirst(Path: PAnsiChar; var FindData: TWin32FindData): THandle; stdcall;
|
||||
function FsFindNext(Hdl: THandle; var FindData: TWin32FindData): BOOL; stdcall;
|
||||
function FsFindClose(Hdl: THandle): Integer; stdcall;
|
||||
|
||||
function FsExecuteFile(MainWin: THandle; RemoteName, Verb: PAnsiChar): Integer;
|
||||
stdcall;
|
||||
function FsExecuteFile(MainWin: THandle; RemoteName, Verb: PAnsiChar): Integer; stdcall;
|
||||
function FsRenMovFile(OldName, NewName: PAnsiChar; Move, OverWrite: BOOL;
|
||||
RemoteInfo: pRemoteInfo): Integer; stdcall;
|
||||
function FsGetFile(RemoteName, LocalName: PAnsiChar; CopyFlags: Integer;
|
||||
|
|
@ -78,8 +76,8 @@ procedure FsSetCryptCallback(pCryptProc: TCryptProc; CryptoNr, Flags: Integer);
|
|||
procedure FsGetDefRootName(DefRootName: PAnsiChar; MaxLen: Integer); stdcall;
|
||||
procedure FsSetDefaultParams(dps: pFsDefaultParamStruct); stdcall;
|
||||
|
||||
{Dialog API function}
|
||||
procedure SetDlgProc(var SetDlgProcInfo: TSetDlgProcInfo);stdcall;
|
||||
{ Dialog API function }
|
||||
procedure SetDlgProc(var SetDlgProcInfo: TSetDlgProcInfo); stdcall;
|
||||
|
||||
var
|
||||
gSetDlgProcInfo: TSetDlgProcInfo;
|
||||
|
|
@ -136,6 +134,7 @@ begin
|
|||
Connection.Password := EmptyStr
|
||||
else
|
||||
Connection.Password := DecodeBase64(IniFile.ReadString('FTP', 'Connection' + sIndex + 'Password', EmptyStr));
|
||||
Connection.PassiveMode:= IniFile.ReadBool('FTP', 'Connection' + sIndex + 'PassiveMode', True);
|
||||
// add connection to connection list
|
||||
ConnectionList.AddObject(Connection.ConnectionName, Connection);
|
||||
end;
|
||||
|
|
@ -164,6 +163,7 @@ begin
|
|||
IniFile.DeleteKey('FTP', 'Connection' + sIndex + 'Password')
|
||||
else
|
||||
IniFile.WriteString('FTP', 'Connection' + sIndex + 'Password', EncodeBase64(Connection.Password));
|
||||
IniFile.WriteBool('FTP', 'Connection' + sIndex + 'PassiveMode', Connection.PassiveMode);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -181,9 +181,14 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function CryptFunc(Mode: LongInt; ConnectionName: AnsiString; var Password: AnsiString): LongInt;
|
||||
begin
|
||||
if (Mode = FS_CRYPT_LOAD_PASSWORD) or (Mode = FS_CRYPT_LOAD_PASSWORD_NO_UI) then
|
||||
SetLength(Password, MAX_PATH);
|
||||
Result:= CryptProc(PluginNumber, CryptoNumber, Mode, PAnsiChar(ConnectionName), PAnsiChar(Password), MAX_PATH);
|
||||
end;
|
||||
|
||||
function ShowPasswordDialog(out Password: AnsiString): Boolean;
|
||||
const
|
||||
MAX_PATH = 256;
|
||||
var
|
||||
pcTemp: PAnsiChar;
|
||||
begin
|
||||
|
|
@ -197,9 +202,7 @@ begin
|
|||
FreeMem(pcTemp);
|
||||
end;
|
||||
|
||||
|
||||
function FtpConnect(const ConnectionName: AnsiString; out FtpSend: TFTPSendEx)
|
||||
: Boolean;
|
||||
function FtpConnect(const ConnectionName: AnsiString; out FtpSend: TFTPSendEx): Boolean;
|
||||
var
|
||||
I: Integer;
|
||||
Connection: TConnection;
|
||||
|
|
@ -215,22 +218,25 @@ begin
|
|||
FtpSend := TFTPSendEx.Create;
|
||||
FtpSend.OnStatus:= FtpSend.FTPStatus;
|
||||
FtpSend.TargetHost := Connection.Host;
|
||||
FtpSend.PassiveMode:= Connection.PassiveMode;
|
||||
if Connection.Port <> EmptyStr then
|
||||
FtpSend.TargetPort := Connection.Port;
|
||||
if Connection.UserName <> EmptyStr then
|
||||
FtpSend.UserName := Connection.UserName;
|
||||
if Connection.Password <> EmptyStr then
|
||||
FtpSend.Password := Connection.Password
|
||||
else // if no saved password then ask it
|
||||
if Connection.MasterPassword then
|
||||
begin
|
||||
if CryptFunc(FS_CRYPT_LOAD_PASSWORD, Connection.ConnectionName, Connection.Password) <> FS_FILE_OK then
|
||||
Connection.Password:= EmptyStr;
|
||||
end;
|
||||
if Connection.Password = EmptyStr then // if no saved password then ask it
|
||||
begin
|
||||
if ShowPasswordDialog(Connection.Password) then
|
||||
FtpSend.Password := Connection.Password
|
||||
else
|
||||
if not ShowPasswordDialog(Connection.Password) then
|
||||
begin
|
||||
FreeAndNil(FtpSend);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
FtpSend.Password := Connection.Password;
|
||||
// try to connect
|
||||
if FtpSend.Login then
|
||||
begin
|
||||
|
|
@ -247,10 +253,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
|
||||
function AddQuickConnection(const Connection: TConnection): Boolean;
|
||||
const
|
||||
MAX_PATH = 256;
|
||||
var
|
||||
pcTemp: PAnsiChar;
|
||||
begin
|
||||
|
|
@ -298,8 +301,6 @@ end;
|
|||
|
||||
|
||||
procedure AddConnection;
|
||||
const
|
||||
MAX_PATH = 256;
|
||||
var
|
||||
pcTemp: PAnsiChar;
|
||||
bCancel: Boolean;
|
||||
|
|
@ -314,7 +315,7 @@ begin
|
|||
begin
|
||||
if MasterPassword then
|
||||
begin
|
||||
if CryptProc(PluginNumber, CryptoNumber, FS_CRYPT_SAVE_PASSWORD, PAnsiChar(ConnectionName), PAnsiChar(Password), Length(Password)) = FS_FILE_OK then
|
||||
if CryptFunc(FS_CRYPT_SAVE_PASSWORD, ConnectionName, Password) = FS_FILE_OK then
|
||||
Password:= EmptyStr;
|
||||
end;
|
||||
ConnectionList.AddObject(ConnectionName, gConnection);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue