summaryrefslogtreecommitdiff
path: root/UMain.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-12 15:50:20 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-12 15:50:20 +0200
commitf35af507573469b7c1692f01922d323bd1000fbc (patch)
tree619e72d4aa486bc97974293cf045f263e98263b6 /UMain.pas
parentb417ac914af5e3dfeb27eb5bde6210f88c5b9ec4 (diff)
downloadtuxcmd-f35af507573469b7c1692f01922d323bd1000fbc.tar.xz
Connection Manager password callback improvements
Diffstat (limited to 'UMain.pas')
-rw-r--r--UMain.pas100
1 files changed, 17 insertions, 83 deletions
diff --git a/UMain.pas b/UMain.pas
index c01b01f..719ac2d 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -1726,6 +1726,7 @@ var ListView: TGTKListView;
end;
procedure DoThread;
+ var DialogParent: PGtkWidget;
begin
try
OpenDirThread.AEngine := Engine;
@@ -1757,13 +1758,17 @@ var ListView: TGTKListView;
if OpenDirThread.VFSAskQuestion_Display then begin
OpenDirThread.VFSAskQuestion_Display := False;
DebugMsg(['Main thread: displaying question dialog']);
- HandleVFSAskQuestionCallback(FRemoteWait.FWidget, OpenDirThread.VFSAskQuestion_Message, OpenDirThread.VFSAskQuestion_Choices, OpenDirThread.VFSAskQuestion_Choice);
+ if FRemoteWait.Visible then DialogParent := FRemoteWait.FWidget
+ else DialogParent := FWidget;
+ HandleVFSAskQuestionCallback(DialogParent, OpenDirThread.VFSAskQuestion_Message, OpenDirThread.VFSAskQuestion_Choices, OpenDirThread.VFSAskQuestion_Choice);
OpenDirThread.VFSCallbackEvent.SetEvent;
end;
if OpenDirThread.VFSAskPassword_Display then begin
OpenDirThread.VFSAskPassword_Display := False;
DebugMsg(['Main thread: displaying password prompt']);
- OpenDirThread.VFSAskPassword_Result := HandleVFSAskPasswordCallback(FRemoteWait.FWidget,
+ if FRemoteWait.Visible then DialogParent := FRemoteWait.FWidget
+ else DialogParent := FWidget;
+ OpenDirThread.VFSAskPassword_Result := HandleVFSAskPasswordCallback(DialogParent,
OpenDirThread.VFSAskPassword_Message,
OpenDirThread.VFSAskPassword_default_user,
OpenDirThread.VFSAskPassword_default_domain,
@@ -5958,94 +5963,23 @@ end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
-procedure vfs_ask_question_callback(const AMessage: PChar; const Choices: PPChar; choice: PInteger; user_data: Pointer); cdecl;
-begin
-// DebugMsg(['******* vfs_ask_question_callback spawned, user_data = 0x', IntToHex(QWord(user_data), 16), ', ThreadID = 0x', IntToHex(pthread_self, 16)]);
- HandleVFSAskQuestionCallback(user_data, AMessage, Choices, choice);
-end;
-
-function vfs_ask_password_callback(const AMessage: PChar; const default_user: PChar; const default_domain: PChar; flags: TVFSAskPasswordFlags;
- username, password: PPChar; anonymous: PInteger; domain: PPChar; password_save: PVFSPasswordSave;
- user_data: Pointer): LongBool; cdecl;
-begin
-// DebugMsg(['******* vfs_ask_password_callback spawned, user_data = 0x', IntToHex(QWord(user_data), 16), ', ThreadID = 0x', IntToHex(pthread_self, 16)]);
- Result := HandleVFSAskPasswordCallback(user_data, AMessage, default_user, default_domain, flags, username, password, anonymous, domain, password_save);
-// DebugMsg(['after vfs_ask_password_callback: password = ', password^]);
-end;
-
procedure TFMain.miOpenConnectionClick(Sender: TObject);
-var Engine: TVFSEngine;
- SourceEngine: TPanelEngine;
- i, j: integer;
- VFSPlugin: TVFSPlugin;
- ConnInfo: TConnMgrItem;
- b: boolean;
+var b: boolean;
begin
try
InternalLock;
- ConnInfo := nil;
-
+
FConnectionManager := TFConnectionManager.Create(Self);
+ if LeftLastFocused then FConnectionManager.SourcePanelEngine := LeftPanelEngine
+ else FConnectionManager.SourcePanelEngine := RightPanelEngine;
b := FConnectionManager.Run = mbOK;
- if FConnectionManager.ListView.Selected <> nil then begin
- ConnInfo := FConnectionManager.ListView.Selected.AsPointer(0);
- ConfConnMgrActiveItem := FConnectionManager.ListView.Selected.Index;
- end;
- WriteConnections; // Save the list to the file
+ if FConnectionManager.ListView.Selected <> nil then ConfConnMgrActiveItem := FConnectionManager.ListView.Selected.Index;
+ WriteConnections; // Save connection manager data
- if b then begin
- if PluginList.Count = 0 then begin
- Application.MessageBox(LANGThereIsNoModuleAvailable, [mbOK], mbError, mbOK, mbOK);
- Exit;
- end;
- if ConnInfo = nil then Exit;
-
- // Find the VFS module to use for this connection
- VFSPlugin := nil;
- if Length(ConnInfo.PluginID) > 0 then
- for i := 0 to PluginList.Count - 1 do
- if TVFSPlugin(PluginList[i]).VFSName = ConnInfo.PluginID then begin
- VFSPlugin := PluginList[i];
- Break;
- end;
- if VFSPlugin = nil then begin
- for i := 0 to PluginList.Count - 1 do begin
- if Length(TVFSPlugin(PluginList[i]).Services) > 0 then
- for j := 0 to Length(TVFSPlugin(PluginList[i]).Services) - 1 do
- if WideCompareText(TVFSPlugin(PluginList[i]).Services[j], ConnInfo.ServiceType) = 0 then begin
- VFSPlugin := PluginList[i];
- Break;
- end;
- if VFSPlugin <> nil then Break;
- end;
- if VFSPlugin = nil then VFSPlugin := PluginList[0]; // Fallback in hope something else could handle it
- end;
-
- if (LeftLastFocused and (LeftPanelEngine is TVFSEngine)) or ((not LeftLastFocused) and (RightPanelEngine is TVFSEngine)) then
- begin
- if Application.MessageBox(LANGCloseOpenConnection, [mbYes, mbNo], mbWarning, mbYes, mbNo) <> mbYes then Exit;
- CloseVFS(LeftLastFocused, True);
- end;
-
- // Construct the VFS Engine and try to open the connection
- if LeftLastFocused then SourceEngine := LeftPanelEngine
- else SourceEngine := RightPanelEngine;
- Engine := TVFSEngine.Create(VFSPlugin);
- Engine.ParentEngine := SourceEngine;
- Engine.SavePath := SourceEngine.Path;
-
- FRemoteWait := TFRemoteWait.Create(Application);
- FRemoteWait.ParentForm := FConnectionManager;
- FRemoteWait.ShowModal;
- Application.ProcessMessages;
- b := Engine.VFSOpenURI(UTF8ToStr(ConnInfo.URI), @vfs_ask_question_callback, @vfs_ask_password_callback, FRemoteWait.FWidget);
- FRemoteWait.Free;
- if not b then begin
- Application.MessageBox(LANGCouldntOpenURI, [mbOK], mbError, mbOK, mbOK);
- Exit;
- end;
- if LeftLastFocused then LeftPanelEngine := Engine
- else RightPanelEngine := Engine;
+ if b and (FConnectionManager.ConnectedEngine <> nil) then begin
+ if FConnectionManager.SourcePanelEngine is TVFSEngine then CloseVFS(LeftLastFocused, True);
+ if LeftLastFocused then LeftPanelEngine := FConnectionManager.ConnectedEngine
+ else RightPanelEngine := FConnectionManager.ConnectedEngine;
DoRefresh(LeftLastFocused, False, False);
end;
finally