소스 검색

Bug 1909: Returning back to Login dialog, when ad-hoc connection fails

https://winscp.net/tracker/1909
(cherry picked from commit 2fa3ea2c34d27ed313f14d134713282bdf420131)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp

Source commit: 32d19f9045071232a5be95a6bc94575c2a10d651
Martin Prikryl 5 년 전
부모
커밋
be1f53da15
3개의 변경된 파일44개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 0
      source/forms/CustomScpExplorer.cpp
  2. 0 4
      source/forms/Login.cpp
  3. 43 6
      source/windows/TerminalManager.cpp

+ 1 - 0
source/forms/CustomScpExplorer.cpp

@@ -6654,6 +6654,7 @@ void __fastcall TCustomScpExplorerForm::NeedSession(bool Startup)
   try
   {
     // Cache, as the login dialog can change its value
+    // See also DoShow. Also see TTerminalManager::NewSession.
     bool ShowLogin = WinConfiguration->ShowLoginWhenNoSession;
     try
     {

+ 0 - 4
source/forms/Login.cpp

@@ -1288,10 +1288,6 @@ bool __fastcall TLoginDialog::Execute(TList * DataList)
       FNewSiteData->CopyData(SessionData);
       FNewSiteData->Special = false;
 
-      // This is actualy bit pointless.
-      // As of now, we hardly ever get any useful data in ad-hoc DataList.
-      // (this was implemented for support taking session url from clipboard instead
-      // of command-line, but without autoconnect, but this functionality was cancelled)
       if (!FNewSiteData->IsSameDecrypted(StoredSessions->DefaultSettings))
       {
         // we want to start with new site page

+ 43 - 6
source/windows/TerminalManager.cpp

@@ -1520,15 +1520,52 @@ void __fastcall TTerminalManager::NewSession(const UnicodeString & SessionUrl, b
     StoredSessions->Reload();
   }
 
-  UnicodeString DownloadFile; // unused
-  std::unique_ptr<TObjectList> DataList(new TObjectList());
+  std::unique_ptr<TObjectList> DataList;
 
-  GetLoginData(SessionUrl, NULL, DataList.get(), DownloadFile, true, LinkedForm);
-
-  if (DataList->Count > 0)
+  bool Retry;
+  do
   {
-    ActiveTerminal = NewTerminals(DataList.get());
+    Retry = false;
+    if (!DataList) // first round
+    {
+      DataList.reset(new TObjectList());
+      UnicodeString DownloadFile; // unused
+      GetLoginData(SessionUrl, NULL, DataList.get(), DownloadFile, true, LinkedForm);
+    }
+    else
+    {
+      if (!DoLoginDialog(DataList.get(), LinkedForm))
+      {
+        Abort(); // As GetLoginData would do
+      }
+    }
+
+    if (DataList->Count > 0)
+    {
+      TManagedTerminal * ANewTerminal = NewTerminals(DataList.get());
+      bool AdHoc = (DataList->Count == 1) && (StoredSessions->FindSame(reinterpret_cast<TSessionData *>(DataList->Items[0])) == NULL);
+      bool CanRetry = SessionUrl.IsEmpty() && AdHoc;
+      bool ShowLoginWhenNoSession = WinConfiguration->ShowLoginWhenNoSession;
+      if (CanRetry)
+      {
+        // we will show our own login dialog, so prevent opening an empty one
+        WinConfiguration->ShowLoginWhenNoSession = false;
+      }
+      try
+      {
+        ActiveTerminal = ANewTerminal;
+      }
+      __finally
+      {
+        if (CanRetry) // do not reset the value, unless really needed, as it can theoretically be changed meanwhile by the user
+        {
+          WinConfiguration->ShowLoginWhenNoSession = ShowLoginWhenNoSession;
+        }
+      }
+      Retry = CanRetry && (ActiveTerminal != ANewTerminal);
+    }
   }
+  while (Retry);
 }
 //---------------------------------------------------------------------------
 void __fastcall TTerminalManager::Idle(bool SkipCurrentTerminal)