瀏覽代碼

Bug 1681: Create background queue connection right after session starts

https://winscp.net/tracker/1681

Source commit: 9caab57ebfcbcb79fc70ab3d0301e130966dfd85
Martin Prikryl 7 年之前
父節點
當前提交
3e2c325c65

+ 1 - 0
source/core/Global.h

@@ -51,5 +51,6 @@ void __fastcall DoAssert(wchar_t * Message, wchar_t * Filename, int LineNumber);
 #define TraceInitPtr(p) (p)
 #define TraceInitStr(p) (p)
 #define DebugUsedParam(p) ((&p) == (&p))
+#define DebugUsedArg(p)
 //---------------------------------------------------------------------------
 #endif

+ 24 - 0
source/core/Queue.cpp

@@ -2028,6 +2028,30 @@ TQueueItemProxy * __fastcall TTerminalQueueStatus::FindByQueueItem(
   return NULL;
 }
 //---------------------------------------------------------------------------
+// TBootstrapQueueItem
+//---------------------------------------------------------------------------
+__fastcall TBootstrapQueueItem::TBootstrapQueueItem()
+{
+  FInfo->SingleFile = true;
+}
+//---------------------------------------------------------------------------
+void __fastcall TBootstrapQueueItem::DoExecute(TTerminal * DebugUsedArg(Terminal))
+{
+  // noop
+}
+//---------------------------------------------------------------------------
+UnicodeString __fastcall TBootstrapQueueItem::StartupDirectory() const
+{
+  return UnicodeString();
+}
+//---------------------------------------------------------------------------
+bool __fastcall TBootstrapQueueItem::Complete()
+{
+  TQueueItem::Complete();
+  // To hide the item, even if "keep done items" is on
+  return false;
+}
+//---------------------------------------------------------------------------
 // TLocatedQueueItem
 //---------------------------------------------------------------------------
 __fastcall TLocatedQueueItem::TLocatedQueueItem(TTerminal * Terminal) :

+ 12 - 1
source/core/Queue.h

@@ -209,7 +209,7 @@ protected:
   virtual UnicodeString __fastcall StartupDirectory() const = 0;
   virtual void __fastcall ProgressUpdated();
   virtual TQueueItem * __fastcall CreateParallelOperation();
-  bool __fastcall Complete();
+  virtual bool __fastcall Complete();
 };
 //---------------------------------------------------------------------------
 class TQueueItemProxy
@@ -299,6 +299,17 @@ private:
   TQueueItemProxy * __fastcall GetItem(int Index);
 };
 //---------------------------------------------------------------------------
+class TBootstrapQueueItem : public TQueueItem
+{
+public:
+  __fastcall TBootstrapQueueItem();
+
+protected:
+  virtual void __fastcall DoExecute(TTerminal * Terminal);
+  virtual UnicodeString __fastcall StartupDirectory() const;
+  virtual bool __fastcall Complete();
+};
+//---------------------------------------------------------------------------
 class TLocatedQueueItem : public TQueueItem
 {
 protected:

+ 7 - 0
source/windows/GUIConfiguration.cpp

@@ -556,6 +556,7 @@ void __fastcall TGUIConfiguration::Default()
   FMaxWatchDirectories = 500;
   FSynchronizeOptions = soRecurse | soSynchronizeAsk;
   FQueueTransfersLimit = 2;
+  FQueueBootstrap = false;
   FQueueKeepDoneItems = true;
   FQueueKeepDoneItemsFor = 15;
   FQueueAutoPopup = true;
@@ -635,6 +636,7 @@ void __fastcall TGUIConfiguration::UpdateStaticUsage()
     KEY(Integer,  SynchronizeMode); \
     KEY(Integer,  MaxWatchDirectories); \
     KEY(Integer,  QueueTransfersLimit); \
+    KEY(Bool,     QueueBootstrap); \
     KEY(Integer,  QueueKeepDoneItems); \
     KEY(Integer,  QueueKeepDoneItemsFor); \
     KEY(Bool,     QueueAutoPopup); \
@@ -1345,6 +1347,11 @@ void __fastcall TGUIConfiguration::SetQueueTransfersLimit(int value)
   SET_CONFIG_PROPERTY(QueueTransfersLimit);
 }
 //---------------------------------------------------------------------------
+void __fastcall TGUIConfiguration::SetQueueBootstrap(bool value)
+{
+  SET_CONFIG_PROPERTY(QueueBootstrap);
+}
+//---------------------------------------------------------------------------
 void __fastcall TGUIConfiguration::SetQueueKeepDoneItems(bool value)
 {
   SET_CONFIG_PROPERTY(QueueKeepDoneItems);

+ 3 - 0
source/windows/GUIConfiguration.h

@@ -171,6 +171,7 @@ private:
   bool FQueueAutoPopup;
   bool FSessionRememberPassword;
   int FQueueTransfersLimit;
+  bool FQueueBootstrap;
   bool FQueueKeepDoneItems;
   int FQueueKeepDoneItemsFor;
   TGUICopyParamType FDefaultCopyParam;
@@ -220,6 +221,7 @@ protected:
   void __fastcall SetNewDirectoryProperties(const TRemoteProperties & value);
   virtual void __fastcall Saved();
   void __fastcall SetQueueTransfersLimit(int value);
+  void __fastcall SetQueueBootstrap(bool value);
   void __fastcall SetQueueKeepDoneItems(bool value);
   void __fastcall SetQueueKeepDoneItemsFor(int value);
   void __fastcall SetLocaleInternal(LCID value, bool Safe, bool CompleteOnly);
@@ -257,6 +259,7 @@ public:
   __property int SynchronizeMode = { read = FSynchronizeMode, write = FSynchronizeMode };
   __property int MaxWatchDirectories = { read = FMaxWatchDirectories, write = FMaxWatchDirectories };
   __property int QueueTransfersLimit = { read = FQueueTransfersLimit, write = SetQueueTransfersLimit };
+  __property bool QueueBootstrap = { read = FQueueBootstrap, write = SetQueueBootstrap };
   __property bool QueueKeepDoneItems = { read = FQueueKeepDoneItems, write = SetQueueKeepDoneItems };
   __property int QueueKeepDoneItemsFor = { read = FQueueKeepDoneItemsFor, write = SetQueueKeepDoneItemsFor };
   __property bool QueueAutoPopup = { read = FQueueAutoPopup, write = FQueueAutoPopup };

+ 7 - 3
source/windows/QueueController.cpp

@@ -364,9 +364,13 @@ void __fastcall TQueueController::FillQueueViewItem(TListItem * Item,
       ProgressStr = L"";
     }
 
-    // cannot use ProgressData->Temp as it is set only after the transfer actually starts
-    Values[0] = Info->Source.IsEmpty() ? LoadStr(PROGRESS_TEMP_DIR) : Info->Source;
-    Values[1] = Info->Destination.IsEmpty() ? LoadStr(PROGRESS_TEMP_DIR) : Info->Destination;
+    // If both are empty, it's bootstrap item => do not show anything
+    if (!Info->Source.IsEmpty() || !Info->Destination.IsEmpty())
+    {
+      // cannot use ProgressData->Temp as it is set only after the transfer actually starts
+      Values[0] = Info->Source.IsEmpty() ? LoadStr(PROGRESS_TEMP_DIR) : Info->Source;
+      Values[1] = Info->Destination.IsEmpty() ? LoadStr(PROGRESS_TEMP_DIR) : Info->Destination;
+    }
 
     __int64 TotalTransferred = QueueItem->TotalTransferred;
     if (TotalTransferred >= 0)

+ 5 - 0
source/windows/TerminalManager.cpp

@@ -305,6 +305,11 @@ void __fastcall TTerminalManager::DoConnectTerminal(TTerminal * Terminal, bool R
       ManagedTerminal->ReopenStart = 0;
     }
   }
+
+  if (DebugAlwaysTrue(Terminal->Active) && !Reopen && GUIConfiguration->QueueBootstrap)
+  {
+    FindQueueForTerminal(Terminal)->AddItem(new TBootstrapQueueItem());
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TTerminalManager::CloseAutheticateForm()