summaryrefslogtreecommitdiff
path: root/vfs/UVFSCore.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-28 16:51:52 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-28 16:51:52 +0100
commita67cd9193a6ac04d34c92c1a817fb0f5e44af30f (patch)
tree888227edebb4844efb01cd70bcbfc459b09d2a56 /vfs/UVFSCore.pas
parent4234ca950044c27a1b2fcc92f45d816ef217487f (diff)
downloadtuxcmd-a67cd9193a6ac04d34c92c1a817fb0f5e44af30f.tar.xz
Password callback support from all VFS modulesv0.6.54
Cleanup, remove unused dialogs
Diffstat (limited to 'vfs/UVFSCore.pas')
-rw-r--r--vfs/UVFSCore.pas112
1 files changed, 47 insertions, 65 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas
index ee2a6ca..8bba788 100644
--- a/vfs/UVFSCore.pas
+++ b/vfs/UVFSCore.pas
@@ -41,7 +41,6 @@ type
FVFSGetPrefix: TVFSGetPrefix;
FVFSGetFileSystemSize: TVFSGetFileSystemSize;
FVFSGetFileSystemFree: TVFSGetFileSystemFree;
- FVFSLogin: TVFSLogin;
FVFSFileExists: TVFSFileExists;
FVFSFileInfo: TVFSFileInfo;
FVFSMkDir: TVFSMkDir;
@@ -65,7 +64,6 @@ type
FVFSTwoSameFiles: TVFSTwoSameFiles;
FVFSGetExts: TVFSGetExts;
FVFSGetServices: TVFSGetServices;
- FVFSSetPassword: TVFSSetPassword;
FVFSGetPasswordRequired: TVFSGetPasswordRequired;
FVFSSetCallbacks: TVFSSetCallbacks;
public
@@ -88,23 +86,21 @@ type
FGlobs: Pointer;
FSourcePlugin: TVFSPlugin;
FBlockSize: Cardinal;
- FProgressFunc: TEngineProgressFunc;
- FSenderThread: Pointer;
BreakProcessingKind: integer;
- FPassword: string;
- procedure SetFPassword(Value: string);
public
ArchiveMode: boolean;
+ Password: string;
+ PasswordUsed: boolean;
constructor Create(SourcePlugin: TVFSPlugin);
- function VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): boolean;
- function VFSOpenEx(OpenFile: string): TVFSResult;
+ function VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean;
+ function VFSOpenEx(OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): TVFSResult;
function VFSClose: boolean;
destructor Destroy; override;
function GetListing(var List: TList; const AddDotFiles: boolean): integer; override;
function GetListing(var List: TList; const AddDotFiles: boolean; APath: string): integer; override;
function ChangeDir(const NewPath: string): integer; override;
- function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): integer;
+ function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): integer;
function ExplicitChDir(const NewPath: string): integer; override;
function GetFileSystemSize: Int64; override;
function GetFileSystemSize(const APath: string): Int64; override;
@@ -134,21 +130,22 @@ type
function GetPath: string; override;
procedure SetPath(Value: string); override;
function GetPrefix: string; override;
- function Login(Username, Password: string): integer; override;
function GetBlockSize: Cardinal; override;
procedure SetBlockSize(Value: Cardinal); override;
function CopyFileIn(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; override;
function CopyFileOut(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; override;
+ function CopyFileInEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean;
+ AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean;
+ function CopyFileOutEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean;
+ AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean;
function IsOnSameFS(const Path1, Path2: string): boolean; override;
function TwoSameFiles(const Path1, Path2: string): boolean; override;
- function SetPassword(Password: string): integer;
function GetPasswordRequired: boolean;
published
property Path: string read GetPath write SetPath;
property BlockSize: Cardinal read GetBlockSize write SetBlockSize;
- property Password: string read FPassword write SetFPassword;
end;
@@ -199,7 +196,6 @@ begin
@FVFSGetPrefix := dlsym(ModuleHandle, 'VFSGetPrefix');
@FVFSGetFileSystemSize := dlsym(ModuleHandle, 'VFSGetFileSystemSize');
@FVFSGetFileSystemFree := dlsym(ModuleHandle, 'VFSGetFileSystemFree');
- @FVFSLogin := dlsym(ModuleHandle, 'VFSLogin');
@FVFSFileExists := dlsym(ModuleHandle, 'VFSFileExists');
@FVFSFileInfo := dlsym(ModuleHandle, 'VFSFileInfo');
@FVFSMkDir := dlsym(ModuleHandle, 'VFSMkDir');
@@ -223,7 +219,6 @@ begin
@FVFSTwoSameFiles := dlsym(ModuleHandle, 'VFSTwoSameFiles');
@FVFSGetExts := dlsym(ModuleHandle, 'VFSGetExts');
@FVFSGetServices := dlsym(ModuleHandle, 'VFSGetServices');
- @FVFSSetPassword := dlsym(ModuleHandle, 'VFSSetPassword');
@FVFSGetPasswordRequired := dlsym(ModuleHandle, 'VFSGetPasswordRequired');
@FVFSSetCallbacks := dlsym(ModuleHandle, 'VFSSetCallbacks');
// Initialize the extensions list
@@ -294,7 +289,8 @@ begin
ArchiveMode := False;
BreakProcessingKind := 0;
FGlobs := nil;
- FPassword := '';
+ Password := '';
+ PasswordUsed := False;
if @FSourcePlugin.FVFSNew <> nil then FGlobs := FSourcePlugin.FVFSNew(@VFSLogFunc);
end;
@@ -308,23 +304,28 @@ begin
end;
end;
-function TVFSEngine.VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): boolean;
+function TVFSEngine.VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean;
begin
Result := False;
if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil) then begin
if @FSourcePlugin.FVFSSetCallbacks <> nil then
- FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, CallbackData);
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(URI)) = cVFS_OK;
if @FSourcePlugin.FVFSSetCallbacks <> nil then
- FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil);
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
end;
end;
-function TVFSEngine.VFSOpenEx(OpenFile: string): TVFSResult;
+function TVFSEngine.VFSOpenEx(OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): TVFSResult;
begin
Result := cVFS_OK;
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil)
- then Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(OpenFile));
+ if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil) then begin
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
+ Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(OpenFile));
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
+ end;
end;
function TVFSEngine.VFSClose: boolean;
@@ -510,30 +511,22 @@ begin
DebugMsg(['^^VFS (II): ChangeDir end.']);
end;
-function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): integer;
+function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): integer;
begin
if (FGlobs <> nil) and (@FSourcePlugin.FVFSChangeDir <> nil) then begin
if @FSourcePlugin.FVFSSetCallbacks <> nil then
- FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, CallbackData);
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
Result := ChangeDir(NewPath);
if @FSourcePlugin.FVFSSetCallbacks <> nil then
- FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil);
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
end;
end;
-
procedure TVFSEngine.SetPath(Value: string);
begin
ChangeDir(Value);
end;
-function TVFSEngine.Login(Username, Password: string): integer;
-begin
- if (FGlobs <> nil) and (@FSourcePlugin.FVFSLogin <> nil)
- then Result := FSourcePlugin.FVFSLogin(FGlobs, PChar(Username), PChar(Password))
- else Result := cVFS_OK;
-end;
-
function TVFSEngine.FileExists(const FileName: string; const Use_lstat: boolean = False): Boolean;
begin
if (FGlobs <> nil) and (@FSourcePlugin.FVFSFileExists <> nil)
@@ -840,32 +833,31 @@ end;
(********************************************************************************************************************************)
-
-function VFSCopyCallBackFunc(iPos, iMax:Int64; data: Pointer): LongBool; cdecl;
+function TVFSEngine.CopyFileIn(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean;
begin
-// DebugMsg(['VFSCopyCallBackFunc called (iPos = ', iPos, ', iMax = ', iMax, ')']);
- Result := True;
- if not Assigned(data) then Exit;
- if Assigned(TVFSEngine(data).FProgressFunc) then
- try
- Result := TVFSEngine(data).FProgressFunc(TVFSEngine(data).FSenderThread, iPos);
- except
- on E: Exception do DebugMsg(['*** Exception raised in VFSCopyCallBackFunc(iPos=', iPos, ', iMax=', iMax, ', data=', data, '): (', E.ClassName, '): ', E.Message]);
- end;
+ Result := CopyFileInEx(Sender, SourceFile, DestFile, ErrorFunc, Append, nil, nil, nil, nil);
end;
function TVFSEngine.CopyFileOut(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean;
+begin
+ Result := CopyFileInEx(Sender, SourceFile, DestFile, ErrorFunc, Append, nil, nil, nil, nil);
+end;
+
+function TVFSEngine.CopyFileOutEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc; Append: boolean;
+ AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean;
var Res: TVFSResult;
begin
Result := False;
try
if @FSourcePlugin.FVFSCopyOut <> nil then begin
- FSenderThread := Sender;
- FProgressFunc := ProgressFunc;
// DebugMsg(['0 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$']);
// DebugMsg([' Pointer(FGlobs) = 0x', IntToHex(Int64(FGlobs), 16), ', Pointer(@NewVFSCopyCallBackFunc) = 0x', IntToHex(Int64(@NewVFSCopyCallBackFunc), 16), ', Pointer(Self) = 0x', IntToHex(Int64(Self), 16)]);
try
- Res := FSourcePlugin.FVFSCopyOut(FGlobs, PChar(SourceFile), PChar(DestFile), @VFSCopyCallBackFunc, Self, Append);
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
+ Res := FSourcePlugin.FVFSCopyOut(FGlobs, PChar(SourceFile), PChar(DestFile), Append);
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
except
on E: Exception do begin
DebugMsg(['*** Exception raised in TVFSEngine.CopyFileOut(Sender=', QWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]);
@@ -879,7 +871,7 @@ begin
cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, SourceFile);
cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, DestFile);
cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, SourceFile);
- cVFS_Cancelled: Result := False;
+ cVFS_Cancelled: ErrorFunc(Sender, 0, 0, SourceFile);
end;
end else Result := False;
except
@@ -887,16 +879,19 @@ begin
end;
end;
-function TVFSEngine.CopyFileIn(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean;
+function TVFSEngine.CopyFileInEx(Sender: Pointer; SourceFile, DestFile: string; ErrorFunc: TEngineErrorFunc;
+ Append: boolean; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean;
var Res: TVFSResult;
begin
Result := False;
try
if @FSourcePlugin.FVFSCopyIn <> nil then begin
- FSenderThread := Sender;
- FProgressFunc := ProgressFunc;
try
- Res := FSourcePlugin.FVFSCopyIn(FGlobs, PChar(SourceFile), PChar(DestFile), @VFSCopyCallBackFunc, Self, Append);
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData);
+ Res := FSourcePlugin.FVFSCopyIn(FGlobs, PChar(SourceFile), PChar(DestFile), Append);
+ if @FSourcePlugin.FVFSSetCallbacks <> nil then
+ FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil);
except
on E: Exception do begin
DebugMsg(['*** Exception raised in TVFSEngine.CopyFileIn(Sender=', QWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]);
@@ -909,7 +904,7 @@ begin
cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, SourceFile);
cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, DestFile);
cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, SourceFile);
- cVFS_Cancelled: Result := False;
+ cVFS_Cancelled: ErrorFunc(Sender, 0, 0, SourceFile);
end;
end else Result := False;
except
@@ -920,25 +915,12 @@ end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
-function TVFSEngine.SetPassword(Password: string): integer;
-begin
- if @FSourcePlugin.FVFSSetPassword <> nil then Result := FSourcePlugin.FVFSSetPassword(FGlobs, PChar(Password))
- else Result := 0;
- FPassword := Password;
-end;
-
function TVFSEngine.GetPasswordRequired: boolean;
begin
if @FSourcePlugin.FVFSGetPasswordRequired <> nil then Result := FSourcePlugin.FVFSGetPasswordRequired(FGlobs)
else Result := False;
end;
-procedure TVFSEngine.SetFPassword(Value: string);
-begin
- SetPassword(Value);
-end;
-
-
(********************************************************************************************************************************)
(********************************************************************************************************************************)
function GetBinaryPath: string;