mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: Show ftp disconnect menu
FIX: Bug [0000567] "Don't close log window after ftp disconnect"
This commit is contained in:
parent
ffe4c9223d
commit
109ae054e4
3 changed files with 76 additions and 35 deletions
|
|
@ -223,10 +223,9 @@ end;
|
|||
procedure MainLogProc(PluginNr, MsgType: Integer; LogString: UTF8String);
|
||||
var
|
||||
I: Integer;
|
||||
sMsg: UTF8String;
|
||||
sMsg, sName, sPath: String;
|
||||
bLogFile, bLogWindow: Boolean;
|
||||
LogMsgType: TLogMsgType = lmtInfo;
|
||||
bLogFile: Boolean;
|
||||
sName: UTF8String;
|
||||
CallbackDataClass: TCallbackDataClass;
|
||||
Begin
|
||||
sMsg:= rsMsgLogInfo;
|
||||
|
|
@ -235,23 +234,25 @@ Begin
|
|||
case MsgType of
|
||||
msgtype_connect:
|
||||
begin
|
||||
bLogWindow:= True;
|
||||
if Assigned(CallbackDataClass) then
|
||||
begin
|
||||
I:= Pos(#32, LogString);
|
||||
sName:= WfxOperationList[PluginNr] + ':' + Copy(LogString, I, MaxInt);
|
||||
AddNetworkConnection(sName, CallbackDataClass.FileSource);
|
||||
end;
|
||||
begin
|
||||
I:= Pos(#32, LogString);
|
||||
sPath:= Copy(LogString, I + 1, MaxInt);
|
||||
sName:= WfxOperationList[PluginNr] + ':' + Copy(LogString, I, MaxInt);
|
||||
AddNetworkConnection(sName, sPath, CallbackDataClass.FileSource);
|
||||
end;
|
||||
sMsg:= sMsg + '[' + IntToStr(MsgType) + ']';
|
||||
ShowLogWindow(True);
|
||||
end;
|
||||
msgtype_disconnect:
|
||||
begin
|
||||
if Assigned(CallbackDataClass) then
|
||||
begin
|
||||
I:= Pos(#32, LogString);
|
||||
sName:= WfxOperationList[PluginNr] + Copy(LogString, I, MaxInt);
|
||||
RemoveNetworkConnection(sName);
|
||||
end;
|
||||
begin
|
||||
bLogWindow:= False;
|
||||
I:= Pos(#32, LogString);
|
||||
sName:= WfxOperationList[PluginNr] + ':' + Copy(LogString, I, MaxInt);
|
||||
RemoveNetworkConnection(sName);
|
||||
end;
|
||||
end;
|
||||
msgtype_details,
|
||||
msgtype_operationcomplete,
|
||||
|
|
@ -260,13 +261,13 @@ Begin
|
|||
sMsg:= sMsg + '[' + IntToStr(MsgType) + ']';
|
||||
msgtype_importanterror:
|
||||
begin
|
||||
sMsg:= rsMsgLogError + '[' + IntToStr(MsgType) + ']';
|
||||
LogMsgType:= lmtError;
|
||||
sMsg:= rsMsgLogError + '[' + IntToStr(MsgType) + ']';
|
||||
bLogFile:= (log_vfs_op in gLogOptions) and (log_errors in gLogOptions);
|
||||
end;
|
||||
end;
|
||||
// write log info
|
||||
logWrite(sMsg + ', ' + logString, LogMsgType, True, bLogFile);
|
||||
logWrite(sMsg + ', ' + logString, LogMsgType, bLogWindow, bLogFile);
|
||||
|
||||
//DCDebug('MainLogProc ('+ sMsg + ',' + logString + ')');
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -1137,15 +1137,17 @@ object frmMain: TfrmMain
|
|||
end
|
||||
object mnuNetwork: TMenuItem
|
||||
Caption = 'Network'
|
||||
Visible = False
|
||||
object miNetworkConnect: TMenuItem
|
||||
Action = actNetworkConnect
|
||||
Visible = False
|
||||
end
|
||||
object miNetworkQuickConnect: TMenuItem
|
||||
Action = actNetworkQuickConnect
|
||||
Visible = False
|
||||
end
|
||||
object miNetworkDisconnect: TMenuItem
|
||||
Action = actNetworkDisconnect
|
||||
Enabled = False
|
||||
end
|
||||
end
|
||||
object mnuTabs: TMenuItem
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ type
|
|||
function NewFileSourceRecord(FileSource: IFileSource): PFileSourceRecord;
|
||||
procedure DisposeFileSourceRecord(FileSourceRecord: PFileSourceRecord);
|
||||
|
||||
procedure AddNetworkConnection(const ConnectionName: UTF8String; FileSource: IFileSource);
|
||||
procedure RemoveNetworkConnection(const ConnectionName: UTF8String);
|
||||
procedure AddNetworkConnection(const ConnectionName, Path: String; FileSource: IFileSource);
|
||||
procedure RemoveNetworkConnection(const ConnectionName: String);
|
||||
|
||||
var
|
||||
WfxConnectionList: TStringList = nil;
|
||||
|
|
@ -25,7 +25,7 @@ var
|
|||
implementation
|
||||
|
||||
uses
|
||||
Menus, fMain;
|
||||
Menus, DCStrUtils, fMain, uWfxPluginFileSource, uLog, uGlobs;
|
||||
|
||||
function NewFileSourceRecord(FileSource: IFileSource): PFileSourceRecord;
|
||||
begin
|
||||
|
|
@ -39,38 +39,76 @@ begin
|
|||
Dispose(FileSourceRecord);
|
||||
end;
|
||||
|
||||
procedure AddNetworkConnection(const ConnectionName: UTF8String; FileSource: IFileSource);
|
||||
procedure OnNetworkDisconnect(Self, Sender: TObject);
|
||||
var
|
||||
miTemp: TMenuItem;
|
||||
Index: Integer;
|
||||
Connection: PFileSourceRecord;
|
||||
FileSource: IWfxPluginFileSource;
|
||||
MenuItem: TMenuItem absolute Sender;
|
||||
begin
|
||||
if WfxConnectionList.Find(MenuItem.Caption, Index) then
|
||||
begin
|
||||
Connection:= PFileSourceRecord(WfxConnectionList.Objects[Index]);
|
||||
FileSource:= Connection.FileSource as IWfxPluginFileSource;
|
||||
FileSource.WfxModule.WfxDisconnect(MenuItem.Hint);
|
||||
with frmMain do
|
||||
begin
|
||||
if ActiveFrame.FileSource.Equals(FileSource) and
|
||||
IsInPath(MenuItem.Hint, ActiveFrame.CurrentPath, True, True) then
|
||||
begin
|
||||
ActiveFrame.RemoveCurrentFileSource;
|
||||
end
|
||||
else if NotActiveFrame.FileSource.Equals(FileSource) and
|
||||
IsInPath(MenuItem.Hint, NotActiveFrame.CurrentPath, True, True) then
|
||||
begin
|
||||
NotActiveFrame.RemoveCurrentFileSource
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure AddNetworkConnection(const ConnectionName, Path: String; FileSource: IFileSource);
|
||||
var
|
||||
Handler: TMethod;
|
||||
MenuItem: TMenuItem;
|
||||
begin
|
||||
WfxConnectionList.AddObject(ConnectionName, TObject(NewFileSourceRecord(FileSource)));
|
||||
with frmMain do
|
||||
begin
|
||||
miTemp:= TMenuItem.Create(miNetworkDisconnect);
|
||||
miTemp.Caption:= ConnectionName;
|
||||
miNetworkDisconnect.Add(miTemp);
|
||||
MenuItem:= TMenuItem.Create(miNetworkDisconnect);
|
||||
MenuItem.Hint:= Path;
|
||||
MenuItem.Caption:= ConnectionName;
|
||||
Handler.Data:= MenuItem;
|
||||
Handler.Code:= @OnNetworkDisconnect;
|
||||
MenuItem.OnClick:= TNotifyEvent(Handler);
|
||||
miNetworkDisconnect.Add(MenuItem);
|
||||
miNetworkDisconnect.Enabled:= miNetworkDisconnect.Count > 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RemoveNetworkConnection(const ConnectionName: UTF8String);
|
||||
procedure RemoveNetworkConnection(const ConnectionName: String);
|
||||
var
|
||||
I: Integer;
|
||||
Index: Integer;
|
||||
begin
|
||||
I:= WfxConnectionList.IndexOf(ConnectionName);
|
||||
if I >= 0 then
|
||||
with frmMain do
|
||||
if WfxConnectionList.Find(ConnectionName, Index) then
|
||||
with frmMain do
|
||||
begin
|
||||
DisposeFileSourceRecord(PFileSourceRecord(WfxConnectionList.Objects[Index]));
|
||||
WfxConnectionList.Delete(Index);
|
||||
miNetworkDisconnect.Remove(miNetworkDisconnect.Find(ConnectionName));
|
||||
miNetworkDisconnect.Enabled:= miNetworkDisconnect.Count > 0;
|
||||
if WfxConnectionList.Count = 0 then
|
||||
begin
|
||||
DisposeFileSourceRecord(PFileSourceRecord(WfxConnectionList.Objects[I]));
|
||||
WfxConnectionList.Delete(I);
|
||||
miNetworkDisconnect.Remove(miNetworkDisconnect.Find(ConnectionName));
|
||||
if gLogWindow = False then ShowLogWindow(False);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
WfxConnectionList:= TStringList.Create;
|
||||
|
||||
finalization
|
||||
if Assigned(WfxConnectionList) then
|
||||
FreeAndNil(WfxConnectionList);
|
||||
FreeAndNil(WfxConnectionList);
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue