UPD: Network connection manager

This commit is contained in:
Alexander Koblov 2010-05-22 14:02:33 +00:00
commit d3ff7390e1
3 changed files with 39 additions and 11 deletions

View file

@ -866,8 +866,17 @@ begin
Result:= False;
if Connection = #0 then
begin
if QuickConnection then
Result:= True;
if QuickConnection then
begin
I:= ActiveConnectionList.IndexOf(cQuickConnection);
if I >= 0 then
begin
Con:= TConnection(ActiveConnectionList.Objects[I]);
StrPLCopy(Connection, Con.Host, MaxLen);
StrPLCopy(RemotePath, Con.Path, MaxLen);
Result:= True;
end;
end;
end
else if FtpConnect(Connection, FtpSend) then
begin

View file

@ -60,22 +60,32 @@ procedure TfrmConnectionManager.tvConnectionsSelectionChanged(Sender: TObject);
var
bEnabled: Boolean;
begin
bEnabled:= Assigned(tvConnections.Selected) and Assigned(tvConnections.Selected.Data);
btnConnect.Enabled:= not bEnabled;
btnAdd.Enabled:= bEnabled;
btnEdit.Enabled:= not bEnabled;
btnDelete.Enabled:= not bEnabled;
if not Assigned(tvConnections.Selected) then
begin
btnConnect.Enabled:= False;
btnAdd.Enabled:= False;
btnEdit.Enabled:= False;
btnDelete.Enabled:= False;
end
else
begin
bEnabled:= Assigned(tvConnections.Selected.Data);
btnConnect.Enabled:= not bEnabled;
btnAdd.Enabled:= bEnabled;
btnEdit.Enabled:= not bEnabled;
btnDelete.Enabled:= not bEnabled;
end;
end;
procedure TfrmConnectionManager.btnAddClick(Sender: TObject);
var
WfxModule: TWfxModule;
WfxPluginFileSource: TWfxPluginFileSource;
Connection: UTF8String;
begin
WfxModule:= TWfxModule(tvConnections.Selected.Data);
if Assigned(WfxModule) then
WfxPluginFileSource:= TWfxPluginFileSource(tvConnections.Selected.Data);
if Assigned(WfxPluginFileSource) then
begin
if WfxModule.WfxNetworkManageConnection(Connection, FS_NM_ACTION_ADD) then
if WfxPluginFileSource.WfxModule.WfxNetworkManageConnection(Connection, FS_NM_ACTION_ADD) then
begin
with tvConnections.Items.AddChild(tvConnections.Selected, Connection) do
StateIndex:= 1;

View file

@ -156,6 +156,7 @@ type
function WfxNetworkGetConnection(Index: LongInt; var Connection: UTF8String): Boolean;
function WfxNetworkManageConnection(var Connection: UTF8String; Action: LongInt): Boolean;
function WfxNetworkOpenConnection(var Connection, RemotePath: UTF8String): Boolean;
procedure WfxNetworkCloseConnection(const Connection: UTF8String);
public
constructor Create;
destructor Destroy; override;
@ -549,6 +550,14 @@ begin
end;
end;
procedure TWFXModule.WfxNetworkCloseConnection(const Connection: UTF8String);
begin
if Assigned(FsDisconnectW) then
FsDisconnectW(PWideChar(UTF8Decode(Connection)))
else if Assigned(FsDisconnect) then
FsDisconnect(PAnsiChar(UTF8ToSys(Connection)));
end;
constructor TWFXModule.Create;
begin