diff options
Diffstat (limited to 'vfs')
| -rw-r--r-- | vfs/UVFSCore.pas | 32 | ||||
| -rw-r--r-- | vfs/uVFSprototypes.pas | 36 |
2 files changed, 62 insertions, 6 deletions
diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index 0237121..e884a09 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -67,6 +67,7 @@ type FVFSGetServices: TVFSGetServices; FVFSSetPassword: TVFSSetPassword; FVFSGetPasswordRequired: TVFSGetPasswordRequired; + FVFSSetCallbacks: TVFSSetCallbacks; public ModuleHandle: Pointer; FullPath: string; // module path @@ -95,14 +96,15 @@ type public ArchiveMode: boolean; constructor Create(SourcePlugin: TVFSPlugin); - function VFSOpenURI(OpenFile: string): boolean; + function VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): boolean; function VFSOpenEx(OpenFile: string): 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; const ShowProgress: boolean = True): integer; override; + function ChangeDir(const NewPath: string): integer; override; + function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): integer; function ExplicitChDir(const NewPath: string): integer; override; function GetFileSystemSize: Int64; override; function GetFileSystemSize(const APath: string): Int64; override; @@ -223,6 +225,7 @@ begin @FVFSGetServices := dlsym(ModuleHandle, 'VFSGetServices'); @FVFSSetPassword := dlsym(ModuleHandle, 'VFSSetPassword'); @FVFSGetPasswordRequired := dlsym(ModuleHandle, 'VFSGetPasswordRequired'); + @FVFSSetCallbacks := dlsym(ModuleHandle, 'VFSSetCallbacks'); // Initialize the extensions list SetLength(Extensions, 0); SetLength(Services, 0); @@ -305,11 +308,16 @@ begin end; end; -function TVFSEngine.VFSOpenURI(OpenFile: string): boolean; +function TVFSEngine.VFSOpenURI(URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): boolean; begin Result := False; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil) - then Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(OpenFile)) = cVFS_OK; + if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpen <> nil) then begin + if @FSourcePlugin.FVFSSetCallbacks <> nil then + FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, CallbackData); + Result := FSourcePlugin.FVFSOpen(FGlobs, PChar(URI)) = cVFS_OK; + if @FSourcePlugin.FVFSSetCallbacks <> nil then + FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil); + end; end; function TVFSEngine.VFSOpenEx(OpenFile: string): TVFSResult; @@ -489,7 +497,7 @@ begin else Result := '/'; end; -function TVFSEngine.ChangeDir(const NewPath: string; const ShowProgress: boolean = True): integer; +function TVFSEngine.ChangeDir(const NewPath: string): integer; begin DebugMsg(['^^VFS (II): ChangeDir begin']); Result := 0; @@ -502,6 +510,18 @@ begin DebugMsg(['^^VFS (II): ChangeDir end.']); end; +function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; CallbackData: Pointer): integer; +begin + if (FGlobs <> nil) and (@FSourcePlugin.FVFSChangeDir <> nil) then begin + if @FSourcePlugin.FVFSSetCallbacks <> nil then + FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, CallbackData); + Result := ChangeDir(NewPath); + if @FSourcePlugin.FVFSSetCallbacks <> nil then + FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil); + end; +end; + + procedure TVFSEngine.SetPath(Value: string); begin ChangeDir(Value); diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas index 6959a7b..18830aa 100644 --- a/vfs/uVFSprototypes.pas +++ b/vfs/uVFSprototypes.pas @@ -76,6 +76,17 @@ type // File descriptor for Open, Read, Write, Close, Seek operations TVFSFileDes = Pointer; + TVFSAskPasswordFlags = (VFS_ASK_PASSWORD_NEED_PASSWORD = 1 shl 0, + VFS_ASK_PASSWORD_NEED_USERNAME = 1 shl 1, + VFS_ASK_PASSWORD_NEED_DOMAIN = 1 shl 2, + VFS_ASK_PASSWORD_SAVING_SUPPORTED = 1 shl 3, + VFS_ASK_PASSWORD_ANONYMOUS_SUPPORTED = 1 shl 4); + + PVFSPasswordSave = ^TVFSPasswordSave; + TVFSPasswordSave = (VFS_PASSWORD_SAVE_NEVER, + VFS_PASSWORD_SAVE_FOR_SESSION, + VFS_PASSWORD_SAVE_PERMANENTLY); + TVFSItemType = (vRegular=0, vSymlink=1, vChardev=2, vBlockdev=3, vDirectory=4, vFifo=5, vSock=6, vOther=7); {$IFDEF KYLIX} @@ -245,9 +256,34 @@ type //// pridat typ pluginu - jestli archive nebo protocol - prip. jeste pridat ktery protokoly je to schopno handlovat + + // Return index of the choice selected or negative number when dialog has been cancelled + PVFSAskQuestionCallback = ^TVFSAskQuestionCallback; + TVFSAskQuestionCallback = procedure (const AMessage: PChar; + const Choices: PPChar; + choice: PInteger; + user_data: Pointer); cdecl; + + PVFSAskPasswordCallback = ^TVFSAskPasswordCallback; + TVFSAskPasswordCallback = function (const AMessage: PChar; + const default_user: PChar; + const default_domain: PChar; + flags: TVFSAskPasswordFlags; + username: PPChar; + password: PPChar; + anonymous: PInteger; + domain: PPChar; + password_save: PVFSPasswordSave; + user_data: Pointer): LongBool; cdecl; + + TVFSSetCallbacks = procedure (g: TVFSGlobs; ask_question_callback: PVFSAskQuestionCallback; ask_password_callback: PVFSAskPasswordCallback; Data: Pointer); cdecl; + + // TODO: some function to check the CRC of the archive - it should need also some progress feedback - the processed file and percentage progress +// Prekopat error logging - asi neco na zpusob GError, stringy se budou vracet i z pluginu + implementation end. |
