mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: Feature [0000176] "add Network and ftp to drive list"
This commit is contained in:
parent
a6d7d6331a
commit
610d2c9423
7 changed files with 187 additions and 73 deletions
|
|
@ -240,8 +240,8 @@ Begin
|
|||
if Assigned(CallbackDataClass) then
|
||||
begin
|
||||
I:= Pos(#32, LogString);
|
||||
sName:= WfxOperationList[PluginNr];
|
||||
sPath:= Copy(LogString, I + 1, MaxInt);
|
||||
sName:= WfxOperationList[PluginNr] + ':' + Copy(LogString, I, MaxInt);
|
||||
AddNetworkConnection(sName, sPath, CallbackDataClass.FileSource);
|
||||
end;
|
||||
sMsg:= sMsg + '[' + IntToStr(MsgType) + ']';
|
||||
|
|
@ -252,8 +252,9 @@ Begin
|
|||
begin
|
||||
bLogWindow:= False;
|
||||
I:= Pos(#32, LogString);
|
||||
sName:= WfxOperationList[PluginNr] + ':' + Copy(LogString, I, MaxInt);
|
||||
RemoveNetworkConnection(sName);
|
||||
sName:= WfxOperationList[PluginNr];
|
||||
sPath:= Copy(LogString, I + 1, MaxInt);
|
||||
RemoveNetworkConnection(sName, sPath);
|
||||
end;
|
||||
end;
|
||||
msgtype_details,
|
||||
|
|
|
|||
|
|
@ -1139,7 +1139,6 @@ object frmMain: TfrmMain
|
|||
Caption = 'Network'
|
||||
object miNetworkConnect: TMenuItem
|
||||
Action = actNetworkConnect
|
||||
Visible = False
|
||||
end
|
||||
object miNetworkQuickConnect: TMenuItem
|
||||
Action = actNetworkQuickConnect
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ uses
|
|||
uShellExecute, fSymLink, fHardLink, uExceptions, uUniqueInstance, Clipbrd,
|
||||
uFileSourceOperationOptionsUI, uDebug, uHotkeyManager, uFileSourceUtil,
|
||||
XMLRead, DCOSUtils, DCStrUtils, fOptions, fOptionsFrame, fOptionsToolbar,
|
||||
uHotDir, uFileSorting, DCBasicTypes, foptionsDirectoryHotlist
|
||||
uHotDir, uFileSorting, DCBasicTypes, foptionsDirectoryHotlist, uConnectionManager
|
||||
{$IFDEF COLUMNSFILEVIEW_VTV}
|
||||
, uColumnsFileViewVtv
|
||||
{$ENDIF}
|
||||
|
|
@ -3673,6 +3673,8 @@ begin
|
|||
DrivesList.Remove(I);
|
||||
end;
|
||||
|
||||
UpdateDriveList(DrivesList);
|
||||
|
||||
// create drives drop down menu
|
||||
FDrivesListPopup.UpdateDrivesList(DrivesList);
|
||||
|
||||
|
|
@ -5359,7 +5361,7 @@ procedure TfrmMain.SetPanelDrive(aPanel: TFilePanelSelect; Drive: PDrive; Activa
|
|||
var
|
||||
aFileView, OtherFileView: TFileView;
|
||||
begin
|
||||
if IsAvailable(Drive, Drive^.AutoMount) then
|
||||
if (Drive^.DriveType = dtVirtual) or IsAvailable(Drive, Drive^.AutoMount) then
|
||||
begin
|
||||
case aPanel of
|
||||
fpLeft:
|
||||
|
|
@ -5374,6 +5376,15 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
// Special case for virtual drive
|
||||
if Drive^.DriveType = dtVirtual then
|
||||
begin
|
||||
ChooseFileSource(aFileView, GetNetworkPath(Drive));
|
||||
if ActivateIfNeeded and (tb_activate_panel_on_click in gDirTabOptions) then
|
||||
SetActiveFrame(aPanel);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Copy path opened in the other panel if the file source and drive match
|
||||
// and that path is not already opened in this panel.
|
||||
if OtherFileView.FileSource.IsClass(TFileSystemFileSource) and
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ procedure ShowOpenWithDialog(const FileList: TStringList);
|
|||
implementation
|
||||
|
||||
uses
|
||||
ExtDlgs, LCLProc, uShellContextMenu
|
||||
ExtDlgs, LCLProc, uShellContextMenu, uConnectionManager
|
||||
{$IF DEFINED(MSWINDOWS)}
|
||||
, Menus, Graphics, ComObj, fMain, DCOSUtils, uOSUtils, uFileSystemFileSource
|
||||
, uTotalCommander, InterfaceBase, FileUtil, Windows, ShlObj, uShlObjAdditional
|
||||
|
|
@ -437,22 +437,30 @@ var
|
|||
aFile: TFile;
|
||||
Files: TFiles;
|
||||
begin
|
||||
aFile := TFileSystemFileSource.CreateFile(EmptyStr);
|
||||
aFile.FullPath := ADrive^.Path;
|
||||
aFile.Attributes := faFolder;
|
||||
Files:= TFiles.Create(EmptyStr); // free in ShowContextMenu
|
||||
Files.Add(aFile);
|
||||
ShowContextMenu(Parent, Files, X, Y, False, CloseEvent);
|
||||
if ADrive.DriveType = dtVirtual then
|
||||
ShowVirtualDriveMenu(ADrive, X, Y, CloseEvent)
|
||||
else begin
|
||||
aFile := TFileSystemFileSource.CreateFile(EmptyStr);
|
||||
aFile.FullPath := ADrive^.Path;
|
||||
aFile.Attributes := faFolder;
|
||||
Files:= TFiles.Create(EmptyStr); // free in ShowContextMenu
|
||||
Files.Add(aFile);
|
||||
ShowContextMenu(Parent, Files, X, Y, False, CloseEvent);
|
||||
end;
|
||||
end;
|
||||
{$ELSE}
|
||||
begin
|
||||
// Free previous created menu
|
||||
FreeThenNil(ShellContextMenu);
|
||||
// Create new context menu
|
||||
ShellContextMenu:= TShellContextMenu.Create(nil, ADrive);
|
||||
ShellContextMenu.OnClose := CloseEvent;
|
||||
// show context menu
|
||||
ShellContextMenu.PopUp(X, Y);
|
||||
if ADrive.DriveType = dtVirtual then
|
||||
ShowVirtualDriveMenu(ADrive, X, Y, CloseEvent)
|
||||
else begin
|
||||
// Free previous created menu
|
||||
FreeThenNil(ShellContextMenu);
|
||||
// Create new context menu
|
||||
ShellContextMenu:= TShellContextMenu.Create(nil, ADrive);
|
||||
ShellContextMenu.OnClose := CloseEvent;
|
||||
// show context menu
|
||||
ShellContextMenu.PopUp(X, Y);
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,23 @@ unit uConnectionManager;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, uFileSource;
|
||||
Classes, SysUtils, uFileSource, uDrive, uDrivesList;
|
||||
|
||||
type
|
||||
TFileSourceRecord = record
|
||||
Name, Path: String;
|
||||
FileSource: IFileSource;
|
||||
end;
|
||||
PFileSourceRecord = ^TFileSourceRecord;
|
||||
|
||||
function NewFileSourceRecord(FileSource: IFileSource): PFileSourceRecord;
|
||||
procedure DisposeFileSourceRecord(FileSourceRecord: PFileSourceRecord);
|
||||
function GetNetworkPath(ADrive: PDrive): String;
|
||||
procedure UpdateDriveList(ADriveList: TDrivesList);
|
||||
procedure ShowVirtualDriveMenu(ADrive: PDrive; X, Y : Integer; CloseEvent: TNotifyEvent);
|
||||
|
||||
procedure AddNetworkConnection(const ConnectionName, Path: String; FileSource: IFileSource);
|
||||
procedure RemoveNetworkConnection(const ConnectionName: String);
|
||||
procedure AddNetworkConnection(const Name, Path: String; FileSource: IFileSource);
|
||||
procedure RemoveNetworkConnection(const Name, Path: String);
|
||||
|
||||
procedure CloseNetworkConnection();
|
||||
|
||||
var
|
||||
WfxConnectionList: TStringList = nil;
|
||||
|
|
@ -25,11 +29,21 @@ var
|
|||
implementation
|
||||
|
||||
uses
|
||||
Menus, DCStrUtils, fMain, uWfxPluginFileSource, uLog, uGlobs;
|
||||
Menus, StrUtils, DCStrUtils, fMain, uWfxPluginFileSource, uLog, uGlobs, uFileSourceUtil, uFileView;
|
||||
|
||||
function NewFileSourceRecord(FileSource: IFileSource): PFileSourceRecord;
|
||||
var
|
||||
ContextMenu: TPopupMenu = nil;
|
||||
|
||||
function GetConnectionName(const Name, Path: String): String; inline;
|
||||
begin
|
||||
Result:= Name + ': ' + Path;
|
||||
end;
|
||||
|
||||
function NewFileSourceRecord(FileSource: IFileSource; const Name, Path: String): PFileSourceRecord;
|
||||
begin
|
||||
New(Result);
|
||||
Result^.Name:= Name;
|
||||
Result^.Path:= Path;
|
||||
Result^.FileSource:= FileSource;
|
||||
end;
|
||||
|
||||
|
|
@ -39,68 +53,157 @@ begin
|
|||
Dispose(FileSourceRecord);
|
||||
end;
|
||||
|
||||
procedure OnNetworkDisconnect(Self, Sender: TObject);
|
||||
procedure CloseConnection(Index: Integer);
|
||||
var
|
||||
Index: Integer;
|
||||
Connection: PFileSourceRecord;
|
||||
Connection: TFileSourceRecord;
|
||||
FileSource: IWfxPluginFileSource;
|
||||
MenuItem: TMenuItem absolute Sender;
|
||||
begin
|
||||
if WfxConnectionList.Find(MenuItem.Caption, Index) then
|
||||
Connection:= PFileSourceRecord(WfxConnectionList.Objects[Index])^;
|
||||
FileSource:= Connection.FileSource as IWfxPluginFileSource;
|
||||
FileSource.WfxModule.WfxDisconnect(Connection.Path);
|
||||
with frmMain do
|
||||
begin
|
||||
Connection:= PFileSourceRecord(WfxConnectionList.Objects[Index]);
|
||||
FileSource:= Connection.FileSource as IWfxPluginFileSource;
|
||||
FileSource.WfxModule.WfxDisconnect(MenuItem.Hint);
|
||||
with frmMain do
|
||||
if ActiveFrame.FileSource.Equals(FileSource) and
|
||||
IsInPath(Connection.Path, ActiveFrame.CurrentPath, True, True) then
|
||||
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;
|
||||
ActiveFrame.RemoveCurrentFileSource;
|
||||
end
|
||||
else if NotActiveFrame.FileSource.Equals(FileSource) and
|
||||
IsInPath(Connection.Path, NotActiveFrame.CurrentPath, True, True) then
|
||||
begin
|
||||
NotActiveFrame.RemoveCurrentFileSource
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure AddNetworkConnection(const ConnectionName, Path: String; FileSource: IFileSource);
|
||||
procedure OnNetworkDisconnect(Self, Sender: TObject);
|
||||
var
|
||||
Index: Integer;
|
||||
MenuItem: TMenuItem absolute Sender;
|
||||
begin
|
||||
if WfxConnectionList.Find(MenuItem.Hint, Index) then
|
||||
begin
|
||||
CloseConnection(Index);
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetNetworkPath(ADrive: PDrive): String;
|
||||
begin
|
||||
Result:= ADrive^.DeviceId + StringReplace(ADrive^.Path, '\', '/', [rfReplaceAll]);
|
||||
end;
|
||||
|
||||
procedure UpdateDriveList(ADriveList: TDrivesList);
|
||||
var
|
||||
Drive: PDrive;
|
||||
Index: Integer;
|
||||
FileSourceRecord: PFileSourceRecord;
|
||||
begin
|
||||
for Index:= 0 to WfxConnectionList.Count - 1 do
|
||||
begin
|
||||
FileSourceRecord:= PFileSourceRecord(WfxConnectionList.Objects[Index]);
|
||||
New(Drive);
|
||||
Drive^.IsMounted:= True;
|
||||
Drive^.DriveType:= dtVirtual;
|
||||
Drive^.Path:= FileSourceRecord.Path;
|
||||
Drive^.DisplayName:= IntToStr(Index);
|
||||
Drive^.DeviceId:= 'wfx://' + FileSourceRecord.Name;
|
||||
Drive^.DriveLabel:= GetConnectionName(FileSourceRecord.Name, FileSourceRecord.Path);
|
||||
ADriveList.Add(Drive);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure ShowVirtualDriveMenu(ADrive: PDrive; X, Y: Integer; CloseEvent: TNotifyEvent);
|
||||
var
|
||||
Handler: TMethod;
|
||||
MenuItem: TMenuItem;
|
||||
begin
|
||||
WfxConnectionList.AddObject(ConnectionName, TObject(NewFileSourceRecord(FileSource)));
|
||||
// Free previous created menu
|
||||
FreeAndNil(ContextMenu);
|
||||
|
||||
// Create new context menu
|
||||
ContextMenu:= TPopupMenu.Create(nil);
|
||||
ContextMenu.OnClose := CloseEvent;
|
||||
|
||||
MenuItem:= TMenuItem.Create(ContextMenu);
|
||||
MenuItem.Caption:= ADrive.DriveLabel;
|
||||
MenuItem.Enabled:= False;
|
||||
ContextMenu.Items.Add(MenuItem);
|
||||
|
||||
MenuItem:= TMenuItem.Create(ContextMenu);
|
||||
MenuItem.Caption:= '-';
|
||||
ContextMenu.Items.Add(MenuItem);
|
||||
|
||||
MenuItem:= TMenuItem.Create(ContextMenu);
|
||||
MenuItem.Caption:= frmMain.actNetworkDisconnect.Caption;
|
||||
MenuItem.Hint:= ADrive.DriveLabel;
|
||||
Handler.Data:= MenuItem;
|
||||
Handler.Code:= @OnNetworkDisconnect;
|
||||
MenuItem.OnClick:= TNotifyEvent(Handler);
|
||||
ContextMenu.Items.Add(MenuItem);
|
||||
|
||||
// Show context menu
|
||||
ContextMenu.PopUp(X, Y);
|
||||
end;
|
||||
|
||||
procedure AddNetworkConnection(const Name, Path: String; FileSource: IFileSource);
|
||||
var
|
||||
ConnectionName: String;
|
||||
FileSourceRecord: PFileSourceRecord;
|
||||
begin
|
||||
ConnectionName:= GetConnectionName(Name, Path);
|
||||
FileSourceRecord:= NewFileSourceRecord(FileSource, Name, Path);
|
||||
WfxConnectionList.AddObject(ConnectionName, TObject(FileSourceRecord));
|
||||
with frmMain do
|
||||
begin
|
||||
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;
|
||||
miNetworkDisconnect.Enabled:= WfxConnectionList.Count > 0;
|
||||
UpdateDiskCount;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RemoveNetworkConnection(const ConnectionName: String);
|
||||
procedure RemoveNetworkConnection(const Name, Path: String);
|
||||
var
|
||||
Index: Integer;
|
||||
ConnectionName: String;
|
||||
begin
|
||||
ConnectionName:= GetConnectionName(Name, Path);
|
||||
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;
|
||||
miNetworkDisconnect.Enabled:= WfxConnectionList.Count > 0;
|
||||
if WfxConnectionList.Count = 0 then
|
||||
begin
|
||||
if gLogWindow = False then ShowLogWindow(False);
|
||||
end;
|
||||
UpdateDiskCount;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CloseNetworkConnection;
|
||||
var
|
||||
Index: Integer;
|
||||
ConnectionName: String;
|
||||
FileView: TFileView = nil;
|
||||
begin
|
||||
if WfxConnectionList.Count > 0 then
|
||||
with frmMain do
|
||||
begin
|
||||
if ActiveFrame.FileSource.IsInterface(IWfxPluginFileSource) then
|
||||
FileView:= ActiveFrame
|
||||
else if NotActiveFrame.FileSource.IsInterface(IWfxPluginFileSource) then begin
|
||||
FileView:= NotActiveFrame
|
||||
end;
|
||||
if Assigned(FileView) then
|
||||
begin
|
||||
ConnectionName:= ExtractWord(2, FileView.CurrentAddress, ['/']);
|
||||
ConnectionName:= GetConnectionName(ConnectionName, PathDelim + ExtractWord(1, FileView.CurrentPath, [PathDelim]));
|
||||
if WfxConnectionList.Find(ConnectionName, Index) then CloseConnection(Index);
|
||||
end
|
||||
// Close last connection
|
||||
else begin
|
||||
CloseConnection(WfxConnectionList.Count - 1);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -111,4 +214,4 @@ finalization
|
|||
FreeAndNil(WfxConnectionList);
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ type
|
|||
dtOptical, // CD, DVD, Blu-Ray, etc.
|
||||
dtRamDisk, // Ram-disk
|
||||
dtRemovable, // Drive with removable media
|
||||
dtRemovableUsb); // Drive connected via USB
|
||||
dtRemovableUsb, // Drive connected via USB
|
||||
dtVirtual); // Virtual drive
|
||||
|
||||
{ TDrive }
|
||||
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ uses Forms, Controls, Dialogs, Clipbrd, strutils, LCLProc, HelpIntfs, StringHash
|
|||
fViewOperations, uVfsModule, uMultiListFileSource, uExceptions,
|
||||
DCOSUtils, DCStrUtils, DCBasicTypes, uFileSourceCopyOperation, fSyncDirsDlg,
|
||||
uHotDir, DCXmlConfig, dmCommonData, fOptionsFrame, foptionsDirectoryHotlist,
|
||||
fOptionsToolbar, fMainCommandsDlg
|
||||
fOptionsToolbar, fMainCommandsDlg, uConnectionManager
|
||||
{$IFDEF COLUMNSFILEVIEW_VTV}
|
||||
, uColumnsFileViewVtv
|
||||
{$ENDIF}
|
||||
|
|
@ -3545,21 +3545,12 @@ end;
|
|||
|
||||
procedure TMainCommands.cm_NetworkConnect(const Params: array of string);
|
||||
begin
|
||||
{
|
||||
ShowConnectionManager(frmMain.ActiveFrame);
|
||||
}
|
||||
DoOpenVirtualFileSystemList(frmMain.ActiveFrame);
|
||||
end;
|
||||
|
||||
procedure TMainCommands.cm_NetworkDisconnect(const Params: array of string);
|
||||
begin
|
||||
{
|
||||
if frmMain.ActiveFrame.FileSource.IsClass(TWfxPluginFileSource) then
|
||||
with frmMain.ActiveFrame.FileSource as IWfxPluginFileSource do
|
||||
begin
|
||||
if param <> EmptyStr then
|
||||
WfxModule.WfxNetworkCloseConnection(param);
|
||||
end;
|
||||
}
|
||||
CloseNetworkConnection();
|
||||
end;
|
||||
|
||||
procedure TMainCommands.cm_HorizontalFilePanels(const Params: array of string);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue