summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-24 16:48:37 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-24 16:48:37 +0200
commita55a55d43d949b2b33aa0337aa2695d838e6a875 (patch)
treecb68de3707642076a04c358ed71b67757502c25f
parent63cba0c9834d3b0b6bf6295d165cffbecd315f23 (diff)
downloadtuxcmd-a55a55d43d949b2b33aa0337aa2695d838e6a875.tar.xz
Show only networking plugins where appropriate
Also rename VFSGetExts and VFSGetServices functions
-rw-r--r--UConnectionManager.pas21
-rw-r--r--UConnectionProperties.pas14
-rw-r--r--UQuickConnect.pas38
-rw-r--r--vfs/UVFSCore.pas31
-rw-r--r--vfs/uVFSprototypes.pas8
5 files changed, 65 insertions, 47 deletions
diff --git a/UConnectionManager.pas b/UConnectionManager.pas
index 1744dbc..72574b5 100644
--- a/UConnectionManager.pas
+++ b/UConnectionManager.pas
@@ -335,7 +335,8 @@ begin
ConnMgrItem.Password := PasswordEntry.Text;
ConnMgrItem.TargetDir := TargetDirEntry.Text;
ConnMgrItem.PluginID := '';
- if PluginOptionMenu.ItemIndex <> 0 then ConnMgrItem.PluginID := TVFSPlugin(PluginList[PluginOptionMenu.ItemIndex - 1]).ModuleID;
+ if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then
+ ConnMgrItem.PluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID;
end;
ConnectionMgrList.Add(ConnMgrItem);
Item := ListView.Items.Add;
@@ -366,9 +367,9 @@ begin
FConnectionProperties.URIEntry.Text := ConstructURI(True, False, ConnMgrItem.ServiceType, ConnMgrItem.Server, ConnMgrItem.Username, ConnMgrItem.Password, ConnMgrItem.TargetDir);
FConnectionProperties.ServiceTypeOptionMenuChanged(Sender);
// Find the plugin by PluginID
- for i := 0 to PluginList.Count - 1 do
- if TVFSPlugin(PluginList[i]).ModuleID = ConnMgrItem.PluginID then begin
- FConnectionProperties.PluginOptionMenu.ItemIndex := i + 1;
+ for i := 0 to FConnectionProperties.PluginOptionMenu.Items.Count - 1 do
+ if (FConnectionProperties.PluginOptionMenu.Items[i].Data <> nil) and (TVFSPlugin(FConnectionProperties.PluginOptionMenu.Items[i].Data).ModuleID = ConnMgrItem.PluginID) then begin
+ FConnectionProperties.PluginOptionMenu.ItemIndex := i;
Break;
end;
@@ -381,7 +382,8 @@ begin
ConnMgrItem.Password := PasswordEntry.Text;
ConnMgrItem.TargetDir := TargetDirEntry.Text;
ConnMgrItem.PluginID := '';
- if PluginOptionMenu.ItemIndex <> 0 then ConnMgrItem.PluginID := TVFSPlugin(PluginList[PluginOptionMenu.ItemIndex - 1]).ModuleID;
+ if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then
+ ConnMgrItem.PluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID;
end;
Item.SetValue(1, ConnMgrItem.ConnectionName);
Item.SetValue(2, FConnectionProperties.MakeURI(True));
@@ -407,9 +409,9 @@ begin
FConnectionProperties.URIEntry.Text := ConstructURI(True, False, ConnMgrItem.ServiceType, ConnMgrItem.Server, ConnMgrItem.Username, ConnMgrItem.Password, ConnMgrItem.TargetDir);
FConnectionProperties.ServiceTypeOptionMenuChanged(Sender);
// Find the plugin by PluginID
- for i := 0 to PluginList.Count - 1 do
- if TVFSPlugin(PluginList[i]).ModuleID = ConnMgrItem.PluginID then begin
- FConnectionProperties.PluginOptionMenu.ItemIndex := i + 1;
+ for i := 0 to FConnectionProperties.PluginOptionMenu.Items.Count - 1 do
+ if (FConnectionProperties.PluginOptionMenu.Items[i].Data <> nil) and (TVFSPlugin(FConnectionProperties.PluginOptionMenu.Items[i].Data).ModuleID = ConnMgrItem.PluginID) then begin
+ FConnectionProperties.PluginOptionMenu.ItemIndex := i;
Break;
end;
@@ -423,7 +425,8 @@ begin
ConnMgrItem.Password := PasswordEntry.Text;
ConnMgrItem.TargetDir := TargetDirEntry.Text;
ConnMgrItem.PluginID := '';
- if PluginOptionMenu.ItemIndex <> 0 then ConnMgrItem.PluginID := TVFSPlugin(PluginList[PluginOptionMenu.ItemIndex - 1]).ModuleID;
+ if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then
+ ConnMgrItem.PluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID;
end;
ConnectionMgrList.Add(ConnMgrItem);
Item := ListView.Items.Add;
diff --git a/UConnectionProperties.pas b/UConnectionProperties.pas
index 3e68080..edf6927 100644
--- a/UConnectionProperties.pas
+++ b/UConnectionProperties.pas
@@ -189,12 +189,14 @@ begin
MenuItem := TGTKMenuItem.CreateTyped(Self, itLabel);
MenuItem.Caption := LANGConnProp_MenuItemCaption;
PluginOptionMenu.Items.Add(MenuItem);
- for i := 0 to PluginList.Count - 1 do begin
- MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
- MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
- PluginOptionMenu.Items.Add(MenuItem);
- end;
+ for i := 0 to PluginList.Count - 1 do
+ if TVFSPlugin(PluginList[i]).HandlesNetwork then begin
+ MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
+ MenuItem.Data := PluginList[i];
+ MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
+ PluginOptionMenu.Items.Add(MenuItem);
+ end;
// Fill the protocol menu
for i := 1 to ServiceTypeTable_Count do begin
diff --git a/UQuickConnect.pas b/UQuickConnect.pas
index ca2824a..2779826 100644
--- a/UQuickConnect.pas
+++ b/UQuickConnect.pas
@@ -147,18 +147,20 @@ begin
MenuItem := TGTKMenuItem.CreateTyped(Self, itLabel);
MenuItem.Caption := LANGConnProp_MenuItemCaption;
PluginOptionMenu.Items.Add(MenuItem);
- for i := 0 to PluginList.Count - 1 do begin
- MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
- MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
- ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
- PluginOptionMenu.Items.Add(MenuItem);
- end;
+ for i := 0 to PluginList.Count - 1 do
+ if TVFSPlugin(PluginList[i]).HandlesNetwork then begin
+ MenuItem := TGTKMenuItem.CreateTyped(Self, itImageText);
+ MenuItem.Data := PluginList[i];
+ MenuItem.SetCaptionPlain(Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
+ ExtractFileName(TVFSPlugin(PluginList[i]).FullPath)]));
+ PluginOptionMenu.Items.Add(MenuItem);
+ end;
// Find last used plugin
- if Length(Trim(ConfQuickConnectPluginID)) > 0 then
- for i := 0 to PluginList.Count - 1 do
- if TVFSPlugin(PluginList[i]).ModuleID = ConfQuickConnectPluginID then begin
- PluginOptionMenu.ItemIndex := i + 1;
+ if (Length(Trim(ConfQuickConnectPluginID)) > 0) and (PluginOptionMenu.Items.Count > 0) then
+ for i := 0 to PluginOptionMenu.Items.Count - 1 do
+ if (PluginOptionMenu.Items[i].Data <> nil) and (TVFSPlugin(PluginOptionMenu.Items[i].Data).ModuleID = ConfQuickConnectPluginID) then begin
+ PluginOptionMenu.ItemIndex := i;
Break;
end;
@@ -236,8 +238,8 @@ procedure TFQuickConnect.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Length(Trim(URIComboBox.Entry.Text)) > 0 then
SaveItemToHistory(URIComboBox.Entry.Text, QuickConnectHistory);
- if PluginOptionMenu.ItemIndex <> 0
- then ConfQuickConnectPluginID := TVFSPlugin(PluginList[PluginOptionMenu.ItemIndex - 1]).ModuleID
+ if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil)
+ then ConfQuickConnectPluginID := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data).ModuleID
else ConfQuickConnectPluginID := '';
end;
@@ -282,14 +284,10 @@ begin
// Find VFS module to use for this connection
VFSPlugin := nil;
- if PluginOptionMenu.ItemIndex <> 0 then ConfQuickConnectPluginID := TVFSPlugin(PluginList[PluginOptionMenu.ItemIndex - 1]).ModuleID
- else ConfQuickConnectPluginID := '';
- if Length(ConfQuickConnectPluginID) > 0 then
- for i := 0 to PluginList.Count - 1 do
- if TVFSPlugin(PluginList[i]).ModuleID = ConfQuickConnectPluginID then begin
- VFSPlugin := PluginList[i];
- Break;
- end;
+ if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then begin
+ VFSPlugin := PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data;
+ ConfQuickConnectPluginID := VFSPlugin.ModuleID;
+ end else ConfQuickConnectPluginID := '';
if VFSPlugin = nil then begin
Scheme := '';
if Pos('://', URIComboBox.Entry.Text) > 0 then
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas
index 475730c..a0ada8f 100644
--- a/vfs/UVFSCore.pas
+++ b/vfs/UVFSCore.pas
@@ -63,11 +63,13 @@ type
FVFSCopyIn: TVFSCopyIn;
FVFSIsOnSameFS: TVFSIsOnSameFS;
FVFSTwoSameFiles: TVFSTwoSameFiles;
- FVFSGetExts: TVFSGetExts;
- FVFSGetServices: TVFSGetServices;
+ FVFSGetArchiveExts: TVFSGetArchiveExts;
+ FVFSGetNetworkServices: TVFSGetNetworkServices;
FVFSGetPasswordRequired: TVFSGetPasswordRequired;
FVFSSetCallbacks: TVFSSetCallbacks;
FVFSResetPassword: TVFSResetPassword;
+ function GetHandlesArchives: boolean;
+ function GetHandlesNetwork: boolean;
public
ModuleHandle: Pointer;
FullPath: string; // module path
@@ -80,6 +82,9 @@ type
function ModuleName: string;
function ModuleAbout: string;
function ModuleCopyright: string;
+ published
+ property HandlesArchives: boolean read GetHandlesArchives;
+ property HandlesNetwork: boolean read GetHandlesNetwork;
end;
@@ -231,8 +236,8 @@ begin
@FVFSSetBlockSize := dlsym(ModuleHandle, 'VFSSetBlockSize');
@FVFSIsOnSameFS := dlsym(ModuleHandle, 'VFSIsOnSameFS');
@FVFSTwoSameFiles := dlsym(ModuleHandle, 'VFSTwoSameFiles');
- @FVFSGetExts := dlsym(ModuleHandle, 'VFSGetExts');
- @FVFSGetServices := dlsym(ModuleHandle, 'VFSGetServices');
+ @FVFSGetArchiveExts := dlsym(ModuleHandle, 'VFSGetArchiveExts');
+ @FVFSGetNetworkServices := dlsym(ModuleHandle, 'VFSGetNetworkServices');
@FVFSGetPasswordRequired := dlsym(ModuleHandle, 'VFSGetPasswordRequired');
@FVFSSetCallbacks := dlsym(ModuleHandle, 'VFSSetCallbacks');
@FVFSResetPassword := dlsym(ModuleHandle, 'VFSResetPassword');
@@ -240,15 +245,15 @@ begin
// Initialize the extensions list
SetLength(Extensions, 0);
SetLength(Services, 0);
- if @FVFSGetExts <> nil then begin
- s := FVFSGetExts;
+ if @FVFSGetArchiveExts <> nil then begin
+ s := FVFSGetArchiveExts;
if s <> nil then begin
ParseString(String(s), ';', Extensions);
real_libc_free(s);
end;
end;
- if @FVFSGetServices <> nil then begin
- s := FVFSGetServices;
+ if @FVFSGetNetworkServices <> nil then begin
+ s := FVFSGetNetworkServices;
if s <> nil then begin
ParseString(String(s), ';', Services);
real_libc_free(s);
@@ -321,6 +326,16 @@ begin
end else Result := '';
end;
+function TVFSPlugin.GetHandlesArchives: boolean;
+begin
+ Result := Length(Extensions) > 0;
+end;
+
+function TVFSPlugin.GetHandlesNetwork: boolean;
+begin
+ Result := Length(Services) > 0;
+end;
+
(********************************************************************************************************************************)
(********************************************************************************************************************************)
constructor TVFSEngine.Create(SourcePlugin: TVFSPlugin);
diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas
index d236d01..2de5ec4 100644
--- a/vfs/uVFSprototypes.pas
+++ b/vfs/uVFSprototypes.pas
@@ -203,14 +203,14 @@ type
TVFSGetCharset = function (g:TVFSGlobs): PChar; cdecl;
// TODO: Returns charset which the plugin uses
// tuxcmd will take care of memory deallocation
- TVFSGetExts = function: PChar; cdecl;
+ TVFSGetArchiveExts = function: PChar; cdecl;
// Returns the list of filename extensions which the module can handle separated by ';' (without a leading dots)
+ // Returning NULL or not defining the symbol at all means plugin can't handle archives
// tuxcmd will take care of memory deallocation
- TVFSGetServices = function: PChar; cdecl;
+ TVFSGetNetworkServices = function: PChar; cdecl;
// Returns the list of supported remote protocols separated by ';' (without the '://')
+ // Returning NULL or not defining the symbol at all means plugin can't access network services
// tuxcmd will take care of memory deallocation
- TVFSCaps = function (const sExt: PChar): Integer; cdecl;
- // TODO: Returns a bit mask of plugin capabilities
TVFSSetProtocolLogFunc = procedure (g:TVFSGlobs; ProtocolLogFunc: TVFSLogFunc); cdecl;
// TODO: Sets the protocol log function (unlike module debug log func this is intended only for server messages (FTP mainly))
TVFSSetBlockSize = procedure (g:TVFSGlobs; Value: Cardinal); cdecl;